Re: [sandbox PATCH v4 16/21] Image: Add Volume Support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 28, 2015 at 01:47:44PM +0000, Eren Yagdiran wrote:
> Volumes let user to map host-paths into sandbox. Docker containers
> need volumes for data persistence.

I'm a little bit puzzelled about how this feature is supposed
to be used. IIUC, in the Docker json file we have something
like

{
    "/var/my-app-data/": {},
    "/etc/some-config.d/": {},
}

> +    def getVolumes(self):
> +        volumes = self.json_data['container_config']['Volumes']
> +        volumelist = []
> +        if isinstance(volumes,collections.Iterable):
> +          for key,value in volumes.iteritems():
> +            volumelist.append(key)
> +        return volumelist

This will just return a python list

  ["/var/my-app-data/", "/etc/some-config.d"]


> diff --git a/virt-sandbox-image/virt-sandbox-image.py b/virt-sandbox-image/virt-sandbox-image.py
> index 058738a..79f8d8c 100755
> --- a/virt-sandbox-image/virt-sandbox-image.py

> @@ -150,6 +151,25 @@ def run(args):
>          if networkArgs is not None:
>              params.append('-N')
>              params.append(networkArgs)
> +        allVolumes = source.get_volume(configfile)
> +        volumeArgs = args.volume
> +        if volumeArgs is not None:
> +            allVolumes = allVolumes + volumeArgs
> +        for volume in allVolumes:
> +            volumeSplit = volume.split(":")

We don't have any ':' in our returned list from getVolumes()


> +            volumelen = len(volumeSplit)
> +            if volumelen == 2:
> +                hostPath = volumeSplit[0]
> +                guestPath = volumeSplit[1]
> +            elif volumelen == 1:
> +                guestPath = volumeSplit[0]
> +                hostPath = storage_dir + guestPath
> +                if not os.path.exists(hostPath):
> +                    os.makedirs(hostPath)
> +            else:
> +                pass

So we seem to just skip this ?

> +            params.append("--mount")
> +            params.append("host-bind:%s=%s" %(guestPath,hostPath))
>          params.append('--')
>          params.append(commandToRun)
>          cmd = cmd + params

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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]