X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_lcm%2Fns.py;h=9d8812a92a18e9aadd54c9d54f176641493f631b;hb=refs%2Fchanges%2F39%2F8539%2F1;hp=c9b7767005874a8a1c9c0215c4a27463fb9e57b2;hpb=63f90047f7b6a8253c6e3aafb493163ffdfcc4e1;p=osm%2FLCM.git diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index c9b7767..9d8812a 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -1500,6 +1500,7 @@ class NsLcm(LcmBase): nsr_id=nsr_id, db_nsr=db_nsr, db_vnfrs=db_vnfrs, + db_vnfds=db_vnfds ) ) self.lcm_tasks.register("ns", nsr_id, nslcmop_id, "instantiate_KDUs", task_kdu) @@ -1986,7 +1987,7 @@ class NsLcm(LcmBase): self.logger.warn(logging_text + ' ERROR adding relations: {}'.format(e)) return False - async def deploy_kdus(self, logging_text, nsr_id, db_nsr, db_vnfrs): + async def deploy_kdus(self, logging_text, nsr_id, db_nsr, db_vnfrs, db_vnfds): # Launch kdus if present in the descriptor deployed_ok = True @@ -2022,6 +2023,8 @@ class NsLcm(LcmBase): k8sclustertype = None error_text = None cluster_uuid = None + vnfd_id = vnfr_data.get('vnfd-id') + pkgdir = deep_get(db_vnfds.get(vnfd_id), ('_admin', 'storage', 'pkg-dir')) if kdur.get("helm-chart"): kdumodel = kdur["helm-chart"] k8sclustertype = "chart" @@ -2033,6 +2036,15 @@ class NsLcm(LcmBase): else: error_text = "kdu type is neither helm-chart nor juju-bundle. Maybe an old NBI version is" \ " running" + # check if kdumodel is a file and exists + try: + # path format: /vnfdid/pkkdir/kdumodel + filename = '{}/{}/{}s/{}'.format(vnfd_id, pkgdir, k8sclustertype_full, kdumodel) + if self.fs.file_exists(filename, mode='file') or self.fs.file_exists(filename, mode='dir'): + kdumodel = self.fs.path + filename + except Exception: + # it is not a file + pass try: if not error_text: cluster_uuid = _get_cluster_id(kdur["k8s-cluster"]["id"], k8sclustertype_full) @@ -2068,32 +2080,33 @@ class NsLcm(LcmBase): pending_tasks[task] = "_admin.deployed.K8s.{}.".format(index) index += 1 - if not pending_tasks: - return - self.logger.debug(logging_text + 'Waiting for terminate pending tasks...') - pending_list = list(pending_tasks.keys()) - while pending_list: - done_list, pending_list = await asyncio.wait(pending_list, timeout=30*60, - return_when=asyncio.FIRST_COMPLETED) - if not done_list: # timeout - for task in pending_list: - db_nsr_update[pending_tasks(task) + "detailed-status"] = "Timeout" - deployed_ok = False - break - for task in done_list: - exc = task.exception() - if exc: - db_nsr_update[pending_tasks[task] + "detailed-status"] = "{}".format(exc) - deployed_ok = False - else: - db_nsr_update[pending_tasks[task] + "kdu-instance"] = task.result() + + if pending_tasks: + self.logger.debug(logging_text + 'Waiting for terminate pending tasks...') + pending_list = list(pending_tasks.keys()) + while pending_list: + done_list, pending_list = await asyncio.wait(pending_list, timeout=30*60, + return_when=asyncio.FIRST_COMPLETED) + if not done_list: # timeout + for task in pending_list: + db_nsr_update[pending_tasks(task) + "detailed-status"] = "Timeout" + deployed_ok = False + break + for task in done_list: + exc = task.exception() + if exc: + db_nsr_update[pending_tasks[task] + "detailed-status"] = "{}".format(exc) + deployed_ok = False + else: + db_nsr_update[pending_tasks[task] + "kdu-instance"] = task.result() if not deployed_ok: raise LcmException('Cannot deploy KDUs') except Exception as e: - self.logger.critical(logging_text + "Exit Exception {} while '{}': {}".format(type(e).__name__, step, e)) - raise LcmException("{} Exit Exception {} while '{}': {}".format(logging_text, type(e).__name__, step, e)) + msg = "{} Exit Exception {} while '{}': {}".format(logging_text, type(e).__name__, step, e) + self.logger.error(msg) + raise LcmException(msg) finally: if db_nsr_update: self.update_db_2("nsrs", nsr_id, db_nsr_update)