summaryrefslogtreecommitdiffstats
path: root/testcases/VIM/OpenStack
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-02-02 19:05:56 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2016-02-02 19:05:56 +0100
commit16038f444c1e80006e13b72cb0597976a0b2f92e (patch)
tree52f69a1f30858174e451cfc44fff3a9e1b13a061 /testcases/VIM/OpenStack
parent3630ec141c8ef230388735499bf9a57c775db3d0 (diff)
Consider volumes and floatingips as defaults in clean_openstack
Change-Id: I3ffc864768a7c474ee1063eecee1e2085de807b5 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'testcases/VIM/OpenStack')
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/clean_openstack.py49
-rw-r--r--testcases/VIM/OpenStack/CI/libraries/generate_defaults.py25
2 files changed, 56 insertions, 18 deletions
diff --git a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
index 100342304..e47750052 100644
--- a/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
+++ b/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py
@@ -72,9 +72,11 @@ except Exception, e:
default_images = defaults_yaml.get('images')
default_instances = defaults_yaml.get('instances')
+default_volumes = defaults_yaml.get('volumes')
default_networks = defaults_yaml.get('networks')
default_routers = defaults_yaml.get('routers')
default_security_groups = defaults_yaml.get('secgroups')
+default_floatingips = defaults_yaml.get('floatingips')
default_users = defaults_yaml.get('users')
default_tenants = defaults_yaml.get('tenants')
@@ -140,19 +142,23 @@ def remove_volumes(cinder_client):
for volume in volumes:
volume_id = getattr(volume, 'id')
- logger.debug("Removing cinder volume %s ..." % volume_id)
- if functest_utils.delete_volume(cinder_client, volume_id):
- logger.debug(" > Done!")
- else:
- logger.debug("Trying forced removal...")
- if functest_utils.delete_volume(cinder_client,
- volume_id,
- forced=True):
+ volume_name = getattr(volume, 'display_name')
+ logger.debug("'%s', ID=%s " %(volume_name,volume_id))
+ if volume_id not in default_volumes:
+ logger.debug("Removing cinder volume %s ..." % volume_id)
+ if functest_utils.delete_volume(cinder_client, volume_id):
logger.debug(" > Done!")
else:
- logger.error("There has been a problem removing the "
- "volume %s..." % volume_id)
-
+ logger.debug("Trying forced removal...")
+ if functest_utils.delete_volume(cinder_client,
+ volume_id,
+ forced=True):
+ logger.debug(" > Done!")
+ else:
+ logger.error("There has been a problem removing the "
+ "volume %s..." % volume_id)
+ else:
+ logger.debug(" > this is a default volume and will NOT be deleted.")
def remove_floatingips(nova_client):
logger.info("Removing floating IPs...")
@@ -161,19 +167,28 @@ def remove_floatingips(nova_client):
logger.debug("No floating IPs found.")
return
+ init_len = len(floatingips)
+ deleted = 0
for fip in floatingips:
fip_id = getattr(fip, 'id')
- logger.debug("Removing floating IP %s ..." % fip_id)
- if functest_utils.delete_floating_ip(nova_client, fip_id):
- logger.debug(" > Done!")
+ fip_ip = getattr(fip, 'ip')
+ logger.debug("'%s', ID=%s " %(fip_ip,fip_id))
+ if fip_id not in default_floatingips:
+ logger.debug("Removing floating IP %s ..." % fip_id)
+ if functest_utils.delete_floating_ip(nova_client, fip_id):
+ logger.debug(" > Done!")
+ deleted += 1
+ else:
+ logger.error("There has been a problem removing the "
+ "floating IP %s..." % fip_id)
else:
- logger.error("There has been a problem removing the "
- "floating IP %s..." % fip_id)
+ logger.debug(" > this is a default floating IP and will NOT be deleted.")
+
timeout = 50
while timeout > 0:
floatingips = functest_utils.get_floating_ips(nova_client)
- if floatingips is None or len(floatingips) == 0:
+ if floatingips is None or len(floatingips) == (init_len - deleted):
break
else:
logger.debug("Waiting for floating ips to be released...")
diff --git a/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py b/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
index 0e34d6c7b..72987ddda 100644
--- a/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
+++ b/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py
@@ -39,7 +39,7 @@ args = parser.parse_args()
""" logging configuration """
-logger = logging.getLogger('clean_openstack')
+logger = logging.getLogger('generate_defaults')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
@@ -85,6 +85,16 @@ def get_images(nova_client):
return {'images': dic_images}
+def get_volumes(cinder_client):
+ logger.debug("Getting volumes...")
+ dic_volumes = {}
+ volumes = functest_utils.get_volumes(cinder_client)
+ if volumes != None:
+ for volume in volumes:
+ dic_volumes.update({volume.id:volume.display_name})
+ return {'volumes': dic_volumes}
+
+
def get_networks(neutron_client):
logger.debug("Getting networks")
dic_networks = {}
@@ -94,6 +104,7 @@ def get_networks(neutron_client):
dic_networks.update({network['id']:network['name']})
return {'networks': dic_networks}
+
def get_routers(neutron_client):
logger.debug("Getting routers")
dic_routers = {}
@@ -114,6 +125,16 @@ def get_security_groups(neutron_client):
return {'secgroups': dic_secgroups}
+def get_floatinips(nova_client):
+ logger.debug("Getting Floating IPs...")
+ dic_floatingips = {}
+ floatingips = functest_utils.get_floating_ips(nova_client)
+ if not (floatingips is None or len(floatingips) == 0):
+ for floatingip in floatingips:
+ dic_floatingips.update({floatingip.id:floatingip.ip})
+ return {'floatingips': dic_floatingips}
+
+
def get_users(keystone_client):
logger.debug("Getting users...")
dic_users = {}
@@ -158,9 +179,11 @@ def main():
defaults = {}
defaults.update(get_instances(nova_client))
defaults.update(get_images(nova_client))
+ defaults.update(get_volumes(cinder_client))
defaults.update(get_networks(neutron_client))
defaults.update(get_routers(neutron_client))
defaults.update(get_security_groups(neutron_client))
+ defaults.update(get_floatinips(nova_client))
defaults.update(get_users(keystone_client))
defaults.update(get_tenants(keystone_client))