K8s action support 67/8767/4
authorDominik Fleischmann <dominik.fleischmann@canonical.com>
Tue, 7 Apr 2020 10:39:36 +0000 (12:39 +0200)
committerDominik Fleischmann <dominik.fleischmann@canonical.com>
Thu, 16 Apr 2020 14:44:56 +0000 (16:44 +0200)
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 <dominik.fleischmann@canonical.com>
osm_lcm/ns.py

index 55fa899..4176db0 100644 (file)
@@ -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"],