Trees | Indices | Help |
|
---|
|
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__="""MonitorClass 15 16 Organizes Monitors 17 18 $Id: MonitorClass.py,v 1.11 2004/04/09 00:34:39 edahl Exp $""" 19 20 __version__ = "$Revision$"[11:-2] 21 22 from Globals import DTMLFile 23 from Globals import InitializeClass 24 from AccessControl import ClassSecurityInfo 25 from AccessControl import Permissions as permissions 26 from Acquisition import aq_base 27 from OFS.Folder import Folder 28 from Products.PageTemplates.PageTemplateFile import PageTemplateFile 29 from Products.ZenRelations.RelationshipManager import RelationshipManager 30 from Products.ZenUtils.Utils import checkClass 31 from ZenModelRM import ZenModelRM 3234 """make a device class""" 35 dc = MonitorClass(id, title) 36 context._setObject(id, dc) 37 38 if REQUEST is not None: 39 REQUEST['RESPONSE'].redirect(context.absolute_url() + '/manage_main')40 41 addMonitorClass = DTMLFile('dtml/addMonitorClass',globals()) 4244 #isInTree = 1 45 meta_type = "MonitorClass" 46 sub_class = 'MonitorClass' 47 48 _properties = ( 49 {'id':'title', 'type':'string', 'mode':'w'}, 50 {'id':'sub_class', 'type':'string', 'mode':'w'}, 51 {'id':'sub_meta_types', 'type':'lines', 'mode':'w'}, 52 ) 53 54 factory_type_information = ( 55 { 56 'id' : 'MonitorClass', 57 'meta_type' : meta_type, 58 'description' : "Monitor Class", 59 'icon' : 'Classification_icon.gif', 60 'product' : 'ZenModel', 61 'factory' : 'manage_addMonitorClass', 62 'immediate_view' : 'monitorList', 63 'actions' : 64 ( 65 { 'id' : 'view' 66 , 'name' : 'View' 67 , 'action' : 'monitorList' 68 , 'permissions' : ( 69 permissions.view, ) 70 , 'visible' : 0 71 }, 72 ) 73 }, 74 ) 75 76 security = ClassSecurityInfo() 77164 165 InitializeClass(MonitorClass) 16679 """get or create the status monitor name""" 80 from Products.ZenModel.StatusMonitorConf \ 81 import manage_addStatusMonitorConf 82 statusMonitorObj = self.getDmdRoot("Monitors").StatusMonitors 83 if not hasattr(statusMonitorObj, monitorName): 84 manage_addStatusMonitorConf(statusMonitorObj, monitorName) 85 return statusMonitorObj._getOb(monitorName)86 8789 """return a list of all status monitor names""" 90 status = self.getDmdRoot("Monitors").StatusMonitors 91 snames = status.objectIds() 92 snames.sort() 93 return snames9496 """get or create the performance monitor name""" 97 from Products.ZenModel.PerformanceConf \ 98 import manage_addPerformanceConf 99 perfServerObj = self.getDmdRoot("Monitors").Performance 100 if not hasattr(perfServerObj, monitorName): 101 manage_addPerformanceConf(perfServerObj, monitorName) 102 return perfServerObj._getOb(monitorName)103 104106 """return a list of all performance monitor names""" 107 perfServer = self.getDmdRoot("Monitors").Performance 108 cnames = perfServer.objectIds() 109 cnames.sort() 110 return cnames111 112114 """get contained objects that are sub classes of sub_class""" 115 retdata = [] 116 for obj in self.objectValues(): 117 if checkClass(obj.__class__, self.sub_class): 118 retdata.append(obj) 119 return retdata120 121123 'Add an object of sub_class, from a module of the same name' 124 msg = '' 125 child = self._getOb(submon) or self 126 if ids: 127 if len(ids) < len(child._objects): 128 num = 0 129 for id in ids: 130 if child.hasObject(id): 131 child._delObject(id) 132 num += 1 133 msg = 'Deleted %s monitors' % num 134 135 else: 136 msg = 'You must have at least one monitor' 137 else: 138 msg = 'No monitors are selected' 139 if REQUEST: 140 if msg: 141 REQUEST['message'] = msg 142 return self.callZenScreen(REQUEST)143 144146 'Remove an object from this one' 147 values = {} 148 child = self._getOb(submon) or self 149 exec('from Products.ZenModel.%s import %s' % (child.sub_class, 150 child.sub_class), values) 151 ctor = values[child.sub_class] 152 if id: child._setObject(id, ctor(id)) 153 if REQUEST: 154 REQUEST['message'] = 'Monitor created' 155 return self.callZenScreen(REQUEST)156 157159 """patch to export all device components 160 """ 161 for o in self.objectValues(): 162 if hasattr(aq_base(o), 'exportXml'): 163 o.exportXml(ofile, ignorerels)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:23 2007 | http://epydoc.sourceforge.net |