def get_poe_port_mapping(snmp_proxy, host):
    if not host in POE_PORT_MAPPING_CACHE:
        if b"IF-MIB" not in get_loaded_mibs():
            load_mib(b"IF-MIB")
        iface_port_indexes = list(
                int(k) for k, v in snmp_proxy.ifSpeed.items()
                if v in POE_PORT_SPEEDS)
        iface_type_indexes = list(
                int(k) for k, v in snmp_proxy.ifType.items()
                if int(v) == ETHERNETCSMACD)
        poe_port_indexes = list(
                (int(grp_idx), int(grp_port)) \
                for grp_idx, grp_port in snmp_proxy.pethPsePortAdminEnable.keys())
        # check if we have the same number of poe ports and 10/100/1000 ports
        if len(iface_port_indexes) == len(poe_port_indexes):
            # this probably means we can associate iface_port_indexes and
            # poe_port_indexes one by one:
            iface_to_poe_index = { a: b for a, b in \
                    zip(iface_port_indexes, poe_port_indexes) }
        # otherwise, check if we have a linear range of ethernet ports
        # (i.e. there are no holes in those port indexes)
        elif max(a-b for a, b in \
                zip(iface_type_indexes[1:], iface_type_indexes[:-1])) == 1:
            # this probably means we can associate iface_type_indexes and
            # poe_port_indexes one by one:
            iface_to_poe_index = { a: b for a, b in \
                    zip(iface_type_indexes, poe_port_indexes) }
        else:
            raise RuntimeError(MSG_ISSUE_POE_PORT_MAPPING % host)
        POE_PORT_MAPPING_CACHE[host] = iface_to_poe_index
    return POE_PORT_MAPPING_CACHE[host]
 def load():
     load_mib(b"TPLINK-MIB")
     load_mib(b"TPLINK-LLDP-MIB")
     load_mib(b"TPLINK-LLDPINFO-MIB")
 def load():
     load_mib(b"LLDP-MIB")
Beispiel #4
0
 def __init__(self, snmp_proxy):
     load_mib(b"Q-BRIDGE-MIB")
     self.snmp = snmp_proxy
 def load(cls):
     load_mib(b"POWER-ETHERNET-MIB")
 def load(cls):
     load_mib(b"TPLINK-MIB")
     load_mib(b"TPLINK-POWER-OVER-ETHERNET-MIB")
 def load(cls):
     load_mib(b"NETGEAR-POWER-ETHERNET-MIB")
Beispiel #8
0
 def __init__(self, snmp_proxy):
     self.snmp = snmp_proxy
     load_mib(b"NETGEAR-SWITCHING-MIB")