]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Update console checking, and DRY
authorZack Cerza <zack@redhat.com>
Wed, 24 Aug 2016 17:10:08 +0000 (11:10 -0600)
committerZack Cerza <zack@redhat.com>
Wed, 24 Aug 2016 17:13:32 +0000 (11:13 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
tasks/ceph_manager.py
tasks/mds_thrash.py

index ef26fbbd492f9a998df6e52b780d1e1a7009a441..7f9aa789758646213ee13383b3a94bebede13f1c 100644 (file)
@@ -1908,14 +1908,17 @@ class CephManager:
             remote = self.find_remote('osd', osd)
             self.log('kill_osd on osd.{o} '
                      'doing powercycle of {s}'.format(o=osd, s=remote.name))
-            assert remote.console is not None, ("powercycling requested "
-                                                "but RemoteConsole is not "
-                                                "initialized.  "
-                                                "Check ipmi config.")
+            self._assert_ipmi(remote)
             remote.console.power_off()
         else:
             self.ctx.daemons.get_daemon('osd', osd, self.cluster).stop()
 
+    @staticmethod
+    def _assert_ipmi(remote):
+        assert remote.console.has_ipmi_credentials, (
+            "powercycling requested but RemoteConsole is not "
+            "initialized.  Check ipmi config.")
+
     def blackhole_kill_osd(self, osd):
         """
         Stop osd if nothing else works.
@@ -1934,10 +1937,7 @@ class CephManager:
             remote = self.find_remote('osd', osd)
             self.log('kill_osd on osd.{o} doing powercycle of {s}'.
                      format(o=osd, s=remote.name))
-            assert remote.console is not None, ("powercycling requested "
-                                                "but RemoteConsole is not "
-                                                "initialized.  "
-                                                "Check ipmi config.")
+            self._assert_ipmi(remote)
             remote.console.power_on()
             if not remote.console.check_status(300):
                 raise Exception('Failed to revive osd.{o} via ipmi'.
@@ -1994,11 +1994,7 @@ class CephManager:
             remote = self.find_remote('mon', mon)
             self.log('kill_mon on mon.{m} doing powercycle of {s}'.
                      format(m=mon, s=remote.name))
-            assert remote.console is not None, ("powercycling requested "
-                                                "but RemoteConsole is not "
-                                                "initialized.  "
-                                                "Check ipmi config.")
-
+            self._assert_ipmi(remote)
             remote.console.power_off()
         else:
             self.ctx.daemons.get_daemon('mon', mon, self.cluster).stop()
@@ -2012,11 +2008,7 @@ class CephManager:
             remote = self.find_remote('mon', mon)
             self.log('revive_mon on mon.{m} doing powercycle of {s}'.
                      format(m=mon, s=remote.name))
-            assert remote.console is not None, ("powercycling requested "
-                                                "but RemoteConsole is not "
-                                                "initialized.  "
-                                                "Check ipmi config.")
-
+            self._assert_ipmi(remote)
             remote.console.power_on()
             self.make_admin_daemon_dir(remote)
         self.ctx.daemons.get_daemon('mon', mon, self.cluster).restart()
index faf1abad42e749dfd7fad20cdd38ae2d18119081..a68eeddd06a3c0b64821bfbe024c80fa09f68335 100644 (file)
@@ -136,14 +136,17 @@ class MDSThrasher(Greenlet):
                          remotes.iterkeys())
             self.log('kill_mds on mds.{m} doing powercycle of {s}'.
                      format(m=mds, s=remote.name))
-            assert remote.console is not None, ("powercycling requested "
-                                                "but RemoteConsole is not "
-                                                "initialized.  "
-                                                "Check ipmi config.")
+            self._assert_ipmi(remote)
             remote.console.power_off()
         else:
             self.ctx.daemons.get_daemon('mds', mds).stop()
 
+    @staticmethod
+    def _assert_ipmi(remote):
+        assert remote.console.has_ipmi_credentials, (
+            "powercycling requested but RemoteConsole is not "
+            "initialized.  Check ipmi config.")
+
     def kill_mds_by_rank(self, rank):
         """
         kill_mds wrapper to kill based on rank passed.
@@ -161,10 +164,7 @@ class MDSThrasher(Greenlet):
                          remotes.iterkeys())
             self.log('revive_mds on mds.{m} doing powercycle of {s}'.
                      format(m=mds, s=remote.name))
-            assert remote.console is not None, ("powercycling requested "
-                                                "but RemoteConsole is not "
-                                                "initialized.  "
-                                                "Check ipmi config.")
+            self._assert_ipmi(remote)
             remote.console.power_on()
             self.manager.make_admin_daemon_dir(self.ctx, remote)
         args = []