• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python mib.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中snimpy.mib.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testIndexes

 def testIndexes(self):
     """Test that we can retrieve correctly the index of tables"""
     self.assertEqual([str(i) for i in mib.get("SNIMPY-MIB", "snimpySimpleTable").index], ["snimpySimpleIndex"])
     self.assertEqual(
         [str(i) for i in mib.get("SNIMPY-MIB", "snimpyComplexTable").index],
         ["snimpyComplexFirstIP", "snimpyComplexSecondIP"],
     )
开发者ID:pombredanne,项目名称:snimpy,代码行数:7,代码来源:test_mib.py


示例2: testOid

 def testOid(self):
     """Test OID basic type"""
     a = basictypes.build("SNIMPY-MIB", "snimpyObjectId",
                          mib.get("SNIMPY-MIB", "snimpyInteger"))
     self.assert_(isinstance(a, basictypes.Oid))
     self.assertEqual(a, mib.get("SNIMPY-MIB", "snimpyInteger"))
     self.assertEqual(a, mib.get("SNIMPY-MIB", "snimpyInteger").oid)
     # Suboid
     self.assert_((list(mib.get("SNIMPY-MIB",
                                "snimpyInteger").oid) + [2, 3]) in a)
     self.assert_((list(mib.get("SNIMPY-MIB",
                                "snimpyInteger").oid)[:-1] +
                   [29, 3]) not in a)
     # Ability to extract a component
     self.assertEqual(a[0], 1)
     self.assertEqual(a[1], 3)
     self.assertEqual(a[-3], 45121)
     self.assertEqual(a[-1], 3)
     self.assertEqual(a[:3], (1, 3, 6))
     # Also accepts list
     a = basictypes.build("SNIMPY-MIB", "snimpyObjectId",
                          (1, 2, 3, 4))
     self.assertEqual(a, (1, 2, 3, 4))
     self.assert_((1, 2, 3, 4, 5) in a)
     self.assert_((3, 4, 5, 6) not in a)
开发者ID:AudricP,项目名称:snimpy,代码行数:25,代码来源:test_basictypes.py


示例3: testOidGreedy

 def testOidGreedy(self):
     """Test greediness of fromOid."""
     tt = {
         "snimpyIndexVarLen":
         ((5, 104, 101, 108, 108, 111, 111, 111, 111), (6, "hello")),
         "snimpyIndexFixedLen":
         ((104, 101, 108, 108, 111, 49, 49, 111), (6, "hello1")),
         "snimpyIndexImplied":
         ((104, 101, 108, 108, 111, 50), (6, "hello2")),
         "snimpyComplexFirstIP":
         ((15, 15, 16, 100, 23, 74, 87), (4, "15.15.16.100")),
         "snimpySimpleIndex": ((17, 19, 20), (1, 17)),
         "snimpyIndexOidVarLen": ((3, 247, 145, 475568, 475, 263),
                                  (4, (247, 145, 475568))),
     }
     for t in tt:
         self.assertEqual(mib.get("SNIMPY-MIB", t).type.fromOid(
             mib.get("SNIMPY-MIB", t), tt[t][0]),
             tt[t][1])
     # Test if too short
     tt = {"snimpyComplexFirstIP": (17, 19, 20),
           "snimpyIndexFixedLen": (104, 101, 108),
           "snimpyIndexVarLen": (6, 102, 103, 104, 105),
           "snimpyIndexOidVarLen": (3, 247, 145),
           }
     for t in tt:
         self.assertRaises(ValueError,
                           mib.get("SNIMPY-MIB", t).type.fromOid,
                           mib.get("SNIMPY-MIB", t), tt[t])
开发者ID:AudricP,项目名称:snimpy,代码行数:29,代码来源:test_basictypes.py


示例4: testEnums

 def testEnums(self):
     """Test that we got the enum values correctly"""
     self.assertEqual(mib.get('SNIMPY-MIB', "snimpyInteger").enum, None)
     self.assertEqual(mib.get("SNIMPY-MIB", "snimpyEnum").enum,
                      {1: "up",
                       2: "down",
                       3: "testing"})
     self.assertEqual(mib.get("SNIMPY-MIB", "snimpyBits").enum,
                      {0: "first",
                       1: "second",
                       2: "third",
                       7: "last"})
开发者ID:fragfutter,项目名称:snimpy,代码行数:12,代码来源:test_mib.py


