diff options
author | Tim Irnich <tim.irnich@ericsson.com> | 2017-11-09 08:06:14 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-11-09 08:06:14 +0000 |
commit | 846b76273c4296062a8101fe9720a38827a54150 (patch) | |
tree | c1717fa0fd700c705b7cd51dd7a6969cb190588a | |
parent | 9830307e679b928aae43e2b458228d0549693309 (diff) | |
parent | 3aaf0df6141f2ac468c20ab838ea8f6433bd7a65 (diff) |
Merge "remove flavor at the end of the test"
-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, |