From 54347661382b1211cf8e154f2cfdde15d04ef5b1 Mon Sep 17 00:00:00 2001 From: Jithin Jose Date: Tue, 11 Apr 2017 03:44:37 -0400 Subject: [PATCH] Clean up openstack network after failed instantiate Signed-off-by: Jithin Jose --- rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py index 68702bbb..e06e311d 100644 --- a/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py +++ b/rwcal/plugins/vala/rwcal_openstack/rwcal_openstack.py @@ -904,8 +904,13 @@ class RwcalOpenstackPlugin(GObject.Object, RwCal.Cloud): drv.neutron_subnet_create(**kwargs) except Exception as e: self.log.error("Encountered exceptions during network creation. Exception: %s", str(e)) - raise - + # This is to delete the network if neutron_subnet_create fails after creation of network + # Note:- Any subnet created will be implicitly deleted. + try: + drv.neutron_network_delete(network_id) + except Exception as delete_exception: + self.log.debug("Exception while deleting the network after failure of neutron_subnet_create or make_subnet_args: %s", str(delete_exception)) + raise e return network_id -- 2.17.1