Call python script directly in preparation & post-phase 39/35439/1
authorAlex Yang <yangyang1@zte.com.cn>
Sat, 27 May 2017 02:01:19 +0000 (10:01 +0800)
committerAlex Yang <yangyang1@zte.com.cn>
Sat, 27 May 2017 03:41:23 +0000 (11:41 +0800)
Avoid calling python though a bash in the deployment script of python.

Change-Id: I655c7b919ea5970ff842ac03cafed11b82d03601
Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
deploy/daisy_server.py

index ec30ec9..5fa0957 100644 (file)
@@ -205,8 +205,9 @@ class DaisyServer(object):
         if self.adapter != 'libvirt':
             return
         LI('Prepare some configuration files')
-        cmd = 'bash {script} -n {net_file}'.format(
-            script=path_join(self.remote_dir, 'deploy/prepare.sh'),
+        cmd = 'export PYTHONPATH={python_path}; python {script} -nw {net_file}'.format(
+            python_path=self.remote_dir,
+            script=path_join(self.remote_dir, 'deploy/prepare/execute.py'),
             net_file=path_join(self.remote_dir, 'network.yml'))
         self.ssh_run(cmd)
 
@@ -258,7 +259,8 @@ class DaisyServer(object):
 
     def post_deploy(self):
         LI('Post deploy ...')
-        cmd = 'bash {script} -n {net_file}'.format(
-            script=path_join(self.remote_dir, 'deploy/post.sh'),
+        cmd = 'export PYTHONPATH={python_path}; python {script} -nw {net_file}'.format(
+            python_path=self.remote_dir,
+            script=path_join(self.remote_dir, 'deploy/post/execute.py'),
             net_file=path_join(self.remote_dir, 'network.yml'))
         self.ssh_run(cmd, check=False)