def get_port_speed(self, ctx, port_id: int) -> int: """ Retrieve speed of a port. :raise PortNotFound """ oid, ip, community = self.get_oid_switch_ipand_community_from_port_id( ctx, port_id) try: return get_SNMP_value(community, ip, 'IF-MIB', 'ifSpeed', oid) except NetworkManagerReadError: raise
def get_port_mab(self, ctx, port_id: int) -> bool: """ Retrieve whether MAB is active on a port. :raise PortNotFound """ oid, ip, community = self.get_oid_switch_ipand_community_from_port_id( ctx, port_id) try: return get_SNMP_value(community, ip, 'CISCO-MAC-AUTH-BYPASS-MIB', 'cmabIfAuthEnabled', oid) except NetworkManagerReadError: raise
def get_port_vlan(self, ctx, port_id: int) -> int: """ Get the VLAN assigned to a port. :raise PortNotFound """ oid, ip, community = self.get_oid_switch_ipand_community_from_port_id( ctx, port_id) try: return get_SNMP_value(community, ip, 'CISCO-VLAN-MEMBERSHIP-MIB', 'vmVlan', oid) except NetworkManagerReadError: raise
def get_port_status(self, ctx, port_id: int) -> bool: """ Retrieve the status of a port. :raise PortNotFound """ oid, ip, community = self.get_oid_switch_ipand_community_from_port_id( ctx, port_id) try: return get_SNMP_value(community, ip, 'IF-MIB', 'ifAdminStatus', oid) except NetworkManagerReadError: raise
def get_port_use(self, ctx, port_id: int) -> bool: """ Retrieve usage of a port. :raise PortNotFound """ oid, ip, community = self.get_oid_switch_ipand_community_from_port_id( ctx, port_id) try: return get_SNMP_value(community, ip, 'IEEE8021-PAE-MIB', 'dot1xAuthAuthControlledPortStatus', oid) except NetworkManagerReadError: raise
def update_port_status(self, ctx, port_id: int) -> str: """ Update the status of a port. :raise PortNotFound """ oid, ip, community = self.get_oid_switch_ipand_community_from_port_id( ctx, port_id) try: port_state = get_SNMP_value(community, ip, 'IF-MIB', 'ifAdminStatus', oid) if port_state == "up": return set_SNMP_value(community, ip, 'IF-MIB', 'ifAdminStatus', oid, 2) else: return set_SNMP_value(community, ip, 'IF-MIB', 'ifAdminStatus', oid, 1) except NetworkManagerReadError: raise
def update_port_mab(self, ctx, port_id: int) -> str: """ Update whether MAB should be active on a port. :raise PortNotFound """ oid, ip, community = self.get_oid_switch_ipand_community_from_port_id( ctx, port_id) try: mab_state = get_SNMP_value(community, ip, 'CISCO-MAC-AUTH-BYPASS-MIB', 'cmabIfAuthEnabled', oid) if mab_state == "false": return set_SNMP_value(community, ip, 'CISCO-MAC-AUTH-BYPASS-MIB', 'cmabIfAuthEnabled', oid, 1) else: return set_SNMP_value(community, ip, 'CISCO-MAC-AUTH-BYPASS-MIB', 'cmabIfAuthEnabled', oid, 2) except NetworkManagerReadError: raise
def update_port_auth(self, ctx, port_id: int) -> None: """ Update whether MAB should be active on a port. :raise PortNotFound """ oid, ip, community = self.get_oid_switch_ipand_community_from_port_id( ctx, port_id) try: auth_state = get_SNMP_value(community, ip, 'IEEE8021-PAE-MIB', 'dot1xAuthAuthControlledPortControl', oid) if auth_state == "auto": #auth activée return set_SNMP_value(community, ip, 'IEEE8021-PAE-MIB', 'dot1xAuthAuthControlledPortControl', oid, 3) else: set_SNMP_value(community, ip, 'CISCO-VLAN-MEMBERSHIP-MIB', 'vmVlan', oid, 1) return set_SNMP_value(community, ip, 'IEEE8021-PAE-MIB', 'dot1xAuthAuthControlledPortControl', oid, 2) except NetworkManagerReadError: raise