diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/functest_utils.py | 15 | ||||
-rwxr-xr-x | utils/openstack_clean.py | 11 | ||||
-rwxr-xr-x | utils/openstack_utils.py | 7 |
3 files changed, 28 insertions, 5 deletions
diff --git a/utils/functest_utils.py b/utils/functest_utils.py index 8c5dd835a..644ad1a1b 100644 --- a/utils/functest_utils.py +++ b/utils/functest_utils.py @@ -294,7 +294,7 @@ def get_ci_envvars(): def execute_command(cmd, exit_on_error=True, info=False, error_msg="", - verbose=True): + verbose=True, output_file=None): if not error_msg: error_msg = ("The command '%s' failed." % cmd) msg_exec = ("Executing command: '%s'" % cmd) @@ -305,10 +305,17 @@ def execute_command(cmd, exit_on_error=True, info=False, error_msg="", logger.debug(msg_exec) p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + if output_file: + f = open(output_file, "w") for line in iter(p.stdout.readline, b''): - line = line.replace('\n', '') - print line - sys.stdout.flush() + if output_file: + f.write(line) + else: + line = line.replace('\n', '') + print line + sys.stdout.flush() + if output_file: + f.close() p.stdout.close() returncode = p.wait() if returncode != 0: diff --git a/utils/openstack_clean.py b/utils/openstack_clean.py index 8e7dee8fb..ef26be1f3 100755 --- a/utils/openstack_clean.py +++ b/utils/openstack_clean.py @@ -202,9 +202,20 @@ def remove_networks(neutron_client, default_networks, default_routers): else: remove_routers(neutron_client, routers, default_routers) + # trozet: wait for Neutron to auto-cleanup HA networks when HA router is + # deleted + time.sleep(5) + # remove networks if network_ids is not None: for net_id in network_ids: + networks = os_utils.get_network_list(neutron_client) + if networks is None: + logger.debug("No networks left to remove") + break + elif not any(network['id'] == net_id for network in networks): + logger.debug("Network %s has already been removed" % net_id) + continue logger.debug("Removing network %s ..." % net_id) if os_utils.delete_neutron_net(neutron_client, net_id): logger.debug(" > Done!") diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py index bc718bb2b..ff9b54a58 100755 --- a/utils/openstack_utils.py +++ b/utils/openstack_utils.py @@ -705,6 +705,11 @@ def create_network_association(neutron_client, bgpvpn_id, neutron_network_id): return neutron_client.create_network_association(bgpvpn_id, json_body) +def create_router_association(neutron_client, bgpvpn_id, router_id): + json_body = {"router_association": {"router_id": router_id}} + return neutron_client.create_router_association(bgpvpn_id, json_body) + + def update_bgpvpn(neutron_client, bgpvpn_id, **kwargs): json_body = {"bgpvpn": kwargs} return neutron_client.update_bgpvpn(bgpvpn_id, json_body) @@ -1077,7 +1082,7 @@ def create_tenant(keystone_client, tenant_name, tenant_description): enabled=True) return tenant.id except Exception, e: - logger.error("Error [create_tenant(cinder_client, '%s', '%s')]: %s" + logger.error("Error [create_tenant(keystone_client, '%s', '%s')]: %s" % (tenant_name, tenant_description, e)) return None |