Check if cloud is built-in cloud when adding a model
[osm/N2VC.git] / n2vc / k8s_helm_conn.py
index 1efacc4..d3fbed6 100644 (file)
@@ -327,7 +327,8 @@ class K8sHelmConnector(K8sConnector):
             timeout: float = 300,
             params: dict = None,
             db_dict: dict = None,
-            kdu_name: str = None
+            kdu_name: str = None,
+            namespace: str = None
     ):
 
         self.log.debug('installing {} in cluster {}'.format(kdu_model, cluster_uuid))
@@ -348,6 +349,10 @@ class K8sHelmConnector(K8sConnector):
         atomic_str = ''
         if atomic:
             atomic_str = '--atomic'
+        # namespace
+        namespace_str = ''
+        if namespace:
+            namespace_str = "--namespace {}".format(namespace)
 
         # version
         version_str = ''
@@ -374,9 +379,11 @@ class K8sHelmConnector(K8sConnector):
                 pass
 
         # helm repo install
-        command = '{} install {} --output yaml --kubeconfig={} --home={} {} {} --name={} {} {}'\
-            .format(self._helm_command, atomic_str, config_filename, helm_dir,
-                    params_str, timeout_str, kdu_instance, kdu_model, version_str)
+        command = '{helm} install {atomic} --output yaml --kubeconfig={config} --home={dir} {params} {timeout} ' \
+                  '--name={name} {ns} {model} {ver}'.format(helm=self._helm_command, atomic=atomic_str,
+                                                            config=config_filename, dir=helm_dir, params=params_str,
+                                                            timeout=timeout_str, name=kdu_instance, ns=namespace_str,
+                                                            model=kdu_model, ver=version_str)
         self.log.debug('installing: {}'.format(command))
 
         if atomic:
@@ -649,6 +656,29 @@ class K8sHelmConnector(K8sConnector):
 
         return self._output_to_table(output)
 
+    async def exec_primitive(
+        self,
+        cluster_uuid: str = None,
+        kdu_instance: str = None,
+        primitive_name: str = None,
+        timeout: float = 300,
+        params: dict = None,
+        db_dict: dict = None,
+    ) -> str:
+        """Exec primitive (Juju action)
+
+        :param cluster_uuid str: The UUID of the cluster
+        :param kdu_instance str: The unique name of the KDU instance
+        :param primitive_name: Name of action that will be executed
+        :param timeout: Timeout for action execution
+        :param params: Dictionary of all the parameters needed for the action
+        :db_dict: Dictionary for any additional data
+
+        :return: Returns the output of the action
+        """
+        raise K8sException("KDUs deployed with Helm don't support actions "
+                           "different from rollback, upgrade and status")
+
     async def inspect_kdu(
             self,
             kdu_model: str,