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

Source Code for Module Products.ZenModel.Classifier

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