summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsunbin <bins@vmware.com>2018-05-09 13:50:30 +0800
committersunbin <bins@vmware.com>2018-05-09 14:06:03 +0800
commit867ec0c8a092a525a423e0dc5044b7e206a448c7 (patch)
tree30c96786fa3b8686d5c1385ebb9dc9458b564693
parent69bf5aff787a6a37688ee212f6e6612da8c29b77 (diff)
Support inject many files
Change-Id: Iac95fffc217fe79c4cff2c6dad2881137b3f8493 Issue-ID: MULTICLOUD-227 Signed-off-by: sunbin <bins@vmware.com>
-rw-r--r--vio/vio/pub/vim/vimapi/nova/OperateServers.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/vio/vio/pub/vim/vimapi/nova/OperateServers.py b/vio/vio/pub/vim/vimapi/nova/OperateServers.py
index 5fd1c73..78b86ea 100644
--- a/vio/vio/pub/vim/vimapi/nova/OperateServers.py
+++ b/vio/vio/pub/vim/vimapi/nova/OperateServers.py
@@ -97,10 +97,24 @@ class OperateServers(OperateNova):
)
inject_files = create_req.get('contextArray', [])
if inject_files:
- req['personality'] = []
- for i in inject_files:
- req['personality'].append(
- {"path": i["fileName"], "contents": i["fileData"]})
+ user_data = []
+ strUserData = ""
+ user_data.append("#cloud-config\n")
+ for f in inject_files:
+ user_data.append("write_files:\n")
+ user_data.append("- encoding: b64\n")
+ user_data.append(" content: " +
+ f["source_data_base64"] + "\n")
+ user_data.append(" owner: root:root\n")
+ user_data.append(" path: " + f["dest_path"] + "\n")
+ user_data.append(" permissions: '0644'\n")
+ user_data.append("\n")
+ if userdata:
+ user_data.append("runcmd:\n")
+ user_data.append("- " + userdata + "\n")
+
+ strUserData.join(user_data)
+ req["user_data"] = strUserData
return cc.create_server(**req)