From: Periyasamy Palanisamy Date: Wed, 8 Nov 2017 15:02:26 +0000 (+0100) Subject: remove flavor at the end of the test X-Git-Tag: 6.0.0~32^2 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F69%2F46869%2F3;p=sdnvpn.git remove flavor at the end of the test JIRA: SDNVPN-122 Change-Id: I89f457e0d5a7c7c98bab223e722a5eb5a23387b6 Signed-off-by: Periyasamy Palanisamy --- diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py index 1afccf7..8310217 100644 --- a/sdnvpn/lib/utils.py +++ b/sdnvpn/lib/utils.py @@ -592,7 +592,13 @@ def cleanup_neutron(neutron_client, floatingip_ids, bgpvpn_ids, interfaces, return True -def cleanup_nova(nova_client, instance_ids): +def cleanup_nova(nova_client, instance_ids, flavor_ids=None): + if flavor_ids is not None and len(flavor_ids) != 0: + for flavor_id in flavor_ids: + if not nova_client.flavors.delete(flavor_id): + logging.error('Fail to delete flavor. ' + 'Flavor with id {} was not deleted.'. + format(flavor_id)) if len(instance_ids) != 0: for instance_id in instance_ids: if not os_utils.delete_instance(nova_client, instance_id): diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py index 3dc1e7c..fe1d116 100644 --- a/sdnvpn/test/functest/testcase_3.py +++ b/sdnvpn/test/functest/testcase_3.py @@ -143,7 +143,7 @@ def main(): neutron_client = os_utils.get_neutron_client() (floatingip_ids, instance_ids, router_ids, network_ids, image_ids, - subnet_ids, interfaces, bgpvpn_ids) = ([] for i in range(8)) + subnet_ids, interfaces, bgpvpn_ids, flavor_ids) = ([] for i in range(9)) try: sg_id = os_utils.create_security_group_full( @@ -221,7 +221,8 @@ def main(): fake_fip['fip_addr'], ext_net_mask) - test_utils.create_custom_flavor() + _, flavor_id = test_utils.create_custom_flavor() + flavor_ids.append(flavor_id) quagga_vm = test_utils.create_instance( nova_client, @@ -278,7 +279,7 @@ def main(): logger.error("exception occurred while executing testcase_3: %s", e) raise finally: - test_utils.cleanup_nova(nova_client, instance_ids) + test_utils.cleanup_nova(nova_client, instance_ids, flavor_ids) test_utils.cleanup_glance(glance_client, image_ids) test_utils.cleanup_neutron(neutron_client, floatingip_ids, bgpvpn_ids, interfaces, subnet_ids,