當前位置: 首頁>>代碼示例>>Python>>正文


Python TrapFilter.TrapFilter類代碼示例

本文整理匯總了Python中Products.ZenEvents.TrapFilter.TrapFilter的典型用法代碼示例。如果您正苦於以下問題:Python TrapFilter類的具體用法?Python TrapFilter怎麽用?Python TrapFilter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TrapFilter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testParseV1FilterDefinitionFailsForInvalidTrap

    def testParseV1FilterDefinitionFailsForInvalidTrap(self):
        filter = TrapFilter()
        results = filter._parseV1FilterDefinition(99, "include", ["a"])
        self.assertEquals(results, "Invalid generic trap 'a'; must be one of 0-5")

        results = filter._parseV1FilterDefinition(99, "include", ["6"])
        self.assertEquals(results, "Invalid generic trap '6'; must be one of 0-5")
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:7,代碼來源:testTrapFilter.py

示例2: testParseV1FilterDefinitionFailsForInvalidEnterpriseSpecificTrap

    def testParseV1FilterDefinitionFailsForInvalidEnterpriseSpecificTrap(self):
        filter = TrapFilter()
        results = filter._parseV1FilterDefinition(99, "include", [".1.3.6.1.4.5", "abc"])
        self.assertEquals(results, "Specific trap 'abc' invalid; must be non-negative integer")

        results = filter._parseV1FilterDefinition(99, "include", [".1.3.6.1.4.5", "-1"])
        self.assertEquals(results, "Specific trap '-1' invalid; must be non-negative integer")
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:7,代碼來源:testTrapFilter.py

示例3: testParseV1FilterDefinitionForGenericTrap

    def testParseV1FilterDefinitionForGenericTrap(self):
        filter = TrapFilter()
        results = filter._parseV1FilterDefinition(99, "include", ["0"])
        self.assertEquals(results, None)
        self.assertEquals(len(filter._v1Traps), 1)
        self.assertEquals(len(filter._v1Filters), 0)
        self.assertEquals(len(filter._v2Filters), 0)

        genericTrapDefinition = filter._v1Traps["0"]
        self.assert_(genericTrapDefinition != None)
        self.assertEquals(genericTrapDefinition.lineNumber, 99)
        self.assertEquals(genericTrapDefinition.action, "include")
        self.assertEquals(genericTrapDefinition.genericTrap, "0")

        # Now add another to make sure we can parse more than one
        results = filter._parseV1FilterDefinition(100, "exclude", ["5"])
        self.assertEquals(results, None)
        self.assertEquals(len(filter._v1Traps), 2)
        self.assertEquals(len(filter._v1Filters), 0)
        self.assertEquals(len(filter._v2Filters), 0)

        genericTrapDefinition = filter._v1Traps["5"]
        self.assert_(genericTrapDefinition != None)
        self.assertEquals(genericTrapDefinition.lineNumber, 100)
        self.assertEquals(genericTrapDefinition.action, "exclude")
        self.assertEquals(genericTrapDefinition.genericTrap, "5")
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:26,代碼來源:testTrapFilter.py

示例4: testValidateOIDFailsForInvalidGlobbing

    def testValidateOIDFailsForInvalidGlobbing(self):
        filter = TrapFilter()
        results = filter._validateOID("1.2.3.*.5.*")
        self.assertEquals(results, "When using '*', only a single '*' at the end of OID is allowed")

        results = filter._validateOID("1.*.5")
        self.assertEquals(results, "When using '*', only a single '*' at the end of OID is allowed")

        results = filter._validateOID("1.5*")
        self.assertEquals(results, "When using '*', only a single '*' at the end of OID is allowed")

        results = filter._validateOID("*.")
        self.assertEquals(results, "When using '*', only a single '*' at the end of OID is allowed")

        results = filter._validateOID("*.1")
        self.assertEquals(results, "When using '*', only a single '*' at the end of OID is allowed")

        results = filter._validateOID("*.*")
        self.assertEquals(results, "When using '*', only a single '*' at the end of OID is allowed")

        results = filter._validateOID("5*")
        self.assertEquals(results, "When using '*', only a single '*' at the end of OID is allowed")

        results = filter._validateOID("*5")
        self.assertEquals(results, "When using '*', only a single '*' at the end of OID is allowed")

        results = filter._validateOID(".*")
        self.assertEquals(results, "When using '*', only a single '*' at the end of OID is allowed")
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:28,代碼來源:testTrapFilter.py

