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

Source Code for Module 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 OFS.OrderedFolder import OrderedFolder 
 28   
 29  from ZenModelItem import ZenModelItem 
 30   
31 -def manage_addClassifier(context, title = None, REQUEST = None):
32 """make a device""" 33 ce = Classifier('ZenClassifier', title) 34 context._setObject(ce.id, ce) 35 if REQUEST: 36 REQUEST['RESPONSE'].redirect(context.absolute_url()+'/manage_main')
37 38 39
40 -class Classifier(ZenModelItem, OrderedFolder):
41 42 meta_type = 'Classifier' 43 44 # Screen action bindings (and tab definitions) 45 factory_type_information = ( 46 { 47 'id' : 'Classifier', 48 'meta_type' : 'Classifier', 49 'description' : """Class to manage product information""", 50 'icon' : 'Classifier_icon.gif', 51 'product' : 'ZenModel', 52 'factory' : 'manage_addClassifier', 53 'immediate_view' : 'manageClassifiers', 54 'actions' : 55 ( 56 { 'id' : 'overview' 57 , 'name' : 'Overview' 58 , 'action' : 'manageClassifiers' 59 , 'permissions' : ( 60 permissions.view, ) 61 }, 62 { 'id' : 'viewHistory' 63 , 'name' : 'Modifications' 64 , 'action' : 'viewHistory' 65 , 'permissions' : ( 66 permissions.view, ) 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