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"
TIS_PATCH_VER=2
TIS_PATCH_VER=3

View File

@ -8,13 +8,13 @@ License: Apache-2.0
URL: unknown
Source0: %{name}-%{version}.tar.gz
Requires: ansible
Requires: python
Requires: python-netaddr
Requires: sshpass
Requires: python2-ptyprocess
Requires: python2-pexpect
Requires: python2-django
Requires: ansible
Requires: sshpass
Requires: sysinv
%description
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
vars:
script_content: |
# Use this utility to be consistent with the current config_controller
# though the underlying regex used is not flexible.
from controllerconfig.utils import is_valid_domain_or_ip
# Make use of sysinv Address Validator
from sysinv.common.utils import is_valid_domain_or_ip
if not is_valid_domain_or_ip( "{{ input_address }}" ):
raise Exception("Invalid domain name!")
raise Exception("Invalid address format!")
shell: "{{ script_content }}"
args:
executable: /usr/bin/python
failed_when: false
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
fail:
msg: "{{ input_address }} is an invalid address!."
when: (domain_name_ip_check.rc != 0) and
(input_address | ipaddr == false)
msg: "{{ input_address }} is an invalid address."
when: domain_name_ip_check.rc != 0

View File

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