Switch to using sysinv URL and Address validators

In this commit the bootstrap playbook is updated to make use of
sysinv URL and Address validators to ensure a) consistent user
experience and b) future validation updates will be done in one
spot.

Note: Currently, sysinv Address validator does not accept CIDR notation
as the current docker engine does not support CIDR in NO_PROXY list.
Ref: https://github.com/docker/docker.github.io/issues/8191.

Change-Id: I433303dde93801f3e45cd7d10935eb1de28b9090
Closes-Bug: 1833710
Depends-On: Ic5a450ede0390529e795ca0120200a0f7bbf52ce
Signed-off-by: Tee Ngo <Tee.Ngo@windriver.com>
This commit is contained in:
Tee Ngo 2019-06-24 10:46:18 -04:00
parent 8fa6359ba0
commit 7c719262b6
4 changed files with 12 additions and 18 deletions

View File

@ -1,2 +1,2 @@
SRC_DIR="playbookconfig" SRC_DIR="playbookconfig"
TIS_PATCH_VER=2 TIS_PATCH_VER=3

View File

@ -8,13 +8,13 @@ License: Apache-2.0
URL: unknown URL: unknown
Source0: %{name}-%{version}.tar.gz Source0: %{name}-%{version}.tar.gz
Requires: ansible
Requires: python Requires: python
Requires: python-netaddr Requires: python-netaddr
Requires: sshpass
Requires: python2-ptyprocess Requires: python2-ptyprocess
Requires: python2-pexpect Requires: python2-pexpect
Requires: python2-django Requires: sshpass
Requires: ansible Requires: sysinv
%description %description
This package contains playbooks used for configuring StarlingX. This package contains playbooks used for configuring StarlingX.

View File

@ -11,21 +11,17 @@
- name: Check if the supplied address is a valid domain name or ip address - name: Check if the supplied address is a valid domain name or ip address
vars: vars:
script_content: | script_content: |
# Use this utility to be consistent with the current config_controller # Make use of sysinv Address Validator
# though the underlying regex used is not flexible. from sysinv.common.utils import is_valid_domain_or_ip
from controllerconfig.utils import is_valid_domain_or_ip
if not is_valid_domain_or_ip( "{{ input_address }}" ): if not is_valid_domain_or_ip( "{{ input_address }}" ):
raise Exception("Invalid domain name!") raise Exception("Invalid address format!")
shell: "{{ script_content }}" shell: "{{ script_content }}"
args: args:
executable: /usr/bin/python executable: /usr/bin/python
failed_when: false failed_when: false
register: domain_name_ip_check register: domain_name_ip_check
# Do the final catch-all check using Ansible ipaddr filter to pick up
# addresses with CIDR notation and whatever future valid formats will be.
- name: Fail if the supplied address is not a valid domain name or ip address - name: Fail if the supplied address is not a valid domain name or ip address
fail: fail:
msg: "{{ input_address }} is an invalid address!." msg: "{{ input_address }} is an invalid address."
when: (domain_name_ip_check.rc != 0) and when: domain_name_ip_check.rc != 0
(input_address | ipaddr == false)

View File

@ -12,11 +12,9 @@
- name: Check if the supplied proxy is a valid URL - name: Check if the supplied proxy is a valid URL
vars: vars:
script_content: | script_content: |
# Make use of django URL Validator # Make use of sysinv URL Validator
from django.core.validators import URLValidator from sysinv.common.utils import is_url
try: if not is_url( "{{ input_url }}" ):
URLValidator()( "{{ input_url }}" )
except Exception:
raise Exception("Invalid url format!") raise Exception("Invalid url format!")
shell: "{{ script_content }}" shell: "{{ script_content }}"
args: args: