]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move console checking to its own function
authorZack Cerza <zack@redhat.com>
Tue, 16 Aug 2016 16:06:47 +0000 (10:06 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 16 Aug 2016 23:07:33 +0000 (17:07 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/nuke.py

index 957a6dbbe66e0cf80da689df1c9866804d7d0582..b3dbf47e1114c8174ab32a2c589ee49d231ed7e5 100644 (file)
@@ -389,6 +389,32 @@ def synch_clocks(remotes):
         )
 
 
+def check_console(hostname):
+    shortname = orchestra.remote.getShortName(hostname)
+    console = orchestra.remote.getRemoteConsole(
+        name=hostname,
+        ipmiuser=config['ipmi_user'],
+        ipmipass=config['ipmi_password'],
+        ipmidomain=config['ipmi_domain'])
+    cname = '{host}.{domain}'.format(
+        host=shortname,
+        domain=config['ipmi_domain'])
+    log.info('checking console status of %s' % cname)
+    if not console.check_status():
+        # not powered on or can't get IPMI status.  Try to power on
+        console.power_on()
+        # try to get status again
+        log.info('checking console status of %s' % cname)
+        if not console.check_status(timeout=100):
+            log.error(
+                "Failed to get console status for %s, " % cname
+            )
+        else:
+            log.info('console ready on %s' % cname)
+    else:
+        log.info('console ready on %s' % cname)
+
+
 def stale_openstack(ctx):
     targets = dict(map(lambda i: (i['ID'], i),
                        OpenStack.list_instances()))
@@ -659,28 +685,7 @@ def nuke_helper(ctx, should_unlock):
     log.debug('{ctx}'.format(ctx=ctx))
     if (not ctx.noipmi and 'ipmi_user' in config and
             'vpm' not in shortname):
-        console = orchestra.remote.getRemoteConsole(
-            name=host,
-            ipmiuser=config['ipmi_user'],
-            ipmipass=config['ipmi_password'],
-            ipmidomain=config['ipmi_domain'])
-        cname = '{host}.{domain}'.format(
-            host=shortname,
-            domain=config['ipmi_domain'])
-        log.info('checking console status of %s' % cname)
-        if not console.check_status():
-            # not powered on or can't get IPMI status.  Try to power on
-            console.power_on()
-            # try to get status again
-            log.info('checking console status of %s' % cname)
-            if not console.check_status(timeout=100):
-                log.error(
-                    "Failed to get console status for %s, " % cname
-                )
-            else:
-                log.info('console ready on %s' % cname)
-        else:
-            log.info('console ready on %s' % cname)
+        check_console(host)
 
     if ctx.check_locks:
         # does not check to ensure if the node is 'up'