import pyssh
# Timeouts in seconds
-TELNET_TIMEOUT = 30
+TELNET_TIMEOUT = 45
# Event class ID from pcu events
#NODE_POWER_CONTROL = 3
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)
self.host, "iloxml/Get_Network.xml",
self.username, self.password)
p_ilo = Popen(cmd, stdout=PIPE, shell=True)
- cmd2 = "/bin/grep 'MESSAGE' | /bin/grep -v 'No error'"
+ cmd2 = "grep 'MESSAGE' | grep -v 'No error'"
p_grep = Popen(cmd2, stdin=p_ilo.stdout, stdout=PIPE, stderr=PIPE, shell=True)
sout, serr = p_grep.communicate()
cmd = "cmdhttps/locfg.pl -s %s -f %s -u %s -p %s" % (
self.host, "iloxml/Reset_Server.xml",
self.username, self.password)
- print cmd
p_ilo = Popen(cmd, stdin=PIPE, stdout=PIPE, shell=True)
- cmd2 = "/bin/grep 'MESSAGE' | /bin/grep -v 'No error'"
- print cmd2
- p_grep = Popen(cmd2, stdin=p_ilo.stdout, stdout=PIPE, stderr=PIPE, shell=True)
+ cmd2 = "grep 'MESSAGE' | grep -v 'No error'"
+ p_grep = Popen(cmd2, stdin=p_ilo.stdout, stdout=PIPE, stderr=PIPE)
sout, serr = p_grep.communicate()
p_ilo.wait()
p_grep.wait()
ret = True
return ret
-
-def reboot(nodename):
- return reboot_policy(nodename, True, False)
def reboot_policy(nodename, continue_probe, dryrun):
global verbose
logger.debug("Trying PCU %s %s" % (pcu['hostname'], pcu['model']))
ret = reboot_test(nodename, values, continue_probe, verbose, dryrun)
- print ret
- if ret != 0:
+ if rb_ret != 0:
return False
else:
return True
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)
# iLO
elif continue_probe and values['model'].find("HP iLO") >= 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 = 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)