diff options
author | Huang Haibin <haibin.huang@intel.com> | 2018-04-26 00:34:46 +0800 |
---|---|---|
committer | Huang Haibin <haibin.huang@intel.com> | 2018-04-26 00:35:53 +0800 |
commit | 6e398d3abf920b156917c0895ecfb07315774423 (patch) | |
tree | 0ff411ca0018b1fd3a4b7e11386e6afdccdffabb /share | |
parent | 3b489ef5aa8593582e550568fff263827aff0a6f (diff) |
Fix inject file error for openstack
Change-Id: Ic9e8f5eb9de715294bc0ee6d9dd222ac85412fa6
Issue-ID: MULTICLOUD-216
Signed-off-by: Huang Haibin <haibin.huang@intel.com>
Diffstat (limited to 'share')
-rw-r--r-- | share/newton_base/openoapi/server.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/share/newton_base/openoapi/server.py b/share/newton_base/openoapi/server.py index 95eab2bf..d21917a4 100644 --- a/share/newton_base/openoapi/server.py +++ b/share/newton_base/openoapi/server.py @@ -336,13 +336,30 @@ class Servers(APIView): contextarray = server.pop("contextArray", None) volumearray = server.pop("volumeArray", None) + userdata = server.pop("userdata", None) if contextarray: - # now set "contextArray" array - personalities = [] + user_data = [] + strUserData = '' + source_content = "" + dest_path = "" for context in contextarray: - personalities.append({"path": context["fileName"], "contents": context["fileData"]}) - if len(personalities) > 0: - server["personality"] = personalities + if context["fileName"] == "source_path": + source_content = context["fileData"] + if context["fileName"] == "dest_path": + dest_path = context["fileData"] + if len(source_content) > 0: + user_data.append("#cloud-config\n") + user_data.append("write_files:\n") + user_data.append("- encoding: b64\n") + user_data.append(" content: " + source_content + "\n") + user_data.append(" owner: root:root\n") + user_data.append(" path: " + dest_path + "\n") + user_data.append(" permissions: '0644'\n") + user_data.append("\n") + user_data.append("runcmd:") + user_data.append("- " + userdata + "\n") + strUserData.join(user_data) + server["user_data"] = user_data VimDriverUtils.replace_key_by_mapping(server, self.keys_mapping, True) |