示例5: testValidateOIDForGlob

    def testValidateOIDForGlob(self):
        filter = TrapFilter()
        results = filter._validateOID("*")
        self.assertEquals(results, None)

        results = filter._validateOID("1.2.*")
        self.assertEquals(results, None)
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:7,代碼來源:testTrapFilter.py

示例6: testDropV1EventForGenericTrapForNoMatch

    def testDropV1EventForGenericTrapForNoMatch(self):
        genericTrap = 1
        filterDef = GenericTrapFilterDefinition(99, "exclude", genericTrap)
        filter = TrapFilter()
        filter._v1Traps[genericTrap] = filterDef

        event = {"snmpVersion": "1", "snmpV1GenericTrapType": 2}
        self.assertTrue(filter._dropV1Event(event))
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:8,代碼來源:testTrapFilter.py

示例7: testDropV1EventForGenericTrapInclusion

    def testDropV1EventForGenericTrapInclusion(self):
        genericTrap = 0
        filterDef = GenericTrapFilterDefinition(99, "include", genericTrap)
        filter = TrapFilter()
        filter._v1Traps[genericTrap] = filterDef

        event = {"snmpVersion": "1", "snmpV1GenericTrapType": genericTrap}
        self.assertFalse(filter._dropV1Event(event))
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:8,代碼來源:testTrapFilter.py

示例8: testDropV2EventForSimpleExactMatches

    def testDropV2EventForSimpleExactMatches(self):
        filterDef = V2FilterDefinition(99, "include", "1.2.3")
        filtersByLevel = {filterDef.oid: filterDef}
        filter = TrapFilter()
        filter._v2Filters[3] = filtersByLevel

        filterDef = V2FilterDefinition(99, "include", "1.2.3.4")
        filtersByLevel = {filterDef.oid: filterDef}
        filter._v2Filters[4] = filtersByLevel

        event = {"snmpVersion": "2", "oid": "1.2.3"}
        self.assertFalse(filter._dropV2Event(event))

        event["oid"] = "1.2.3.4"
        self.assertFalse(filter._dropV2Event(event))

        # OIDs with fewer or more levels than the existing filters should NOT match
        event["oid"] = "1.2"
        self.assertTrue(filter._dropV2Event(event))
        event["oid"] = "1.2.3.4.9"
        self.assertTrue(filter._dropV2Event(event))

        # OIDs that differ only in the last level should NOT match
        event["oid"] = "1.2.9"
        self.assertTrue(filter._dropV2Event(event))
        event["oid"] = "1.2.3.9"
        self.assertTrue(filter._dropV2Event(event))
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:27,代碼來源:testTrapFilter.py

示例9: testDropV1EventForMissingEnterpriseOID

    def testDropV1EventForMissingEnterpriseOID(self):
        filterDef = V1FilterDefinition(99, "include", "*")
        filtersByLevel = {filterDef.oid: filterDef}
        filter = TrapFilter()
        filter._v1Filters[1] = filtersByLevel

        event = {
            "snmpVersion": "1",
            "snmpV1GenericTrapType": 6,
        }
        self.assertTrue(filter._dropV1Event(event))
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:11,代碼來源:testTrapFilter.py

示例10: testDropV2EventForSimpleGlobMatch

    def testDropV2EventForSimpleGlobMatch(self):
        filterDef = V2FilterDefinition(99, "exclude", "1.2.3.*")
        filtersByLevel = {filterDef.oid: filterDef}
        filter = TrapFilter()
        filter._v2Filters[4] = filtersByLevel

        event = {"snmpVersion": "2", "oid": "1.2.3.4"}
        self.assertTrue(filter._dropV2Event(event))

        filterDef.action = "include"
        self.assertFalse(filter._dropV2Event(event))
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:11,代碼來源:testTrapFilter.py

示例11: testDropV2EventExcludeAll

    def testDropV2EventExcludeAll(self):
        filterDef = V2FilterDefinition(99, "exclude", "*")
        filtersByLevel = {filterDef.oid: filterDef}
        filter = TrapFilter()
        filter._v2Filters[1] = filtersByLevel

        event = {"snmpVersion": "2", "oid": "1"}
        self.assertTrue(filter._dropV2Event(event))

        event["oid"] = "1.2.3"
        self.assertTrue(filter._dropV2Event(event))
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:11,代碼來源:testTrapFilter.py

