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

# Source Code for Package Products.ZenModel

      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 as published by
      8  # the Free Software Foundation.
      9  #
     10  # For complete information please visit: http://www.zenoss.com/oss/
     11  #
     12  ###########################################################################
     13  __doc__="""__init__
     14
     15  Initialize the Confmon Product
     16
     17  Products must follow the following standard
     18  The name of the module (file) and the name of the product class inside
     19  the file must be the same.
     20
     21  If there is a ZMI add screen it must be called "add" + class name (ie addDevice)and it must be defined at the module level.
     22
     23  the class factory must be a function at the module level called
     24  manage_add + class name (ie manage_addDevice)
     25
     26  If there is an icon for the product it should be called class name + _icon.gif
     27  """
     28
     29  import os
     30  import logging
     31  log = logging.getLogger("zen")
     32
     33  if 0:
     34      __path__ = None                     # keep pyflakes quiet
     35
     36  from Products.CMFCore.DirectoryView import registerDirectory
     37
     38  confmon_globals = globals()
     39
     40  productNames = (
     41      'AdministrativeRole',
     42      'AdministrativeRoleable',
     43      'AreaGraphPoint',
     44      'BasicDataSource',
     45      'BasicDeviceLoader',
     46      'BatchDeviceLoader',
     47      'BuiltInDS',
     48      'CPU',
     49      'CdefGraphPoint',
     50      'CiscoLoader',
     51      'Classifier',
     52      'ClassifierEntry',
     53      'Collection',
     54      'CollectionItem',
     55      'Commandable',
     56      'CommentGraphPoint',
     57      'ComplexGraphPoint',
     58      'ConfigurationError',
     59      'ConfmonPropManager',
     60      'CustomDeviceReportClass',
     61      'DataPointGraphPoint',
     62      'DataRoot',
     63      'DefGraphPoint',
     64      'Device',
     65      'DeviceClass',
     66      'DeviceComponent',
     67      'DeviceGroup',
     68      'DeviceHW',
     69      'DeviceManagerBase',
     70      'DeviceOrganizer',
     71      'DeviceReport',
     72      'DeviceReportClass',
     73      'DeviceResultInt',
     74      'DmdBuilder',
     75      'EventView',
     76      'Exceptions',
     77      'ExpansionCard',
     78      'Fan',
     79      'FileSystem',
     80      'GprintGraphPoint',
     81      'GraphDefinition',
     82      'GraphGroup',
     83      'GraphPoint',
     84      'GraphReport',
     85      'GraphReportClass',
     86      'GraphReportElement',
     87      'HWComponent',
     88      'HardDisk',
     89      'Hardware',
     90      'HardwareClass',
     91      'HruleGraphPoint',
     92      'IpAddress',
     93      'IpInterface',
     94      'IpNetwork',
     95      'IpRouteEntry',
     96      'IpService',
     97      'IpServiceClass',
     98      'IpServiceLoader',
     99      'LineGraphPoint',
    100      'Link',
    101      'LinkManager',
    102      'Linkable',
    103      'Location',
    104      'Lockable',
    105      'MEProduct',
    106      'MaintenanceWindow',
    107      'MaintenanceWindowable',
    108      'ManagedEntity',
    109      'Manufacturer',
    110      'ManufacturerRoot',
    111      'MibBase',
    112      'MibModule',
    113      'MibNode',
    114      'MibNotification',
    115      'MibOrganizer',
    116      'MinMaxThreshold',
    117      'Monitor',
    118      'MonitorClass',
    119      'MultiGraphReport',
    120      'MultiGraphReportClass',
    121      'OSComponent',
    122      'OSProcess',
    123      'OSProcessClass',
    124      'OSProcessOrganizer',
    125      'OperatingSystem',
    126      'Organizer',
    127      'PerformanceConf',
    128      'PerformanceView',
    129      'PowerSupply',
    130      'PrintGraphPoint',
    131      'ProductClass',
    132      'RRDDataPoint',
    133      'RRDDataSource',
    134      'RRDGraph',
    135      'RRDTemplate',
    136      'RRDThreshold',
    137      'RRDView',
    138      'Report',
    139      'ReportClass',
    140      'Service',
    141      'ServiceClass',
    142      'ServiceOrganizer',
    143      'ShiftGraphPoint',
    144      'SiteError',
    145      'Software',
    146      'SoftwareClass',
    147      'StatusColor',
    148      'System',
    149      'TemperatureSensor',
    150      'TemplateContainer',
    151      'ThresholdClass',
    152      'ThresholdGraphPoint',
    153      'ThresholdInstance',
    154      'TickGraphPoint',
    155      'UserCommand',
    156      'UserSettings',
    157      'VdefGraphPoint',
    158      'VruleGraphPoint',
    159      'WinService',
    160      'XmlDataLoader',
    161      'ZDeviceLoader',
    162      'ZVersion',
    163      'ZenDate',
    164      'ZenMenu',
    165      'ZenMenuItem',
    166      'ZenMenuable',
    167      'ZenModelBase',
    168      'ZenModelItem',
    169      'ZenModelRM',
    170      'ZenPack',
    171      'ZenPackLoader',
    172      'ZenPackManager',
    173      'ZenPackPersistence',
    174      'ZenPackable',
    175      'ZenPacker',
    176      'ZenStatus',
    177      'ZenossInfo',
    178      'ZenossSecurity',
    179      'ZentinelPortal',
    180  )
    181
    182  # Make the skins available as DirectoryViews.
    183  registerDirectory('skins', globals())
    184  registerDirectory('help', globals())
    185
    186
    187  confmonModules = []
    188 -def loadConfmonModules():
    189      # import all modules
    190      for product in productNames:
    191          mod = __import__(product, globals(), locals(), [])
    192          confmonModules.append(mod)
    193
    194
    195 -def initialize(registrar):
    196      contentClasses = ()
    197      contentConstructors = ()
    198
    199      registrar.registerHelp()
    200      registrar.registerHelpTitle('Zentinel Portal Help')
    201
    202      if not confmonModules: loadConfmonModules()
    203      # register products with zope
    204      for module in confmonModules:
    205          args = []
    206          kwargs = {}
    207          className = module.__name__.split('.')[-1]
    208          addDtmlName = "add%s" % className
    209          factoryName = "manage_add%s" % className
    210          iconName = "www/%s_icon.gif" % className
    211          confclass = getattr(module, className, None)
    212          #contentClasses.append(confclass)
    213          if not confclass: continue
    214          args.append(confclass)
    215          constructors = []
    216          addDtml = getattr(module, addDtmlName, None)
    217          if addDtml: constructors.append(addDtml)
    218          factory = getattr(module, factoryName, None)
    219          if factory: constructors.append(factory)
    220          if not constructors: continue
    221          kwargs['constructors'] = constructors
    222          kwargs['permission'] = "Add DMD Objects"
    223          if os.path.exists(os.path.join(__path__[0], iconName)):
    224              kwargs['icon'] = iconName
    225          log.debug("Register Class=%s",className)
    226          log.debug("kwargs=%s", constructors)
    227          apply(registrar.registerClass, args, kwargs)
    228