Separate qcow plugin scripts 10/243210/2
authorbiao716.wang <biao716.wang@samsung.com>
Fri, 4 Sep 2020 02:51:02 +0000 (11:51 +0900)
committerbiao716.wang <biao716.wang@samsung.com>
Fri, 4 Sep 2020 02:52:21 +0000 (11:52 +0900)
Change-Id: Ieb7d4e761b7847ae218dbe9724996f54daf78070
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
mic/imager/qcow.py [new file with mode: 0755]
plugins/imager/qcow_plugin.py

diff --git a/mic/imager/qcow.py b/mic/imager/qcow.py
new file mode 100755 (executable)
index 0000000..f4b66fc
--- /dev/null
@@ -0,0 +1,57 @@
+#
+# Copyright (c) 2014 Intel, Inc.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+import os
+import shutil
+
+from mic.imager.loop import LoopImageCreator
+from mic.utils import errors, fs_related, runner
+
+class QcowImageCreator(LoopImageCreator):
+    img_format = 'qcow'
+
+    def __init__(self, creatoropts=None, pkgmgr=None):
+        LoopImageCreator.__init__(self, creatoropts, pkgmgr)
+        self.cmd_qemuimg = 'qemu-img'
+
+    def _stage_final_image(self):
+        try:
+            self.cmd_qemuimg = fs_related.find_binary_path('qemu-img')
+        except errors.CreatorError:
+            return LoopImageCreator._stage_final_image(self)
+
+        self._resparse()
+
+        imgfile = None
+        for item in self._instloops:
+            if item['mountpoint'] == '/':
+                if item['fstype'] == "ext4":
+                    runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s'
+                                % imgfile)
+                self.image_files.setdefault('partitions', {}).update(
+                         {item['mountpoint']: item['label']})
+                imgfile = os.path.join(self._imgdir, item['name'])
+
+        if imgfile:
+            qemuimage = imgfile + ".x86"
+            runner.show("%s convert -O qcow2 %s %s"
+                        % (self.cmd_qemuimg, imgfile, qemuimage))
+            os.unlink(imgfile)
+            os.rename(qemuimage, imgfile)
+
+        for item in os.listdir(self._imgdir):
+            shutil.move(os.path.join(self._imgdir, item),
+                        os.path.join(self._outdir, item))
index 7bc6193..cec6757 100755 (executable)
@@ -22,44 +22,8 @@ from mic import msger, rt_util
 from mic.conf import configmgr
 from mic.plugin import pluginmgr
 from mic.pluginbase import ImagerPlugin
-from mic.imager.loop import LoopImageCreator
-from mic.utils import errors, fs_related, runner
-
-class QcowImageCreator(LoopImageCreator):
-    img_format = 'qcow'
-
-    def __init__(self, creatoropts=None, pkgmgr=None):
-        LoopImageCreator.__init__(self, creatoropts, pkgmgr) 
-        self.cmd_qemuimg = 'qemu-img'
-
-    def _stage_final_image(self):
-        try:
-            self.cmd_qemuimg = fs_related.find_binary_path('qemu-img')
-        except errors.CreatorError:
-            return LoopImageCreator._stage_final_image(self)
-
-        self._resparse()
-
-        imgfile = None
-        for item in self._instloops:
-            if item['mountpoint'] == '/':
-                if item['fstype'] == "ext4":
-                    runner.show('/sbin/tune2fs -O ^huge_file,extents,uninit_bg %s'
-                                % imgfile)
-                self.image_files.setdefault('partitions', {}).update(
-                         {item['mountpoint']: item['label']})
-                imgfile = os.path.join(self._imgdir, item['name'])
-
-        if imgfile:
-            qemuimage = imgfile + ".x86"
-            runner.show("%s convert -O qcow2 %s %s"
-                        % (self.cmd_qemuimg, imgfile, qemuimage))
-            os.unlink(imgfile)
-            os.rename(qemuimage, imgfile)
-
-        for item in os.listdir(self._imgdir):
-            shutil.move(os.path.join(self._imgdir, item),
-                        os.path.join(self._outdir, item))
+from mic.imager.qcow import QcowImageCreator
+from mic.utils import errors, runner
 
 class QcowPlugin(ImagerPlugin):
     name = 'qcow'