From 771c32b24679051e6fc8f70fc86268e4087c875b Mon Sep 17 00:00:00 2001 From: Dominik Fleischmann Date: Tue, 7 Apr 2020 12:39:36 +0200 Subject: [PATCH] K8s action support This commit enables k8s actions by executing them the same way as any other ns-action. It needs a mandatory parameter which is application-name. This commit adds an additional check so that if no charm is present in the kdu-configuration section it is understood that the action will be executed on the KDU workloads. The commit 8761 in N2VC depends on this commit https://osm.etsi.org/gerrit/#/c/osm/N2VC/+/8761/ Change-Id: I6adf9a4f786690af5222a208137d95fc28949b34 Signed-off-by: Dominik Fleischmann --- osm_lcm/ns.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 55fa899..4176db0 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -3168,8 +3168,11 @@ class NsLcm(LcmBase): else: desc_params = self._format_additional_params(db_nsr.get("additionalParamsForNs")) + if kdu_name: + kdu_action = True if not deep_get(kdu, ("kdu-configuration", "juju")) else False + # TODO check if ns is in a proper status - if kdu_name and primitive in ("upgrade", "rollback", "status"): + if kdu_name and (primitive in ("upgrade", "rollback", "status") or kdu_action): # kdur and desc_params already set from before if primitive_params: desc_params.update(primitive_params) @@ -3221,13 +3224,24 @@ class NsLcm(LcmBase): cluster_uuid=kdu.get("k8scluster-uuid"), kdu_instance=kdu.get("kdu-instance")), timeout=timeout_ns_action) + else: + kdu_instance = kdu.get("kdu-instance") or "{}-{}".format(kdu["kdu-name"], nsr_id) + params = self._map_primitive_params(config_primitive_desc, primitive_params, desc_params) + + detailed_status = await asyncio.wait_for( + self.k8scluster_map[kdu["k8scluster-type"]].exec_primitive( + cluster_uuid=kdu.get("k8scluster-uuid"), + kdu_instance=kdu_instance, + primitive_name=primitive, + params=params, db_dict=db_dict, + timeout=timeout_ns_action), + timeout=timeout_ns_action) if detailed_status: nslcmop_operation_state = 'COMPLETED' else: detailed_status = '' nslcmop_operation_state = 'FAILED' - else: nslcmop_operation_state, detailed_status = await self._ns_execute_primitive( self._look_for_deployed_vca(nsr_deployed["VCA"], -- 2.25.1