diff options
author | Manuel Buil <mbuil@suse.com> | 2017-03-31 12:39:03 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-03-31 12:39:03 +0000 |
commit | f3f681af057352f26c7447009b0a9cdc144fac5c (patch) | |
tree | 4c9af2a228d0ffc661c7b41c5e6577458bd91262 /sfc/lib/utils.py | |
parent | e61239dbb4f96bb4b798cd3c6e6d6c953d4fcee4 (diff) | |
parent | 4afb88fb03f4b9280470e53322d5a630d22548f5 (diff) |
Merge "Fix hardcoded domain in wait_for_clf_rules"
Diffstat (limited to 'sfc/lib/utils.py')
-rw-r--r-- | sfc/lib/utils.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py index fc5ed025..ba29a8a6 100644 --- a/sfc/lib/utils.py +++ b/sfc/lib/utils.py @@ -82,6 +82,15 @@ def download_image(url, image_path): logger.info("Using old image") +def get_av_zones(): + ''' + Return the availability zone each host belongs to + ''' + nova_client = os_utils.get_nova_client() + hosts = os_utils.get_hypervisors(nova_client) + return ['nova::{0}'.format(host) for host in hosts] + + def create_vnf_in_av_zone( tacker_client, vnf_name, vnfd_name, default_param_file, av_zone=None): param_file = default_param_file @@ -480,9 +489,17 @@ def promised_rsps_in_computes( def wait_for_classification_rules(ovs_logger, compute_nodes, odl_ip, odl_port, topology, timeout=200): try: + hypervisors = get_av_zones() + av_zone_regex = re.compile(r'nova::node-([0-9]+)\.(.+)') + # Example: String "nova::node-13.domain.tld" is matched + # It's deconstructed as: + # group(0) -> nova::node-13.domain.tld + # group(1) -> 13 + # group(2) -> domain.tld + hypervisor_matches = [av_zone_regex.match(h) for h in hypervisors] compute_av_zones = { - node.id: 'nova::node-{0}.domain.tld'.format(node.id) - for node in compute_nodes + hypervisor_match.group(1): hypervisor_match.group(0) + for hypervisor_match in hypervisor_matches } # keep only vnfs |