1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""DmdBuilder
15
16 DmdBuilder builds out the core containment structure used in the dmd database.
17
18 Devices
19 Groups
20 Locations
21 Networks
22 ServiceAreas
23 Services
24 Systems
25
26 $Id: DmdBuilder.py,v 1.11 2004/04/06 22:33:07 edahl Exp $"""
27
28 __version__ = "$Revision: 1.11 $"[11:-2]
29
30 import sys
31 import os
32
33 import transaction
34 import Zope2
35
36 from OFS.Image import File
37 from Acquisition import aq_base
38
39 from Products.ZenModel.DeviceClass import DeviceClass
40 from Products.ZenModel.Location import Location
41 from Products.ZenModel.DeviceGroup import DeviceGroup
42 from Products.ZenModel.ProductClass import ProductClass
43 from Products.ZenModel.IpNetwork import manage_addIpNetwork
44 from Products.ZenModel.ManufacturerRoot import ManufacturerRoot
45 from Products.ZenModel.MibOrganizer import MibOrganizer
46 from Products.ZenModel.OSProcessOrganizer import OSProcessOrganizer
47 from Products.ZenModel.ServiceOrganizer import ServiceOrganizer
48 from Products.ZenModel.System import System
49 from Products.ZenModel.MonitorClass import MonitorClass
50 from Products.ZenModel.ReportClass import ReportClass
51 from Products.ZenModel.DeviceReportClass import DeviceReportClass
52 from Products.ZenModel.CustomDeviceReportClass import CustomDeviceReportClass
53 from Products.ZenModel.GraphReportClass import GraphReportClass
54 from Products.ZenModel.MultiGraphReportClass import MultiGraphReportClass
55 from Products.ZenModel.DataRoot import DataRoot
56 from Products.ZenModel.ZDeviceLoader import manage_addZDeviceLoader
57 from Products.ZenModel.ZenossInfo import manage_addZenossInfo
58 from Products.ZenWidgets.ZenTableManager import manage_addZenTableManager
59 from Products.ZenModel.PerformanceConf import manage_addPerformanceConf
60 from Products.ZenModel.StatusMonitorConf import manage_addStatusMonitorConf
61 from Products.ZenRRD.RenderServer import manage_addRenderServer
62 from Products.ZenReports.ReportServer import manage_addReportServer
63 from Products.ZenEvents.MySqlEventManager import manage_addMySqlEventManager
64 from Products.ZenEvents.EventClass import manage_addEventClass
65 from Products.CMFCore.DirectoryView import manage_addDirectoryView
66 from Products.ZenModel.UserSettings import manage_addUserSettingsManager
67 from Products.ZenModel.LinkManager import manage_addLinkManager
68 from Products.ZenWidgets.PortletManager import manage_addPortletManager
69 from Products.ZenWidgets.ZenossPortlets import ZenossPortlets
70
71 classifications = {
72 'Devices': DeviceClass,
73 'Groups': DeviceGroup,
74 'Locations': Location,
75 'Systems': System,
76 'Services': ServiceOrganizer,
77 'Manufacturers': ManufacturerRoot,
78 'Mibs': MibOrganizer,
79 'Processes': OSProcessOrganizer,
80 'Monitors': MonitorClass,
81 'Reports': ReportClass,
82 }
83
85
86
87 dmdroots = (
88 'Devices',
89 'Groups',
90 'Locations',
91 'Systems',
92 'Services',
93 'Processes',
94 'Manufacturers',
95 'Mibs',
96 'Monitors',
97 'Reports',
98 )
99
100
101 monRoots = ('StatusMonitors','Performance')
102
103
104 - def __init__(self, portal, evthost, evtuser, evtpass, evtdb,
105 smtphost, smtpport, snpphost, snppport):
106 self.portal = portal
107 self.evthost = evthost
108 self.evtuser = evtuser
109 self.evtpass = evtpass
110 self.evtdb = evtdb
111 dmd = DataRoot('dmd')
112 self.portal._setObject(dmd.id, dmd)
113 self.dmd = self.portal._getOb('dmd')
114 self.dmd.smtpHost = smtphost
115 self.dmd.snppHost = snpphost
116 self.dmd.smtpPort = smtpport
117 self.dmd.snppPort = snppport
118
119
123
124
134
135
137 for id, cmd in (
138 ('ping', 'ping -c2 ${device/manageIp}'),
139 ('traceroute', 'traceroute -q 1 -w 2 ${device/manageIp}'),
140 ('DNS forward', 'host ${device/manageIp}'),
141 ('DNS reverse', 'host ${device/id}'),
142 ('snmpwalk', 'snmpwalk -v1 -c${device/zSnmpCommunity}'
143 ' ${here/manageIp} system'),
144 ):
145 self.dmd.manage_addUserCommand(id, cmd=cmd)
146
147
158
159
173
178
179
181 self.buildRoots()
182 self.buildMonitors()
183 self.buildUserCommands()
184 self.buildReportClasses()
185 self.buildPortlets()
186 manage_addEventClass(self.dmd)
187 manage_addZDeviceLoader(self.dmd)
188 manage_addZenTableManager(self.portal)
189 manage_addZenossInfo(self.portal)
190 manage_addDirectoryView(self.portal,'ZenUtils/js', 'js')
191 manage_addRenderServer(self.portal, "RenderServer")
192 manage_addReportServer(self.portal, "ReportServer")
193 manage_addMySqlEventManager(self.dmd, evthost=self.evthost,
194 evtuser=self.evtuser, evtpass=self.evtpass,
195 evtdb=self.evtdb)
196 manage_addMySqlEventManager(self.dmd, evthost=self.evthost,
197 evtuser=self.evtuser, evtpass=self.evtpass,
198 evtdb=self.evtdb,
199 history=True)
200 manage_addUserSettingsManager(self.dmd)
201 manage_addLinkManager(self.dmd)
202 manage_addIpNetwork(self.dmd, "Networks")
203