X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Flibjuju.py;h=bf356f46b5c4a0ca581cae4d0ab073093e3777aa;hp=a79d00d8c8a46b56da6b1242a02a27612512f8c5;hb=refs%2Fchanges%2F98%2F10498%2F1;hpb=ff9d9013c43951a782da38116357a8274b4549ee;ds=sidebyside diff --git a/n2vc/libjuju.py b/n2vc/libjuju.py index a79d00d..bf356f4 100644 --- a/n2vc/libjuju.py +++ b/n2vc/libjuju.py @@ -117,7 +117,7 @@ class Libjuju: def _create_health_check_task(self): return self.loop.create_task(self.health_check()) - async def get_controller(self, timeout: float = 5.0) -> Controller: + async def get_controller(self, timeout: float = 15.0) -> Controller: """ Get controller @@ -853,8 +853,9 @@ class Libjuju: """ controller = await self.get_controller() - model = await self.get_model(controller, model_name) + model = None try: + model = await self.get_model(controller, model_name) self.log.debug("Destroying model {}".format(model_name)) uuid = model.info.uuid @@ -888,6 +889,10 @@ class Libjuju: raise Exception( "Timeout waiting for model {} to be destroyed".format(model_name) ) + except Exception as e: + if model: + await self.disconnect_model(model) + raise e finally: await self.disconnect_controller(controller)