Greg Padgett has uploaded a new change for review.

Change subject: vm payload: creation of full pathnames in payload
......................................................................

vm payload: creation of full pathnames in payload

Change required for cloud-init integration: support the creation of
payloads with files residing in subdirectories of the payload image.

Change-Id: Ifd76b5d9a3b79126dfcb764ac368a3631d743d1c
Bug-Url: https://bugzilla.redhat.com/619761
Signed-off-by: Greg Padgett <[email protected]>
---
M vdsm/mkimage.py
1 file changed, 9 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/16072/1

diff --git a/vdsm/mkimage.py b/vdsm/mkimage.py
index 0eabae2..9b3c00a 100644
--- a/vdsm/mkimage.py
+++ b/vdsm/mkimage.py
@@ -35,7 +35,7 @@
 _P_PAYLOAD_IMAGES = os.path.join(P_VDSM_RUN, 'payload')
 
 
-def _decodeFilesIntoDir(files, dirname):
+def _decodeFilesIntoDir(files, parentdir):
     '''
     create temp files from files list
 
@@ -47,7 +47,14 @@
     '''
 
     for name, content in files.iteritems():
-        filename = os.path.join(dirname, name)
+        filename = os.path.join(parentdir, name)
+        dirname = os.path.dirname(filename)
+        if not os.path.exists(dirname):
+            try:
+                os.makedirs(dirname)
+            except OSError as e:
+                if e.errno != os.errno.EEXIST:
+                    raise
         with file(filename, 'w') as f:
             f.write(base64.b64decode(content))
 


-- 
To view, visit http://gerrit.ovirt.org/16072
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd76b5d9a3b79126dfcb764ac368a3631d743d1c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Greg Padgett <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to