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

# Source Code for Module Products.ZenModel.Classifier

      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
     14  __doc__="""Classifier
     15
     16  Organizes classifier subclasses to perform high level classification of
     17  a device.  Subclasses know how to collect information from a device
     18  and look in their indexes for a ClassifierEntry about the device.
     19
     20  $Id: Classifier.py,v 1.4 2004/03/26 23:58:44 edahl Exp $"""
     21
     22  __version__ = "$Revision: 1.4 $"[11:-2]
     23
     24  from AccessControl import ClassSecurityInfo
     25  from Globals import InitializeClass
     26  from AccessControl import Permissions as permissions
     27  from Products.ZenModel.ZenossSecurity import *
     28  from OFS.OrderedFolder import OrderedFolder
     29
     30  from ZenModelItem import ZenModelItem
     31
     32 -def manage_addClassifier(context, title = None, REQUEST = None):
     33      """make a device"""
     34      ce = Classifier('ZenClassifier', title)
     35      context._setObject(ce.id, ce)
     36      if REQUEST:
     37          REQUEST['RESPONSE'].redirect(context.absolute_url()+'/manage_main')
     38
     39
     40
     41 -class Classifier(ZenModelItem, OrderedFolder):
     42
     43      meta_type = 'Classifier'
     44
     45      # Screen action bindings (and tab definitions)
     46      factory_type_information = (
     47          {
     48              'id'             : 'Classifier',
     49              'meta_type'      : 'Classifier',
     50              'description'    : """Class to manage product information""",
     51              'icon'           : 'Classifier_icon.gif',
     52              'product'        : 'ZenModel',
     53              'factory'        : 'manage_addClassifier',
     54              'immediate_view' : 'manageClassifiers',
     55              'actions'        :
     56              (
     57                  { 'id'            : 'overview'
     58                  , 'name'          : 'Overview'
     59                  , 'action'        : 'manageClassifiers'
     60                  , 'permissions'   : (
     61                    permissions.view, )
     62                  },
     63                  { 'id'            : 'viewHistory'
     64                  , 'name'          : 'Modifications'
     65                  , 'action'        : 'viewHistory'
     66                  , 'permissions'   : (ZEN_VIEW_MODIFICATIONS,)
     67                  },
     68              )
     69            },
     70          )
     71
     72      security = ClassSecurityInfo()
     73
     74 -    def __init__(self, id, title=None):
     75          self.id = id
     76          self.title = title
     77          self.curClassifierEntryId = 0
     78
     79
     80 -    def classifyDevice(self, deviceName, loginInfo, log=None):
     81          """kick off device classification against all classifiers
     82          will walk down a tree of classifiers until the most specific
     83          is found.  Top level classifiers can jump into the tree
     84          where lower level classifiers will then take over the process
     85          """
     86          classifierEntry = None
     87          for classifier in self.getClassifierValues():
     88              classifierEntry = classifier.getClassifierEntry(
     89                                              deviceName, loginInfo,log)
     90              if classifierEntry: break
     91          return classifierEntry
     92
     93
     94 -    def getClassifierValues(self):
     95          return self.objectValues()
     96
     97
     98 -    def getClassifierNames(self):
     99          """return a list of availible classifiers for entry popup"""
    100          return self.objectIds()
    101
    102
    103 -    def getNextClassifierEntryId(self):
    104          cid = self.curClassifierEntryId
    105          self.curClassifierEntryId += 1
    106          return "ClassifierEntry-" + str(cid)
    107
    108
    109  InitializeClass(Classifier)
    110