[sandbox v2 3/5] virt-sandbox-image: remove the format parameter

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

 



The format parameter isn't used so far and would only be misleading
users. Removing it for the while, but may be reintroduced later when
adding storage backend support.
---
 libvirt-sandbox/image/cli.py                  |  9 ++-------
 libvirt-sandbox/image/sources/DockerSource.py | 18 ++++--------------
 libvirt-sandbox/image/sources/Source.py       |  3 +--
 3 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/libvirt-sandbox/image/cli.py b/libvirt-sandbox/image/cli.py
index 4500713..f067347 100755
--- a/libvirt-sandbox/image/cli.py
+++ b/libvirt-sandbox/image/cli.py
@@ -75,8 +75,7 @@ def create(args):
     source = tmpl.get_source_impl()
     source.create_template(template=tmpl,
                            templatedir=args.template_dir,
-                           connect=args.connect,
-                           format=args.format)
+                           connect=args.connect)
 
 def run(args):
     if args.connect is not None:
@@ -95,7 +94,6 @@ def run(args):
                                imagedir=args.image_dir,
                                sandboxname=name)
 
-    format = "qcow2"
     commandToRun = source.get_command(tmpl, args.template_dir, args.args)
     if len(commandToRun) == 0:
         commandToRun = ["/bin/sh"]
@@ -103,7 +101,7 @@ def run(args):
     if args.connect is not None:
         cmd.append("-c")
         cmd.append(args.connect)
-    params = ['-m','host-image:/=%s,format=%s' %(diskfile,format)]
+    params = ['-m','host-image:/=%s,format=qcow2' % diskfile]
 
     networkArgs = args.network
     if networkArgs is not None:
@@ -185,9 +183,6 @@ def gen_create_args(subparser):
     requires_template(parser)
     requires_connect(parser)
     requires_template_dir(parser)
-    parser.add_argument("-f","--format",
-                        default="qcow2",
-                        help=_("format format for image"))
     parser.set_defaults(func=create)
 
 def gen_run_args(subparser):
diff --git a/libvirt-sandbox/image/sources/DockerSource.py b/libvirt-sandbox/image/sources/DockerSource.py
index 0d76717..1f6f94f 100644
--- a/libvirt-sandbox/image/sources/DockerSource.py
+++ b/libvirt-sandbox/image/sources/DockerSource.py
@@ -241,11 +241,7 @@ class DockerSource(Source):
             debug("FAIL %s\n" % str(e))
             raise
 
-    def create_template(self, template, templatedir, connect=None, format=None):
-        if format is None:
-            format = "qcow2"
-        self._check_disk_format(format)
-
+    def create_template(self, template, templatedir, connect=None):
         self.download_template(template, templatedir)
 
         imagelist = self._get_image_list(template, templatedir)
@@ -253,7 +249,7 @@ class DockerSource(Source):
 
         parentImage = None
         for imagetagid in imagelist:
-            templateImage = templatedir + "/" + imagetagid + "/template." + format
+            templateImage = templatedir + "/" + imagetagid + "/template.qcow2"
             cmd = ["qemu-img","create","-f","qcow2"]
             if parentImage is not None:
                 cmd.append("-o")
@@ -264,21 +260,15 @@ class DockerSource(Source):
             subprocess.call(cmd)
 
             if parentImage is None:
-                self.format_disk(templateImage,format,connect)
+                self.format_disk(templateImage, "qcow2", connect)
 
             path = templatedir + "/" + imagetagid + "/template."
             self.extract_tarball(path + "qcow2",
-                                 format,
+                                 "qcow2",
                                  path + "tar.gz",
                                  connect)
             parentImage = templateImage
 
-
-    def _check_disk_format(self,format):
-        supportedFormats = ['qcow2']
-        if not format in supportedFormats:
-            raise ValueError(["Unsupported image format %s" % format])
-
     def _get_image_list(self, template, destdir):
         imageparent = {}
         imagenames = {}
diff --git a/libvirt-sandbox/image/sources/Source.py b/libvirt-sandbox/image/sources/Source.py
index 15737c1..a31bab8 100644
--- a/libvirt-sandbox/image/sources/Source.py
+++ b/libvirt-sandbox/image/sources/Source.py
@@ -36,12 +36,11 @@ class Source():
 
     @abstractmethod
     def create_template(self, template, templatedir,
-                        connect=None, format=None):
+                        connect=None):
         """
         :param template: libvirt_sandbox.template.Template object
         :param templatedir: local directory path in which to store the template
         :param connect: libvirt connection URI
-        :param format: disk image format
 
         Create a set of local disk images populated with the content
         of a template. The images creation process will be isolated
-- 
2.1.4

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