예제 #1
0
    def getCommunityName(self, trxContext, entryName):
        self._log("get-community-name").debug2(
            "called. trxContext=%s, entryName=%s", trxContext, entryName)

        tagValueList = TagValues()

        valCommName = Value()
        tagValueList.push(
            ("snmpCommunityName",
             "http://tail-f.com/ns/mibs/SNMP-COMMUNITY-MIB/200308060000Z"),
            valCommName)

        targetKeyPath = KeyPath()

        valCommunity = Value()
        (tag, ns, prefix) = (
            "SNMP-COMMUNITY-MIB",
            "http://tail-f.com/ns/mibs/SNMP-COMMUNITY-MIB/200308060000Z",
            "SNMP_COMMUNITY_MIB")
        valCommunity.setXmlTag((tag, ns, prefix))
        targetKeyPath.addKeyPathPostfix(valCommunity)

        valCommunityTable = Value()
        (tag, ns, prefix) = (
            "snmpCommunityTable",
            "http://tail-f.com/ns/mibs/SNMP-COMMUNITY-MIB/200308060000Z",
            "SNMP_COMMUNITY_MIB")
        valCommunityTable.setXmlTag((tag, ns, prefix))
        targetKeyPath.addKeyPathPostfix(valCommunityTable)

        valEntry = Value()
        (tag, ns, prefix) = (
            "snmpCommunityEntry",
            "http://tail-f.com/ns/mibs/SNMP-COMMUNITY-MIB/200308060000Z",
            "SNMP_COMMUNITY_MIB")
        valEntry.setXmlTag((tag, ns, prefix))
        targetKeyPath.addKeyPathPostfix(valEntry)

        valKey = Value()
        valKey.setBuf((entryName, len(entryName)))
        targetKeyPath.addKeyPathPostfix(valKey)

        res = self._maapiDomain.readMaapi(tagValueList, targetKeyPath,
                                          trxContext)
        if res != ReturnCodes.kOk:
            self._log('get-community-name-domain-failed').error(
                'self._maapiDomain.readMaapi() failed. PARAMS')
            return None

        communityName = tagValueList.getAt(tagValueList.getLen() -
                                           1)[1].asBuf()

        self._log("get-community-name-done").debug2(
            "done. trxContext=%s, entryName=%s, communityName=%s", trxContext,
            entryName, communityName)
        return communityName
    def getDestinationInTargetTableEntry (self, trxContext, entryName):
        self._log("get-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)

        valTAddr = Value()
        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.readMaapi(tagValueList, targetKeyPath, trxContext)
        if res != ReturnCodes.kOk:
            self._log('get-destination-in-target-table-entry-read-domain-failed').error('self._maapiDomain.writeMaapi() failed. PARAMS')
            return None

        ipAddress = tagValueList.getAt(tagValueList.getLen()-3)[1].asBinary()[0:6]

        self._log("get-destination-in-target-table-entry-done").debug2("done. trxContext=%s, entryName=%s, ipAddress=%s", trxContext, entryName, ipAddress)
        return ipAddress
예제 #3
0
    def readSnmpCounters(self, operData):
        self._log("read-snmp-counters").debug3("called. operData=%s", operData)

        tagValueList = TagValues()

        if operData.isInPacketsRequested():
            posValInPkts = tagValueList.getLen()
            valInPkts = Value()
            tagValueList.push(
                ("snmpInPkts",
                 "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"),
                valInPkts)

        if operData.isInBadVersionPacketsRequested():
            posValInBadVersions = tagValueList.getLen()
            valInBadVersions = Value()
            tagValueList.push(
                ("snmpInBadVersions",
                 "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"),
                valInBadVersions)

        if operData.isInBadCommunityPacketsRequested():
            posValInBadCommunityNames = tagValueList.getLen()
            valInBadCommunityNames = Value()
            tagValueList.push(
                ("snmpInBadCommunityNames",
                 "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"),
                valInBadCommunityNames)

        if operData.isInBadCommunityUsePacketsRequested():
            posValInBadCommunityUses = tagValueList.getLen()
            valInBadCommunityUses = Value()
            tagValueList.push(
                ("snmpInBadCommunityUses",
                 "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"),
                valInBadCommunityUses)

        if operData.isInAsnParseErrorsRequested():
            posValInASNParseErrs = tagValueList.getLen()
            valInASNParseErrs = Value()
            tagValueList.push(
                ("snmpInASNParseErrs",
                 "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"),
                valInASNParseErrs)

        if operData.isSilentDroppedPacketsRequested():
            posValSilentDrops = tagValueList.getLen()
            valSilentDrops = Value()
            tagValueList.push(
                ("snmpSilentDrops",
                 "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"),
                valSilentDrops)

        res = self._maapiDomain.readMaapi(tagValueList, self.targetKeyPath,
                                          None)
        if res != ReturnCodes.kOk:
            self._log('read-snmp-counters-domain-failed').error(
                'self._maapiDomain.readMaapi() failed. operData=%s', operData)
            return None

        if operData.isInPacketsRequested():
            operData.setInPackets(
                tagValueList.getAt(posValInPkts)[1].asUint32())

        if operData.isInBadVersionPacketsRequested():
            self._log("read-snmp-counters-got-in-bad-version").debug3(
                "got snmpInBadVersions=%s",
                tagValueList.getAt(posValInBadVersions)[1])
            operData.setInBadVersionPackets(
                tagValueList.getAt(posValInBadVersions)[1].asUint32())

        if operData.isInBadCommunityPacketsRequested():
            operData.setInBadCommunityPackets(
                tagValueList.getAt(posValInBadCommunityNames)[1].asUint32())

        if operData.isInBadCommunityUsePacketsRequested():
            operData.setInBadCommunityUsePackets(
                tagValueList.getAt(posValInBadCommunityUses)[1].asUint32())

        if operData.isInAsnParseErrorsRequested():
            operData.setInAsnParseErrors(
                tagValueList.getAt(posValInASNParseErrs)[1].asUint32())

        if operData.isSilentDroppedPacketsRequested():
            operData.setSilentDroppedPackets(
                tagValueList.getAt(posValSilentDrops)[1].asUint32())

        self._log("read-snmp-counters-done").debug3("returning: operData=%s",
                                                    operData)
        return ReturnCodes.kOk
예제 #4
0
    def readSnmpCounters (self, operData):
        self._log("read-snmp-counters").debug3("called. operData=%s", operData)

        tagValueList = TagValues()

        if operData.isInPacketsRequested():
            posValInPkts = tagValueList.getLen()
            valInPkts = Value()
            tagValueList.push(("snmpInPkts", "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"), valInPkts)

        if operData.isInBadVersionPacketsRequested():
            posValInBadVersions = tagValueList.getLen()
            valInBadVersions = Value()
            tagValueList.push(("snmpInBadVersions", "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"), valInBadVersions)

        if operData.isInBadCommunityPacketsRequested():
            posValInBadCommunityNames = tagValueList.getLen()
            valInBadCommunityNames = Value()
            tagValueList.push(("snmpInBadCommunityNames", "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"), valInBadCommunityNames)

        if operData.isInBadCommunityUsePacketsRequested():
            posValInBadCommunityUses = tagValueList.getLen()
            valInBadCommunityUses = Value()
            tagValueList.push(("snmpInBadCommunityUses", "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"), valInBadCommunityUses)

        if operData.isInAsnParseErrorsRequested():
            posValInASNParseErrs = tagValueList.getLen()
            valInASNParseErrs = Value()
            tagValueList.push(("snmpInASNParseErrs", "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"), valInASNParseErrs)

        if operData.isSilentDroppedPacketsRequested():
            posValSilentDrops = tagValueList.getLen()
            valSilentDrops = Value()
            tagValueList.push(("snmpSilentDrops", "http://tail-f.com/ns/mibs/SNMPv2-MIB/200210160000Z"), valSilentDrops)

        res = self._maapiDomain.readMaapi(tagValueList, self.targetKeyPath, None)
        if res != ReturnCodes.kOk:
            self._log('read-snmp-counters-domain-failed').error('self._maapiDomain.readMaapi() failed. operData=%s', operData)
            return None

        if operData.isInPacketsRequested():
            operData.setInPackets(tagValueList.getAt(posValInPkts)[1].asUint32())

        if operData.isInBadVersionPacketsRequested():
            self._log("read-snmp-counters-got-in-bad-version").debug3("got snmpInBadVersions=%s", tagValueList.getAt(posValInBadVersions)[1])
            operData.setInBadVersionPackets(tagValueList.getAt(posValInBadVersions)[1].asUint32())

        if operData.isInBadCommunityPacketsRequested():
            operData.setInBadCommunityPackets(tagValueList.getAt(posValInBadCommunityNames)[1].asUint32())

        if operData.isInBadCommunityUsePacketsRequested():
            operData.setInBadCommunityUsePackets(tagValueList.getAt(posValInBadCommunityUses)[1].asUint32())

        if operData.isInAsnParseErrorsRequested():
            operData.setInAsnParseErrors(tagValueList.getAt(posValInASNParseErrs)[1].asUint32())

        if operData.isSilentDroppedPacketsRequested():
            operData.setSilentDroppedPackets(tagValueList.getAt(posValSilentDrops)[1].asUint32())

        self._log("read-snmp-counters-done").debug3("returning: operData=%s", operData)
        return ReturnCodes.kOk