Re: [PATCH sandbox v5 12/20] Image: Add get_disk function to Source

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

 



On Tue, 2015-09-08 at 17:29 +0100, Daniel P. Berrange wrote:
> From: Eren Yagdiran <erenyagdiran@xxxxxxxxx>
> 
> Provide a way to know which disk image to use for the sandbox depending on the used source
> DockerSource will need to locate the topmost disk image among all the layers images
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  libvirt-sandbox/image/sources/DockerSource.py | 12 ++++++++++++
>  libvirt-sandbox/image/sources/Source.py       | 12 ++++++++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/libvirt-sandbox/image/sources/DockerSource.py b/libvirt-sandbox/image/sources/DockerSource.py
> index 2607011..31c1d80 100644
> --- a/libvirt-sandbox/image/sources/DockerSource.py
> +++ b/libvirt-sandbox/image/sources/DockerSource.py
> @@ -362,6 +362,18 @@ class DockerSource(Source):
>          configfile = templatedir + "/" + toplayer + "/template.json"
>          return configfile, diskfile
>  
> +    def get_disk(self,templatename, templatedir, imagedir, sandboxname):
> +        configfile, diskfile = self._get_template_data(templatename, templatedir)
> +        tempfile = imagedir + "/" + sandboxname + ".qcow2"
> +        if not os.path.exists(imagedir):
> +            os.makedirs(imagedir)
> +        cmd = ["qemu-img","create","-q","-f","qcow2"]
> +        cmd.append("-o")
> +        cmd.append("backing_fmt=qcow2,backing_file=%s" % diskfile)
> +        cmd.append(tempfile)
> +        subprocess.call(cmd)
> +        return tempfile
> +
>      def get_command(self, templatename, templatedir, userargs):
>          configfile, diskfile = self._get_template_data(templatename, templatedir)
>          configParser = DockerConfParser(configfile)
> diff --git a/libvirt-sandbox/image/sources/Source.py b/libvirt-sandbox/image/sources/Source.py
> index 4305d0b..a5d3844 100644
> --- a/libvirt-sandbox/image/sources/Source.py
> +++ b/libvirt-sandbox/image/sources/Source.py
> @@ -83,3 +83,15 @@ class Source():
>          is specified, then this should override the default args in
>          the image"""
>          pass
> +
> +    @abstractmethod
> +    def get_disk(self,templatename, templatedir, imagedir, sandboxname):
> +        """
> +        :param templatename: name of the template image to download
> +        :param templatedir: local directory path in which to find template
> +        :param imagedir: local directory in which to storage disk image
> +
> +        Creates an instance private disk image, backed by the content
> +        of a template.
> +        """
> +        pass

ACK

--
Cedric

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