コード例 #1
0
class InterfacesMIB(metaclass=MIBMeta, prefix='.1.3.6.1.2.1.2'):
    """
    'interfaces' https://tools.ietf.org/html/rfc1213#section-3.5
    """

    if_updater = InterfacesUpdater()
    _ifNumber = len(if_updater.if_name_map)

    # OID sub-identifiers are 1-based, while the actual interfaces are zero-based.
    # offset the interface range when registering the OIDs
    if_range = if_updater.oid_sai_map.keys()

    # (subtree, value_type, callable_, *args, handler=None)
    ifNumber = MIBEntry('1', ValueType.INTEGER,
                        lambda: InterfacesMIB._ifNumber)

    # ifTable ::= { interfaces 2 }
    # ifEntry ::= { ifTable 1 }

    ifIndex = \
        ContextualMIBEntry('2.1.1', if_range, ValueType.INTEGER, lambda sub_id: sub_id - 1)

    ifDescr = \
        ContextualMIBEntry('2.1.2', if_range, ValueType.OCTET_STRING, if_updater.interface_description)

    # FIXME: Placeholder
    # ethernetCsmacd(6), -- for all ethernet-like interfaces,
    #                    -- regardless of speed, as per RFC3635
    ifType = \
        ContextualMIBEntry('2.1.3', if_range, ValueType.INTEGER, lambda sub_id: 6)

    # FIXME Placeholder. ACS switches only use the MTU value of 9196
    ifMtu = \
        ContextualMIBEntry('2.1.4', if_range, ValueType.INTEGER, lambda sub_id: 9196)

    # FIXME Placeholder.
    #   "If the bandwidth of the interface is greater
    #   than the maximum value reportable by this object,
    #   then this object should report its maximum value
    #   (4.294,967,295) and ifHighSpeed must be used to
    #   report the interface's speed."
    ifSpeed = \
        ContextualMIBEntry('2.1.5', if_range, ValueType.GAUGE_32, lambda sub_id: 4294967295)

    # FIXME Placeholder.
    ifPhysAddress = \
        ContextualMIBEntry('2.1.6', if_range, ValueType.OCTET_STRING, lambda sub_id: '')

    # FIXME Placeholder. 1 -- up; 2 -- down; 3 -- testing
    ifAdminStatus = \
        ContextualMIBEntry('2.1.7', if_range, ValueType.INTEGER, lambda sub_id: 1)

    # FIXME Placeholder. 1 -- up; 2 -- down; 3 -- testing
    ifOperStatus = \
        ContextualMIBEntry('2.1.8', if_range, ValueType.INTEGER, lambda sub_id: 1)

    # FIXME Placeholder.
    ifLastChange = \
        ContextualMIBEntry('2.1.9', if_range, ValueType.TIME_TICKS, lambda sub_id: 0)

    ifInOctets = \
        ContextualMIBEntry('2.1.10', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(10))

    ifInUcastPkts = \
        ContextualMIBEntry('2.1.11', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(11))

    ifInNUcastPkts = \
        ContextualMIBEntry('2.1.12', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(12))

    ifInDiscards = \
        ContextualMIBEntry('2.1.13', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(13))

    ifInErrors = \
        ContextualMIBEntry('2.1.14', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(14))

    ifInUnknownProtos = \
        ContextualMIBEntry('2.1.15', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(15))

    ifOutOctets = \
        ContextualMIBEntry('2.1.16', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(16))

    ifOutUcastPkts = \
        ContextualMIBEntry('2.1.17', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(17))

    ifOutNUcastPkts = \
        ContextualMIBEntry('2.1.18', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(18))

    ifOutDiscards = \
        ContextualMIBEntry('2.1.19', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(19))

    ifOutErrors = \
        ContextualMIBEntry('2.1.20', if_range, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(20))

    ifOutQLen = \
        ContextualMIBEntry('2.1.21', if_range, ValueType.GAUGE_32, if_updater.get_counter,
                           DbTables(21))

    # FIXME Placeholder
    ifSpecific = \
        ContextualMIBEntry('2.1.22', if_range, ValueType.OBJECT_IDENTIFIER, lambda sub_id: ObjectIdentifier.null_oid())