示例5: testTooLargeOid

    def testTooLargeOid(self):
        """Handle the special case of octet string as OID with too large octets.

        See: https://github.com/vincentbernat/snimpy/pull/14
        """
        self.assertEqual(mib.get("SNIMPY-MIB",
                                 "snimpyIndexImplied").type.fromOid(
                                     mib.get("SNIMPY-MIB",
                                             "snimpyIndexImplied"),
                                     (104, 0xff00 | 101, 108, 108, 111)),
                         (5, basictypes.build("SNIMPY-MIB",
                                              "snimpyIndexImplied",
                                              "hello")))
开发者ID:AudricP,项目名称:snimpy,代码行数:13,代码来源:test_basictypes.py


示例6: testMultipleGet

 def testMultipleGet(self):
     """Get multiple values at once"""
     ooid1 = mib.get("SNMPv2-MIB", "sysDescr").oid + (0,)
     ooid2 = mib.get("IF-MIB", "ifNumber").oid + (0,)
     ooid3 = mib.get("IF-MIB", "ifType").oid + (1,)
     (oid1, a1), (oid2, a2), (oid3, a3) = self.session.get(ooid1, ooid2, ooid3)
     self.assertEqual(oid1, ooid1)
     self.assertEqual(oid2, ooid2)
     self.assertEqual(oid3, ooid3)
     self.assertEqual(a1, b"Snimpy Test Agent public")
     self.assert_(a2 > 1)
     b = basictypes.build("IF-MIB", "ifType", a3)
     self.assertEqual(b, "softwareLoopback")
开发者ID:mirceaulinic,项目名称:snimpy,代码行数:13,代码来源:test_snmp.py


示例7: testMultipleGet

 def testMultipleGet(self):
     """Get multiple values at once"""
     ooid1 = mib.get('SNMPv2-MIB', 'sysDescr').oid + (0,)
     ooid2 = mib.get('IF-MIB', 'ifNumber').oid + (0,)
     ooid3 = mib.get('IF-MIB', 'ifType').oid + (1,)
     (oid1, a1), (oid2, a2), (oid3, a3) = self.session.get(
         ooid1, ooid2, ooid3)
     self.assertEqual(oid1, ooid1)
     self.assertEqual(oid2, ooid2)
     self.assertEqual(oid3, ooid3)
     self.assertEqual(a1, " ".join(os.uname()))
     self.assert_(a2 > 1)
     b = basictypes.build('IF-MIB', 'ifType', a3)
     self.assertEqual(b, "softwareLoopback")
开发者ID:ajufrancis,项目名称:snimpy,代码行数:14,代码来源:testsnmp.py


示例8: testImplied

 def testImplied(self):
     """Check that we can get implied attribute for a given table"""
     self.assertEqual(
         mib.get("SNIMPY-MIB",
                 'snimpySimpleTable').implied,
         False)
     self.assertEqual(
         mib.get("SNIMPY-MIB",
                 'snimpyComplexTable').implied,
         False)
     self.assertEqual(
         mib.get("SNIMPY-MIB",
                 'snimpyIndexTable').implied,
         True)
开发者ID:fragfutter,项目名称:snimpy,代码行数:14,代码来源:test_mib.py


示例9: testWalk

 def testWalk(self):
     """Check if we can walk"""
     ooid = mib.get("IF-MIB", "ifDescr").oid
     self.session.bulk = 4
     results = self.session.walk(ooid)
     self.assertEqual(results,
                      ((ooid + (1,), b"lo"),
                       (ooid + (2,), b"eth0"),
                       (ooid + (3,), b"eth1"),
                       (mib.get("IF-MIB", "ifType").oid + (1,), 24)))
     self.session.bulk = 2
     results = self.session.walk(ooid)
     self.assertEqual(results[:2],
                      ((ooid + (1,), b"lo"),
                       (ooid + (2,), b"eth0")))
开发者ID:unikmhz,项目名称:snimpy,代码行数:15,代码来源:test_snmp.py


示例10: testTypeName

    def testTypeName(self):
        """Check that we can get the current declared type name"""
        table = mib.get("SNIMPY-MIB", "snimpyInetAddressTable")
        attr = table.index[1]

        self.assertEqual(attr.typeName, b"InetAddress")

        attr.typeName = b"InetAddressIPv4"
        self.assertEqual(attr.typeName, b"InetAddressIPv4")

        attr.typeName = b"InetAddressIPv6"
        self.assertEqual(attr.typeName, b"InetAddressIPv6")

        attr = mib.get("SNIMPY-MIB", "snimpySimpleIndex")
        self.assertEqual(attr.typeName, b"Integer32")
