diff options
author | Bin Yang <bin.yang@windriver.com> | 2020-02-28 23:16:51 +0800 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2020-02-28 23:29:20 +0800 |
commit | f7596bca0552ce6c4db33968c05bca3ecf410aa1 (patch) | |
tree | 406439b6de95a81358097588751a59d6526780d3 /share | |
parent | 852c29fdefd20a7859d877f982d468eca6aecf22 (diff) |
Fix starlingx infra_workload API issue
Use base64 to encode and decode content of override_values.yaml
Change-Id: Ib74eff3ac5acee35689cdd0665146b785fe3bcd4
Issue-ID: MULTICLOUD-1003
Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'share')
-rw-r--r-- | share/starlingx_base/resource/k8s_infra_workload_helper.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/share/starlingx_base/resource/k8s_infra_workload_helper.py b/share/starlingx_base/resource/k8s_infra_workload_helper.py index e66c166b..5dd0bcfa 100644 --- a/share/starlingx_base/resource/k8s_infra_workload_helper.py +++ b/share/starlingx_base/resource/k8s_infra_workload_helper.py @@ -17,6 +17,7 @@ import logging import json import requests import tarfile +import base64 from ruamel import yaml @@ -68,7 +69,7 @@ class InfraWorkloadHelper: # 1, create profile if not exists # manifest.yaml content - manifest_yaml = { + manifest_yaml_json = { "version": "v1", "type": { "values": "override_values.yaml" @@ -86,10 +87,8 @@ class InfraWorkloadHelper: for attr in user_directive.get("attributes", []): aname = attr.get("attribute_name", None) avalue = attr.get("attribute_value", None) - if aname == "override_values": - # manifest_yaml = avalue["manifest_yaml"] - # #override_values_yaml = avalue["override_values_yaml"] - override_values_yaml = avalue + if aname == "override_values_yaml_base64": + override_values_yaml_json = yaml.load(base64.b64encode(avalue), Loader=yaml.Loader) elif aname == "definition-name": rbname = avalue elif aname == "definition-version": @@ -99,7 +98,7 @@ class InfraWorkloadHelper: multicloudK8sUrl = "%s://%s:%s/api/multicloud-k8s/v1" % ( settings.MSB_SERVICE_PROTOCOL, settings.MSB_SERVICE_ADDR, settings.MSB_SERVICE_PORT) - if rbname and rbversion and profilename: + if rbname and rbversion and profilename and override_values_yaml: # package them into tarball basedir="/tmp/%s_%s_%s/" % (rbname, rbversion, profilename) manifest_yaml_filename="manifest.yaml" @@ -109,10 +108,10 @@ class InfraWorkloadHelper: os.mkdir(basedir) logger.debug("k8s profile temp dir for %s,%s,%s is %s" % (rbname, rbversion, profilename, basedir)) with open(basedir+manifest_yaml_filename, "w") as f: - yaml.dump(manifest_yaml, f, Dumper=yaml.RoundTripDumper) + yaml.dump(manifest_yaml_json, f, Dumper=yaml.RoundTripDumper) with open(basedir+override_values_yaml_filename, "w") as f: - #yaml.dump(override_values_yaml, f, Dumper=yaml.RoundTripDumper) - f.write(override_values_yaml) + yaml.dump(override_values_yaml_json, f, Dumper=yaml.RoundTripDumper) + #f.write(override_values_yaml) tar = tarfile.open(basedir+profile_filename, "w:gz") # tar.add(basedir+manifest_yaml_filename, arcname=manifest_yaml_filename,filter=resettarfile) |