Destroy machines before destroying the model 15/8515/1 v7.0.1rc2
authorquilesj <e.nvi001.tid@telefonica.com>
Wed, 15 Jan 2020 12:30:09 +0000 (12:30 +0000)
committerisraelad <adam.israel@canonical.com>
Wed, 22 Jan 2020 12:50:15 +0000 (13:50 +0100)
Change-Id: If42c99ac9ec88a492d89a201f12a93872a476783
Signed-off-by: quilesj <e.nvi001.tid@telefonica.com>
(cherry picked from commit bd5a0c9bcbcd078a2c914f77671d23d4e2afca98)

n2vc/n2vc_juju_conn.py

index cf865a8..00b1bc1 100644 (file)
@@ -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