self.logger.error(f"{error} occured while getting the charm name")
raise LcmException(error)
+ def get_vca_info(self, ee_item, db_nsr, get_charm_name: bool):
+ vca_name = charm_name = vca_type = None
+ if ee_item.get("juju"):
+ vca_name = ee_item["juju"].get("charm")
+ if get_charm_name:
+ charm_name = self.find_charm_name(db_nsr, str(vca_name))
+ vca_type = (
+ "lxc_proxy_charm"
+ if ee_item["juju"].get("charm") is not None
+ else "native_charm"
+ )
+ if ee_item["juju"].get("cloud") == "k8s":
+ vca_type = "k8s_proxy_charm"
+ elif ee_item["juju"].get("proxy") is False:
+ vca_type = "native_charm"
+ elif ee_item.get("helm-chart"):
+ vca_name = ee_item["helm-chart"]
+ vca_type = "helm-v3"
+ return vca_name, charm_name, vca_type
+
class TaskRegistry(LcmBase):
"""
)
)
if del_repo_list or added_repo_dict:
+ unset = updated = None
if k8sclustertype == "helm-chart":
unset = {
"_admin.helm_charts_added." + item: None
k8s_cluster_id, del_repo_list, added_repo_dict
)
)
- self.db.set_one(
- "k8sclusters",
- {"_id": k8s_cluster_id},
- updated,
- unset=unset,
- )
+ if updated and unset:
+ self.db.set_one(
+ "k8sclusters",
+ {"_id": k8s_cluster_id},
+ updated,
+ unset=unset,
+ )
# Instantiate kdu
step = "Instantiating KDU {}.{} in k8s cluster {}".format(
)
)
ee_descriptor_id = ee_item.get("id")
- if ee_item.get("juju"):
- vca_name = ee_item["juju"].get("charm")
- if get_charm_name:
- charm_name = self.find_charm_name(db_nsr, str(vca_name))
- vca_type = (
- "lxc_proxy_charm"
- if ee_item["juju"].get("charm") is not None
- else "native_charm"
- )
- if ee_item["juju"].get("cloud") == "k8s":
- vca_type = "k8s_proxy_charm"
- elif ee_item["juju"].get("proxy") is False:
- vca_type = "native_charm"
- elif ee_item.get("helm-chart"):
- vca_name = ee_item["helm-chart"]
- vca_type = "helm-v3"
- else:
+ vca_name, charm_name, vca_type = self.get_vca_info(
+ ee_item, db_nsr, get_charm_name
+ )
+ if not vca_type:
self.logger.debug(
- logging_text + "skipping non juju neither charm configuration"
+ logging_text + "skipping, non juju/charm/helm configuration"
)
continue
if nsr_deployed.get("VCA"):
stage[1] = "Deleting all execution environments."
self.logger.debug(logging_text + stage[1])
- vca_id = self.get_vca_id({}, db_nsr)
- task_delete_ee = asyncio.ensure_future(
- asyncio.wait_for(
- self._delete_all_N2VC(db_nsr=db_nsr, vca_id=vca_id),
- timeout=self.timeout.charm_delete,
+ helm_vca_list = get_deployed_vca(db_nsr, {"type": "helm-v3"})
+ if helm_vca_list:
+ # Delete Namespace and Certificates
+ await self.vca_map["helm-v3"].delete_tls_certificate(
+ namespace=db_nslcmop["nsInstanceId"],
+ certificate_name=self.EE_TLS_NAME,
)
- )
- # task_delete_ee = asyncio.ensure_future(self.n2vc.delete_namespace(namespace="." + nsr_id))
- tasks_dict_info[task_delete_ee] = "Terminating all VCA"
-
- # Delete Namespace and Certificates if necessary
- if check_helm_ee_in_ns(list(db_vnfds_from_member_index.values())):
- await self.vca_map["helm-v3"].delete_tls_certificate(
- namespace=db_nslcmop["nsInstanceId"],
- certificate_name=self.EE_TLS_NAME,
- )
- await self.vca_map["helm-v3"].delete_namespace(
- namespace=db_nslcmop["nsInstanceId"],
- )
-
+ await self.vca_map["helm-v3"].delete_namespace(
+ namespace=db_nslcmop["nsInstanceId"],
+ )
+ else:
+ vca_id = self.get_vca_id({}, db_nsr)
+ task_delete_ee = asyncio.ensure_future(
+ asyncio.wait_for(
+ self._delete_all_N2VC(db_nsr=db_nsr, vca_id=vca_id),
+ timeout=self.timeout.charm_delete,
+ )
+ )
+ tasks_dict_info[task_delete_ee] = "Terminating all VCA"
# Delete from k8scluster
stage[1] = "Deleting KDUs."
self.logger.debug(logging_text + stage[1])
# get all needed from database
db_nsr = None
db_nslcmop = None
+ db_vnfd = None
db_nsr_update = {}
db_nslcmop_update = {}
nslcmop_operation_state = None
error_description_nslcmop = None
exc = None
step = ""
+ kdu_action = False
+
try:
# wait for any previous tasks in process
step = "Waiting for previous operations to terminate"
self.update_db_2("nsrs", nsr_id, db_nsr_update)
# look for primitive
- config_primitive_desc = descriptor_configuration = None
+ config_primitive_desc = None
if vdu_id:
descriptor_configuration = get_configuration(db_vnfd, vdu_id)
elif kdu_name:
change_type = "updated"
detailed_status = ""
member_vnf_index = None
+ vca_id = None
try:
# wait for any previous tasks in process
)
)
ee_descriptor_id = ee_item.get("id")
- if ee_item.get("juju"):
- vca_name = ee_item["juju"].get("charm")
- if get_charm_name:
- charm_name = self.find_charm_name(db_nsr, str(vca_name))
- vca_type = (
- "lxc_proxy_charm"
- if ee_item["juju"].get("charm") is not None
- else "native_charm"
- )
- if ee_item["juju"].get("cloud") == "k8s":
- vca_type = "k8s_proxy_charm"
- elif ee_item["juju"].get("proxy") is False:
- vca_type = "native_charm"
- elif ee_item.get("helm-chart"):
- vca_name = ee_item["helm-chart"]
- vca_type = "helm-v3"
- else:
+ vca_name, charm_name, vca_type = self.get_vca_info(
+ ee_item, db_nsr, get_charm_name
+ )
+ if not vca_type:
self.logger.debug(
- logging_text + "skipping non juju neither charm configuration"
+ logging_text + "skipping, non juju/charm/helm configuration"
)
continue