X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=functest%2Futils%2Fopenstack_clean.py;h=ce61fcacf3aac95d5ce04daf5d8895ef624a4151;hb=a434c3fefdf075cb6be44b964b64fc12db1cb8d5;hp=b1ad9664ec4d6b55092a862253f8cb1db3420448;hpb=a59fea1046d167b4609c9b86836d178e799dc688;p=functest.git diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py index b1ad9664e..ce61fcacf 100755 --- a/functest/utils/openstack_clean.py +++ b/functest/utils/openstack_clean.py @@ -49,9 +49,14 @@ def remove_instances(nova_client, default_instances): for instance in instances: instance_name = getattr(instance, 'name') instance_id = getattr(instance, 'id') + instance_status = getattr(instance, 'status') + instance_state = getattr(instance, 'OS-EXT-STS:task_state') + logger.debug("'%s', ID=%s " % (instance_name, instance_id)) if (instance_id not in default_instances and - instance_name not in default_instances.values()): + instance_name not in default_instances.values() and + instance_status != 'DELETED' and + (instance_status != 'BUILD' or instance_state != 'deleting')): logger.debug("Removing instance '%s' ..." % instance_id) if os_utils.delete_instance(nova_client, instance_id): logger.debug(" > Request sent.") @@ -397,7 +402,7 @@ def main(): default_security_groups = snapshot_yaml.get('secgroups') default_floatingips = snapshot_yaml.get('floatingips') default_users = snapshot_yaml.get('users') - # default_tenants = snapshot_yaml.get('tenants') + default_tenants = snapshot_yaml.get('tenants') if not os_utils.check_credentials(): logger.error("Please source the openrc credentials and run " @@ -418,10 +423,8 @@ def main(): separator() remove_users(keystone_client, default_users) separator() - # TODO (Helen) tenant does not exist in V3 - # need to figure our anohter general verification point - # remove_tenants(keystone_client, default_tenants) - # separator() + remove_tenants(keystone_client, default_tenants) + separator() if __name__ == '__main__':