feat(sol006): LCM migration to SOL006
[osm/LCM.git] / osm_lcm / lcm_helm_conn.py
index 904b7d9..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,
         )
 
@@ -190,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
@@ -424,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))
@@ -468,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):