diff options
author | mdehaan@mdehaan.rdu.redhat.com <> | 2007-01-03 17:57:15 -0500 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-01-03 17:57:15 -0500 |
commit | 6d1e1e4a75f82ddf8937e94dd569a12fc702b7ab (patch) | |
tree | 6ddec051fc3bacc185e082df69d53eedd71e3c1b /cobbler/action_status.py | |
parent | df34ff6a18706644308f17b369a0ed3085b92216 (diff) | |
download | third_party-cobbler-6d1e1e4a75f82ddf8937e94dd569a12fc702b7ab.tar.gz third_party-cobbler-6d1e1e4a75f82ddf8937e94dd569a12fc702b7ab.tar.xz third_party-cobbler-6d1e1e4a75f82ddf8937e94dd569a12fc702b7ab.zip |
Add kickstart pre-signaling to indicate starts in addition to stops.
Diffstat (limited to 'cobbler/action_status.py')
-rw-r--r-- | cobbler/action_status.py | 113 |
1 files changed, 98 insertions, 15 deletions
diff --git a/cobbler/action_status.py b/cobbler/action_status.py index de3da43..2c0fba1 100644 --- a/cobbler/action_status.py +++ b/cobbler/action_status.py @@ -19,20 +19,103 @@ import cobbler_msg class BootStatusReport: - def __init__(self,config): - """ - Constructor - """ - self.config = config - self.settings = config.settings() - - def run(self): - """ - Returns None if there are no errors, otherwise returns a list - of things to correct prior to running application 'for real'. - (The CLI usage is "cobbler check" before "cobbler sync") - """ - print "..." - return True + def __init__(self,config,mode): + """ + Constructor + """ + self.config = config + self.settings = config.settings() + self.mode = mode + + # ------------------------------------------------------- + + def run(self): + """ + Calculate and print a kickstart-status report. + For kickstart trees not in /var/lib/cobbler (or a symlink off of there) + tracking will be incomplete. This should be noted in the docs. + """ + + done = {} # keep track of finish times by IP addr + files = {} # keep up with xfer'd files by IP addr + + # gather stats from logfiles, allowing for rotations in the log file ... + for i in range(0,6): + + # figure out what logfile to open + j = "" + if i != 0: + j = "%s" % (i-1) + fname = "/var/log/cobbler/cobbler%s.log" % j + + # open it if it's there + if not os.path.exists(fname): + print "no such file: %s" % fname + break + logfile = open(fname, "r") + + # each line in the file corresponds to an accessed file + while(True): + data = logfile.readline() + if data is None or data == "": + break + + # fields are tab delimited + # (1) seconds since 1970, in decimal + # (2) ASCII date for humans + # (3) IP address of requester + # (4) HTTP request line + + (epoch, strdate, ip, request) = data.split("\t") + + # HTTP request line is essentially space delimited + # (1) method, which should always be GET + # (2) filename, which is relative from server root + # (3) protocol, such as HTTP/1.1 + + (method, filepath, protocol) = request.split(" ") + + # make room in the nested datastructures for report info + + if not done.has_key(ip): + done[ip] = [] # list of kickstart finish times + if not files.has_key(ip): + files[ip] = {} # hash of access times and filenames + + # keep track of when IP addresses's finish. Right now, we don't + # care much about profile or system name but can get this later. + + if filepath.find("?system_done") != -1: + done[ip].append(epoch) + elif filepath.find("?profile_done") != -1: + done[ip].append(epoch) + else: + files[ip][epoch] = filepath + + # FIXME: what's a good way to see when systems START? For FC6+ + # it will install via yum, so xml and xml.gz files come first. + # elsewhere, that's not true. + + logfile.close() + + + # report on the data found in all of the files, aggregated. + + self.generate_report(files,done) + return True + + #----------------------------------------- + + def generate_report(self,files,done): + """ + Given the information about transferred files and kickstart finish times, attempt + to produce a report that most describes the state of the system. + + FIXME: just text for now, but should pay attention to self.mode and possibly offer + a HTML or XML or YAML version for other apps. Not all, just some alternatives. + """ + print "%s" % files + print "%s" % done + |