fix(sapd): sapd used to specify exposed connections at NS level. Fixes Bug 1321
[osm/LCM.git] / osm_lcm / lcm_helm_conn.py
index 9608b63..831190b 100644 (file)
@@ -29,6 +29,9 @@ from osm_lcm.frontend_pb2 import SshKeyRequest, SshKeyReply
 from osm_lcm.frontend_grpc import FrontendExecutorStub
 from osm_lcm.lcm_utils import LcmBase
 
+from osm_lcm.data_utils.database.database import Database
+from osm_lcm.data_utils.filesystem.filesystem import Filesystem
+
 from n2vc.n2vc_conn import N2VCConnector
 from n2vc.k8s_helm_conn import K8sHelmConnector
 from n2vc.k8s_helm3_conn import K8sHelm3Connector
@@ -72,8 +75,6 @@ class LCMHelmConn(N2VCConnector, LcmBase):
     _MAX_RETRY_TIME = 30
 
     def __init__(self,
-                 db: object,
-                 fs: object,
                  log: object = None,
                  loop: object = None,
                  url: str = None,
@@ -84,17 +85,20 @@ class LCMHelmConn(N2VCConnector, LcmBase):
         Initialize EE helm connector.
         """
 
+        self.db = Database().instance.db
+        self.fs = Filesystem().instance.fs
+
         # parent class constructor
         N2VCConnector.__init__(
             self,
-            db=db,
-            fs=fs,
             log=log,
             loop=loop,
             url=url,
             username=username,
             vca_config=vca_config,
             on_update_db=on_update_db,
+            db=self.db,
+            fs=self.fs
         )
 
         self.log.debug("Initialize helm N2VC connector")
@@ -111,8 +115,8 @@ class LCMHelmConn(N2VCConnector, LcmBase):
             kubectl_command=self.vca_config.get("kubectlpath"),
             helm_command=self.vca_config.get("helmpath"),
             fs=self.fs,
-            log=self.log,
             db=self.db,
+            log=self.log,
             on_update_db=None,
         )
 
@@ -137,7 +141,8 @@ class LCMHelmConn(N2VCConnector, LcmBase):
                                            total_timeout: float = None,
                                            config: dict = None,
                                            artifact_path: str = None,
-                                           vca_type: str = None) -> (str, dict):
+                                           vca_type: str = None,
+                                           *kargs, **kwargs) -> (str, dict):
         """
         Creates a new helm execution environment deploying the helm-chat indicated in the
         attifact_path
@@ -189,6 +194,9 @@ class LCMHelmConn(N2VCConnector, LcmBase):
         else:
             full_path = self.fs.path + "/" + helm_chart_path
 
+        while full_path.find("//") >= 0:
+            full_path = full_path.replace("//", "/")
+
         try:
             # Call helm conn install
             # Obtain system cluster id from database
@@ -222,7 +230,8 @@ class LCMHelmConn(N2VCConnector, LcmBase):
             raise N2VCException("Error deploying chart ee: {}".format(e))
 
     async def register_execution_environment(self, namespace: str, credentials: dict, db_dict: dict,
-                                             progress_timeout: float = None, total_timeout: float = None) -> str:
+                                             progress_timeout: float = None, total_timeout: float = None,
+                                             *kargs, **kwargs) -> str:
         # nothing to do
         pass
 
@@ -422,7 +431,7 @@ class LCMHelmConn(N2VCConnector, LcmBase):
             # Uninstall chart, for backward compatibility we must assume that if there is no
             # version it is helm-v2
             if version == "helm-v3":
-                await  self._k8sclusterhelm3.uninstall(system_cluster_uuid, helm_id)
+                await self._k8sclusterhelm3.uninstall(system_cluster_uuid, helm_id)
             else:
                 await self._k8sclusterhelm2.uninstall(system_cluster_uuid, helm_id)
             self.log.info("ee_id: {} deleted".format(ee_id))
@@ -445,6 +454,7 @@ class LCMHelmConn(N2VCConnector, LcmBase):
         progress_timeout: float = None,
         total_timeout: float = None,
         config: dict = None,
+        *kargs, **kwargs
     ) -> str:
         pass
 
@@ -465,7 +475,7 @@ class LCMHelmConn(N2VCConnector, LcmBase):
 
     @retryer(max_wait_time=_MAX_RETRY_TIME, delay_time=_EE_RETRY_DELAY)
     async def _execute_primitive(self, ip_addr, primitive_name, params, db_dict=None):
-        return await  self._execute_primitive_internal(ip_addr, primitive_name, params, db_dict=db_dict)
+        return await self._execute_primitive_internal(ip_addr, primitive_name, params, db_dict=db_dict)
 
     async def _execute_primitive_internal(self, ip_addr, primitive_name, params, db_dict=None):