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 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__="""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 ) 64 }, 65 ) 66 67 security = ClassSecurityInfo() 68
69 - def __init__(self, id, title=None):
70 self.id = id 71 self.title = title 72 self.curClassifierEntryId = 0
73 74
75 - def classifyDevice(self, deviceName, loginInfo, log=None):
76 """kick off device classification against all classifiers 77 will walk down a tree of classifiers until the most specific 78 is found. Top level classifiers can jump into the tree 79 where lower level classifiers will then take over the process 80 """ 81 classifierEntry = None 82 for classifier in self.getClassifierValues(): 83 classifierEntry = classifier.getClassifierEntry( 84 deviceName, loginInfo,log) 85 if classifierEntry: break 86 return classifierEntry
87 88
89 - def getClassifierValues(self):
90 return self.objectValues()
91 92
93 - def getClassifierNames(self):
94 """return a list of availible classifiers for entry popup""" 95 return self.objectIds()
96 97
98 - def getNextClassifierEntryId(self):
99 cid = self.curClassifierEntryId 100 self.curClassifierEntryId += 1 101 return "ClassifierEntry-" + str(cid)
102 103 104 InitializeClass(Classifier) 105