import logging
import os
+from n2vc.config import ModelConfig
from n2vc.exceptions import (
N2VCBadArgumentsException,
N2VCException,
)
self.api_proxy = None
- if "enable_os_upgrade" in vca_config:
- self.enable_os_upgrade = vca_config["enable_os_upgrade"]
- else:
- self.enable_os_upgrade = True
-
- if "apt_mirror" in vca_config:
- self.apt_mirror = vca_config["apt_mirror"]
- else:
- self.apt_mirror = None
+ model_config = ModelConfig(vca_config)
self.cloud = vca_config.get('cloud')
self.k8s_cloud = None
self.libjuju = Libjuju(
endpoint=self.url,
api_proxy=self.api_proxy,
- enable_os_upgrade=self.enable_os_upgrade,
- apt_mirror=self.apt_mirror,
username=self.username,
password=self.secret,
cacert=self.ca_cert,
log=self.log,
db=self.db,
n2vc=self,
+ model_config=model_config,
)
# create juju pub key file in lcm container at
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,