Add a new 'status' workflow for Helm Plugin 07/74207/1
authorHong Guan <hg4105@att.com>
Tue, 4 Dec 2018 19:35:36 +0000 (14:35 -0500)
committerHong Guan <hg4105@att.com>
Tue, 4 Dec 2018 19:35:36 +0000 (14:35 -0500)
Change-Id: I87aa50b5ab5524494f035b290323c697169f26b9
Issue-ID: CCSDK-788
Signed-off-by: Hong Guan <hg4105@att.com>
helm/helm-type.yaml
helm/plugin/tasks.py
helm/plugin/workflows.py
helm/setup.py

index 15b5956..0b32d34 100644 (file)
@@ -19,7 +19,7 @@ plugins:
   helm-plugin:
     executor: central_deployment_agent
     package_name: helm
-    package_version: 3.0.0
+    package_version: 3.0.1
 
 node_types:
 
@@ -106,6 +106,7 @@ node_types:
         stop: helm-plugin.plugin.tasks.stop
         upgrade: helm-plugin.plugin.tasks.upgrade
         rollback: helm-plugin.plugin.tasks.rollback
+        status: helm-plugin.plugin.tasks.status
 
 
 workflows:
@@ -134,3 +135,6 @@ workflows:
         description: The id of the node-instance that you want to modify.
       revision:
         description: Check the node runtime property history, find the revision number you want to rollback to
+  status:
+    mapping: helm-plugin.plugin.workflows.status
+    parameters:
index 3374e94..7cb9147 100644 (file)
@@ -368,3 +368,22 @@ def rollback(**kwargs):
             retry_after=5)
     get_current_helm_value(chartName)
     get_helm_history(chartName)
+
+@operation
+def status(**kwargs):
+    componentName = ctx.node.properties['component-name']
+    namespace = ctx.node.properties['namespace']
+
+    chartName = namespace + "-" + componentName
+    statusCommand = 'helm status ' + chartName + tiller_host() + tls()
+    output = execute_command(statusCommand)
+    if output == False:
+        return ctx.operation.retry(
+            message='helm status failed, re-try after 5 second ',
+            retry_after=5)
+
+    status_output = [line.strip() for line in output.split('\n') if
+                            line.strip()]
+    for index in range(len(status_output)):
+        status_output[index] = status_output[index].replace('\t', ' ')
+    ctx.instance.runtime_properties['install-status'] = status_output
index 2999b73..de5549d 100644 (file)
@@ -83,3 +83,13 @@ def rollback(node_instance_id, revision, **kwargs):
     operation_args = {'operation': 'rollback', }
     operation_args['kwargs'] = kwargs
     node_instance.execute_operation(**operation_args)
+
+@workflow
+def status(**kwargs):
+
+    for node in ctx.nodes:
+        for node_instance in node.instances:
+            kwargs = {}
+            operation_args = {'operation': 'status', }
+            operation_args['kwargs'] = kwargs
+            node_instance.execute_operation(**operation_args)
index 5eba25c..b020186 100644 (file)
@@ -24,7 +24,7 @@ setup(
 
     # Do not use underscores in the plugin name.
     name='helm',
-    version='3.0.0',
+    version='3.0.1',
     author='Nicolas Hu(AT&T)',
     author_email='jh245g@att.com',
     description='This plugin will install/uninstall/upgrade/rollback helm '