+ def _look_for_k8scluster(self, session, rollback, vnfr, vim_account, vnfr_update, vnfr_update_rollback):
+ """
+ Look for an available k8scluster for all the kuds in the vnfd matching version and cni requirements.
+ Fills vnfr.kdur with the selected k8scluster
+
+ :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
+ :param rollback: list with the database modifications to rollback if needed
+ :param vnfr: vnfr to be updated. It is modified with pdu interface info if pdu is found
+ :param vim_account: vim_account where this vnfr should be deployed
+ :param vnfr_update: dictionary filled by this method with changes to be done at database vnfr
+ :param vnfr_update_rollback: dictionary filled by this method with original content of vnfr in case a rollback
+ of the changed vnfr is needed
+
+ :return: List of KDU interfaces that are connected to an existing VIM network. Each item contains:
+ "vim-network-name": used at VIM
+ "name": interface name
+ "vnf-vld-id": internal VNFD vld where this interface is connected, or
+ "ns-vld-id": NSD vld where this interface is connected.
+ NOTE: One, and only one between 'vnf-vld-id' and 'ns-vld-id' contains a value. The other will be None
+ """
+
+ ifaces_forcing_vim_network = []
+ for kdur_index, kdur in enumerate(get_iterable(vnfr.get("kdur"))):
+ kdu_filter = self._get_project_filter(session)
+ kdu_filter["vim_account"] = vim_account
+ # TODO kdu_filter["_admin.operationalState"] = "ENABLED"
+
+ available_k8sclusters = self.db.get_list("k8sclusters", kdu_filter)
+ k8s_requirements = {} # just for logging
+ for k8scluster in available_k8sclusters:
+ # restrict by cni
+ if kdur["k8s-cluster"].get("cni"):
+ k8s_requirements["cni"] = kdur["k8s-cluster"]["cni"]
+ if not set(kdur["k8s-cluster"]["cni"]).intersection(k8scluster.get("cni", ())):
+ continue
+ # restrict by version
+ if kdur["k8s-cluster"].get("version"):
+ k8s_requirements["version"] = kdur["k8s-cluster"]["version"]
+ if k8scluster.get("k8s_version") not in kdur["k8s-cluster"]["version"]:
+ continue
+ break
+ else:
+ raise EngineException(
+ "No k8scluster with requirements='{}' at vim_account={} found for member_vnf_index={}, kdu={}"
+ .format(k8s_requirements, vim_account, vnfr["member-vnf-index-ref"], kdur["kdu-name"]))
+
+ # step 3. Fill vnfr info by filling kdur
+ kdu_text = "kdur.{}.".format(kdur_index)
+ vnfr_update_rollback[kdu_text + "k8s-cluster.id"] = None
+ vnfr_update[kdu_text + "k8s-cluster.id"] = k8scluster["_id"]
+
+ # TODO proccess interfaces ifaces_forcing_vim_network
+ return ifaces_forcing_vim_network
+