#
import time
+
+import yaml
+
import functest.utils.functest_logger as ft_logger
import functest.utils.openstack_utils as os_utils
-import yaml
-import functest.utils.functest_constants as ft_constants
+from functest.utils.constants import CONST
logger = ft_logger.Logger("openstack_clean").getLogger()
-OS_SNAPSHOT_FILE = ft_constants.OPENSTACK_SNAPSHOT_FILE
+OS_SNAPSHOT_FILE = CONST.openstack_snapshot_file
def separator():
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.")
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 "
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__':