From ac1e9bb99f3acb754054737870093606d56030a1 Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Tue, 25 Nov 2008 23:33:21 +0000 Subject: [PATCH] fixed runtime errors with moved files in model, and reboot --- findbadpcu.py | 2 +- grouprins.py | 2 +- monitor/model.py | 76 +++++++++++++++++++++++--------------------- monitor/policy.py | 20 ++++++------ nodecommon.py | 2 +- nodeinfo.py | 2 +- nodequery.py | 2 +- pcubad.py | 2 +- pcucontrol/reboot.py | 8 ++--- sitebad.py | 2 +- siteinfo.py | 2 +- 11 files changed, 61 insertions(+), 59 deletions(-) diff --git a/findbadpcu.py b/findbadpcu.py index f7a3576..3a28478 100755 --- a/findbadpcu.py +++ b/findbadpcu.py @@ -13,7 +13,7 @@ import threadpool import threading import monitor -from monitor.pcu import reboot +from pcucontrol import reboot from monitor import config from monitor.database.info.model import FindbadPCURecordSync, FindbadPCURecord, session from monitor import util diff --git a/grouprins.py b/grouprins.py index 5ebe912..ba3ba88 100755 --- a/grouprins.py +++ b/grouprins.py @@ -17,7 +17,7 @@ from monitor import util from monitor import const from monitor import database from monitor import parser as parsermodule -from monitor.pcu import reboot +from pcucontrol import reboot from monitor.wrapper import plc api = plc.getAuthAPI() diff --git a/monitor/model.py b/monitor/model.py index ce941f2..d06edae 100755 --- a/monitor/model.py +++ b/monitor/model.py @@ -600,6 +600,45 @@ class NodeRecord: self.ticket = None self.target = target + +class MonRecord(object): + def __init__(self, data): + self.keys = data.keys() + self.keys.sort() + self.__dict__.update(data) + return + + def get(self): + ret= {} + for k in self.keys: + ret[k] = self.__dict__[k] + return ret + + def __repr__(self): + str = "" + str += self.host + "\n" + for k in self.keys: + if "message" in k or "msg" in k: + continue + if 'time' in k: + s_time=time.strftime("%Y/%m/%d %H:%M:%S", + time.gmtime(self.__dict__[k])) + str += "\t'%s' : %s\n" % (k, s_time) + else: + str += "\t'%s' : %s\n" % (k, self.__dict__[k]) + str += "\t--" + return str + + def delField(self, field): + if field in self.__dict__: + del self.__dict__[field] + + if field in self.keys: + for i in range(0,len(self.keys)): + if self.keys[i] == field: + del self.keys[i] + break + class Action(MonRecord): def __init__(self, host, data): self.host = host @@ -647,43 +686,6 @@ def node_end_record(node): del act_all return True -class MonRecord(object): - def __init__(self, data): - self.keys = data.keys() - self.keys.sort() - self.__dict__.update(data) - return - - def get(self): - ret= {} - for k in self.keys: - ret[k] = self.__dict__[k] - return ret - - def __repr__(self): - str = "" - str += self.host + "\n" - for k in self.keys: - if "message" in k or "msg" in k: - continue - if 'time' in k: - s_time=time.strftime("%Y/%m/%d %H:%M:%S", - time.gmtime(self.__dict__[k])) - str += "\t'%s' : %s\n" % (k, s_time) - else: - str += "\t'%s' : %s\n" % (k, self.__dict__[k]) - str += "\t--" - return str - - def delField(self, field): - if field in self.__dict__: - del self.__dict__[field] - - if field in self.keys: - for i in range(0,len(self.keys)): - if self.keys[i] == field: - del self.keys[i] - break class LogRoll: def __init__(self, list=None): diff --git a/monitor/policy.py b/monitor/policy.py index cc61fee..a8f3cd7 100644 --- a/monitor/policy.py +++ b/monitor/policy.py @@ -258,7 +258,7 @@ class MonitorMergeDiagnoseSendEscellate: return rec def checkStageAndTime(self, record): - """ + """ The core variables are: send_email_to : defines who to send messages to at this time @@ -268,15 +268,15 @@ class MonitorMergeDiagnoseSendEscellate: save_act_all : whether or not to save the action record in the db. action/stage : stage tracks which state we're in. - """ - stages = { - "initial" : [ { action='noop', next="weekone"}], - "weekone" : [ { action='noop', index=0, save=True, email=TECH, length=7*SPERDAY, next="weektwo" }, ], - "weektwo" : [ { action='nocreate', index=1, save=True, email=TECH|PI, length=7*SPERDAY, next="waitforever" }, ], - "waitforever" : [ { action='suspendslices',index=2, save=True, email=TECH|PI|USER, length=7*SPERDAY, next="waitforever" }, ], - "paused" : [ { action='noop', save=True length=30*SPERDAY, next="weekone" }, ] - "improvement" : [ { action='close_rt', index=0, save=True, email=TECH, next="monitor-end-record" }, ], - } + """ + #stages = { + # "initial" : [ { action='noop', next="weekone"}], + # "weekone" : [ { action='noop', index=0, save=True, email=TECH, length=7*SPERDAY, next="weektwo" }, ], + # "weektwo" : [ { action='nocreate', index=1, save=True, email=TECH|PI, length=7*SPERDAY, next="waitforever" }, ], + # "waitforever" : [ { action='suspendslices',index=2, save=True, email=TECH|PI|USER, length=7*SPERDAY, next="waitforever" }, ], + # "paused" : [ { action='noop', save=True length=30*SPERDAY, next="weekone" }, ] + # "improvement" : [ { action='close_rt', index=0, save=True, email=TECH, next="monitor-end-record" }, ], + #} # TODO: make this time relative to the PREVIOUS action taken. current_time = time.time() current_stage = record.getMostRecentStage() diff --git a/nodecommon.py b/nodecommon.py index 9551a4a..082550b 100644 --- a/nodecommon.py +++ b/nodecommon.py @@ -1,7 +1,7 @@ import time import struct -from monitor.pcu import reboot +from pcucontrol import reboot from monitor import util from monitor import database diff --git a/nodeinfo.py b/nodeinfo.py index 3c8e4e5..29d77bb 100755 --- a/nodeinfo.py +++ b/nodeinfo.py @@ -8,7 +8,7 @@ from monitor import util from monitor import parser as parsermodule from monitor import database -from monitor.pcu import reboot +from pcucontrol import reboot import time from monitor.model import * diff --git a/nodequery.py b/nodequery.py index 4378e2c..3c5428a 100755 --- a/nodequery.py +++ b/nodequery.py @@ -13,7 +13,7 @@ import time import re import string -from monitor.pcu import reboot +from pcucontrol import reboot from monitor.wrapper import plc, plccache api = plc.getAuthAPI() diff --git a/pcubad.py b/pcubad.py index e13accc..04118e2 100755 --- a/pcubad.py +++ b/pcubad.py @@ -7,7 +7,7 @@ import time from datetime import datetime,timedelta from monitor import database -from monitor.pcu import reboot +from pcucontrol import reboot from monitor import parser as parsermodule from monitor import config from monitor.database import HistoryPCURecord, FindbadPCURecord diff --git a/pcucontrol/reboot.py b/pcucontrol/reboot.py index 9c97f9c..f753471 100755 --- a/pcucontrol/reboot.py +++ b/pcucontrol/reboot.py @@ -14,16 +14,16 @@ import array, struct from monitor.wrapper import plc import base64 from subprocess import PIPE, Popen -import ssh.pxssh as pxssh -import ssh.pexpect as pexpect +import pcucontrol.transports.ssh.pxssh as pxssh +import pcucontrol.transports.ssh.pexpect as pexpect import socket from monitor.util import command # Use our versions of telnetlib and pyssh sys.path.insert(0, os.path.dirname(sys.argv[0])) -import telnetlib +import pcucontrol.transports.telnetlib as telnetlib sys.path.insert(0, os.path.dirname(sys.argv[0]) + "/pyssh") -import pyssh +import pcucontrol.transports.pyssh as pyssh # Timeouts in seconds TELNET_TIMEOUT = 45 diff --git a/sitebad.py b/sitebad.py index 2c1628a..12ae8c8 100755 --- a/sitebad.py +++ b/sitebad.py @@ -7,7 +7,7 @@ import time from datetime import datetime,timedelta from monitor import database -from monitor.pcu import reboot +from pcucontrol import reboot from monitor import parser as parsermodule from monitor import config from monitor.database import HistorySiteRecord, FindbadNodeRecord diff --git a/siteinfo.py b/siteinfo.py index 609cde2..9101443 100755 --- a/siteinfo.py +++ b/siteinfo.py @@ -4,7 +4,7 @@ from monitor.wrapper import plc api = plc.getAuthAPI() from monitor import database -from monitor.pcu import reboot +from pcucontrol import reboot import time from nodecommon import * -- 2.43.0