+ async def get_executed_actions(self, model_name: str) -> list:
+ """
+ Get executed/history of actions for a model.
+
+ :param: model_name: Model name, str.
+ :return: List of executed actions for a model.
+ """
+ model = None
+ executed_actions = []
+ controller = await self.get_controller()
+ try:
+ model = await self.get_model(controller, model_name)
+ # Get all unique action names
+ actions = {}
+ for application in model.applications:
+ application_actions = await self.get_actions(application, model_name)
+ actions.update(application_actions)
+ # Get status of all actions
+ for application_action in actions:
+ app_action_status_list = await model.get_action_status(
+ name=application_action
+ )
+ for action_id, action_status in app_action_status_list.items():
+ executed_action = {
+ "id": action_id,
+ "action": application_action,
+ "status": action_status,
+ }
+ # Get action output by id
+ action_status = await model.get_action_output(executed_action["id"])
+ for k, v in action_status.items():
+ executed_action[k] = v
+ executed_actions.append(executed_action)
+ except Exception as e:
+ raise JujuError(
+ "Error in getting executed actions for model: {}. Error: {}".format(
+ model_name, str(e)
+ )
+ )
+ finally:
+ if model:
+ await self.disconnect_model(model)
+ await self.disconnect_controller(controller)
+ return executed_actions
+
+ async def get_application_configs(
+ self, model_name: str, application_name: str
+ ) -> dict:
+ """
+ Get available configs for an application.
+
+ :param: model_name: Model name, str.
+ :param: application_name: Application name, str.
+
+ :return: A dict which has key - action name, value - action description
+ """
+ model = None
+ application_configs = {}
+ controller = await self.get_controller()
+ try:
+ model = await self.get_model(controller, model_name)
+ application = self._get_application(
+ model, application_name=application_name
+ )
+ application_configs = await application.get_config()
+ except Exception as e:
+ raise JujuError(
+ "Error in getting configs for application: {} in model: {}. Error: {}".format(
+ application_name, model_name, str(e)
+ )
+ )
+ finally:
+ if model:
+ await self.disconnect_model(model)
+ await self.disconnect_controller(controller)
+ return application_configs
+
+ @retry(attempts=3, delay=5)
+ async def get_model(self, controller: Controller, model_name: str) -> Model: