X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Fns.py;h=7bd6a92e1cd4a9c7be12fd4ba78f776c52278117;hb=ae230237a438867e2c82a697c33e26838b849f80;hp=5bbbb21e1e2f4fdeb840580504516917f850e3ef;hpb=75b620db5807a1ecd1b62da3c92b42d5b5386307;p=osm%2FLCM.git diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 5bbbb21..7bd6a92 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -62,6 +62,8 @@ from osm_lcm.data_utils.nsd import ( get_vnf_profiles, ) from osm_lcm.data_utils.vnfd import ( + get_kdu, + get_kdu_services, get_relation_list, get_vdu_list, get_vdu_profile, @@ -96,6 +98,7 @@ from n2vc.n2vc_juju_conn import N2VCJujuConnector from n2vc.exceptions import N2VCException, N2VCNotFound, K8sException from osm_lcm.lcm_helm_conn import LCMHelmConn +from osm_lcm.osm_config import OsmConfigBuilder from osm_lcm.prometheus import parse_job from copy import copy, deepcopy @@ -1419,7 +1422,7 @@ class NsLcm(LcmBase): :param nsr_id: :param vnfr_id: :param kdu_name: - :return: IP address + :return: IP address, K8s services """ # self.logger.debug(logging_text + "Starting wait_kdu_up") @@ -1441,7 +1444,7 @@ class NsLcm(LcmBase): ) if kdur.get("status"): if kdur["status"] in ("READY", "ENABLED"): - return kdur.get("ip-address") + return kdur.get("ip-address"), kdur.get("services") else: raise LcmException( "target KDU={} is in error state".format(kdu_name) @@ -1984,9 +1987,33 @@ class NsLcm(LcmBase): # wait for RO (ip-address) Insert pub_key into VM if vnfr_id: if kdu_name: - rw_mgmt_ip = await self.wait_kdu_up( + rw_mgmt_ip, services = await self.wait_kdu_up( logging_text, nsr_id, vnfr_id, kdu_name ) + vnfd = self.db.get_one( + "vnfds_revisions", + {"_id": f'{db_vnfr["vnfd-id"]}:{db_vnfr["revision"]}'}, + ) + kdu = get_kdu(vnfd, kdu_name) + kdu_services = [ + service["name"] for service in get_kdu_services(kdu) + ] + exposed_services = [] + for service in services: + if any(s in service["name"] for s in kdu_services): + exposed_services.append(service) + await self.vca_map[vca_type].exec_primitive( + ee_id=ee_id, + primitive_name="config", + params_dict={ + "osm-config": json.dumps( + OsmConfigBuilder( + k8s={"services": exposed_services} + ).build() + ) + }, + vca_id=vca_id, + ) else: rw_mgmt_ip = await self.wait_vm_up_insert_key_ro( logging_text, @@ -1997,6 +2024,7 @@ class NsLcm(LcmBase): user=user, pub_key=pub_key, ) + else: rw_mgmt_ip = None # This is for a NS configuration @@ -5037,7 +5065,17 @@ class NsLcm(LcmBase): actions.add(primitive["name"]) for primitive in kdu_configuration.get("config-primitive", []): actions.add(primitive["name"]) - kdu_action = True if primitive_name in actions else False + kdu = find_in_list( + nsr_deployed["K8s"], + lambda kdu: kdu_name == kdu["kdu-name"] + and kdu["member-vnf-index"] == vnf_index, + ) + kdu_action = ( + True + if primitive_name in actions + and kdu["k8scluster-type"] not in ("helm-chart", "helm-chart-v3") + else False + ) # TODO check if ns is in a proper status if kdu_name and (