1
2
3
4
5
6
7
8
9
10
11 __doc__ = '''SnmpTrapConfig
12
13 Provides configuration for an OID translation service.
14 '''
15
16 import logging
17 log = logging.getLogger('zen.HubService.SnmpTrapConfig')
18
19 import Globals
20
21 from twisted.spread import pb
22 from twisted.internet import reactor, defer
23
24 from Products.ZenCollector.services.config import CollectorConfigService
25 from Products.ZenHub.zodb import onUpdate, onDelete
26
27 from Products.ZenModel.Device import Device
28 from Products.ZenModel.DeviceClass import DeviceClass
29 from Products.ZenModel.MibBase import MibBase
30 from Products.Zuul.interfaces import ICatalogTool
31
32 SNMPV3_USER_ZPROPS = ["zSnmpEngineId",
33 "zSnmpSecurityName",
34 "zSnmpAuthType",
35 "zSnmpAuthPassword",
36 "zSnmpPrivType",
37 "zSnmpPrivPassword",
38 ]
42
43 -class User(pb.Copyable, pb.RemoteCopy):
54 pb.setUnjellyableForClass(User, User)
57
60
73
74 @defer.inlineCallbacks
100
102 cat = ICatalogTool(self.dmd)
103 brains = cat.search(("Products.ZenModel.Device.Device", "Products.ZenModel.DeviceClass.DeviceClass"))
104 for brain in brains:
105 device = brain.getObject()
106 self._create_user(device)
107
108 @onUpdate(DeviceClass)
111
112 @onUpdate(Device)
115
116 @onUpdate(MibBase)
118 for listener in self.listeners:
119 listener.callRemote('notifyConfigChanged')
120
121 @onDelete(MibBase)
123 for listener in self.listeners:
124 listener.callRemote('notifyConfigChanged')
125
126
127 if __name__ == '__main__':
128 from pprint import pprint
129 from Products.ZenHub.ServiceTester import ServiceTester
133 ServiceTester.buildOptions(self)
134 self.parser.add_option('--resolve', dest='request',
135 help="Specify a specific OID or name to map to the name or OID.")
136 self.parser.add_option('--exactMatch', dest='exactMatch',
137 action='store_true', default=True,
138 help="When resolving to name, use an exact match")
139 self.parser.add_option('--fuzzyMatch', dest='exactMatch',
140 action='store_false',
141 help="When resolving to name, don't use an exact match")
142 self.parser.add_option('--list', dest='list',
143 action='store_true', default=False,
144 help="List all OIDs?")
145
155
160
163
171
172 tester = TrapTester(SnmpTrapConfig)
173 tester.run()
174