From: quilesj Date: Wed, 15 Jan 2020 12:30:09 +0000 (+0000) Subject: Destroy machines before destroying the model X-Git-Tag: release-v8.0-start~41 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F8481%2F2;p=osm%2FN2VC.git Destroy machines before destroying the model Change-Id: If42c99ac9ec88a492d89a201f12a93872a476783 Signed-off-by: quilesj --- diff --git a/n2vc/n2vc_juju_conn.py b/n2vc/n2vc_juju_conn.py index cf865a8..00b1bc1 100644 --- a/n2vc/n2vc_juju_conn.py +++ b/n2vc/n2vc_juju_conn.py @@ -1240,6 +1240,15 @@ class N2VCJujuConnector(N2VCConnector): model = await self._juju_get_model(model_name=model_name) uuid = model.info.uuid + # destroy machines + machines = await model.get_machines() + for machine_id in machines: + try: + await self._juju_destroy_machine(model_name=model_name, machine_id=machine_id) + except Exception as e: + # ignore exceptions destroying machine + pass + await self._juju_disconnect_model(model_name=model_name) self.juju_models[model_name] = None self.juju_observers[model_name] = None