Revert "Needed for feature 10938: extract_prometheus_scrape_jobs populating prom... 38/12838/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 16 Jan 2023 16:08:04 +0000 (17:08 +0100)
committerGabriel Cuba <gcuba@whitestack.com>
Tue, 17 Jan 2023 21:44:06 +0000 (16:44 -0500)
This reverts commit bd49c837f9d1714597710169ed99255b47251005.

Change-Id: I3306c56bc9851eb9d118d4047db8c115450e944e
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_lcm/ns.py
osm_lcm/tests/test_ns.py

index 8f2b192..cbcf67e 100644 (file)
@@ -1731,7 +1731,6 @@ class NsLcm(LcmBase):
         vdu_id,
         kdu_name,
         vdu_index,
-        kdu_index,
         config_descriptor,
         deploy_params,
         base_folder,
@@ -2157,11 +2156,6 @@ class NsLcm(LcmBase):
                     vnfr_id=vnfr_id,
                     nsr_id=nsr_id,
                     target_ip=rw_mgmt_ip,
-                    vnf_member_index=db_vnfr.get("member-vnf-index-ref", ""),
-                    vdu_id=vdu_id,
-                    vdu_index=vdu_index,
-                    kdu_name=kdu_name,
-                    kdu_index=kdu_index,
                 )
                 if prometheus_jobs:
                     self.update_db_2(
@@ -2598,7 +2592,6 @@ class NsLcm(LcmBase):
                 vdu_index = 0
                 vdu_name = None
                 kdu_name = None
-                kdu_index = None
 
                 # Get additional parameters
                 deploy_params = {"OSM": get_osm_params(db_vnfr)}
@@ -2622,7 +2615,6 @@ class NsLcm(LcmBase):
                         kdu_name=kdu_name,
                         member_vnf_index=member_vnf_index,
                         vdu_index=vdu_index,
-                        kdu_index=kdu_index,
                         vdu_name=vdu_name,
                         deploy_params=deploy_params,
                         descriptor_config=descriptor_config,
@@ -2655,7 +2647,6 @@ class NsLcm(LcmBase):
                     if descriptor_config:
                         vdu_name = None
                         kdu_name = None
-                        kdu_index = None
                         for vdu_index in range(vdud_count):
                             # TODO vnfr_params["rw_mgmt_ip"] = vdur["ip-address"]
                             self._deploy_n2vc(
@@ -2671,7 +2662,6 @@ class NsLcm(LcmBase):
                                 vnfd_id=vnfd_id,
                                 vdu_id=vdu_id,
                                 kdu_name=kdu_name,
-                                kdu_index=kdu_index,
                                 member_vnf_index=member_vnf_index,
                                 vdu_index=vdu_index,
                                 vdu_name=vdu_name,
@@ -2688,10 +2678,8 @@ class NsLcm(LcmBase):
                         vdu_id = None
                         vdu_index = 0
                         vdu_name = None
-                        kdu_index, kdur = next(
-                            x
-                            for x in enumerate(db_vnfr["kdur"])
-                            if x[1]["kdu-name"] == kdu_name
+                        kdur = next(
+                            x for x in db_vnfr["kdur"] if x["kdu-name"] == kdu_name
                         )
                         deploy_params_kdu = {"OSM": get_osm_params(db_vnfr)}
                         if kdur.get("additionalParams"):
@@ -2711,7 +2699,6 @@ class NsLcm(LcmBase):
                             kdu_name=kdu_name,
                             member_vnf_index=member_vnf_index,
                             vdu_index=vdu_index,
-                            kdu_index=kdu_index,
                             vdu_name=vdu_name,
                             deploy_params=deploy_params_kdu,
                             descriptor_config=descriptor_config,
@@ -2728,7 +2715,6 @@ class NsLcm(LcmBase):
                 member_vnf_index = None
                 vdu_id = None
                 kdu_name = None
-                kdu_index = None
                 vdu_index = 0
                 vdu_name = None
 
@@ -2751,7 +2737,6 @@ class NsLcm(LcmBase):
                     kdu_name=kdu_name,
                     member_vnf_index=member_vnf_index,
                     vdu_index=vdu_index,
-                    kdu_index=kdu_index,
                     vdu_name=vdu_name,
                     deploy_params=deploy_params,
                     descriptor_config=descriptor_config,
@@ -3735,7 +3720,6 @@ class NsLcm(LcmBase):
         kdu_name,
         member_vnf_index,
         vdu_index,
-        kdu_index,
         vdu_name,
         deploy_params,
         descriptor_config,
@@ -3862,7 +3846,6 @@ class NsLcm(LcmBase):
                     vdu_id=vdu_id,
                     kdu_name=kdu_name,
                     vdu_index=vdu_index,
-                    kdu_index=kdu_index,
                     deploy_params=deploy_params,
                     config_descriptor=descriptor_config,
                     base_folder=base_folder,
@@ -6803,7 +6786,6 @@ class NsLcm(LcmBase):
                                 vdu_id = None
                                 vdu_name = None
                                 kdu_name = None
-                                kdu_index = None
                                 self._deploy_n2vc(
                                     logging_text=logging_text
                                     + "member_vnf_index={} ".format(member_vnf_index),
@@ -6815,7 +6797,6 @@ class NsLcm(LcmBase):
                                     vnfd_id=vnfd_id,
                                     vdu_id=vdu_id,
                                     kdu_name=kdu_name,
-                                    kdu_index=kdu_index,
                                     member_vnf_index=member_vnf_index,
                                     vdu_index=vdu_index,
                                     vdu_name=vdu_name,
@@ -6842,7 +6823,6 @@ class NsLcm(LcmBase):
                             if descriptor_config:
                                 vdu_name = None
                                 kdu_name = None
-                                kdu_index = None
                                 stage[
                                     1
                                 ] = "Scaling member_vnf_index={}, vdu_id={}, vdu_index={} ".format(
@@ -6865,7 +6845,6 @@ class NsLcm(LcmBase):
                                     kdu_name=kdu_name,
                                     member_vnf_index=member_vnf_index,
                                     vdu_index=vdu_index,
-                                    kdu_index=kdu_index,
                                     vdu_name=vdu_name,
                                     deploy_params=deploy_params_vdu,
                                     descriptor_config=descriptor_config,
@@ -7266,42 +7245,8 @@ class NsLcm(LcmBase):
             )
 
     async def extract_prometheus_scrape_jobs(
-        self,
-        ee_id: str,
-        artifact_path: str,
-        ee_config_descriptor: dict,
-        vnfr_id: str,
-        nsr_id: str,
-        target_ip: str,
-        vnf_member_index: str = "",
-        vdu_id: str = "",
-        vdu_index: int = None,
-        kdu_name: str = "",
-        kdu_index: int = None,
-    ) -> dict:
-        """Method to extract prometheus scrape jobs from EE's Prometheus template job file
-            This method will wait until the corresponding VDU or KDU is fully instantiated
-
-        Args:
-            ee_id (str): Execution Environment ID
-            artifact_path (str): Path where the EE's content is (including the Prometheus template file)
-            ee_config_descriptor (dict): Execution Environment's configuration descriptor
-            vnfr_id (str): VNFR ID where this EE applies
-            nsr_id (str): NSR ID where this EE applies
-            target_ip (str): VDU/KDU instance IP address
-            vnf_member_index (str, optional): VNF index where this EE applies. Defaults to "".
-            vdu_id (str, optional): VDU ID where this EE applies. Defaults to "".
-            vdu_index (int, optional): VDU index where this EE applies. Defaults to None.
-            kdu_name (str, optional): KDU name where this EE applies. Defaults to "".
-            kdu_index (int, optional): KDU index where this EE applies. Defaults to None.
-
-        Raises:
-            LcmException: When the VDU or KDU instance was not found in an hour
-
-        Returns:
-            _type_: Prometheus jobs
-        """
-        self.logger.debug(f"KDU: {kdu_name}; KDU INDEX: {kdu_index}")
+        self, ee_id, artifact_path, ee_config_descriptor, vnfr_id, nsr_id, target_ip
+    ):
         # look if exist a file called 'prometheus*.j2' and
         artifact_content = self.fs.dir_ls(artifact_path)
         job_file = next(
@@ -7317,52 +7262,6 @@ class NsLcm(LcmBase):
         with self.fs.file_open((artifact_path, job_file), "r") as f:
             job_data = f.read()
 
-        vdur_name = ""
-        kdur_name = ""
-        for r in range(360):
-            db_vnfr = self.db.get_one("vnfrs", {"_id": vnfr_id})
-            if vdu_id and vdu_index is not None:
-                vdur = next(
-                    (
-                        x
-                        for x in get_iterable(db_vnfr, "vdur")
-                        if (
-                            x.get("vdu-id-ref") == vdu_id
-                            and x.get("count-index") == vdu_index
-                        )
-                    ),
-                    {},
-                )
-                if vdur.get("name"):
-                    vdur_name = vdur.get("name")
-                    break
-            if kdu_name and kdu_index is not None:
-                kdur = next(
-                    (
-                        x
-                        for x in get_iterable(db_vnfr, "kdur")
-                        if (
-                            x.get("kdu-name") == kdu_name
-                            and x.get("count-index") == kdu_index
-                        )
-                    ),
-                    {},
-                )
-                if kdur.get("name"):
-                    kdur_name = kdur.get("name")
-                    break
-
-            await asyncio.sleep(10, loop=self.loop)
-        else:
-            if vdu_id and vdu_index is not None:
-                raise LcmException(
-                    f"Timeout waiting VDU with name={vdu_id} and index={vdu_index} to be intantiated"
-                )
-            if kdu_name and kdu_index is not None:
-                raise LcmException(
-                    f"Timeout waiting KDU with name={kdu_name} and index={kdu_index} to be intantiated"
-                )
-
         # TODO get_service
         _, _, service = ee_id.partition(".")  # remove prefix   "namespace."
         host_name = "{}-{}".format(service, ee_config_descriptor["metric-service"])
@@ -7373,10 +7272,6 @@ class NsLcm(LcmBase):
             "TARGET_IP": target_ip,
             "EXPORTER_POD_IP": host_name,
             "EXPORTER_POD_PORT": host_port,
-            "NSR_ID": nsr_id,
-            "VNF_MEMBER_INDEX": vnf_member_index,
-            "VDUR_NAME": vdur_name,
-            "KDUR_NAME": kdur_name,
         }
         job_list = parse_job(job_data, variables)
         # ensure job_name is using the vnfr_id. Adding the metadata nsr_id
index 7e72700..b822df3 100644 (file)
@@ -1549,7 +1549,6 @@ class TestInstantiateN2VC(TestBaseNS):
             vdu_id=None,
             kdu_name=None,
             vdu_index=None,
-            kdu_index=None,
             config_descriptor=config_descriptor,
             deploy_params={},
             base_folder=base_folder,