Fix 1462
[osm/N2VC.git] / n2vc / n2vc_juju_conn.py
index 313430d..c09c263 100644 (file)
@@ -207,12 +207,32 @@ class N2VCJujuConnector(N2VCConnector):
 
         for m in models:
             status[m] = await self.libjuju.get_model_status(m)
-
         if yaml_format:
             return obj_to_yaml(status)
         else:
             return obj_to_dict(status)
 
+    async def update_vca_status(self, vcastatus: dict):
+        """
+        Add all configs, actions, executed actions of all applications in a model to vcastatus dict.
+        :param vcastatus: dict containing vcaStatus
+        :return: None
+        """
+        try:
+            for model_name in vcastatus:
+                # Adding executed actions
+                vcastatus[model_name]["executedActions"] = \
+                    await self.libjuju.get_executed_actions(model_name)
+                for application in vcastatus[model_name]["applications"]:
+                    # Adding application actions
+                    vcastatus[model_name]["applications"][application]["actions"] = \
+                        await self.libjuju.get_actions(application, model_name)
+                    # Adding application configs
+                    vcastatus[model_name]["applications"][application]["configs"] = \
+                        await self.libjuju.get_application_configs(model_name, application)
+        except Exception as e:
+            self.log.debug("Error in updating vca status: {}".format(str(e)))
+
     async def create_execution_environment(
         self,
         namespace: str,
@@ -774,15 +794,16 @@ class N2VCJujuConnector(N2VCConnector):
                 # destroy the model
                 # TODO: should this be removed?
                 await self.libjuju.destroy_model(
-                    model_name=model_name, total_timeout=total_timeout
+                    model_name=model_name,
+                    total_timeout=total_timeout,
                 )
             else:
-                # get juju model and observer
-                controller = await self.libjuju.get_controller()
-                model = await self.libjuju.get_model(controller, model_name)
                 # destroy the application
                 await self.libjuju.destroy_application(
-                    model=model, application_name=application_name)
+                    model_name=model_name,
+                    application_name=application_name,
+                    total_timeout=total_timeout,
+                )
         except Exception as e:
             raise N2VCException(
                 message=(