give noop myops xmlrpc call a extra parameter to allow it to work with the
Stephen Soltesz [Thu, 2 Jul 2009 01:22:40 +0000 (01:22 +0000)]
PLC() object which passes an auth struct to every call.
clear penalties for blacklisted sites.
fixed string in grep in RunlevelAgent
added crazy fix for new BayTech sequence.

RunlevelAgent.py
monitor/parser.py
pcucontrol/models/BayTech.py
policy.py
web/MonitorWeb/monitorweb/monitor_xmlrpc.py

index 5865b63..646b0a7 100644 (file)
@@ -130,7 +130,7 @@ def main():
             #   call plc for current boot state?
             #   how long have we been running?
             if env == "bootmanager":
-                bs_val = extract_from('/tmp/bm.log', 'Current boot state:')
+                bs_val = extract_from('/tmp/bm.log', "'Current boot state:'")
                 if len(bs_val) > 0: bs_val = bs_val.split()[-1]
                 ex_val = extract_from('/tmp/bm.log', 'Exception')
                 fs_val = extract_from('/tmp/bm.log', 'mke2fs')
index 5f79f74..b6ae032 100644 (file)
@@ -28,7 +28,7 @@ def parseSetDefaults(parser=None):
        parser.set_defaults(debug = config.debug,
                                        mail = config.mail,
                                        bcc  = config.bcc,
-                                       email = config.email,
+                                       email = config.from_email,
                                        run = config.run,
                                        squeeze = config.squeeze,
                                        policysavedb = config.policysavedb)
index 5883c4b..1b55228 100644 (file)
@@ -191,6 +191,90 @@ class BayTechCtrlC(PCUControl):
 
                return 0
 
+
+class BayTech5CtrlC(PCUControl):
+       """
+               For some reason, these units let you log in fine, but they hang
+               indefinitely, unless you send a Ctrl-C after the password.  No idea
+               why.
+       """
+       supported_ports = [22]
+       def run_ssh(self, node_port, dryrun):
+               print "BayTech5CtrlC %s" % self.host
+
+               ssh_options="-o StrictHostKeyChecking=no -o PasswordAuthentication=yes -o PubkeyAuthentication=no"
+               s = pxssh.pxssh()
+               try:
+                       if not s.login(self.host, self.username, self.password, ssh_options):
+                               raise ExceptionPassword("Invalid Password")
+               except pexpect.EOF:
+                       raise ExceptionNoTransport("No Connection Possible")
+                       
+                       
+               # Otherwise, the login succeeded.
+               # Control Outlets  (5 ,1).........5
+               try:
+                       print "EXPECTING: ", "Enter Request :"
+                       s.send("\r\n")
+                       time.sleep(2)
+                       index = s.expect(["Enter Request"])
+
+                       if index == 0:
+                               print "SENDING: 5"
+                               s.send("5\r\n")
+                               print "EXPECTING: ", "DS-RPC>"
+                               time.sleep(3)
+                               # Send a ctrl-c to the remote process.
+                               #print "SENDING ctrl-c"
+                               #s.send(chr(3))
+
+                               index = s.expect(["DS-RPC>", "Enter user name:", "Port in use."])
+                               if index == 1:
+                                       print "sending username"
+                                       s.send(self.username + "\r\n")
+                                       index = s.expect(["DS-RPC>"])
+                               elif index == 2:
+                                       raise ExceptionPrompt("PCU Reported 'Port in use.'")
+
+                               if index == 0:
+                                       print "SENDING: Reboot %d" % node_port
+                                       #s.send("Reboot %d\r\n" % node_port)
+                                       s.send("Reboot %d\r" % node_port)
+
+                                       print "SLEEPING: 5"
+                                       time.sleep(5)
+                                       print "EXPECTING: ", "Y/N?"
+                                       index = s.expect(["\(Y/N\)\?", "Port in use", "DS-RPC>"])
+                                       if index == 0:
+                                               if dryrun:
+                                                       print "sending N"
+                                                       s.send("N\r\n")
+                                               else:
+                                                       print "SENDING: Y"
+                                                       s.send("Y\r\n")
+                                       elif index == 1:
+                                               raise ExceptionPrompt("PCU Reported 'Port in use.'")
+                                       elif index == 2:
+                                               raise ExceptionSequence("Issued command 'Reboot' failed.")
+
+                               # NOTE: for some reason, the script times out with the
+                               # following line.  In manual tests, it works correctly, but
+                               # with automated tests, evidently it fails.
+                               print "SLEEPING: 5"
+                               time.sleep(5)
+                               #print "TOTAL--", s.allstr, "--EOT"
+                               index = s.expect(["DS-RPC>"])
+                               print "got prompt back"
+
+                       s.close()
+
+               except pexpect.EOF:
+                       raise ExceptionPrompt("EOF before 'Enter Request' Prompt")
+               except pexpect.TIMEOUT:
+                       raise ExceptionPrompt("Timeout before Prompt")
+
+               return 0
+
 class BayTech(PCUControl):
        supported_ports = [22,23]
 
index f9605ae..84bdb44 100755 (executable)
--- a/policy.py
+++ b/policy.py
@@ -139,6 +139,8 @@ def main(hostnames, sitenames):
                if siteblack and not siteblack.expired():
                        print "skipping %s due to blacklist.  will expire %s" % (site, siteblack.willExpire() )
                        skip_due_to_blacklist=True
+                       sitehist.clearPenalty()
+                       sitehist.applyPenalty()
                        continue
 
                # TODO: make query only return records within a certin time range,
index 45f5c01..08f71bc 100644 (file)
@@ -122,7 +122,7 @@ class MonitorXmlrpcServer(object):
        @export_to_docbook(roles=['tech', 'user', 'pi', 'admin'],
                           accepts=[],
                                           returns=Parameter(bool, 'True if successful'))
-       def upAndRunning(self):
+       def upAndRunning(self,noop=None):
                """ This call can indicate to a script whether the server is up
                and running before trying any more sophisticated operations. """
                return True