Added a fix for HPiLO that got lost some how.
[monitor.git] / reboot.py
index 9674bda..49db556 100755 (executable)
--- a/reboot.py
+++ b/reboot.py
@@ -25,7 +25,7 @@ sys.path.insert(0, os.path.dirname(sys.argv[0]) + "/pyssh")
 import pyssh
 
 # Timeouts in seconds
-TELNET_TIMEOUT = 30
+TELNET_TIMEOUT = 45
 
 # Event class ID from pcu events
 #NODE_POWER_CONTROL = 3
@@ -397,6 +397,52 @@ class APCEurope(PCUControl):
                self.close()
                return 0
 
+class APCBrazil(PCUControl):
+       def run(self, node_port, dryrun):
+               self.open(self.host, self.username)
+               self.sendPassword(self.password)
+
+               self.ifThenSend("\r\n> ", "1", ExceptionPassword)
+               self.ifThenSend("\r\n> ", str(node_port))
+               # 4- Immediate Reboot             
+               self.ifThenSend("\r\n> ", "4")
+
+               if not dryrun:
+                       self.ifThenSend("Enter 'YES' to continue or <ENTER> to cancel", 
+                                                       "YES\r\n",
+                                                       ExceptionSequence)
+               else:
+                       self.ifThenSend("Enter 'YES' to continue or <ENTER> to cancel", 
+                                                       "", ExceptionSequence)
+               self.ifThenSend("Press <ENTER> to continue...", "", ExceptionSequence)
+
+               self.close()
+               return 0
+
+class APCBerlin(PCUControl):
+       def run(self, node_port, dryrun):
+               self.open(self.host, self.username)
+               self.sendPassword(self.password)
+
+               self.ifThenSend("\r\n> ", "1", ExceptionPassword)
+               self.ifThenSend("\r\n> ", "2")
+               self.ifThenSend("\r\n> ", "1")
+               self.ifThenSend("\r\n> ", str(node_port))
+               # 3- Immediate Reboot             
+               self.ifThenSend("\r\n> ", "3")
+
+               if not dryrun:
+                       self.ifThenSend("Enter 'YES' to continue or <ENTER> to cancel", 
+                                                       "YES\r\n",
+                                                       ExceptionSequence)
+               else:
+                       self.ifThenSend("Enter 'YES' to continue or <ENTER> to cancel", 
+                                                       "", ExceptionSequence)
+               self.ifThenSend("Press <ENTER> to continue...", "", ExceptionSequence)
+
+               self.close()
+               return 0
+
 class APCFolsom(PCUControl):
        def run(self, node_port, dryrun):
                self.open(self.host, self.username)
@@ -1012,6 +1058,14 @@ def reboot_test(nodename, values, continue_probe, verbose, dryrun):
                                apc = APCEurope(values, verbose, ['22', '23'])
                                rb_ret = apc.reboot(values[nodename], dryrun)
 
+                       elif values['pcu_id'] in [1110,86]:
+                               apc = APCBrazil(values, verbose, ['22', '23'])
+                               rb_ret = apc.reboot(values[nodename], dryrun)
+
+                       elif values['pcu_id'] in [1221]:
+                               apc = APCBerlin(values, verbose, ['22', '23'])
+                               rb_ret = apc.reboot(values[nodename], dryrun)
+
                        elif values['pcu_id'] in [1173,1221,1220,1225]:
                                apc = APCFolsom(values, verbose, ['22', '23'])
                                rb_ret = apc.reboot(values[nodename], dryrun)
@@ -1042,9 +1096,13 @@ def reboot_test(nodename, values, continue_probe, verbose, dryrun):
 
                # iLO
                elif continue_probe and values['model'].find("HP iLO") >= 0:
-                       hpilo = HPiLO(values, verbose, ['22'])
-                       rb_ret = hpilo.reboot(0, dryrun)
-                       if rb_ret != 0:
+                       try:
+                               hpilo = HPiLO(values, verbose, ['22'])
+                               rb_ret = hpilo.reboot(0, dryrun)
+                               if rb_ret != 0:
+                                       hpilo = HPiLOHttps(values, verbose, ['443'])
+                                       rb_ret = hpilo.reboot(0, dryrun)
+                       except:
                                hpilo = HPiLOHttps(values, verbose, ['443'])
                                rb_ret = hpilo.reboot(0, dryrun)