コード例 #2
0
class InterfacesMIB(metaclass=MIBMeta, prefix='.1.3.6.1.2.1.2'):
    """
    'interfaces' https://tools.ietf.org/html/rfc1213#section-3.5
    """

    if_updater = InterfacesUpdater()

    # (subtree, value_type, callable_, *args, handler=None)
    ifNumber = MIBEntry('1', ValueType.INTEGER, if_updater.get_if_number)

    # ifTable ::= { interfaces 2 }
    # ifEntry ::= { ifTable 1 }

    ifIndex = \
        SubtreeMIBEntry('2.1.1', if_updater, ValueType.INTEGER, if_updater.if_index)

    ifDescr = \
        SubtreeMIBEntry('2.1.2', if_updater, ValueType.OCTET_STRING, if_updater.interface_description)

    # FIXME: Placeholder
    # ethernetCsmacd(6), -- for all ethernet-like interfaces,
    #                    -- regardless of speed, as per RFC3635
    ifType = \
        SubtreeMIBEntry('2.1.3', if_updater, ValueType.INTEGER, lambda sub_id: 6)

    ifMtu = \
        SubtreeMIBEntry('2.1.4', if_updater, ValueType.INTEGER, if_updater.get_mtu)

    # FIXME Placeholder.
    #   "If the bandwidth of the interface is greater
    #   than the maximum value reportable by this object,
    #   then this object should report its maximum value
    #   (4.294,967,295) and ifHighSpeed must be used to
    #   report the interface's speed."
    ifSpeed = \
        SubtreeMIBEntry('2.1.5', if_updater, ValueType.GAUGE_32, lambda sub_id: 4294967295)

    # FIXME Placeholder.
    ifPhysAddress = \
        SubtreeMIBEntry('2.1.6', if_updater, ValueType.OCTET_STRING, lambda sub_id: '')

    ifAdminStatus = \
        SubtreeMIBEntry('2.1.7', if_updater, ValueType.INTEGER, if_updater.get_admin_status)

    ifOperStatus = \
        SubtreeMIBEntry('2.1.8', if_updater, ValueType.INTEGER, if_updater.get_oper_status)

    # FIXME Placeholder.
    ifLastChange = \
        SubtreeMIBEntry('2.1.9', if_updater, ValueType.TIME_TICKS, lambda sub_id: 0)

    ifInOctets = \
        SubtreeMIBEntry('2.1.10', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(10))

    ifInUcastPkts = \
        SubtreeMIBEntry('2.1.11', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(11))

    ifInNUcastPkts = \
        SubtreeMIBEntry('2.1.12', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(12))

    ifInDiscards = \
        SubtreeMIBEntry('2.1.13', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(13))

    ifInErrors = \
        SubtreeMIBEntry('2.1.14', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(14))

    ifInUnknownProtos = \
        SubtreeMIBEntry('2.1.15', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(15))

    ifOutOctets = \
        SubtreeMIBEntry('2.1.16', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(16))

    ifOutUcastPkts = \
        SubtreeMIBEntry('2.1.17', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(17))

    ifOutNUcastPkts = \
        SubtreeMIBEntry('2.1.18', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(18))

    ifOutDiscards = \
        SubtreeMIBEntry('2.1.19', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(19))

    ifOutErrors = \
        SubtreeMIBEntry('2.1.20', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(20))

    ifOutQLen = \
        SubtreeMIBEntry('2.1.21', if_updater, ValueType.GAUGE_32, if_updater.get_counter,
                           DbTables(21))

    # FIXME Placeholder
    ifSpecific = \
        SubtreeMIBEntry('2.1.22', if_updater, ValueType.OBJECT_IDENTIFIER, lambda sub_id: ObjectIdentifier.null_oid())
コード例 #3
0
class LLDPLocalSystemData(metaclass=MIBMeta, prefix='.1.0.8802.1.1.2.1.3'):
    """
    lldpLocalSystemData  OBJECT IDENTIFIER
    ::= { lldpObjects 3 }
    """
    chassis_updater = LLDPLocalSystemDataUpdater()

    lldpLocChassisIdSubtype = MIBEntry('1', ValueType.INTEGER,
                                       chassis_updater.table_lookup_integer,
                                       LLDPLocalChassis(1))

    lldpLocChassisId = MIBEntry('2', ValueType.OCTET_STRING,
                                chassis_updater.table_lookup,
                                LLDPLocalChassis(2))

    lldpLocSysName = MIBEntry('3', ValueType.OCTET_STRING,
                              chassis_updater.table_lookup,
                              LLDPLocalChassis(3))

    lldpLocSysDesc = MIBEntry('4', ValueType.OCTET_STRING,
                              chassis_updater.table_lookup,
                              LLDPLocalChassis(4))

    lldpLocSysCapSupported = MIBEntry('5', ValueType.OCTET_STRING,
                                      chassis_updater.table_lookup,
                                      LLDPLocalChassis(5))

    lldpLocSysCapEnabled = MIBEntry('6', ValueType.OCTET_STRING,
                                    chassis_updater.table_lookup,
                                    LLDPLocalChassis(6))

    class LLDPLocPortTable(metaclass=MIBMeta, prefix='.1.0.8802.1.1.2.1.3.7'):
        """
        lldpLocPortTable OBJECT-TYPE
            SYNTAX      SEQUENCE OF LldpLocPortEntry
            MAX-ACCESS  not-accessible
            STATUS      current
            DESCRIPTION
              "This table contains one or more rows per port information
               associated with the local system known to this agent."
            ::= { lldpLocalSystemData 7 }

            LldpLocPortEntry ::= SEQUENCE {
                lldpLocPortNum                LldpPortNumber,
                lldpLocPortIdSubtype          LldpPortIdSubtype,
                lldpLocPortId                 LldpPortId,
                lldpLocPortDesc               SnmpAdminString
            }

        """
        port_updater = LocPortUpdater()

        # lldpLocPortEntry = '1'

        # We're using locally assigned name, so according to textual convention, the subtype is 7
        lldpLocPortIdSubtype = SubtreeMIBEntry('1.2', port_updater,
                                               ValueType.INTEGER,
                                               port_updater.port_id_subtype)

        lldpLocPortId = SubtreeMIBEntry('1.3', port_updater,
                                        ValueType.OCTET_STRING,
                                        port_updater.local_port_id)

        lldpLocPortDesc = SubtreeMIBEntry('1.4', port_updater,
                                          ValueType.OCTET_STRING,
                                          port_updater.port_table_lookup,
                                          "description")

    class LLDPLocManAddrTable(metaclass=MIBMeta,
                              prefix='.1.0.8802.1.1.2.1.3.8'):
        """
        lldpLocManAddrTable OBJECT-TYPE
        SYNTAX      SEQUENCE OF LldpLocManAddrEntry
        MAX-ACCESS  not-accessible
        STATUS      current
        DESCRIPTION
                "This table contains management address information on the
                local system known to this agent."
        ::= { lldpLocalSystemData 8 }
        """
        updater = LLDPLocManAddrUpdater()

        lldpLocManAddrLen = SubtreeMIBEntry('1.3', updater, ValueType.INTEGER,
                                            updater.lookup,
                                            updater.man_addr_len)

        lldpLocManAddrIfSubtype = SubtreeMIBEntry('1.4', updater,
                                                  ValueType.INTEGER,
                                                  updater.lookup,
                                                  updater.man_addr_if_subtype)

        lldpLocManAddrIfId = SubtreeMIBEntry('1.5', updater, ValueType.INTEGER,
                                             updater.lookup,
                                             updater.man_addr_if_id)

        lldpLocManAddrOID = SubtreeMIBEntry('1.6', updater,
                                            ValueType.OBJECT_IDENTIFIER,
                                            updater.lookup,
                                            updater.man_addr_OID)
