
On Tue, Aug 04, 2015 at 08:11:11PM +0000, Eren Yagdiran wrote:
Move the docker-related code to the DockerSource and use the Source mechanism --- virt-sandbox-image/sources/DockerSource.py | 100 +++++++++++++++++++++++++++++ virt-sandbox-image/sources/Source.py | 4 ++ virt-sandbox-image/virt-sandbox-image.py | 70 ++++---------------- 3 files changed, 118 insertions(+), 56 deletions(-)
diff --git a/virt-sandbox-image/sources/DockerSource.py b/virt-sandbox-image/sources/DockerSource.py index cf81ffe..9cd0080 100644 --- a/virt-sandbox-image/sources/DockerSource.py +++ b/virt-sandbox-image/sources/DockerSource.py @@ -223,5 +223,105 @@ class DockerSource(Source):
+ def _format_disk(self,disk,format,connect): + cmd = ['virt-sandbox'] + if connect is not None: + cmd.append("-c") + cmd.append(connect) + params = ['--disk=file:disk_image=%s,format=%s' %(disk,format), + '/sbin/mkfs.ext3', + '/dev/disk/by-tag/disk_image'] + cmd = cmd + params + subprocess.call(cmd)
We need to include the '-p' argument, because if running with qemu:///session you'll be unprivileged by default, so need -p to become root in the sandbox.
+ def _extract_tarballs(self,directory,format,connect): + tempdir = "/mnt" + tarfile = directory + "tar.gz" + diskfile = directory + "qcow2" + cmd = ['virt-sandbox'] + if connect is not None: + cmd.append("-c") + cmd.append(connect) + params = ['-m', + 'host-image:/mnt=%s,format=%s' %(diskfile,format), + '--', + '/bin/tar', + 'zxvf',
Could probably leave out the 'v' flag, since I don't think we need to display a list of every file. Or make it conditional on some --debug flag to virt-sandbox-image.
+ '%s' %tarfile, + '-C', + '/mnt'] + cmd = cmd + params + subprocess.call(cmd)
Same here about -p flag needed Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|