示例12: testParseV1FilterDefinitionFailsForConflictingTrap

    def testParseV1FilterDefinitionFailsForConflictingTrap(self):
        filter = TrapFilter()
        results = filter._parseV1FilterDefinition(99, "include", ["1"])
        self.assertEquals(results, None)

        results = filter._parseV1FilterDefinition(100, "include", ["1"])
        self.assertEquals(results, "Generic trap '1' conflicts with previous definition at line 99")

        # Verify we find a conflict for generic traps where the action differs
        results = filter._parseV1FilterDefinition(100, "exclude", ["1"])
        self.assertEquals(results, "Generic trap '1' conflicts with previous definition at line 99")
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:11,代碼來源:testTrapFilter.py

示例13: testParseV2FilterDefinition

    def testParseV2FilterDefinition(self):
        filter = TrapFilter()
        results = filter._parseV2FilterDefinition(99, "include", ["1.2.3.*"])
        self.assertEquals(results, None)
        self.assertEquals(len(filter._v1Traps), 0)
        self.assertEquals(len(filter._v1Filters), 0)
        self.assertEquals(len(filter._v2Filters), 1)

        oidLevels = 4
        mapByLevel = filter._v2Filters[oidLevels]
        self.assert_(mapByLevel != None)
        self.assertEquals(len(mapByLevel), 1)

        filterDef = mapByLevel["1.2.3.*"]
        self.assert_(filterDef != None)
        self.assertEquals(filterDef.lineNumber, 99)
        self.assertEquals(filterDef.action, "include")
        self.assertEquals(filterDef.oid, "1.2.3.*")

        # Add another 4-level OID
        results = filter._parseV2FilterDefinition(100, "exclude", ["1.2.3.4"])
        self.assertEquals(results, None)
        self.assertEquals(len(filter._v1Traps), 0)
        self.assertEquals(len(filter._v1Filters), 0)
        self.assertEquals(len(filter._v2Filters), 1)

        mapByLevel = filter._v2Filters[oidLevels]
        self.assert_(mapByLevel != None)
        self.assertEquals(len(mapByLevel), 2)

        filterDef = mapByLevel["1.2.3.4"]
        self.assert_(filterDef != None)
        self.assertEquals(filterDef.lineNumber, 100)
        self.assertEquals(filterDef.action, "exclude")
        self.assertEquals(filterDef.oid, "1.2.3.4")

        # Add another single-level OID
        results = filter._parseV2FilterDefinition(101, "exclude", ["*"])
        self.assertEquals(results, None)
        self.assertEquals(len(filter._v1Traps), 0)
        self.assertEquals(len(filter._v1Filters), 0)
        self.assertEquals(len(filter._v2Filters), 2)

        oidLevels = 1
        mapByLevel = filter._v2Filters[oidLevels]
        self.assert_(mapByLevel != None)
        self.assertEquals(len(mapByLevel), 1)

        filterDef = mapByLevel["*"]
        self.assert_(filterDef != None)
        self.assertEquals(filterDef.lineNumber, 101)
        self.assertEquals(filterDef.action, "exclude")
        self.assertEquals(filterDef.oid, "*")
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:53,代碼來源:testTrapFilter.py

示例14: testTransformDropsV2Event

    def testTransformDropsV2Event(self):
        filterDef = V2FilterDefinition(99, "exclude", "1.2.3")
        filtersByLevel = {filterDef.oid: filterDef}
        filter = TrapFilter()
        filter._v2Filters[3] = filtersByLevel
        filter._filtersDefined = True

        event = {
            "snmpVersion": "2",
            "oid": filterDef.oid,
        }
        self.assertEquals(TRANSFORM_DROP, filter.transform(event))
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:12,代碼來源:testTrapFilter.py

示例15: testParseV2FilterDefinitionFailsForEmptyOID

    def testParseV2FilterDefinitionFailsForEmptyOID(self):
        filter = TrapFilter()
        results = filter._parseV2FilterDefinition(99, "include", [])
        self.assertEquals(results, "'' is not a valid OID: Empty OID is invalid")

        results = filter._parseV2FilterDefinition(99, "include", [""])
        self.assertEquals(results, "'' is not a valid OID: Empty OID is invalid")

        results = filter._parseV2FilterDefinition(99, "include", ["."])
        self.assertEquals(results, "'' is not a valid OID: Empty OID is invalid")

        results = filter._parseV2FilterDefinition(99, "include", ["..."])
        self.assertEquals(results, "'' is not a valid OID: Empty OID is invalid")
開發者ID:zenoss,項目名稱:zenoss-prodbin,代碼行數:13,代碼來源:testTrapFilter.py


注:本文中的Products.ZenEvents.TrapFilter.TrapFilter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。