
On Fri, Aug 28, 2015 at 01:47:42PM +0000, Eren Yagdiran wrote:
Run an already-built template If there is no execution command specified by user, source.get_command will find the command to invoke --- virt-sandbox-image/virt-sandbox-image.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/virt-sandbox-image/virt-sandbox-image.py b/virt-sandbox-image/virt-sandbox-image.py index a73619c..c182874 100755 --- a/virt-sandbox-image/virt-sandbox-image.py +++ b/virt-sandbox-image/virt-sandbox-image.py @@ -130,6 +130,31 @@ def check_connect(connectstr): raise ValueError("%s is not supported by Virt-sandbox" %connectstr) return True
+def run(args): + try: + if args.connect is not None: + check_connect(args.connect) + source = dynamic_source_loader(args.source) + diskfile,configfile = source.get_disk(name=args.name,templatedir=args.template_dir,id=args.id) + + format = "qcow2" + commandToRun = args.igniter + if commandToRun is None: + commandToRun = source.get_command(configfile) + cmd = ['virt-sandbox'] + if args.connect is not None: + cmd.append("-c") + cmd.append(args.connect)
We must also pass '-n' to give the instance name, otherwise we'll never be able to run more than one docker image at once
+ params = ['-m','host-image:/=%s,format=%s' %(diskfile,format), + '--', + commandToRun] + cmd = cmd + params + subprocess.call(cmd) + subprocess.call(["rm", "-rf", diskfile])
We should just use os.unlink(diskfile) - no need to shell out to the rm command to just delete a single file 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 :|