From: quilesj Date: Wed, 15 Jan 2020 12:30:09 +0000 (+0000) Subject: Destroy machines before destroying the model X-Git-Tag: v7.0.1rc2^0 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=f2c51f9717e2195e9283e07971c71be135e61a2b;p=osm%2FN2VC.git Destroy machines before destroying the model Change-Id: If42c99ac9ec88a492d89a201f12a93872a476783 Signed-off-by: quilesj (cherry picked from commit bd5a0c9bcbcd078a2c914f77671d23d4e2afca98) --- 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