+ async def install_k8s_proxy_charm(
+ self,
+ charm_name: str,
+ namespace: str,
+ artifact_path: str,
+ db_dict: dict,
+ progress_timeout: float = None,
+ total_timeout: float = None,
+ config: dict = None,
+ ) -> str:
+ """
+ Install a k8s proxy charm
+
+ :param charm_name: Name of the charm being deployed
+ :param namespace: collection of all the uuids related to the charm.
+ :param str artifact_path: where to locate the artifacts (parent folder) using
+ the self.fs
+ the final artifact path will be a combination of this artifact_path and
+ additional string from the config_dict (e.g. charm name)
+ :param dict db_dict: where to write into database when the status changes.
+ It contains a dict with
+ {collection: <str>, filter: {}, path: <str>},
+ e.g. {collection: "nsrs", filter:
+ {_id: <nsd-id>, path: "_admin.deployed.VCA.3"}
+ :param float progress_timeout:
+ :param float total_timeout:
+ :param config: Dictionary with additional configuration
+
+ :returns ee_id: execution environment id.
+ """
+ self.log.info('Installing k8s proxy charm: {}, artifact path: {}, db_dict: {}'
+ .format(charm_name, artifact_path, db_dict))
+
+ if not self.k8s_cloud:
+ raise JujuK8sProxycharmNotSupported("There is not k8s_cloud available")
+
+ if artifact_path is None or len(artifact_path) == 0:
+ raise N2VCBadArgumentsException(
+ message="artifact_path is mandatory", bad_args=["artifact_path"]
+ )
+ if db_dict is None:
+ raise N2VCBadArgumentsException(message='db_dict is mandatory', bad_args=['db_dict'])
+
+ # remove // in charm path
+ while artifact_path.find('//') >= 0:
+ artifact_path = artifact_path.replace('//', '/')
+
+ # check charm path
+ if not self.fs.file_exists(artifact_path, mode="dir"):
+ msg = 'artifact path does not exist: {}'.format(artifact_path)
+ raise N2VCBadArgumentsException(message=msg, bad_args=['artifact_path'])
+
+ if artifact_path.startswith('/'):
+ full_path = self.fs.path + artifact_path
+ else:
+ full_path = self.fs.path + '/' + artifact_path
+
+ _, ns_id, _, _, _ = self._get_namespace_components(namespace=namespace)
+ model_name = '{}-k8s'.format(ns_id)
+
+ await self.libjuju.add_model(model_name, self.k8s_cloud)
+ application_name = self._get_application_name(namespace)
+
+ try:
+ await self.libjuju.deploy_charm(
+ model_name=model_name,
+ application_name=application_name,
+ path=full_path,
+ machine_id=None,
+ db_dict=db_dict,
+ progress_timeout=progress_timeout,
+ total_timeout=total_timeout,
+ config=config
+ )
+ except Exception as e:
+ raise N2VCException(message='Error deploying charm: {}'.format(e))
+
+ self.log.info('K8s proxy charm installed')
+ ee_id = N2VCJujuConnector._build_ee_id(
+ model_name=model_name,
+ application_name=application_name,
+ machine_id="k8s",
+ )
+
+ self._write_ee_id_db(db_dict=db_dict, ee_id=ee_id)
+
+ return ee_id
+