def updateRequestAverageTime(self, duration): """ Increment in log.xml the average requests time since agent is installed @type duration: int @param duration: Request processing time """ try: rnNode = XPath.Evaluate("/log/requests/number",self.doc)[0] oldTextNode = rnNode.childNodes[0] nb = oldTextNode.nodeValue newnb = int(nb) + 1 newTextNode = self.doc.createTextNode(str(newnb)) rnNode.removeChild(oldTextNode) rnNode.appendChild(newTextNode) avgnode = XPath.Evaluate('/log/requests/average-time',self.doc)[0] oldAvgNode = avgnode.childNodes[0] averageTime = float(oldAvgNode.nodeValue) newnb = (averageTime*(newnb-1) + duration)/newnb newAvgNode = self.doc.createTextNode(str(newnb)) avgnode.removeChild(oldAvgNode) avgnode.appendChild(newAvgNode) util.printNodeToFile(self.doc.documentElement, self.logFile) except Exception,exp: print str(exp)
def updateRequestAverageTime(self, duration): """ Increment in log.xml the average requests time since agent is installed @type duration: int @param duration: Request processing time """ try: rnNode = XPath.Evaluate("/log/requests/number", self.doc)[0] oldTextNode = rnNode.childNodes[0] nb = oldTextNode.nodeValue newnb = int(nb) + 1 newTextNode = self.doc.createTextNode(str(newnb)) rnNode.removeChild(oldTextNode) rnNode.appendChild(newTextNode) avgnode = XPath.Evaluate('/log/requests/average-time', self.doc)[0] oldAvgNode = avgnode.childNodes[0] averageTime = float(oldAvgNode.nodeValue) newnb = (averageTime * (newnb - 1) + duration) / newnb newAvgNode = self.doc.createTextNode(str(newnb)) avgnode.removeChild(oldAvgNode) avgnode.appendChild(newAvgNode) util.printNodeToFile(self.doc.documentElement, self.logFile) except Exception, exp: print str(exp)
def copyConfig(self, sourceName, targetName, sourceNode = None): if (targetName in [C.RUNNING, C.CANDIDATE, C.STARTUP]): if sourceName in [C.RUNNING, C.CANDIDATE, C.STARTUP]: moduleReply = self.getConfig(sourceName) if moduleReply.isError(): return moduleReply else: util.printNodeToFile(moduleReply.getXMLNodeReply(), self.files[targetName]) return ModuleReply() elif sourceName in [C.CONFIG, C.URL]: util.printNodeToFile(sourceNode, self.files[targetName]) return ModuleReply() moduleReply = ModuleReply() return moduleReply
def copyConfig(self, sourceName, targetName, sourceNode=None): if (targetName in [C.RUNNING, C.CANDIDATE, C.STARTUP]): if sourceName in [C.RUNNING, C.CANDIDATE, C.STARTUP]: moduleReply = self.getConfig(sourceName) if moduleReply.isError(): return moduleReply else: util.printNodeToFile(moduleReply.getXMLNodeReply(), self.files[targetName]) return ModuleReply() elif sourceName in [C.CONFIG, C.URL]: util.printNodeToFile(sourceNode, self.files[targetName]) return ModuleReply() moduleReply = ModuleReply() return moduleReply
def increment(self, operation): """ Updates the total number of operation: get-config, get, edit-config, ... @type operation: String @param operation: Netconf operation (get-config, edit-config, ...) """ try: node = XPath.Evaluate('/log/nbOp/'+operation,self.doc)[0] oldTextNode = node.childNodes[0] nb = oldTextNode.nodeValue newnb = int(nb) + 1 newTextNode = self.doc.createTextNode(str(newnb)) node.removeChild(oldTextNode) node.appendChild(newTextNode) util.printNodeToFile(self.doc.documentElement, self.logFile) except Exception,exp: print str(exp)
def increment(self, operation): """ Updates the total number of operation: get-config, get, edit-config, ... @type operation: String @param operation: Netconf operation (get-config, edit-config, ...) """ try: node = XPath.Evaluate('/log/nbOp/' + operation, self.doc)[0] oldTextNode = node.childNodes[0] nb = oldTextNode.nodeValue newnb = int(nb) + 1 newTextNode = self.doc.createTextNode(str(newnb)) node.removeChild(oldTextNode) node.appendChild(newTextNode) util.printNodeToFile(self.doc.documentElement, self.logFile) except Exception, exp: print str(exp)