Amend mic cr option of run_script
authoryuhuan.yang <yuhuan.yang@123.com>
Mon, 17 Jul 2017 16:12:38 +0000 (00:12 +0800)
committeryuhuan.yang <yuhuan.yang@123.com>
Mon, 17 Jul 2017 16:13:19 +0000 (00:13 +0800)
Change-Id: Ib088fb9d56b08c9aeae01908827f5507d972cdec

plugins/imager/fs_plugin.py
plugins/imager/loop_plugin.py
plugins/imager/qcow_plugin.py
plugins/imager/raw_plugin.py

index a6b5cf8..b2701a0 100755 (executable)
@@ -17,7 +17,7 @@
 
 import subprocess
 from mic import chroot, msger, rt_util
-from mic.utils import misc, errors, fs_related
+from mic.utils import misc, errors, fs_related, runner
 from mic.imager import fs
 from mic.conf import configmgr
 from mic.plugin import pluginmgr
@@ -118,10 +118,8 @@ class FsPlugin(ImagerPlugin):
         #Run script of --run_script after image created
         if creatoropts['run_script']:
             cmd = creatoropts['run_script']
-            msger.info("Running command in parameter run_script: "+"".join(cmd))
             try:
-                p = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
-                p.communicate()
+                runner.show(cmd)
             except OSError,err:
                 msger.warning(str(err))
 
index c3fa67b..6034a29 100755 (executable)
@@ -21,7 +21,7 @@ import shutil
 import tempfile
 
 from mic import chroot, msger, rt_util
-from mic.utils import misc, fs_related, errors
+from mic.utils import misc, fs_related, errors, runner
 from mic.conf import configmgr
 from mic.plugin import pluginmgr
 from mic.imager.loop import LoopImageCreator, load_mountpoints
@@ -123,10 +123,8 @@ class LoopPlugin(ImagerPlugin):
         #Run script of --run_script after image created
         if creatoropts['run_script']:
             cmd = creatoropts['run_script']
-            msger.info("Running command in parameter run_script: "+"".join(cmd))
             try:
-                p = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
-                p.communicate()
+                runner.show(cmd)
             except OSError,err:
                 msger.warning(str(err))
 
index 27a712b..a81e291 100755 (executable)
@@ -154,10 +154,8 @@ class QcowPlugin(ImagerPlugin):
         #Run script of --run_script after image created
         if creatoropts['run_script']:
             cmd = creatoropts['run_script']
-            msger.info("Running command in parameter run_script: "+"".join(cmd))
             try:
-                p = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
-                p.communicate()
+                runner.show(cmd)   
             except OSError,err:
                 msger.warning(str(err))
 
index 554eac7..1524e74 100755 (executable)
@@ -117,10 +117,8 @@ class RawPlugin(ImagerPlugin):
         #Run script of --run_script after image created
         if creatoropts['run_script']:
             cmd = creatoropts['run_script']
-            msger.info("Running command in parameter run_script: "+"".join(cmd))
             try:
-                p = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
-                p.communicate()
+                runner.show(cmd)
             except OSError,err:
                 msger.warning(str(err))