]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Rename _pexpect_spawn() to _pexpect_spawn_ipmi()
authorZack Cerza <zack@redhat.com>
Wed, 24 Aug 2016 14:39:43 +0000 (08:39 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 30 Aug 2016 16:47:33 +0000 (10:47 -0600)
A new _pexpect_spawn() is added, to be used for general cases. It is
used by _pexpect_spawn_ipmi().

Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/orchestra/console.py

index 29ed6cf181a005dd554c101ad51bb861a5d5b753..23a532db266f8b24d6774b1ccbf92797616f40d3 100644 (file)
@@ -55,18 +55,23 @@ class PhysicalConsole():
                 ".teuthology.yaml"
             )
 
-    def _pexpect_spawn(self, cmd):
+    def _pexpect_spawn_ipmi(self, ipmi_cmd):
         """
         Run the cmd specified using ipmitool.
         """
         self._check_credentials()
-        full_command = self._ipmi_command(cmd)
-        log.debug('pexpect command: %s', full_command)
-        child = pexpect.spawn(
-            full_command,
+        full_command = self._ipmi_command(ipmi_cmd)
+        return self._pexpect_spawn(full_command)
+
+    def _pexpect_spawn(self, cmd):
+        """
+        Run a command using pexpect.spawn(). Return the child object.
+        """
+        log.debug('pexpect command: %s', cmd)
+        return pexpect.spawn(
+            cmd,
             logfile=self.logfile,
         )
-        return child
 
     def _console_command(self):
         if self.has_conserver:
@@ -95,7 +100,7 @@ class PhysicalConsole():
         r = child.expect(
             ['terminated ipmitool', pexpect.TIMEOUT, pexpect.EOF], timeout=t)
         if r != 0:
-            self._pexpect_spawn('sol deactivate')
+            self._pexpect_spawn_ipmi('sol deactivate')
 
     def _wait_for_login(self, timeout=None, attempts=2):
         """
@@ -107,7 +112,7 @@ class PhysicalConsole():
         for i in range(0, attempts):
             start = time.time()
             while time.time() - start < t:
-                child = self._pexpect_spawn('sol activate')
+                child = self._pexpect_spawn_ipmi('sol activate')
                 child.send('\n')
                 log.debug('expect: {s} login'.format(s=self.shortname))
                 r = child.expect(
@@ -132,7 +137,7 @@ class PhysicalConsole():
         total = t
         ta = time.time()
         while total < timeout:
-            c = self._pexpect_spawn('power status')
+            c = self._pexpect_spawn_ipmi('power status')
             r = c.expect(['Chassis Power is {s}'.format(
                 s=state), pexpect.EOF, pexpect.TIMEOUT], timeout=t)
             tb = time.time()
@@ -167,7 +172,7 @@ class PhysicalConsole():
         Power cycle and wait for login.
         """
         log.info('Power cycling {s}'.format(s=self.shortname))
-        child = self._pexpect_spawn('power cycle')
+        child = self._pexpect_spawn_ipmi('power cycle')
         child.expect('Chassis Power Control: Cycle', timeout=self.timeout)
         self._wait_for_login(timeout=300)
         log.info('Power cycle for {s} completed'.format(s=self.shortname))
@@ -180,7 +185,7 @@ class PhysicalConsole():
         log.info('Performing hard reset of {s}'.format(s=self.shortname))
         start = time.time()
         while time.time() - start < self.timeout:
-            child = self._pexpect_spawn('power reset')
+            child = self._pexpect_spawn_ipmi('power reset')
             r = child.expect(['Chassis Power Control: Reset', pexpect.EOF],
                              timeout=self.timeout)
             if r == 0:
@@ -195,7 +200,7 @@ class PhysicalConsole():
         log.info('Power on {s}'.format(s=self.shortname))
         start = time.time()
         while time.time() - start < self.timeout:
-            child = self._pexpect_spawn('power on')
+            child = self._pexpect_spawn_ipmi('power on')
             r = child.expect(['Chassis Power Control: Up/On', pexpect.EOF],
                              timeout=self.timeout)
             if r == 0:
@@ -211,7 +216,7 @@ class PhysicalConsole():
         log.info('Power off {s}'.format(s=self.shortname))
         start = time.time()
         while time.time() - start < self.timeout:
-            child = self._pexpect_spawn('power off')
+            child = self._pexpect_spawn_ipmi('power off')
             r = child.expect(['Chassis Power Control: Down/Off', pexpect.EOF],
                              timeout=self.timeout)
             if r == 0:
@@ -228,12 +233,12 @@ class PhysicalConsole():
         """
         log.info('Power off {s} for {i} seconds'.format(
             s=self.shortname, i=interval))
-        child = self._pexpect_spawn('power off')
+        child = self._pexpect_spawn_ipmi('power off')
         child.expect('Chassis Power Control: Down/Off', timeout=self.timeout)
 
         time.sleep(interval)
 
-        child = self._pexpect_spawn('power on')
+        child = self._pexpect_spawn_ipmi('power on')
         child.expect('Chassis Power Control: Up/On', timeout=self.timeout)
         self._wait_for_login()
         log.info('Power off for {i} seconds completed'.format(