From a7e744ed870eddb1c1628f22fde85f9652fa6dc8 Mon Sep 17 00:00:00 2001 From: "jose.lausuch" Date: Fri, 18 Dec 2015 10:09:22 +0100 Subject: Adding more robust check to delete a port in clean_openstack. Change-Id: I87ec537cde0b8ef8fd8d11aa327e93087f2125c4 Signed-off-by: jose.lausuch --- testcases/VIM/OpenStack/CI/libraries/clean_openstack.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'testcases/VIM/OpenStack/CI/libraries') diff --git a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py index b92c55a4..6516c7db 100644 --- a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py +++ b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py @@ -171,19 +171,28 @@ def remove_networks(neutron_client): logger.debug("There are no ports in the deployment. ") return + #debug information (to be removed when it works many times in a row) + print ports + for port in ports: if port['network_id'] in network_ids: port_id = port['id'] try: subnet_id = port['fixed_ips'][0]['subnet_id'] except: - logger.info(" > ERROR: Error removing port %s." % port_id) + logger.info(" > WARNING: Port %s does not contain 'fixed_ips'" % port_id) print port - print ports - continue router_id = port['device_id'] - if port['device_owner'] == 'network:router_interface': + if len(port['fixed_ips']) == 0 and router_id == '': + logger.debug("Removing port %s ..." % port_id) + if functest_utils.delete_neutron_port(neutron_client, port_id): + logger.debug(" > Done!") + else: + logger.info(" > ERROR: There has been a problem removing the " + "port %s ..." %port_id) + + elif port['device_owner'] == 'network:router_interface': logger.debug("Detaching port %s (subnet %s) from router %s ..." % (port_id,subnet_id,router_id)) if functest_utils.remove_interface_router(neutron_client, -- cgit 1.2.3-korg