diff --git a/src/tripleo_aio_helpers/os_migrate_teardown.py b/src/tripleo_aio_helpers/os_migrate_teardown.py index a743f1f..479ff21 100644 --- a/src/tripleo_aio_helpers/os_migrate_teardown.py +++ b/src/tripleo_aio_helpers/os_migrate_teardown.py @@ -122,30 +122,47 @@ def destroy_private_network(args): print("deleting private network") test_user_openstack_cmd("network delete private", args) +def delete_flavor(args,name): + flavor_exists = [ + flavor + for flavor in openstack_cmd( + "flavor list -f json", args, as_json=True + ) + if flavor["Name"] == "cirros" + ] + + if flavor_exists: + print(f"deleting {name} flavor") + test_user_openstack_cmd("flavor delete f{name}", args) def destroy_cirros_flavor(args): - """Coming soon - create the cirros flavor""" - # pylint: disable=unused-argument - print("creating cirros flavor - NYI") - + """Delete the cirros flavor""" + delete_flavor(args, "cirros") def destroy_rhel_flavor(args): - """Coming soon - create the rhel flavor""" - # pylint: disable=unused-argument - print("creating rhel flavor - NYI") + """Delete the rhel flavor""" + delete_flavor(args, "rhel") +def delete_image(args, name): + image_exists = [ + image + for image in openstack_cmd( + "image list -f json", args, as_json=True + ) + if image["Name"] == "cirros" + ] + + if image_exists: + print(f"deleting {name} image") + test_user_openstack_cmd("image delete f{name}", args) def destroy_cirros_image(args): - """Coming soon - destroy the cirros image""" - # pylint: disable=unused-argument - print("destroying cirros image - NYI") - + """Delete the cirros image""" + delete_image(args, "cirros") def destroy_rhel_image(args): - """Coming soon - create the rhel image""" - # pylint: disable=unused-argument - print("creating rhel image - NYI") - + """Delete the rhel image""" + delete_image(args, "rhel") def destroy_cirros_instance(args): """Delete the cirros instance"""