本文整理汇总了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")
示例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")
示例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")
示例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")
示例5: testValidateOIDForGlob
def testValidateOIDForGlob(self):
filter = TrapFilter()
results = filter._validateOID("*")
self.assertEquals(results, None)
results = filter._validateOID("1.2.*")
self.assertEquals(results, None)
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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")
示例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, "*")
示例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))
示例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")