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)
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
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"
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)
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)