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 import types 15 16 from Globals import DTMLFile 17 from Globals import InitializeClass 18 from AccessControl import ClassSecurityInfo 19 from AccessControl import Permissions 20 from Acquisition import aq_base 21 22 from Products.ZenRelations.RelSchema import * 23 from Products.ZenUtils.Search import makeCaseInsensitiveKeywordIndex 24 25 from Organizer import Organizer 26 from MibModule import MibModule 27 from ZenPackable import ZenPackable 2830 """make a device class""" 31 sc = MibOrganizer(id) 32 context._setObject(id, sc) 33 sc = context._getOb(id) 34 if REQUEST is not None: 35 REQUEST['RESPONSE'].redirect(context.absolute_url() + '/manage_main')36 37 addMibOrganizer = DTMLFile('dtml/addMibOrganizer',globals()) 38 3941 """ 42 DeviceOrganizer is the base class for device organizers. 43 It has lots of methods for rolling up device statistics and information. 44 """ 45 meta_type = "MibOrganizer" 46 dmdRootName = "Mibs" 47 default_catalog = 'mibSearch' 48 49 security = ClassSecurityInfo() 50 51 _relations = Organizer._relations + ZenPackable._relations + ( 52 ("mibs", ToManyCont(ToOne,"Products.ZenModel.MibModule","miborganizer")), 53 ) 54 55 56 # Screen action bindings (and tab definitions) 57 factory_type_information = ( 58 { 59 'immediate_view' : 'mibOrganizerOverview', 60 'actions' : 61 ( 62 { 'id' : 'overview' 63 , 'name' : 'Overview' 64 , 'action' : 'mibOrganizerOverview' 65 , 'permissions' : ( Permissions.view, ) 66 }, 67 { 'id' : 'viewHistory' 68 , 'name' : 'Modifications' 69 , 'action' : 'viewHistory' 70 , 'permissions' : ( Permissions.view, ) 71 }, 72 ) 73 }, 74 ) 75 76187 188 189 190 191 InitializeClass(MibOrganizer) 19278 if not id: id = self.dmdRootName 79 super(MibOrganizer, self).__init__(id) 80 if self.id == self.dmdRootName: 81 self.createCatalog()82 8385 """Return a name in for and oid. 86 """ 87 brains = self.getDmdRoot("Mibs").mibSearch({'oid': oid}) 88 if len(brains) > 0: return brains[0].id 89 return ""90 9193 """Return an oid based on a name in the form MIB::name. 94 """ 95 brains = self.getDmdRoot("Mibs").mibSearch({'id': name}) 96 if len(brains) > 0: return brains[0].oid 97 return ""98 99101 """Count all mibs with in a MibOrganizer. 102 """ 103 count = self.mibs.countObjects() 104 for group in self.children(): 105 count += group.countClasses() 106 return count107 108110 """Create a MibModule 111 """ 112 mibs = self.getDmdRoot(self.dmdRootName) 113 mod = None 114 if not mod: 115 modorg = mibs.createOrganizer(path) 116 mod = MibModule(name) 117 modorg.mibs._setObject(mod.id, mod) 118 mod = modorg.mibs._getOb(mod.id) 119 return mod120 121123 """Create a new service class in this Organizer. 124 """ 125 mm = MibModule(id) 126 self.mibs._setObject(id, mm) 127 if REQUEST: 128 REQUEST['message'] = "Mib Module created" 129 return self.callZenScreen(REQUEST) 130 else: 131 return self.mibs._getOb(id)132 133135 """Remove MibModules from an EventClass. 136 """ 137 if not ids: return self() 138 if type(ids) == types.StringType: ids = (ids,) 139 for id in ids: 140 self.mibs._delObject(id) 141 if REQUEST: 142 REQUEST['message'] = "Mib Module deleted" 143 return self()144 145147 """Move MibModules from this EventClass to moveTarget. 148 """ 149 if not moveTarget or not ids: return self() 150 if type(ids) == types.StringType: ids = (ids,) 151 target = self.getChildMoveTarget(moveTarget) 152 for id in ids: 153 rec = self.mibs._getOb(id) 154 rec._operation = 1 # moving object state 155 self.mibs._delObject(id) 156 target.mibs._setObject(id, rec) 157 if REQUEST: 158 REQUEST['message'] = "Mib Module moved" 159 REQUEST['RESPONSE'].redirect(target.getPrimaryUrlPath())160 161163 """Go through all devices in this tree and reindex them.""" 164 zcat = self._getOb(self.default_catalog) 165 zcat.manage_catalogClear() 166 for mibmod in self.mibs(): 167 mibmod.index_object() 168 for miborg in self.getSubOrganizers(): 169 for mibmod in miborg.mibs(): 170 mibmod.index_object()171 172174 """Create a catalog for mibs searching""" 175 from Products.ZCatalog.ZCatalog import manage_addZCatalog 176 177 # XXX update to use ManagableIndex 178 manage_addZCatalog(self, self.default_catalog, self.default_catalog) 179 zcat = self._getOb(self.default_catalog) 180 cat = zcat._catalog 181 cat.addIndex('oid', makeCaseInsensitiveKeywordIndex('oid')) 182 cat.addIndex('id', makeCaseInsensitiveKeywordIndex('id')) 183 cat.addIndex('summary', makeCaseInsensitiveKeywordIndex('summary')) 184 zcat.addColumn('getPrimaryId') 185 zcat.addColumn('id') 186 zcat.addColumn('oid')
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:21 2007 | http://epydoc.sourceforge.net |