开发者ID:fragfutter,项目名称:snimpy,代码行数:15,代码来源:test_mib.py


示例11: testTypes

    def testTypes(self):
        """Test that we get the correct types"""
        tt = {"snimpyIpAddress": basictypes.IpAddress,
              "snimpyString": basictypes.OctetString,
              "snimpyOctetString": basictypes.OctetString,
              "snimpyUnicodeString": basictypes.OctetString,
              "snimpyMacAddress": basictypes.OctetString,
              "snimpyInteger": basictypes.Integer,
              "snimpyEnum": basictypes.Enum,
              "snimpyObjectId": basictypes.Oid,
              "snimpyBoolean": basictypes.Boolean,
              "snimpyCounter": basictypes.Unsigned32,
              "snimpyGauge": basictypes.Unsigned32,
              "snimpyTimeticks": basictypes.Timeticks,
              "snimpyCounter64": basictypes.Unsigned64,
              "snimpyBits": basictypes.Bits,
              "snimpySimpleIndex": basictypes.Integer,
              "snimpyComplexFirstIP": basictypes.IpAddress,
              "snimpyComplexSecondIP": basictypes.IpAddress,
              "snimpyComplexState": basictypes.Enum}
        for t in tt:
            self.assertEqual(mib.get('SNIMPY-MIB', t).type, tt[t])

        # Also check we get an exception when no type available
        def call():
            mib.get('SNIMPY-MIB', 'snimpySimpleTable').type
        self.assertRaises(mib.SMIException, call)
开发者ID:vincentbernat,项目名称:snimpy,代码行数:27,代码来源:test_mib.py


示例12: testSeveralSessions

 def testSeveralSessions(self):
     ooid = mib.get('SNMPv2-MIB', 'sysDescr').oid + (0,)
     oid1, a1 = self.session.get(ooid)[0]
     oid2, a2 = self.session2.get(ooid)[0]
     self.assertEqual(oid1, ooid)
     self.assertEqual(oid2, ooid)
     self.assertEqual(a1, b"Snimpy Test Agent")
     self.assertEqual(a2, b"Snimpy Test Agent")
开发者ID:fragfutter,项目名称:snimpy,代码行数:8,代码来源:test_snmp.py


示例13: _locate

 def _locate(self, attribute):
     for m in self._loaded:
         try:
             a = mib.get(m, attribute)
             return (m, a)
         except mib.SMIException:
             pass
     raise AttributeError("{0} is not an attribute".format(attribute))
开发者ID:AudricP,项目名称:snimpy,代码行数:8,代码来源:manager.py


示例14: testWalk

 def testWalk(self):
     """Check if we can walk"""
     ooid = mib.get("IF-MIB", "ifDescr").oid
     results = self.session.walk(ooid)
     self.assertEqual(tuple(results),
                      ((ooid + (1,), b"lo"),
                       (ooid + (2,), b"eth0"),
                       (ooid + (3,), b"eth1")))
开发者ID:AudricP,项目名称:snimpy,代码行数:8,代码来源:test_snmp.py


示例15: setAndCheck

 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),
     )
开发者ID:mirceaulinic,项目名称:snimpy,代码行数:9,代码来源:test_snmp.py


示例16: _test

 def _test(self, ipv6, host):
     m = agent.TestAgent(ipv6)
     session = snmp.Session(host="{0}:{1}".format(host, m.port), community="public", version=2)
     try:
         ooid = mib.get("SNMPv2-MIB", "sysDescr").oid + (0,)
         oid, a = session.get(ooid)[0]
         self.assertEqual(a, b"Snimpy Test Agent public")
     finally:
         m.terminate()
开发者ID:mirceaulinic,项目名称:snimpy,代码行数:9,代码来源:test_snmp.py


