diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2004-10-07 19:29:16 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2004-10-07 19:29:16 +0000 |
commit | 43b358a48c86d8ebae070ec7ffa90c6a183f67df (patch) | |
tree | 36358727ab9b7776da604526fea91cce2036e5f7 /src/sbin | |
parent | 93abcedf504a2bae9182422c972086d83120fed5 (diff) | |
download | bcfg2-43b358a48c86d8ebae070ec7ffa90c6a183f67df.tar.gz bcfg2-43b358a48c86d8ebae070ec7ffa90c6a183f67df.tar.bz2 bcfg2-43b358a48c86d8ebae070ec7ffa90c6a183f67df.zip |
implement statistics upload
2004/10/07 10:38:36-05:00 anl.gov!desai
fix api usage
(Logical change 1.82)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@395 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin')
-rw-r--r-- | src/sbin/bcfg2 | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2 index 66d080740..caa997b70 100644 --- a/src/sbin/bcfg2 +++ b/src/sbin/bcfg2 @@ -4,6 +4,7 @@ from os import popen, chmod, unlink from sys import argv, exit, exc_info from string import join from tempfile import mktemp +from time import asctime, localtime from traceback import extract_tb from elementtree.ElementTree import Element, XML, tostring @@ -138,7 +139,20 @@ class ClientState(object): self.InstallEntry(entry) def Commit(self): - self.toolset.Commit() + self.toolset.Commit(self.states) + + def GenerateStats(self): + stats = Element("Statistics") + SubElement(stats, "Structures", good=str(len([k for k,v in self.structures.iteritems() if v])), \ + bad=str(len([k for k,v in self.structures.iteritems() if not v]))) + SubElement(stats, "Entries", good=str(len([k for k,v in self.states.iteritems() if v])), \ + bad=str(len([k for k,v in self.states.iteritems() if not v]))) + if len([k for k,v in self.structures.iteritems() if not v]) == 0: + stats.attrib['state'] = 'clean' + else: + stats.attrib['state'] = 'dirty' + stats.attrib['time'] = asctime(localtime()) + return stats if __name__ == '__main__': # parse command line options @@ -200,6 +214,13 @@ if __name__ == '__main__': for k,v in client.states.iteritems(): if not v: print "%s:%s"%(k.tag, k.attrib['name']) - # install config + # upload statistics + m = Element("upload-statistics") + stats = client.GetStats() + m.append(stats) + + comm.SendMessage(h, tostring(stats)) + r = comm.RecvMessage(h) + # clean up comm.ClientClose(h) |