- if not operation_params.get("skip_terminate_primitives"):
- stage[0] = "Stage 2/3 execute terminating primitives."
- stage[1] = "Looking execution environment that needs terminate."
- self.logger.debug(logging_text + stage[1])
- for vca_index, vca in enumerate(get_iterable(nsr_deployed, "VCA")):
- config_descriptor = None
- if not vca or not vca.get("ee_id") or not vca.get("needed_terminate"):
- continue
- if not vca.get("member-vnf-index"):
- # ns
- config_descriptor = db_nsr.get("ns-configuration")
- elif vca.get("vdu_id"):
- db_vnfd = db_vnfds_from_member_index[vca["member-vnf-index"]]
- vdud = next((vdu for vdu in db_vnfd.get("vdu", ()) if vdu["id"] == vca.get("vdu_id")), None)
- if vdud:
- config_descriptor = vdud.get("vdu-configuration")
- elif vca.get("kdu_name"):
- db_vnfd = db_vnfds_from_member_index[vca["member-vnf-index"]]
- kdud = next((kdu for kdu in db_vnfd.get("kdu", ()) if kdu["name"] == vca.get("kdu_name")), None)
- if kdud:
- config_descriptor = kdud.get("kdu-configuration")
- else:
- config_descriptor = db_vnfds_from_member_index[vca["member-vnf-index"]].get("vnf-configuration")
- task = asyncio.ensure_future(self.destroy_N2VC(logging_text, db_nslcmop, vca, config_descriptor,
- vca_index, False))
- tasks_dict_info[task] = "Terminating VCA {}".format(vca.get("ee_id"))
-
- # wait for pending tasks of terminate primitives
- if tasks_dict_info:
- self.logger.debug(logging_text + 'Waiting for terminate primitive pending tasks...')
- error_list = await self._wait_for_tasks(logging_text, tasks_dict_info,
- min(self.timeout_charm_delete, timeout_ns_terminate),
- stage, nslcmop_id)
- if error_list:
- return # raise LcmException("; ".join(error_list))
- tasks_dict_info.clear()
+ # TODO - check before calling _destroy_N2VC
+ # if not operation_params.get("skip_terminate_primitives"):#
+ # or not vca.get("needed_terminate"):
+ stage[0] = "Stage 2/3 execute terminating primitives."
+ self.logger.debug(logging_text + stage[0])
+ stage[1] = "Looking execution environment that needs terminate."
+ self.logger.debug(logging_text + stage[1])
+ # self.logger.debug("nsr_deployed: {}".format(nsr_deployed))
+ for vca_index, vca in enumerate(get_iterable(nsr_deployed, "VCA")):
+ self.logger.debug("vca_index: {}, vca: {}".format(vca_index, vca))
+ config_descriptor = None
+ if not vca or not vca.get("ee_id"):
+ continue
+ if not vca.get("member-vnf-index"):
+ # ns
+ config_descriptor = db_nsr.get("ns-configuration")
+ elif vca.get("vdu_id"):
+ db_vnfd = db_vnfds_from_member_index[vca["member-vnf-index"]]
+ vdud = next((vdu for vdu in db_vnfd.get("vdu", ()) if vdu["id"] == vca.get("vdu_id")), None)
+ if vdud:
+ config_descriptor = vdud.get("vdu-configuration")
+ elif vca.get("kdu_name"):
+ db_vnfd = db_vnfds_from_member_index[vca["member-vnf-index"]]
+ kdud = next((kdu for kdu in db_vnfd.get("kdu", ()) if kdu["name"] == vca.get("kdu_name")), None)
+ if kdud:
+ config_descriptor = kdud.get("kdu-configuration")
+ else:
+ config_descriptor = db_vnfds_from_member_index[vca["member-vnf-index"]].get("vnf-configuration")
+ vca_type = vca.get("type")
+ exec_terminate_primitives = (not operation_params.get("skip_terminate_primitives") and
+ vca.get("needed_terminate"))
+ # For helm we must destroy_ee
+ destroy_ee = "True" if vca_type == "helm" else "False"
+ task = asyncio.ensure_future(
+ self.destroy_N2VC(logging_text, db_nslcmop, vca, config_descriptor, vca_index,
+ destroy_ee, exec_terminate_primitives))
+ tasks_dict_info[task] = "Terminating VCA {}".format(vca.get("ee_id"))
+
+ # wait for pending tasks of terminate primitives
+ if tasks_dict_info:
+ self.logger.debug(logging_text + 'Waiting for terminate primitive pending tasks...')
+ error_list = await self._wait_for_tasks(logging_text, tasks_dict_info,
+ min(self.timeout_charm_delete, timeout_ns_terminate),
+ stage, nslcmop_id)
+ if error_list:
+ return # raise LcmException("; ".join(error_list))
+ tasks_dict_info.clear()