def get_snmp_connection(args): """ Prepare SNMP transport agent. Connection over SNMP v2c and v3 is supported. The choice of authentication and privacy algorithms for v3 is arbitrary, matching what our switches can do. """ if args.community: auth_data = CommunityData(args.community, mpModel=1) else: if args.priv_proto == 'des': priv_proto = usmDESPrivProtocol if args.priv_proto == 'aes': priv_proto = usmAesCfb128Protocol auth_data = UsmUserData( args.user, args.auth, args.priv, authProtocol=usmHMACSHAAuthProtocol, privProtocol=priv_proto, ) transport_target = UdpTransportTarget((args.switch, 161)) return { 'auth_data': auth_data, 'transport_target': transport_target, }
def __init__(self, address, oid, community): from pysnmp.entity.rfc3413.oneliner.cmdgen import UdpTransportTarget self.oid = oid self._community = community if ':' in address: address, port = address.split(address, 2) else: port = "161" self._transport = UdpTransportTarget((address, int(port)))
def __init__(self, host, port=None): self.transportTarget = UdpTransportTarget((host, port)) self.authData = None self.generator = CommandGenerator()