From: tierno Date: Tue, 7 Apr 2020 09:07:33 +0000 (+0000) Subject: allow k8s namespace parameter X-Git-Tag: v7.1.0rc1~10 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F66%2F8766%2F5;p=osm%2FLCM.git allow k8s namespace parameter Change-Id: If3e1dfbdcbedd637ababfb4a34f4f17b90bf3723 Signed-off-by: tierno --- diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 4e46539..55fa899 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -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"]) diff --git a/osm_lcm/tests/test_ns.py b/osm_lcm/tests/test_ns.py index 1cef588..66be6f2 100644 --- a/osm_lcm/tests/test_ns.py +++ b/osm_lcm/tests/test_ns.py @@ -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"