call copy_attachment() after configure() and move attachment files
[tools/mic.git] / plugins / imager / qcow_plugin.py
old mode 100644 (file)
new mode 100755 (executable)
index 03ed0da..a1d808a
@@ -15,6 +15,7 @@
 # Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 import os
+import subprocess
 import shutil
 
 from mic import msger, rt_util
@@ -64,7 +65,7 @@ class QcowPlugin(ImagerPlugin):
     name = 'qcow'
 
     @classmethod
-    def do_create(cls, subcmd, opts, *args):
+    def do_create(cls, args):
         """${cmd_name}: create qcow image
 
         Usage:
@@ -72,25 +73,15 @@ class QcowPlugin(ImagerPlugin):
 
         ${cmd_option_list}
         """
-        if len(args) != 1:
-            raise errors.Usage("Extra arguments given")
+        if args is None:
+            raise errors.Usage("Invalid arguments")
 
         creatoropts = configmgr.create
-        ksconf = args[0]
+        ksconf = args.ksfile
 
         if creatoropts['runtime'] == "bootstrap":
             configmgr._ksconf = ksconf
             rt_util.bootstrap_mic()
-        elif not rt_util.inbootstrap():
-            try:
-                fs_related.find_binary_path('mic-native')
-            except errors.CreatorError:
-                if not msger.ask("Subpackage \"mic-native\" has not been "
-                                 "installed in your host system, still "
-                                 "continue with \"native\" running mode?",
-                                 False):
-                    raise errors.Abort("Abort because subpackage 'mic-native' "
-                                       "has not been installed")
 
         recording_pkgs = []
         if len(creatoropts['record_pkgs']) > 0:
@@ -120,7 +111,7 @@ class QcowPlugin(ImagerPlugin):
 
         if not pkgmgr:
             raise errors.CreatorError("Can't find backend: %s, "
-                                      "available choices: %s" %
+                                       "available choices: %s" %
                                       (creatoropts['pkgmgr'],
                                        ','.join(backends.keys())))
 
@@ -143,7 +134,10 @@ class QcowPlugin(ImagerPlugin):
             creator.install()
             creator.configure(creatoropts["repomd"])
             creator.copy_kernel()
+            creator.copy_attachment()
+            creator.create_cpio_image()
             creator.unmount()
+            creator.copy_cpio_image()
             creator.package(creatoropts["destdir"])
             creator.create_manifest()
 
@@ -158,6 +152,15 @@ class QcowPlugin(ImagerPlugin):
         finally:
             creator.cleanup()
 
+        #Run script of --run_script after image created
+        if creatoropts['run_script']:
+            cmd = creatoropts['run_script']
+            try:
+                runner.show(cmd)
+            except OSError,err:
+                msger.warning(str(err))
+
+
         msger.info("Finished.")
         return 0