Package Products :: Package ZenModel :: Module DmdBuilder |
[hide private]
[frames] | no frames]

# Source Code for Module Products.ZenModel.DmdBuilder

      1  ###########################################################################
      2  #
      3  # This program is part of Zenoss Core, an open source monitoring platform.
      4  # Copyright (C) 2007, Zenoss Inc.
      5  #
      6  # This program is free software; you can redistribute it and/or modify it
      7  # under the terms of the GNU General Public License version 2 or (at your
      8  # option) any later version as published by the Free Software Foundation.
      9  #
     10  # For complete information please visit: http://www.zenoss.com/oss/
     11  #
     12  ###########################################################################
     13
     14  __doc__="""DmdBuilder
     15  DmdBuilder builds out the core containment structure used in the dmd database.
     16
     17  Devices
     18  Groups
     19  Locations
     20  Networks
     21  ServiceAreas
     22  Services
     23  Systems
     24  """
     25
     26  from Products.ZenModel.DeviceClass import DeviceClass
     27  from Products.ZenModel.Location import Location
     28  from Products.ZenModel.DeviceGroup import DeviceGroup
     29  from Products.ZenModel.IpNetwork import manage_addIpNetwork
     30  from Products.ZenModel.ManufacturerRoot import ManufacturerRoot
     31  from Products.ZenModel.MibOrganizer import MibOrganizer
     32  from Products.ZenModel.OSProcessOrganizer import OSProcessOrganizer
     33  from Products.ZenModel.ServiceOrganizer import ServiceOrganizer
     34  from Products.ZenModel.System import System
     35  from Products.ZenModel.MonitorClass import MonitorClass
     36  from Products.ZenModel.ReportClass import ReportClass
     37  from Products.ZenModel.DeviceReportClass import DeviceReportClass
     38  from Products.ZenModel.CustomDeviceReportClass import CustomDeviceReportClass
     39  from Products.ZenModel.GraphReportClass import GraphReportClass
     40  from Products.ZenModel.MultiGraphReportClass import MultiGraphReportClass
     41  from Products.ZenModel.DataRoot import DataRoot
     42  from Products.ZenModel.ZDeviceLoader import manage_addZDeviceLoader
     43  from Products.ZenModel.ZenossInfo import manage_addZenossInfo
     44  from Products.ZenWidgets.ZenTableManager import manage_addZenTableManager
     45  from Products.ZenModel.PerformanceConf import manage_addPerformanceConf
     46  from Products.ZenRRD.RenderServer import manage_addRenderServer
     47  from Products.ZenReports.ReportServer import manage_addReportServer
     48  from Products.ZenEvents.MySqlEventManager import manage_addMySqlEventManager
     49  from Products.ZenEvents.EventClass import manage_addEventClass
     50  from Products.CMFCore.DirectoryView import manage_addDirectoryView
     51  from Products.ZenModel.UserSettings import manage_addUserSettingsManager
     52  from Products.ZenModel.LinkManager import manage_addLinkManager
     53  from Products.ZenWidgets.PortletManager import manage_addPortletManager
     54  from Products.ZenWidgets.ZenossPortlets import ZenossPortlets
     55  from Products.ZenModel.ZenPackManager import manage_addZenPackManager
     56  from Products.Jobber.manager import manage_addJobManager
     57  from Products.ZenModel.ZenPackPersistence import CreateZenPackPersistenceCatalog
     58  from Products.ZenModel.RRDTemplate import CreateRRDTemplatesCatalog
     59  from Products.ZenModel.MaintenanceWindow import createMaintenanceWindowCatalog
     60  from Products.Zuul.catalog.global_catalog import createGlobalCatalog
     61  from Products.ZenModel.ZenossSecurity import \
     62       MANAGER_ROLE, ZEN_MANAGER_ROLE, ZEN_USER_ROLE, OWNER_ROLE
     63  from Products.ZenModel.NotificationSubscription import manage_addNotificationSubscriptionManager
     64  from Products.ZenModel.Trigger import manage_addTriggerManager
     65
     66
     67 -class DmdBuilder(object):
     68
     69 -    def __init__(self, portal, evthost, evtuser, evtpass, evtdb, evtport,
     70                      smtphost, smtpport, pagecommand):
     71          self.portal = portal
     72          self.evthost = evthost
     73          self.evtuser = evtuser
     74          self.evtpass = evtpass
     75          self.evtport = evtport
     76          self.evtdb = evtdb
     77          dmd = DataRoot('dmd')
     78          self.portal._setObject(dmd.id, dmd)
     79          self.dmd = self.portal._getOb('dmd')
     80          self.dmd._rq = False
     81          self.dmd.smtpHost = smtphost
     82          self.dmd.smtpPort = smtpport
     83          self.dmd.pageCommand = pagecommand
     84          self.dmd.propertyTransformers = {}
     85          self.dmd.manage_permission('Access contents information',
     86                                     ['Authenticated',
     87                                      MANAGER_ROLE,
     88                                      ZEN_MANAGER_ROLE,
     89                                      ZEN_USER_ROLE,
     90                                      OWNER_ROLE],
     91                                     0)
     92
     93 -    def buildRoots(self):
     94          roots = [('Devices', DeviceClass),
     95                   ('Groups', DeviceGroup),
     96                   ('Locations', Location),
     97                   ('Manufacturers', ManufacturerRoot),
     98                   ('Monitors', MonitorClass),
     99                   ('Mibs', MibOrganizer),
    100                   ('Processes', OSProcessOrganizer),
    101                   ('Reports', ReportClass),
    102                   ('Services', ServiceOrganizer),
    103                   ('Systems', System),
    104                   ]
    105          for objectId, construct in roots:
    106              if objectId not in self.dmd.objectIds():
    107                  object = construct(objectId)
    108                  object.isInTree = True
    109                  self.dmd._setObject(objectId, object)
    110          devices = self.dmd._getOb('Devices')
    111          devices.createCatalog()
    112          devices.buildDeviceTreeProperties()
    113
    114 -    def buildMonitors(self):
    115          perfId = 'Performance'
    116          monitors = self.dmd._getOb('Monitors')
    117          if perfId not in monitors.objectIds():
    118              monitors._setObject(perfId, MonitorClass(perfId))
    119              perf = monitors._getOb(perfId)
    120              perf.isInTree = False
    121              perf.sub_class = 'PerformanceConf'
    122              perfConfId = 'localhost'
    123              manage_addPerformanceConf(perf, perfConfId)
    124              perfConf = monitors.Performance._getOb(perfConfId)
    125              perfConf.renderurl = '/zport/RenderServer'
    126
    127 -    def buildUserCommands(self):
    128          for id, cmd, desc in (
    129                  ('ping', 'dcsh --collector=${device/getPerformanceServerName} -n "${device/pingCommand} -c2 ${device/manageIp}"',
    130                   "Is the device responding to ping?"),
    131                  ('traceroute', 'dcsh --collector=${device/getPerformanceServerName} -n "${device/tracerouteCommand} -q 1 -w 2 ${device/manageIp}"',
    132                   "Show the route to the device"),
    133                  ('DNS forward', 'dcsh --collector=${device/getPerformanceServerName} -n "host ${device/id}"',
    134                   "Name to IP address lookup"),
    135                  ('DNS reverse', 'dcsh --collector=${device/getPerformanceServerName} -n "host ${device/manageIp}"',
    136                   "IP address to name lookup"),
    137                  ('snmpwalk', 'dcsh --collector=${device/getPerformanceServerName} -n "snmpwalk -${device/zSnmpVer} -c${device/zSnmpCommunity} ${device/snmpwalkPrefix}${here/manageIp} system"',
    138                   "Display the OIDs available on a device"),
    139                  ):
    140              self.dmd.manage_addUserCommand(id, cmd=cmd, desc=desc)
    141
    142 -    def buildReportClasses(self):
    143          if not hasattr(self.dmd.Reports, 'Device Reports'):
    144              rc = DeviceReportClass('Device Reports')
    145              self.dmd.Reports._setObject(rc.id, rc)
    146          if not hasattr(self.dmd.Reports, 'Custom Device Reports'):
    147              rc = CustomDeviceReportClass('Custom Device Reports')
    148              self.dmd.Reports._setObject(rc.id, rc)
    149          if not hasattr(self.dmd.Reports, 'Graph Reports'):
    150              rc = GraphReportClass('Graph Reports')
    151              self.dmd.Reports._setObject(rc.id, rc)
    152          if not hasattr(self.dmd.Reports, 'Multi-Graph Reports'):
    153              rc = MultiGraphReportClass('Multi-Graph Reports')
    154              self.dmd.Reports._setObject(rc.id, rc)
    155
    156 -    def buildPortlets(self):
    157          manage_addPortletManager(self.portal)
    158          zpmgr = self.portal.ZenPortletManager
    159          ZenossPortlets.register_default_portlets(zpmgr)
    160
    161 -    def build(self):
    162          createGlobalCatalog(self.portal)
    163          self.buildRoots()
    164          self.buildMonitors()
    165          self.buildUserCommands()
    166          self.buildReportClasses()
    167          self.buildPortlets()
    168          manage_addEventClass(self.dmd)
    169          manage_addZDeviceLoader(self.dmd)
    170          manage_addZenTableManager(self.portal)
    171          manage_addZenossInfo(self.portal)
    172          manage_addDirectoryView(self.portal,'ZenUtils/js', 'js')
    173          manage_addRenderServer(self.portal, "RenderServer")
    174          manage_addReportServer(self.portal, "ReportServer")
    175          manage_addMySqlEventManager(self.dmd, evthost=self.evthost,
    176                                      evtuser=self.evtuser, evtpass=self.evtpass,
    177                                      evtdb=self.evtdb, evtport=self.evtport)
    178          manage_addMySqlEventManager(self.dmd, evthost=self.evthost,
    179                                      evtuser=self.evtuser, evtpass=self.evtpass,
    180                                      evtdb=self.evtdb, evtport=self.evtport,
    181                                      history=True)
    182          manage_addUserSettingsManager(self.dmd)
    183          manage_addNotificationSubscriptionManager(self.dmd)
    184          manage_addTriggerManager(self.dmd)
    185          manage_addLinkManager(self.dmd)
    186          manage_addJobManager(self.dmd)
    187          manage_addIpNetwork(self.dmd, "Networks")
    188          manage_addIpNetwork(self.dmd, "IPv6Networks", 64, version=6)
    189          manage_addZenPackManager(self.dmd)
    190          CreateZenPackPersistenceCatalog(self.dmd)
    191          CreateRRDTemplatesCatalog(self.dmd)
    192          createMaintenanceWindowCatalog(self.dmd)
    193