diff options
-rw-r--r-- | sdnvpn/lib/utils.py | 8 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_3.py | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py index 67b75d0..269a319 100644 --- a/sdnvpn/lib/utils.py +++ b/sdnvpn/lib/utils.py @@ -595,7 +595,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, |