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