allow k8s namespace parameter 66/8766/5
authortierno <alfonso.tiernosepulveda@telefonica.com>
Tue, 7 Apr 2020 09:07:33 +0000 (09:07 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Thu, 16 Apr 2020 10:24:57 +0000 (10:24 +0000)
Change-Id: If3e1dfbdcbedd637ababfb4a34f4f17b90bf3723
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osm_lcm/ns.py
osm_lcm/tests/test_ns.py

index 4e46539..55fa899 100644 (file)
@@ -277,7 +277,7 @@ class NsLcm(LcmBase):
             raise LcmException("Error parsing Jinja2 to cloud-init content at vnfd[id={}]:vdu[id={}]: {}".
                                format(vnfd["id"], vdu["id"], e))
 
-    def ns_params_2_RO(self, ns_params, nsd, vnfd_dict, n2vc_key_list):
+    def _ns_params_2_RO(self, ns_params, nsd, vnfd_dict, n2vc_key_list):
         """
         Creates a RO ns descriptor from OSM ns_instantiate params
         :param ns_params: OSM instantiate params
@@ -898,7 +898,7 @@ class NsLcm(LcmBase):
                             await asyncio.wait(task_dependency, timeout=3600)
 
                 stage[2] = "Checking instantiation parameters."
-                RO_ns_params = self.ns_params_2_RO(ns_params, nsd, db_vnfds_ref, n2vc_key_list)
+                RO_ns_params = self._ns_params_2_RO(ns_params, nsd, db_vnfds_ref, n2vc_key_list)
                 stage[2] = "Deploying ns at VIM."
                 db_nsr_update["detailed-status"] = " ".join(stage)
                 self.update_db_2("nsrs", nsr_id, db_nsr_update)
@@ -2116,6 +2116,7 @@ class NsLcm(LcmBase):
                 for kdur in get_iterable(vnfr_data, "kdur"):
                     desc_params = self._format_additional_params(kdur.get("additionalParams"))
                     vnfd_id = vnfr_data.get('vnfd-id')
+                    namespace = kdur.get("k8s-namespace")
                     if kdur.get("helm-chart"):
                         kdumodel = kdur["helm-chart"]
                         k8sclustertype = "helm-chart"
@@ -2165,7 +2166,8 @@ class NsLcm(LcmBase):
                                         "k8scluster-type": k8sclustertype,
                                         "member-vnf-index": vnfr_data["member-vnf-index-ref"],
                                         "kdu-name": kdur["kdu-name"],
-                                        "kdu-model": kdumodel}
+                                        "kdu-model": kdumodel,
+                                        "namespace": namespace}
                     db_nsr_update["_admin.deployed.K8s.{}".format(index)] = k8s_instace_info
                     self.update_db_2("nsrs", nsr_id, db_nsr_update)
 
@@ -2177,7 +2179,7 @@ class NsLcm(LcmBase):
                         self.k8scluster_map[k8sclustertype].install(cluster_uuid=cluster_uuid, kdu_model=kdumodel,
                                                                     atomic=True, params=desc_params,
                                                                     db_dict=db_dict, timeout=600,
-                                                                    kdu_name=kdur["kdu-name"]))
+                                                                    kdu_name=kdur["kdu-name"], namespace=namespace))
 
                     self.lcm_tasks.register("ns", nsr_id, nslcmop_id, "instantiate_KDU-{}".format(index), task)
                     task_instantiation_info[task] = "Deploying KDU {}".format(kdur["kdu-name"])
index 1cef588..66be6f2 100644 (file)
@@ -281,7 +281,7 @@ class TestMyNS(asynctest.TestCase):
             nsd["constituent-vnfd"].append({"vnfd-id-ref": k, "member-vnf-index": k})
 
         n2vc_key_list = ["key"]
-        ro_ns_params = self.my_ns.ns_params_2_RO(ns_params, nsd, vnfd_dict, n2vc_key_list)
+        ro_ns_params = self.my_ns._ns_params_2_RO(ns_params, nsd, vnfd_dict, n2vc_key_list)
         ro_params_expected = {'wim_account': None, "datacenter": ro_vim_id,
                               "vnfs": {"5": {"vdus": {"vdu_id": {"mgmt_keys": n2vc_key_list}}}}}
         self.assertEqual(ro_ns_params, ro_params_expected)
@@ -504,7 +504,7 @@ class TestMyNS(asynctest.TestCase):
         k8s_instace_info = {"kdu-instance": None, "k8scluster-uuid": "73d96432-d692-40d2-8440-e0c73aee209c",
                             "k8scluster-type": "helm-chart",
                             "kdu-name": "ldap", "kdu-model": "stable/openldap:1.2.1",
-                            "member-vnf-index": "multikdu"}
+                            "member-vnf-index": "multikdu", "namespace": None}
 
         self.assertEqual(db_nsr["_admin"]["deployed"]["K8s"][0], k8s_instace_info)
         k8s_instace_info["kdu-name"] = "mongo"