]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add PhysicalConsole.spawn_sol_log()
authorZack Cerza <zack@redhat.com>
Thu, 18 Aug 2016 21:47:57 +0000 (15:47 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 23 Aug 2016 20:40:20 +0000 (14:40 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/orchestra/console.py

index 130962d528d6f6e7aaa2803f12ca0d8c4958e114..c8ec2a5921d7a1f44f06f54474d5ad8b7078c568 100644 (file)
@@ -1,5 +1,7 @@
 import logging
+import os
 import pexpect
+import subprocess
 import time
 
 from teuthology import lockstatus as ls
@@ -209,6 +211,28 @@ class PhysicalConsole():
         log.info('Power off for {i} seconds completed'.format(
             s=self.shortname, i=interval))
 
+    def spawn_sol_log(self, dest_path):
+        """
+        Using the subprocess module, spawn an ipmitool process using 'sol
+        activate' and redirect its output to a file.
+
+        :returns: a subprocess.Popen object
+        """
+        ipmi_cmd = self._build_command('sol activate')
+        pexpect_templ = \
+            "import pexpect; " \
+            "pexpect.run('{cmd}', logfile=file('{log}', 'w'), timeout=None)"
+        python_cmd = 'python -c "%s"' % pexpect_templ.format(
+            cmd=ipmi_cmd,
+            log=dest_path,
+        )
+        proc = subprocess.Popen(
+            python_cmd,
+            shell=True,
+            env=os.environ,
+        )
+        return proc
+
 
 class VirtualConsole():
     """