vnfd = self.db.get_one("vnfds", {"_id": vnfd_id})
# store vnfd
- db_vnfds.append(vnfd) # vnfd's indexed by id
+ db_vnfds.append(vnfd)
# Get or generates the _admin.deployed.VCA list
vca_deployed_list = None
# Step 0: Prepare and set parameters
desc_params = parse_yaml_strings(kdur.get("additionalParams"))
vnfd_id = vnfr_data.get('vnfd-id')
- kdud = next(kdud for kdud in db_vnfds[vnfd_id]["kdu"] if kdud["name"] == kdur["kdu-name"])
+ vnfd_with_id = find_in_list(db_vnfds, lambda vnfd: vnfd["_id"] == vnfd_id)
+ kdud = next(kdud for kdud in vnfd_with_id["kdu"] if kdud["name"] == kdur["kdu-name"])
namespace = kdur.get("k8s-namespace")
if kdur.get("helm-chart"):
- kdumodel = kdur["helm-chart"]
+ kdumodel = kdur["helm-chart"]["kdu-model-locator"]
# Default version: helm3, if helm-version is v2 assign v2
k8sclustertype = "helm-chart-v3"
self.logger.debug("kdur: {}".format(kdur))
if kdur.get("helm-version") and kdur.get("helm-version") == "v2":
k8sclustertype = "helm-chart"
elif kdur.get("juju-bundle"):
- kdumodel = kdur["juju-bundle"]
+ kdumodel = kdur["juju-bundle"]["kdu-model-locator"]
k8sclustertype = "juju-bundle"
else:
raise LcmException("kdu type for kdu='{}.{}' is neither helm-chart nor "
format(vnfr_data["member-vnf-index-ref"], kdur["kdu-name"]))
# check if kdumodel is a file and exists
try:
- storage = deep_get(db_vnfds.get(vnfd_id), ('_admin', 'storage'))
+ vnfd_with_id = find_in_list(db_vnfds, lambda vnfd: vnfd["_id"] == vnfd_id)
+ storage = deep_get(vnfd_with_id, ('_admin', 'storage'))
if storage and storage.get('pkg-dir'): # may be not present if vnfd has not artifacts
# path format: /vnfdid/pkkdir/helm-charts|juju-bundles/kdumodel
filename = '{}/{}/{}s/{}'.format(storage["folder"], storage["pkg-dir"], k8sclustertype,
db_path = "_admin.deployed.K8s.{}".format(index)
db_nsr_update[db_path] = k8s_instance_info
self.update_db_2("nsrs", nsr_id, db_nsr_update)
-
+ vnfd_with_id = find_in_list(db_vnfds, lambda vnf: vnf["_id"] == vnfd_id)
task = asyncio.ensure_future(
- self._install_kdu(nsr_id, db_path, vnfr_data, kdu_index, kdud, db_vnfds[vnfd_id],
+ self._install_kdu(nsr_id, db_path, vnfr_data, kdu_index, kdud, vnfd_with_id,
k8s_instance_info, k8params=desc_params, timeout=600))
self.lcm_tasks.register("ns", nsr_id, nslcmop_id, "instantiate_KDU-{}".format(index), task)
task_instantiation_info[task] = "Deploying KDU {}".format(kdur["kdu-name"])
desc_params = parse_yaml_strings(db_vnfr.get("additionalParamsForVnf"))
else:
desc_params = parse_yaml_strings(db_nsr.get("additionalParamsForNs"))
-
- if kdu_name and get_kdu_configuration(db_vnfd):
- kdu_action = True if not get_kdu_configuration(db_vnfd)["juju"] else False
+ if kdu_name and get_kdu_configuration(db_vnfd, kdu_name):
+ kdu_configuration = get_kdu_configuration(db_vnfd, kdu_name)
+ actions = set()
+ for primitive in kdu_configuration["initial-config-primitive"]:
+ actions.add(primitive["name"])
+ for primitive in kdu_configuration["config-primitive"]:
+ actions.add(primitive["name"])
+ kdu_action = True if primitive_name in actions else False
# TODO check if ns is in a proper status
if kdu_name and (primitive_name in ("upgrade", "rollback", "status") or kdu_action):