[libvirt] [libvirt-sandbox PATCH 0/2] virt-sandbox-image: unbreak start from library

This is basically a V2 of "Drop library/ from template name and image path" with Dan's comment implemented. Guido Günther (2): Drop library/ from image path Sanitize domain name libvirt-sandbox/image/cli.py | 8 ++++++-- libvirt-sandbox/image/sources/docker.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) -- 2.11.0

If one pastes from the output of virt-sansbox-image $ virt-sandbox-image list docker:/library/ubuntu?tag=17.04 docker:/library/debian?tag=latest verbatim $ virt-sandbox-image run -c qemu:///session docker:/library/debian?tag=latest This fails like /home/<usr>/.local/share/libvirt/images/library/debian:qbeilwxard.qcow2: Could not create file: No such file or directory so strip off any leading components. --- libvirt-sandbox/image/sources/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-sandbox/image/sources/docker.py b/libvirt-sandbox/image/sources/docker.py index aa5675e..6ca086c 100755 --- a/libvirt-sandbox/image/sources/docker.py +++ b/libvirt-sandbox/image/sources/docker.py @@ -655,7 +655,7 @@ class DockerSource(base.Source): def get_disk(self, template, templatedir, imagedir, sandboxname): image = DockerImage.from_template(template) configfile, diskfile = self._get_template_data(image, templatedir) - tempfile = imagedir + "/" + sandboxname + ".qcow2" + tempfile = imagedir + "/" + sandboxname.split('/')[-1] + ".qcow2" if not os.path.exists(imagedir): os.makedirs(imagedir) cmd = ["qemu-img","create","-q","-f","qcow2"] -- 2.11.0

On Wed, Jun 07, 2017 at 08:02:04AM +0200, Guido Günther wrote:
If one pastes from the output of virt-sansbox-image
$ virt-sandbox-image list docker:/library/ubuntu?tag=17.04 docker:/library/debian?tag=latest
verbatim
$ virt-sandbox-image run -c qemu:///session docker:/library/debian?tag=latest
This fails like
/home/<usr>/.local/share/libvirt/images/library/debian:qbeilwxard.qcow2: Could not create file: No such file or directory
so strip off any leading components. --- libvirt-sandbox/image/sources/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

Hi, On Fri, Sep 15, 2017 at 01:05:27PM +0100, Daniel P. Berrange wrote:
On Wed, Jun 07, 2017 at 08:02:04AM +0200, Guido Günther wrote:
If one pastes from the output of virt-sansbox-image
$ virt-sandbox-image list docker:/library/ubuntu?tag=17.04 docker:/library/debian?tag=latest
verbatim
$ virt-sandbox-image run -c qemu:///session docker:/library/debian?tag=latest
This fails like
/home/<usr>/.local/share/libvirt/images/library/debian:qbeilwxard.qcow2: Could not create file: No such file or directory
so strip off any leading components. --- libvirt-sandbox/image/sources/docker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Pushed both patches. Thanks! -- Guido

If one pastes from the output of virt-sansbox-image $ virt-sandbox-image list docker:/library/ubuntu?tag=17.04 docker:/library/debian?tag=latest verbatim $ virt-sandbox-image run -c qemu:///session docker:/library/debian?tag=latest This fails like Unable to start sandbox: Failed to create domain: XML error: name library/debian:qbeilwxard cannot contain '/' so don't allow invalid chars like '/' in domain names --- libvirt-sandbox/image/cli.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libvirt-sandbox/image/cli.py b/libvirt-sandbox/image/cli.py index 3a5ccfa..d5e624c 100644 --- a/libvirt-sandbox/image/cli.py +++ b/libvirt-sandbox/image/cli.py @@ -27,6 +27,7 @@ import hashlib import json import os import os.path +import re import shutil import sys import urllib2 @@ -81,6 +82,10 @@ def prepare(args): templatedir=get_template_dir(args), connect=args.connect) +def random_domain_name(tmpl): + randomid = ''.join(random.choice(string.lowercase) for i in range(10)) + return re.sub('[^a-z0-9-]', '_', tmpl.path[1:], re.I) + ":" + randomid + def run(args): if args.connect is not None: check_connect(args.connect) @@ -95,8 +100,7 @@ def run(args): name = args.name if name is None: - randomid = ''.join(random.choice(string.lowercase) for i in range(10)) - name = tmpl.path[1:] + ":" + randomid + name = random_domain_name(tmpl) diskfile = source.get_disk(template=tmpl, templatedir=template_dir, -- 2.11.0

On Wed, Jun 07, 2017 at 08:02:05AM +0200, Guido Günther wrote:
If one pastes from the output of virt-sansbox-image
$ virt-sandbox-image list docker:/library/ubuntu?tag=17.04 docker:/library/debian?tag=latest
verbatim
$ virt-sandbox-image run -c qemu:///session docker:/library/debian?tag=latest
This fails like
Unable to start sandbox: Failed to create domain: XML error: name library/debian:qbeilwxard cannot contain '/'
so don't allow invalid chars like '/' in domain names --- libvirt-sandbox/image/cli.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Wed, Jun 07, 2017 at 08:02:03AM +0200, Guido Günther wrote:
This is basically a V2 of "Drop library/ from template name and image path" with Dan's comment implemented.
Ping? -- Guido
Guido Günther (2): Drop library/ from image path Sanitize domain name
libvirt-sandbox/image/cli.py | 8 ++++++-- libvirt-sandbox/image/sources/docker.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-)
-- 2.11.0
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Hi, On Wed, Jun 21, 2017 at 10:00:32PM +0200, Guido Günther wrote:
On Wed, Jun 07, 2017 at 08:02:03AM +0200, Guido Günther wrote:
This is basically a V2 of "Drop library/ from template name and image path" with Dan's comment implemented.
Ping?
Ping again. -- Guido
-- Guido
Guido Günther (2): Drop library/ from image path Sanitize domain name
libvirt-sandbox/image/cli.py | 8 ++++++-- libvirt-sandbox/image/sources/docker.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-)
-- 2.11.0
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (2)
-
Daniel P. Berrange
-
Guido Günther