示例17: testTableColumnRelation

 def testTableColumnRelation(self):
     """Test that we can get the column from the table and vice-versa"""
     for i in self.tables:
         table = mib.get("SNIMPY-MIB", i)
         for r in table.columns:
             self.assert_(isinstance(r, mib.Column))
             self.assertEqual(str(r.table), str(i))
             self.assert_(str(r).startswith(str(i).replace("Table", "")))
         columns = sorted([str(rr) for rr in self.columns if str(rr).startswith(str(i).replace("Table", ""))])
         tcolumns = [str(rr) for rr in table.columns]
         tcolumns.sort()
         self.assertEqual(columns, tcolumns)
     for r in self.columns:
         column = mib.get("SNIMPY-MIB", r)
         table = column.table
         self.assert_(isinstance(table, mib.Table))
         prefix = str(table).replace("Table", "")
         self.assertEqual(prefix, str(r)[: len(prefix)])
开发者ID:pombredanne,项目名称:snimpy,代码行数:18,代码来源:test_mib.py


示例18: testGetByOid

 def testGetByOid(self):
     """Test that we can get all named attributes by OID."""
     for i in self.scalars:
         nodebyname = mib.get('SNIMPY-MIB', i)
         self.assertEqual(str(mib.getByOid(nodebyname.oid)), i)
         self.assert_(isinstance(mib.getByOid(nodebyname.oid), mib.Scalar))
     for i in self.tables:
         nodebyname = mib.get('SNIMPY-MIB', i)
         self.assertEqual(str(mib.getByOid(nodebyname.oid)), i)
         self.assert_(isinstance(mib.getByOid(nodebyname.oid), mib.Table))
     for i in self.columns:
         nodebyname = mib.get('SNIMPY-MIB', i)
         self.assertEqual(str(mib.getByOid(nodebyname.oid)), i)
         self.assert_(isinstance(mib.getByOid(nodebyname.oid), mib.Column))
     for i in self.nodes:
         nodebyname = mib.get('SNIMPY-MIB', i)
         self.assertEqual(str(mib.getByOid(nodebyname.oid)), i)
         self.assert_(isinstance(mib.getByOid(nodebyname.oid), mib.Node))
开发者ID:fragfutter,项目名称:snimpy,代码行数:18,代码来源:test_mib.py


示例19: testOid

 def testOid(self):
     """Test OID basic type"""
     a = basictypes.build("SNIMPY-MIB", "snimpyObjectId",
                          mib.get("SNIMPY-MIB", "snimpyInteger"))
     self.assert_(isinstance(a, basictypes.Oid))
     self.assertEqual(a, mib.get("SNIMPY-MIB", "snimpyInteger"))
     self.assertEqual(a, mib.get("SNIMPY-MIB", "snimpyInteger").oid)
     # Suboid
     self.assert_((list(mib.get("SNIMPY-MIB",
                                "snimpyInteger").oid) + [2,3]) in a)
     self.assert_((list(mib.get("SNIMPY-MIB",
                                "snimpyInteger").oid)[:-1] + [29,3]) not in a)
     # Also accepts list
     a = basictypes.build("SNIMPY-MIB", "snimpyObjectId",
                          (1,2,3,4))
     self.assertEqual(a, (1,2,3,4))
     self.assert_((1,2,3,4,5) in a)
     self.assert_((3,4,5,6) not in a)
开发者ID:ajufrancis,项目名称:snimpy,代码行数:18,代码来源:testbasictypes.py


示例20: testGet

 def testGet(self):
     """Test that we can get all named attributes"""
     for i in self.scalars:
         self.assertEqual(str(mib.get('SNIMPY-MIB', i)), i)
         self.assert_(isinstance(mib.get('SNIMPY-MIB', i), mib.Scalar))
     for i in self.tables:
         self.assertEqual(str(mib.get('SNIMPY-MIB', i)), i)
         self.assert_(isinstance(mib.get('SNIMPY-MIB', i), mib.Table))
     for i in self.columns:
         self.assertEqual(str(mib.get('SNIMPY-MIB', i)), i)
         self.assert_(isinstance(mib.get('SNIMPY-MIB', i), mib.Column))
     for i in self.nodes:
         self.assertEqual(str(mib.get('SNIMPY-MIB', i)), i)
         self.assert_(isinstance(mib.get('SNIMPY-MIB', i), mib.Node))
     for i in self.notifications:
         self.assertEqual(str(mib.get('SNIMPY-MIB', i)), i)
         self.assert_(isinstance(mib.get('SNIMPY-MIB', i),
                      mib.Notification))
开发者ID:vincentbernat,项目名称:snimpy,代码行数:18,代码来源:test_mib.py



注:本文中的snimpy.mib.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.ClientMatchRuleFactory类代码示例发布时间:2022-05-27
下一篇:
Python basictypes.build函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap