[libvirt] [sandbox PATCH 2/2] Add support for virt-sandbox-service to add additional mount points.
Daniel P. Berrange
berrange at redhat.com
Fri May 10 18:51:43 UTC 2013
On Fri, May 10, 2013 at 02:29:25PM -0400, dwalsh at redhat.com wrote:
> From: Dan Walsh <dwalsh at redhat.com>
>
> Add similar support to virt-sandbox-service that is in virt-sandbox
> to add guest-bind, host-bind and host-image mount points on the command
> line. Openshift needs feature.
> ---
> bin/virt-sandbox-service | 38 ++++++++++++++++++++--
> bin/virt-sandbox-service-bash-completion.sh | 4 ++-
> bin/virt-sandbox-service-create.pod | 49 ++++++++++++++++++++++++++---
> 3 files changed, 82 insertions(+), 9 deletions(-)
>
> diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
> index d7f43a5..0c656d7 100755
> --- a/bin/virt-sandbox-service
> +++ b/bin/virt-sandbox-service
> @@ -330,12 +340,10 @@ class GenericContainer(Container):
> sys.stdout.write(_("Created sandbox container image %s\n") % self.image)
> else:
> sys.stdout.write(_("Created sandbox container dir %s\n") % self.dest)
> + self.add_mounts()
> self.save_config()
>
> def create(self):
> - config_path = self.get_config_path()
> - if os.path.exists(config_path):
> - raise ValueError([_("%s already exists") % config_path ])
You're removing code here that you just added in the previous patch.
> @@ -1007,6 +1017,25 @@ class CheckUnit(argparse.Action):
> unitfiles = [ (value, src) ]
> setattr(namespace, self.dest, unitfiles)
>
> +valid_mounts = { "host-bind", "host-image", "guest-bind" }
> +class AddMount(argparse.Action):
> + def __call__(self, parser, namespace, values, option_string=None):
> + mounts = getattr(namespace, self.dest)
> + mrec = values.split(":")
> + if mrec[0] not in valid_mounts:
> + raise ValueError([_("Invalid mount type '%s'. Valid types %s." % ( mrec[0], ",".join(valid_mounts)))])
> + try:
> + dest,src = mrec[1].split("=");
> + mdict = {"type":mrec[0], "src": src, "dest":dest }
> + except (IndexError, ValueError):
> + raise ValueError([_("Invalid mount '%s' specification.") % values ])
All this code can just go away - the gvir_config_add_mount_strv does
validation already.
> +
> + if mounts:
> + mounts.append(values)
> + else:
> + mounts = [values]
> + setattr(namespace, self.dest, mounts)
> +
> class SetNet(argparse.Action):
> def __call__(self, parser, namespace, values, option_string=None):
> nets = getattr(namespace, self.dest)
> @@ -1056,6 +1085,9 @@ def gen_create_args(subparser):
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 :|
More information about the libvir-list
mailing list