コード例 #4
0
class InterfacesMIB(metaclass=MIBMeta, prefix='.1.3.6.1.2.1.2'):
    """
    'interfaces' https://tools.ietf.org/html/rfc1213#section-3.5
    """

    if_updater = InterfacesUpdater()

    # (subtree, value_type, callable_, *args, handler=None)
    ifNumber = MIBEntry('1', ValueType.INTEGER, if_updater.get_if_number)

    # ifTable ::= { interfaces 2 }
    # ifEntry ::= { ifTable 1 }

    ifIndex = \
        SubtreeMIBEntry('2.1.1', if_updater, ValueType.INTEGER, if_updater.if_index)

    ifDescr = \
        SubtreeMIBEntry('2.1.2', if_updater, ValueType.OCTET_STRING, if_updater.interface_description)

    ifType = \
        SubtreeMIBEntry('2.1.3', if_updater, ValueType.INTEGER, if_updater.get_if_type)

    ifMtu = \
        SubtreeMIBEntry('2.1.4', if_updater, ValueType.INTEGER, if_updater.get_mtu)

    ifSpeed = \
        SubtreeMIBEntry('2.1.5', if_updater, ValueType.GAUGE_32, if_updater.get_speed_bps)

    # FIXME Placeholder.
    ifPhysAddress = \
        SubtreeMIBEntry('2.1.6', if_updater, ValueType.OCTET_STRING, lambda sub_id: '')

    ifAdminStatus = \
        SubtreeMIBEntry('2.1.7', if_updater, ValueType.INTEGER, if_updater.get_admin_status)

    ifOperStatus = \
        SubtreeMIBEntry('2.1.8', if_updater, ValueType.INTEGER, if_updater.get_oper_status)

    # FIXME Placeholder.
    ifLastChange = \
        SubtreeMIBEntry('2.1.9', if_updater, ValueType.TIME_TICKS, lambda sub_id: 0)

    ifInOctets = \
        SubtreeMIBEntry('2.1.10', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(10))

    ifInUcastPkts = \
        SubtreeMIBEntry('2.1.11', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(11))

    ifInNUcastPkts = \
        SubtreeMIBEntry('2.1.12', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(12))

    ifInDiscards = \
        SubtreeMIBEntry('2.1.13', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(13))

    ifInErrors = \
        SubtreeMIBEntry('2.1.14', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(14))

    ifInUnknownProtos = \
        SubtreeMIBEntry('2.1.15', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(15))

    ifOutOctets = \
        SubtreeMIBEntry('2.1.16', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(16))

    ifOutUcastPkts = \
        SubtreeMIBEntry('2.1.17', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(17))

    ifOutNUcastPkts = \
        SubtreeMIBEntry('2.1.18', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(18))

    ifOutDiscards = \
        SubtreeMIBEntry('2.1.19', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(19))

    ifOutErrors = \
        SubtreeMIBEntry('2.1.20', if_updater, ValueType.COUNTER_32, if_updater.get_counter,
                           DbTables(20))

    ifOutQLen = \
        SubtreeMIBEntry('2.1.21', if_updater, ValueType.GAUGE_32, if_updater.get_counter,
                           DbTables(21))

    # FIXME Placeholder
    ifSpecific = \
        SubtreeMIBEntry('2.1.22', if_updater, ValueType.OBJECT_IDENTIFIER, lambda sub_id: ObjectIdentifier.null_oid())