conga/luci/site/luci/Extensions ricci_bridge.p ...
CVSROOT: /cvs/cluster
Module name: conga
Changes by: jparsons at sourceware.org 2006-07-14 16:00:26
Modified files:
luci/site/luci/Extensions: ricci_bridge.py cluster_adapters.py
conga_constants.py
Log message:
Node config support
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_bridge.py.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.1&r2=1.2
luci/site/luci/Extensions/ricci_bridge.py +78 -0
@@ -188,6 +188,23 @@ batch_number, result = self.batchAttemptResult(payload) return (batch_number, result) + def getDaemonStates(self, dlist): + CLUSTER_STR='<?xml version="1.0" ?><ricci async="false" function="process_batch" version="1.0"><batch><module name="service"><request API_version="1.0"><function_call name="query"><var mutable="false" name="search" type="list_xml">' + + for item in dlist: + CLUSTER_STR = CLUSTER_STR + '<service name=\"' + item + '\"/>' + + CLUSTER_STR = CLUSTER_STR + '</var></function_call></request></module></batch></ricci>' + + try: + payload = self.makeConnection(CLUSTER_STR) + except RicciReceiveError, r: + return None + + result = self.extractDaemonInfo(payload) + + return result + def makeConnection(self,query_str): # socket sock = socket(AF_INET, SOCK_STREAM)
@@ -379,6 +396,67 @@ return docc + def extractDaemonInfo(self, doc): + print "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV" + print doc.toxml() + print "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" + resultlist = list() + docc = None + bt_node = None + for node in doc.firstChild.childNodes: + if node.nodeType == xml.dom.Node.ELEMENT_NODE: + if node.nodeName == 'batch': + bt_node = node + if bt_node == None: + print "bt_node == None" + doc = None + else: + #print doc.toxml() + mod_node = None + for node in bt_node.childNodes: + if node.nodeType == xml.dom.Node.ELEMENT_NODE: + if node.nodeName == 'module': + mod_node = node + if mod_node == None: + print "mod_node == None" + doc = None + else: + resp_node = None + for node in mod_node.childNodes: + if node.nodeType == xml.dom.Node.ELEMENT_NODE: + resp_node = node + if resp_node == None: + print "resp_node == None" + doc = None + else: + fr_node = None + for node in resp_node.childNodes: + if node.nodeType == xml.dom.Node.ELEMENT_NODE: + fr_node = node + if fr_node == None: + print "fr_node == None" + doc = None + else: + varnode = None + for node in fr_node.childNodes: + if node.nodeName == 'var': + varnode = node + break + if varnode == None: + print "varnode == None" + doc = None + else: + svc_node = None + for node in varnode.childNodes: + if node.nodeName == 'service': + svchash = {} + svchash['name'] = node.getAttribute('name') + svchash['enabled'] = node.getAttribute('enabled') + svchash['running'] = node.getAttribute('running') + resultlist.append(svchash) + + return resultlist + def batchAttemptResult(self, doc): docc = None rc_node = None
luci/site/luci/Extensions/cluster_adapters.py +59 -5
78 lines not on this page · raw message
luci/site/luci/Extensions/conga_constants.py +5 -0
@@ -41,3 +41,8 @@ PATH_TO_PRIVKEY="/var/lib/luci/var/certs/privkey.pem" PATH_TO_CACERT="/var/lib/luci/var/certs/cacert.pem" + +#Node states +NODE_ACTIVE="0" +NODE_INACTIVE="1" +NODE_UNKNOWN="2"