diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2006-08-29 14:51:17 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2006-08-29 14:51:17 +0000 |
commit | 7e54a98925d75a840753588f7e5e7609858fcd73 (patch) | |
tree | 2ccf535f77c1749d6f5222e99a7f837f7c23c736 | |
parent | 7ed77647f8555da2e36840fb66c885e55f1b6ae8 (diff) | |
download | bcfg2-7e54a98925d75a840753588f7e5e7609858fcd73.tar.gz bcfg2-7e54a98925d75a840753588f7e5e7609858fcd73.tar.bz2 bcfg2-7e54a98925d75a840753588f7e5e7609858fcd73.zip |
Minor GenerateHostInfo cleanups
* Switch to full module imports
* Remove last of the fullnames stuff (from pre-fqdn days)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2132 ce84e21b-d406-0410-9b95-82705330c041
-rwxr-xr-x | src/sbin/GenerateHostInfo | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/sbin/GenerateHostInfo b/src/sbin/GenerateHostInfo index c9723eb0b..eccbe0b5a 100755 --- a/src/sbin/GenerateHostInfo +++ b/src/sbin/GenerateHostInfo @@ -1,30 +1,24 @@ #!/usr/bin/env python -# Jul 17 2005 #GenerateHostInfo - Joey Hagedorn - hagedorn@mcs.anl.gov '''Generates hostinfo.xml at a regular interval''' __revision__ = '$Revision$' -from ConfigParser import ConfigParser -from lxml.etree import parse, tostring -from os import fork, execl, dup2, wait, uname -import sys +from os import dup2, execl, fork, uname, wait +import lxml, sys, time, ConfigParser if __name__ == '__main__': - c = ConfigParser() + c = ConfigParser.ConfigParser() c.read(['/etc/bcfg2.conf']) configpath = "%s/etc/report-configuration.xml" % c.get('server', 'repository') clientdatapath = "%s/Metadata/clients.xml" % c.get('server', 'repository') - sendmailpath = c.get('statistics','sendmailpath') - clientElement = parse(clientdatapath) + clientElement = lxml.etree.parse(clientdatapath) hostlist = [client.get('name') for client in clientElement.findall("Client")] pids = {} - fullnames = {} null = open('/dev/null', 'w+') - #use uname to detect OS and use -t for darwin and -w for linux #/bin/ping on linux /sbin/ping on os x osname = uname()[0] @@ -56,22 +50,14 @@ if __name__ == '__main__': continue chost = pids[cpid] del pids[cpid] + elm = clientElement.xpath("//Client[@name='%s']"%chost)[0] if status == 0: - try: - clientElement.xpath("//Client[@name='%s']"%chost)[0].set("pingable",'Y') - except:#i think this is for a problem with aliases? - clientElement.xpath("//Client[@name='%s']"%fullnames[chost])[0].set("pingable",'Y') - #also set pingtime, if you can get it - + elm.set("pingable",'Y') + elm.set("pingtime", str(time.time())) else: - if chost.count('.') > 0: - fullnames[chost.split('.')[0]] = chost - hostlist.append(chost.split('.')[0]) - else: - clientElement.xpath("//Client[@name='%s']"%(fullnames[chost]))[0].set("pingable",'N') - #also set pingtime if you can get it + elm.set("pingable",'N') fout = open(clientdatapath, 'w') - fout.write(tostring(clientElement.getroot())) + fout.write(lxml.etree.tostring(clientElement.getroot())) fout.close() |