summaryrefslogtreecommitdiffstats
path: root/src/sbin/bcfg2-ping-sweep
diff options
context:
space:
mode:
Diffstat (limited to 'src/sbin/bcfg2-ping-sweep')
-rwxr-xr-xsrc/sbin/bcfg2-ping-sweep12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/sbin/bcfg2-ping-sweep b/src/sbin/bcfg2-ping-sweep
index 70f718690..585e1cc11 100755
--- a/src/sbin/bcfg2-ping-sweep
+++ b/src/sbin/bcfg2-ping-sweep
@@ -20,6 +20,7 @@ if __name__ == '__main__':
cfpath = setup['configfile']
clientdatapath = "%s/Metadata/clients.xml" % setup['repo']
+ pingdatapath = "%s/Metadata/pingdata.xml" % setup['repo']
clientElement = lxml.etree.parse(clientdatapath)
hostlist = [client.get('name')
@@ -32,6 +33,7 @@ if __name__ == '__main__':
#/bin/ping on linux /sbin/ping on os x
osname = uname()[0]
+ container = lxml.etree.Element("PingStatistics")
while hostlist or pids:
if hostlist and len(list(pids.keys())) < 15:
host = hostlist.pop()
@@ -58,15 +60,17 @@ if __name__ == '__main__':
continue
chost = pids[cpid]
del pids[cpid]
- elm = clientElement.xpath("//Client[@name='%s']" % chost)[0]
+ elm = lxml.etree.Element('Client', name=chost)
if status == 0:
elm.set("pingable", 'Y')
elm.set("pingtime", str(time.time()))
else:
elm.set("pingable", 'N')
+ container.append(elm)
- fout = open(clientdatapath, 'w')
- fout.write(lxml.etree.tostring(clientElement.getroot(),
+ fout = open(pingdatapath, 'w')
+ fout.write(lxml.etree.tostring(container,
encoding='UTF-8',
- xml_declaration=True))
+ xml_declaration=True,
+ pretty_print=True))
fout.close()