summaryrefslogtreecommitdiffstats
path: root/helm/plugin/workflows.py
diff options
context:
space:
mode:
authorjh245g <jh245g@att.com>2018-08-02 11:10:49 -0400
committerjh245g <jh245g@att.com>2018-08-02 11:11:23 -0400
commit7ea7c4c8d4f368d831fc145684661594f4f6561c (patch)
tree305cb4030040e6ba65e1532d9fee7ec2f1ec31be /helm/plugin/workflows.py
parent544487f0c1ea4b5efa94a4e97348ea0c412df19c (diff)
Support basic authentication in config repo
Change-Id: Ic2f40abfbb54bf006f750e4aab7993cb1f4bd5c5 Issue-ID: CCSDK-425 Signed-off-by: jh245g <jh245g@att.com>
Diffstat (limited to 'helm/plugin/workflows.py')
-rw-r--r--helm/plugin/workflows.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/helm/plugin/workflows.py b/helm/plugin/workflows.py
index c21f27c..9870bdf 100644
--- a/helm/plugin/workflows.py
+++ b/helm/plugin/workflows.py
@@ -21,6 +21,7 @@ from cloudify.exceptions import NonRecoverableError
import urllib2
import json
import yaml
+import base64
@workflow
@@ -37,7 +38,18 @@ def upgrade(node_instance_id, config_json, config_url, config_format,
if config_json == '' and config_url == '':
kwargs['config'] = config_json
elif config_json == '' and config_url != '':
- response = urllib2.urlopen(config_url)
+ if config_url.find("@"):
+ head, end = config_url.rsplit('@', 1)
+ head, auth = head.rsplit('//', 1)
+ config_url = head + '//' + end
+ username, password = auth.rsplit(':', 1)
+ request = urllib2.Request(config_url)
+ base64string = base64.encodestring(
+ '%s:%s' % (username, password)).replace('\n', '')
+ request.add_header("Authorization", "Basic %s" % base64string)
+ response = urllib2.urlopen(request)
+ else:
+ response = urllib2.urlopen(config_url)
if config_format == 'json':
kwargs['config'] = json.load(response)
elif config_format == 'yaml':