def testGetMacAddress(self): """Get a MAC address""" mib.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib")) oid, a = self.session.get((1, 3, 6, 1, 2, 1, 45121, 1, 15, 0))[0] self.assertEqual(a, b"\x11\x12\x13\x14\x15\x16") b = basictypes.build("SNIMPY-MIB", "snimpyMacAddress", a) self.assertEqual(b, "11:12:13:14:15:16")
def setUp(self): mib.load( os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib")) self.nodes = ["snimpy", "snimpyScalars", "snimpyTables"] self.nodes.sort() self.tables = [ "snimpyComplexTable", "snimpyInetAddressTable", "snimpySimpleTable", "snimpyIndexTable", "snimpyInvalidTable" ] self.tables.sort() self.columns = [ "snimpyComplexFirstIP", "snimpyComplexSecondIP", "snimpySimpleIndex", "snimpyComplexState", "snimpyInetAddressType", "snimpyInetAddress", "snimpyInetAddressState", "snimpySimpleDescr", "snimpySimplePhys", "snimpySimpleType", "snimpyIndexVarLen", "snimpyIndexIntIndex", "snimpyIndexOidVarLen", "snimpyIndexFixedLen", "snimpyIndexImplied", "snimpyIndexInt", "snimpyInvalidIndex", "snimpyInvalidDescr" ] self.columns.sort() self.scalars = [ "snimpyIpAddress", "snimpyString", "snimpyInteger", "snimpyEnum", "snimpyObjectId", "snimpyBoolean", "snimpyCounter", "snimpyGauge", "snimpyTimeticks", "snimpyCounter64", "snimpyBits", "snimpyNotImplemented", "snimpyOctetString", "snimpyUnicodeString", "snimpyMacAddress", "snimpyMacAddressInvalid" ] self.scalars.sort() self.expected_modules = [ u"SNMPv2-SMI", u"SNMPv2-TC", u"SNIMPY-MIB", u"INET-ADDRESS-MIB", u"IANAifType-MIB" ]
def setUp(self): mib.load( os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib")) self.nodes = ["snimpy", "snimpyScalars", "snimpyTables"] self.nodes.sort() self.tables = [ "snimpyComplexTable", "snimpySimpleTable", "snimpyIndexTable" ] self.tables.sort() self.columns = [ "snimpyComplexFirstIP", "snimpyComplexSecondIP", "snimpySimpleIndex", "snimpyComplexState", "snimpySimpleDescr", "snimpySimplePhys", "snimpySimpleType", "snimpyIndexVarLen", "snimpyIndexIntIndex", "snimpyIndexOidVarLen", "snimpyIndexFixedLen", "snimpyIndexImplied", "snimpyIndexInt", ] self.columns.sort() self.scalars = [ "snimpyIpAddress", "snimpyString", "snimpyInteger", "snimpyEnum", "snimpyObjectId", "snimpyBoolean", "snimpyCounter", "snimpyGauge", "snimpyTimeticks", "snimpyCounter64", "snimpyBits" ] self.scalars.sort()
def setUp(self): mib.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib")) self.nodes = ["snimpy", "snimpyScalars", "snimpyTables"] self.nodes.sort() self.tables = ["snimpyComplexTable", "snimpyInetAddressTable", "snimpySimpleTable", "snimpyIndexTable", "snimpyInvalidTable", "snimpyEmptyTable"] self.tables.sort() self.columns = ["snimpyComplexFirstIP", "snimpyComplexSecondIP", "snimpySimpleIndex", "snimpyComplexState", "snimpyInetAddressType", "snimpyInetAddress", "snimpyInetAddressState", "snimpySimpleDescr", "snimpySimplePhys", "snimpySimpleType", "snimpyIndexVarLen", "snimpyIndexIntIndex", "snimpyIndexOidVarLen", "snimpyIndexFixedLen", "snimpyIndexImplied", "snimpyIndexInt", "snimpyInvalidIndex", "snimpyInvalidDescr", "snimpyEmptyIndex", "snimpyEmptyDescr" ] self.columns.sort() self.scalars = ["snimpyIpAddress", "snimpyString", "snimpyInteger", "snimpyEnum", "snimpyObjectId", "snimpyBoolean", "snimpyCounter", "snimpyGauge", "snimpyTimeticks", "snimpyCounter64", "snimpyBits", "snimpyNotImplemented", "snimpyOctetString", "snimpyUnicodeString", "snimpyMacAddress", "snimpyMacAddressInvalid"] self.scalars.sort() self.expected_modules = [u"SNMPv2-SMI", u"SNMPv2-TC", u"SNIMPY-MIB", u"INET-ADDRESS-MIB", u"IANAifType-MIB"]
def testGetMacAddress(self): """Get a MAC address""" mib.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib")) oid, a = self.session.get((1, 3, 6, 1, 2, 1, 45121, 1, 15, 0))[0] self.assertEqual(a, b"\x11\x12\x13\x14\x15\x16") b = basictypes.build('SNIMPY-MIB', 'snimpyMacAddress', a) self.assertEqual(b, "11:12:13:14:15:16")
def setAndCheck(self, oid, value): """Set and check a value""" mib.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib")) ooid = mib.get("SNIMPY-MIB", oid).oid + (0,) self.session.set(ooid, basictypes.build("SNIMPY-MIB", oid, value)) self.assertEqual( basictypes.build("SNIMPY-MIB", oid, self.session.get(ooid)[0][1]), basictypes.build("SNIMPY-MIB", oid, value), )
def setAndCheck(self, oid, value): """Set and check a value""" mib.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib")) ooid = mib.get('SNIMPY-MIB', oid).oid + (0,) self.session.set(ooid, basictypes.build('SNIMPY-MIB', oid, value)) self.assertEqual( basictypes.build('SNIMPY-MIB', oid, self.session.get(ooid)[0][1]), basictypes.build('SNIMPY-MIB', oid, value))
def setUpClass(cls): mib.load('IF-MIB') mib.load('SNMPv2-MIB') cls.agent = None cls.agent2 = None cls.agent = agent.TestAgent(community='public', authpass='******', privpass='******') cls.agent2 = agent.TestAgent(community='private', authpass='******', privpass='******')
def testVariousSet(self): """Set value of many types. This test should be monitored with a traffic capture""" mib.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib")) for oid, value in [('snimpyIpAddress', '10.14.12.12'), ('snimpyInteger', 1574512), ('snimpyEnum', 'testing'), ('snimpyObjectId', (1,2,3,4,5,6)), ('snimpyCounter', 545424), ('snimpyGauge', 4857544), ('snimpyTimeticks', timedelta(3, 18)), ('snimpyBits', ["third", "last"])]: self.assertRaises(self.version == 1 and snmp.SNMPNoSuchName or snmp.SNMPNoAccess, self.session.set, mib.get('SNIMPY-MIB', oid).oid + (0,), basictypes.build('SNIMPY-MIB', oid, value))
def testVariousSet(self): """Set value of many types. This test should be monitored with a traffic capture""" mib.load( os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib")) for oid, value in [('snimpyIpAddress', '10.14.12.12'), ('snimpyInteger', 1574512), ('snimpyEnum', 'testing'), ('snimpyObjectId', (1, 2, 3, 4, 5, 6)), ('snimpyCounter', 545424), ('snimpyGauge', 4857544), ('snimpyTimeticks', timedelta(3, 18)), ('snimpyBits', ["third", "last"])]: self.assertRaises( self.version == 1 and snmp.SNMPNoSuchName or snmp.SNMPNoAccess, self.session.set, mib.get('SNIMPY-MIB', oid).oid + (0, ), basictypes.build('SNIMPY-MIB', oid, value))
def load(mibname): """Load a MIB in memory. :param mibname: MIB name or filename :type mibname: str """ m = mib.load(mibname) if m not in loaded: loaded.append(m) if Manager._complete: for o in mib.getScalars(m) + mib.getColumns(m): setattr(Manager, str(o), 1)
def setUp(self): mib.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib")) self.nodes = ["snimpy", "snimpyScalars", "snimpyTables"] self.nodes.sort() self.tables = ["snimpyComplexTable", "snimpySimpleTable", "snimpyIndexTable"] self.tables.sort() self.columns = [ "snimpyComplexFirstIP", "snimpyComplexSecondIP", "snimpySimpleIndex", "snimpyComplexState", "snimpySimpleDescr", "snimpySimplePhys", "snimpySimpleType", "snimpyIndexVarLen", "snimpyIndexIntIndex", "snimpyIndexOidVarLen", "snimpyIndexFixedLen", "snimpyIndexImplied", "snimpyIndexInt", ] self.columns.sort() self.scalars = [ "snimpyIpAddress", "snimpyString", "snimpyInteger", "snimpyEnum", "snimpyObjectId", "snimpyBoolean", "snimpyCounter", "snimpyGauge", "snimpyTimeticks", "snimpyCounter64", "snimpyBits", "snimpyNotImplemented", "snimpyOctetString", "snimpyUnicodeString", "snimpyMacAddress", ] self.scalars.sort()
def load(mibname): """Load a MIB in memory. :param mibname: MIB name or filename :type mibname: str """ m = mib.load(mibname) if m not in loaded: loaded.append(m) if Manager._complete: for o in mib.getScalars(m) + \ mib.getColumns(m): setattr(Manager, str(o), 1)
def setUpClass(cls): mib.load('IF-MIB') mib.load('SNMPv2-MIB') cls.agent = agent.TestAgent()
def setUpClass(cls): mib.load('IF-MIB') mib.load('SNMPv2-MIB') cls.agents = [] cls.agent = cls.addAgent('public', 'public-authpass', 'public-privpass')
def setUp(self): mib.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), "SNIMPY-MIB.mib"))
def setUp(self): mib.load('IF-MIB') mib.load('SNMPv2-MIB') self.session = snmp.Session(host="localhost", community="public", version=self.version)
def setUpClass(cls): mib.load("IF-MIB") mib.load("SNMPv2-MIB")
def setUpClass(cls): mib.load("IF-MIB") mib.load("SNMPv2-MIB") cls.agents = [] cls.agent = cls.addAgent("public", "public-authpass", "public-privpass")
def setUpClass(cls): mib.load('IF-MIB') mib.load('SNMPv2-MIB')