def fillTagValues (self, keyPath, tagValueList, operData): initialListSize = tagValueList.getLen() for logFunc in self._log("fill-tag-values").debug3Func(): logFunc("called. operData=%s, keyPath=%s, initialListSize=%d", operData.debugStr(True), keyPath, initialListSize) # fill tag values up to current if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = keyPath.getLen() while i < self.myKeyPath.getLen(): valBegin = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valBegin.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valBegin) for logFunc in self._log("fill-tag-values-adding").debug3Func(): logFunc("adding xml begin. i=%d, valBegin=%s, self.myKeyPath.getLen()=%d", i, valBegin, self.myKeyPath.getLen()) i+=1 if operData.isMacAddressRequested() and operData.hasMacAddress(): val = Value() val.setBinary(operData.macAddress.getAddress()) tagValueList.push(("mac-address", "http://qwilt.com/ns/yang/device/tech/qwilt-tech-interfaces"), val) if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = self.myKeyPath.getLen() - 1 while i >= keyPath.getLen(): valEnd = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valEnd.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valEnd) i-=1 for logFunc in self._log("fill-tag-values-ended").debug3Func(): logFunc("ended. operData=%s, keyPath=%s, initialListSize=%d, finalListSize=%d", operData.debugStr(True), keyPath, initialListSize, tagValueList.getLen()) return ReturnCodes.kOk
def fillTagValues(self, keyPath, tagValueList, operData): initialListSize = tagValueList.getLen() for logFunc in self._log("fill-tag-values").debug3Func(): logFunc("called. operData=%s, keyPath=%s, initialListSize=%d", operData.debugStr(True), keyPath, initialListSize) # fill tag values up to current if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = keyPath.getLen() while i < self.myKeyPath.getLen(): valBegin = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valBegin.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valBegin) for logFunc in self._log( "fill-tag-values-adding").debug3Func(): logFunc( "adding xml begin. i=%d, valBegin=%s, self.myKeyPath.getLen()=%d", i, valBegin, self.myKeyPath.getLen()) i += 1 if operData.isColorRequested() and operData.hasColor(): val = Value() val.setEnum(operData.color.getValue()) tagValueList.push(("color", "http://qwilt.com/model/lake-example"), val) if operData.isPatternRequested() and operData.hasPattern(): val = Value() val.setString(operData.pattern) tagValueList.push( ("pattern", "http://qwilt.com/model/lake-example"), val) if operData.isMacAddressRequested() and operData.hasMacAddress(): val = Value() val.setBinary(operData.macAddress.getAddress()) tagValueList.push( ("mac-address", "http://qwilt.com/model/lake-example"), val) if operData.isLineWidthRequested() and operData.hasLineWidth(): val = Value() val.setInt8(operData.lineWidth) tagValueList.push( ("line-width", "http://qwilt.com/model/lake-example"), val) if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = self.myKeyPath.getLen() - 1 while i >= keyPath.getLen(): valEnd = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valEnd.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valEnd) i -= 1 for logFunc in self._log("fill-tag-values-ended").debug3Func(): logFunc( "ended. operData=%s, keyPath=%s, initialListSize=%d, finalListSize=%d", operData.debugStr(True), keyPath, initialListSize, tagValueList.getLen()) return ReturnCodes.kOk
def setDestinationInTargetTableEntry (self, trxContext, entryName, ipAddress): self._log("set-destination-in-target-table-entry").debug2("called. trxContext=%s, entryName=%s", trxContext, entryName) targetKeyPath = KeyPath() valTarget = Value() (tag, ns, prefix) = ("SNMP-TARGET-MIB", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z", "SNMP_TARGET_MIB") valTarget.setXmlTag((tag, ns, prefix)) targetKeyPath.addKeyPathPostfix(valTarget) tagValueList = TagValues() valTargetAddrTable = Value() (tag, ns, prefix) = ("snmpTargetAddrTable","http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z", "SNMP_TARGET_MIB") valTargetAddrTable.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valTargetAddrTable) valBegin = Value() (tag, ns, prefix) = ("snmpTargetAddrEntry", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z", "SNMP_TARGET_MIB") valBegin.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valBegin) valKey = Value() valKey.setString(entryName) tagValueList.push(("snmpTargetAddrName", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z"), valKey) # snmpTargetAddrTAddress to 0.0.0.0.0.162 valTAddr = Value() addrStr = ipAddress valTAddr.setBinary(addrStr) tagValueList.push(("snmpTargetAddrTAddress", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z"), valTAddr) valEnd = Value() valEnd.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valEnd) valTargetAddrTable = Value() (tag, ns, prefix) = ("snmpTargetAddrTable","http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z", "SNMP_TARGET_MIB") valTargetAddrTable.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valTargetAddrTable) res = self._maapiDomain.writeMaapi(tagValueList, targetKeyPath, trxContext) if res != ReturnCodes.kOk: self._log('get-destination-in-target-table-entry-write-domain-failed').error('self._maapiDomain.writeMaapi() failed. PARAMS') return ReturnCodes.kGeneralError self._log("set-destination-in-target-table-entry-done").debug2("done. trxContext=%s, entryName=%s", trxContext, entryName) return ReturnCodes.kOk
def fillTagValues (self, keyPath, tagValueList, operData): initialListSize = tagValueList.getLen() for logFunc in self._log("fill-tag-values").debug3Func(): logFunc("called. operData=%s, keyPath=%s, initialListSize=%d", operData.debugStr(True), keyPath, initialListSize) # fill tag values up to current if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = keyPath.getLen() while i < self.myKeyPath.getLen(): valBegin = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valBegin.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valBegin) for logFunc in self._log("fill-tag-values-adding").debug3Func(): logFunc("adding xml begin. i=%d, valBegin=%s, self.myKeyPath.getLen()=%d", i, valBegin, self.myKeyPath.getLen()) i+=1 if operData.isColorRequested() and operData.hasColor(): val = Value() val.setEnum(operData.color.getValue()) tagValueList.push(("color", "http://qwilt.com/model/lake-example"), val) if operData.isPatternRequested() and operData.hasPattern(): val = Value() val.setString(operData.pattern) tagValueList.push(("pattern", "http://qwilt.com/model/lake-example"), val) if operData.isMacAddressRequested() and operData.hasMacAddress(): val = Value() val.setBinary(operData.macAddress.getAddress()) tagValueList.push(("mac-address", "http://qwilt.com/model/lake-example"), val) if operData.isLineWidthRequested() and operData.hasLineWidth(): val = Value() val.setInt8(operData.lineWidth) tagValueList.push(("line-width", "http://qwilt.com/model/lake-example"), val) if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = self.myKeyPath.getLen() - 1 while i >= keyPath.getLen(): valEnd = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valEnd.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valEnd) i-=1 for logFunc in self._log("fill-tag-values-ended").debug3Func(): logFunc("ended. operData=%s, keyPath=%s, initialListSize=%d, finalListSize=%d", operData.debugStr(True), keyPath, initialListSize, tagValueList.getLen()) return ReturnCodes.kOk
def fillTagValues(self, keyPath, tagValueList, operData): initialListSize = tagValueList.getLen() for logFunc in self._log("fill-tag-values").debug3Func(): logFunc("called. operData=%s, keyPath=%s, initialListSize=%d", operData.debugStr(True), keyPath, initialListSize) # fill tag values up to current if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = keyPath.getLen() while i < self.myKeyPath.getLen(): valBegin = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valBegin.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valBegin) for logFunc in self._log( "fill-tag-values-adding").debug3Func(): logFunc( "adding xml begin. i=%d, valBegin=%s, self.myKeyPath.getLen()=%d", i, valBegin, self.myKeyPath.getLen()) i += 1 if operData.isMacAddressRequested() and operData.hasMacAddress(): val = Value() val.setBinary(operData.macAddress.getAddress()) tagValueList.push( ("mac-address", "http://qwilt.com/ns/yang/device/tech/qwilt-tech-interfaces"), val) if self.myKeyPath.isEqualLen(keyPath, keyPath.getLen()): i = self.myKeyPath.getLen() - 1 while i >= keyPath.getLen(): valEnd = Value() (tag, ns, prefix) = self.myKeyPath.getAt(i).asXmlTag() valEnd.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valEnd) i -= 1 for logFunc in self._log("fill-tag-values-ended").debug3Func(): logFunc( "ended. operData=%s, keyPath=%s, initialListSize=%d, finalListSize=%d", operData.debugStr(True), keyPath, initialListSize, tagValueList.getLen()) return ReturnCodes.kOk
def createTargetAddrTableEntry (self, trxContext, entryName): """ create an entry with the same name in SNMP-TARGET-MIB snmpTargetAddrTable snmpTargetAddrEntry set snmpTargetAddrTDomain to 1.3.6.1.6.1.1 set snmpTargetAddrTAddress to 0.0.0.0.0.162 set snmpTargetAddrTagList to the same name set snmpTargetAddrParams to the same name set snmpTargetAddrMMS to 2048 """ self._log("create-target-addr-table-entry").debug2("called. trxContext=%s, entryName=%s", trxContext, entryName) targetKeyPath = KeyPath() valTarget = Value() (tag, ns, prefix) = ("SNMP-TARGET-MIB", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z", "SNMP_TARGET_MIB") valTarget.setXmlTag((tag, ns, prefix)) targetKeyPath.addKeyPathPostfix(valTarget) tagValueList = TagValues() valTargetAddrTable = Value() (tag, ns, prefix) = ("snmpTargetAddrTable","http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z", "SNMP_TARGET_MIB") valTargetAddrTable.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valTargetAddrTable) valBegin = Value() (tag, ns, prefix) = ("snmpTargetAddrEntry", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z", "SNMP_TARGET_MIB") valBegin.setXmlBegin((tag, ns, prefix)) tagValueList.push((tag, ns), valBegin) valKey = Value() valKey.setString(entryName) tagValueList.push(("snmpTargetAddrName", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z"), valKey) # snmpTargetAddrTDomain to 1.3.6.1.6.1.1 valTDomain = Value() valTDomain.setOid(self.T_DOMAIN_UDP_ADDR) tagValueList.push(("snmpTargetAddrTDomain", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z"), valTDomain) # snmpTargetAddrTAddress to 0.0.0.0.0.162 valTAddr = Value() #addrStr = chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(162) addrStr = chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(162) valTAddr.setBinary(addrStr) tagValueList.push(("snmpTargetAddrTAddress", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z"), valTAddr) # snmpTargetAddrTagList to the same name valTagName = Value() valTagName.setString(self.ALL_TRAPS_TAG_NAME) tagValueList.push(("snmpTargetAddrTagList", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z"), valTagName) # snmpTargetAddrParams to the same name valParamName = Value() valParamName.setString(entryName) tagValueList.push(("snmpTargetAddrParams", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z"), valParamName) # snmpTargetAddrMMS to 2048 valMMS = Value() valMMS.setInt32(self.MAX_MESSAGE_SIZE) tagValueList.push(("snmpTargetAddrMMS", "http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z"), valMMS) valEnd = Value() valEnd.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valEnd) valTargetAddrTable = Value() (tag, ns, prefix) = ("snmpTargetAddrTable","http://tail-f.com/ns/mibs/SNMP-TARGET-MIB/200210140000Z", "SNMP_TARGET_MIB") valTargetAddrTable.setXmlEnd((tag, ns, prefix)) tagValueList.push((tag, ns), valTargetAddrTable) res = self._maapiDomain.writeMaapi(tagValueList, targetKeyPath, trxContext) if res != ReturnCodes.kOk: self._log('create-target-addr-table-entry-write-domain-failed').error('self._maapiDomain.writeMaapi() failed. PARAMS') return ReturnCodes.kGeneralError self._log("create-target-addr-table-entry-done").debug2("done. trxContext=%s, entryName=%s", trxContext, entryName) return ReturnCodes.kOk