From 655f39713cca2595a812ccd60cc738301aef8b2f Mon Sep 17 00:00:00 2001 From: "stark, steven" Date: Mon, 23 Apr 2018 08:49:34 -0700 Subject: [VVP] add bug fixes and reserve port updates Adding test script updates and reserve port Change-Id: I2af5263a48a53117021f166d08395685e89fd122 Issue-ID: VVP-56 Signed-off-by: stark, steven --- ice_validator/tests/utils/nested_iterables.py | 6 ++++-- ice_validator/tests/utils/network_roles.py | 17 +++++++++++++++++ ice_validator/tests/utils/ports.py | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) (limited to 'ice_validator/tests/utils') diff --git a/ice_validator/tests/utils/nested_iterables.py b/ice_validator/tests/utils/nested_iterables.py index 19290c0..eea6e19 100644 --- a/ice_validator/tests/utils/nested_iterables.py +++ b/ice_validator/tests/utils/nested_iterables.py @@ -73,11 +73,13 @@ def find_all_get_param_in_yml(yml): params = [] for k, v in yml.items(): if k == 'get_param' and v not in os_pseudo_parameters: + if isinstance(v, list) and not isinstance(v[0], dict): + params.append(v[0]) + elif not isinstance(v, dict) and isinstance(v, str): + params.append(v) for item in (v if isinstance(v, list) else [v]): if isinstance(item, dict): params.extend(find_all_get_param_in_yml(item)) - elif isinstance(item, str): - params.append(item) continue elif k == 'list_join': for item in (v if isinstance(v, list) else [v]): diff --git a/ice_validator/tests/utils/network_roles.py b/ice_validator/tests/utils/network_roles.py index 5a551ab..fbe6dce 100644 --- a/ice_validator/tests/utils/network_roles.py +++ b/ice_validator/tests/utils/network_roles.py @@ -161,3 +161,20 @@ def is_valid_ipv6_address(ip_address): except (OSError, socket.error): return False return True + + +def property_uses_get_resource(resource, property_name): + ''' + returns true if a port's network property + uses the get_resource function + ''' + if not isinstance(resource, dict): + return False + if 'properties' not in resource: + return False + for k1, v1 in resource["properties"].items(): + if k1 != property_name: + continue + if "get_resource" in v1: + return True + return False diff --git a/ice_validator/tests/utils/ports.py b/ice_validator/tests/utils/ports.py index 51e920a..4d0b4ca 100644 --- a/ice_validator/tests/utils/ports.py +++ b/ice_validator/tests/utils/ports.py @@ -177,3 +177,21 @@ def get_invalid_ip_addresses(resources, port_property): invalid_ip_addresses.append(ip_address) return invalid_ip_addresses + + +def is_reserved_port(port_id): + ''' + Checks to see if the resource id for a port follows + the reserve port concept + ''' + formats = [ + ["port_id", + re.compile(r'reserve_port_(.+?)_floating_ip_\d+')], + ["port_id", + re.compile(r'reserve_port_(.+?)_floating_v6_ip_\d+')], + ] + for f in formats: + m = f[1].match(port_id.lower()) + if m and m.group(1): + return True + return False -- cgit 1.2.3-korg