summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--helm/helm-type.yaml13
-rw-r--r--helm/plugin/tasks.py22
-rw-r--r--helm/plugin/workflows.py22
-rw-r--r--helm/setup.py2
4 files changed, 39 insertions, 20 deletions
diff --git a/helm/helm-type.yaml b/helm/helm-type.yaml
index 2e79849..6645620 100644
--- a/helm/helm-type.yaml
+++ b/helm/helm-type.yaml
@@ -19,7 +19,7 @@ plugins:
helm-plugin:
executor: central_deployment_agent
package_name: onap-helm-plugin
- package_version: 2.2.0
+ package_version: 2.3.0
node_types:
@@ -58,6 +58,10 @@ node_types:
description: String format config file url
type: string
default: ''
+ config-format:
+ description: String format config file format
+ type: string
+ default: 'json'
runtime-config:
default: ''
description: String format json object. To save the runtime config generate from other nodes.
@@ -113,9 +117,12 @@ workflows:
config_json:
description: The changes to the new config json
default: ''
- config_json_url:
- description: The changes to the new config json url
+ config_url:
+ description: The config input url
default: ''
+ config_format:
+ description: The config url input format
+ default: 'json'
chartVersion:
description: chart version
chartRepo:
diff --git a/helm/plugin/tasks.py b/helm/plugin/tasks.py
index 8df29ac..5fda295 100644
--- a/helm/plugin/tasks.py
+++ b/helm/plugin/tasks.py
@@ -146,7 +146,8 @@ def config(**kwargs):
# create helm value file on K8s master
#configPath = ctx.node.properties['config-path']
configJson = str(ctx.node.properties['config'])
- configJsonUrl = str(ctx.node.properties['config-url'])
+ configUrl = str(ctx.node.properties['config-url'])
+ configUrlInputFormat = str(ctx.node.properties['config-format'])
runtime_config = str(ctx.node.properties['runtime-config']) #json
componentName = ctx.node.properties['component-name']
config_dir_root= str(ctx.node.properties['config-dir'])
@@ -183,12 +184,17 @@ def config(**kwargs):
ctx.logger.debug(configPath)
configObj ={}
- if configJson == '' and configJsonUrl == '':
+ if configJson == '' and configUrl == '':
ctx.logger.debug("Will use default HELM value")
- elif configJson == '' and configJsonUrl != '':
- response = urllib2.urlopen(configJsonUrl)
- configObj = json.load(response)
- elif configJson != '' and configJsonUrl == '':
+ elif configJson == '' and configUrl != '':
+ response = urllib2.urlopen(configUrl)
+ if configUrlInputFormat == 'json':
+ configObj = json.load(response)
+ elif configUrlInputFormat == 'yaml':
+ configObj = yaml.load(response)
+ else:
+ raise NonRecoverableError("Unable to get config input format.")
+ elif configJson != '' and configUrl == '':
configObj = json.loads(configJson)
else:
raise NonRecoverableError("Unable to get Json config input")
@@ -222,14 +228,14 @@ def start(**kwargs):
configPath=config_dir_root+str(ctx.deployment.id)+'/'+componentName+'.yaml'
namespace = ctx.node.properties['namespace']
configJson = str(ctx.node.properties['config'])
- configJsonUrl = str(ctx.node.properties['config-url'])
+ configUrl = str(ctx.node.properties['config-url'])
runtimeconfigJson = str(ctx.node.properties['runtime-config'])
chart = chartRepo + "/" + componentName + "-" + chartVersion + ".tgz"
chartName = namespace + "-" + componentName
- if configJson == '' and runtimeconfigJson == '' and configJsonUrl == '':
+ if configJson == '' and runtimeconfigJson == '' and configUrl == '':
installCommand = 'helm install '+ chart + ' --name ' + chartName + ' --namespace ' + namespace+tiller_host()+tls()
else:
installCommand = 'helm install ' + chart + ' --name ' + chartName + ' --namespace ' + namespace + ' -f '+ configPath +tiller_host()+tls()
diff --git a/helm/plugin/workflows.py b/helm/plugin/workflows.py
index d341bf7..7dc8272 100644
--- a/helm/plugin/workflows.py
+++ b/helm/plugin/workflows.py
@@ -20,9 +20,10 @@ from cloudify.workflows import ctx
from cloudify.exceptions import NonRecoverableError
import urllib2
import json
+import yaml
@workflow
-def upgrade(node_instance_id,config_json,config_json_url,chartVersion,chartRepo,**kwargs):
+def upgrade(node_instance_id,config_json,config_url,config_format,chartVersion,chartRepo,**kwargs):
node_instance = ctx.get_node_instance(node_instance_id)
if not node_instance_id:
@@ -31,13 +32,18 @@ def upgrade(node_instance_id,config_json,config_json_url,chartVersion,chartRepo,
node_instance_id))
kwargs = {}
- if config_json == '' and config_json_url == '':
- kwargs['config'] = config_json
- elif config_json == '' and config_json_url != '':
- response = urllib2.urlopen(config_json_url)
- kwargs['config'] = json.load(response)
- elif config_json != '' and config_json_url == '':
- kwargs['config'] = config_json
+ if config_json == '' and config_url == '':
+ kwargs['config'] = config_json
+ elif config_json == '' and config_url != '':
+ response = urllib2.urlopen(config_url)
+ if config_format == 'json':
+ kwargs['config'] = json.load(response)
+ elif config_format == 'yaml':
+ kwargs['config'] = yaml.load(response)
+ else:
+ raise NonRecoverableError("Unable to get config input format")
+ elif config_json != '' and config_url == '':
+ kwargs['config'] = config_json
else:
raise NonRecoverableError("Unable to get Json config input")
diff --git a/helm/setup.py b/helm/setup.py
index c3bfe88..2a60585 100644
--- a/helm/setup.py
+++ b/helm/setup.py
@@ -24,7 +24,7 @@ setup(
# Do not use underscores in the plugin name.
name='onap-helm-plugin',
- version='2.2.0',
+ version='2.3.0',
author='Nicolas Hu(AT&T)',
author_email='jh245g@att.com',
description='This plugin will install/uninstall/upgrade/rollback helm charts of ONAP components. ',