diff options
author | meimei <meimei@huawei.com> | 2015-12-18 14:25:38 +0800 |
---|---|---|
committer | meimei <meimei@huawei.com> | 2015-12-18 14:32:39 +0800 |
commit | 4e9512420f4bc2533eca3e52e9862cf59e2fa9be (patch) | |
tree | 97e0e664b1976cbdee3b1c20a6398ff7b607198d /testcases/VIM/OpenStack/CI/libraries/clean_openstack.py | |
parent | a8980480661f6355c3914d00e5a56e295986137f (diff) |
Fix bug clean_openstack if the function return a None
Change-Id: Ia9257742193526f4293ffc26e05d5590493d5a4f
Signed-off-by: meimei <meimei@huawei.com>
Diffstat (limited to 'testcases/VIM/OpenStack/CI/libraries/clean_openstack.py')
-rw-r--r-- | testcases/VIM/OpenStack/CI/libraries/clean_openstack.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py index 5fa1c8679..b92c55a4e 100644 --- a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py +++ b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py @@ -63,7 +63,7 @@ def separator(): def remove_instances(nova_client): logger.info("Removing Nova instances...") instances = functest_utils.get_instances(nova_client) - if len(instances) == 0: + if instances is None or len(instances) == 0: logger.debug("No instances found.") return @@ -81,7 +81,7 @@ def remove_instances(nova_client): def remove_images(nova_client): logger.info("Removing Glance images...") images = functest_utils.get_images(nova_client) - if len(images) == 0: + if images is None or len(images) == 0: logger.debug("No images found.") return @@ -106,7 +106,7 @@ def remove_volumes(cinder_client, nova_client): timeout = 50 while timeout > 0: instances = functest_utils.get_instances(nova_client) - if len(instances) == 0: + if instances is None or len(instances) == 0: break else: logger.debug("Waiting for instances to be terminated...") @@ -131,7 +131,7 @@ def remove_volumes(cinder_client, nova_client): def remove_floatingips(nova_client): logger.info("Removing floating IPs...") floatingips = functest_utils.get_floating_ips(nova_client) - if len(floatingips) == 0: + if floatingips is None or len(floatingips) == 0: logger.debug("No floating IPs found.") return @@ -167,6 +167,10 @@ def remove_networks(neutron_client): #remove interfaces router and delete ports ports = functest_utils.get_port_list(neutron_client) + if ports is None: + logger.debug("There are no ports in the deployment. ") + return + for port in ports: if port['network_id'] in network_ids: port_id = port['id'] @@ -201,6 +205,9 @@ def remove_networks(neutron_client): #remove routers routers = functest_utils.get_router_list(neutron_client) + if routers is None: + logger.debug("There are no routers in the deployment. ") + return for router in routers: router_id = router['id'] router_name = router['name'] @@ -238,7 +245,7 @@ def remove_networks(neutron_client): def remove_security_groups(neutron_client): logger.info("Removing Security groups...") secgroups = functest_utils.get_security_groups(neutron_client) - if len(secgroups) == 0: + if secgroups is None or len(secgroups) == 0: logger.debug("No security groups found.") return |