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 from Globals import InitializeClass 15 from AccessControl import ClassSecurityInfo 16 from AccessControl import Permissions 17 from Products.ZenModel.ZenossSecurity import * 18 19 from Products.ZenRelations.RelSchema import * 20 21 from ZenModelRM import ZenModelRM 22 from ZenPackable import ZenPackable 23 from Products.ZenWidgets import messaging 24 2527 28 types = ('COUNTER', 'GAUGE', 'DERIVE', 'ABSOLUTE') 29 30 language = "" 31 contact = "" 32 description = "" 33 34 _properties = ( 35 {'id':'language', 'type':'string', 'mode':'w'}, 36 {'id':'contact', 'type':'string', 'mode':'w'}, 37 {'id':'description', 'type':'string', 'mode':'w'}, 38 ) 39 40 _relations = ZenPackable._relations + ( 41 ("miborganizer", ToOne(ToManyCont, "Products.ZenModel.MibOrganizer", "mibs")), 42 ("nodes", ToManyCont(ToOne, "Products.ZenModel.MibNode", "module")), 43 ("notifications", ToManyCont(ToOne, "Products.ZenModel.MibNotification", "module")), 44 ) 45 46 # Screen action bindings (and tab definitions) 47 factory_type_information = ( 48 { 49 'immediate_view' : 'viewMibModule', 50 'actions' : 51 ( 52 { 'id' : 'overview' 53 , 'name' : 'Overview' 54 , 'action' : 'viewMibModule' 55 , 'permissions' : ( Permissions.view, ) 56 }, 57 { 'id' : 'edit' 58 , 'name' : 'Edit' 59 , 'action' : 'editMibModule' 60 , 'permissions' : ( Permissions.view, ) 61 }, 62 { 'id' : 'viewHistory' 63 , 'name' : 'Modifications' 64 , 'action' : 'viewHistory' 65 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,) 66 }, 67 ) 68 }, 69 ) 70 71 security = ClassSecurityInfo() 72 74 return self.id75 7678 return self.nodes.countObjects()79 8082 return self.notifications.countObjects()83 8486 """Delete MibNodes 87 """ 88 for node in self.nodes(): 89 id = getattr(node, 'id', None) 90 if id in ids: 91 self.nodes._delObject(id) 92 if REQUEST: 93 messaging.IMessageSender(self).sendToBrowser( 94 'Mappings Deleted', 95 'Mib nodes deleted: %s' % (', '.join(ids)) 96 ) 97 return self.callZenScreen(REQUEST)98 99101 """Add a MibNode 102 """ 103 node = self.createMibNode(id, oid=oid, nodetype=nodetype) 104 if REQUEST: 105 if node: 106 messaging.IMessageSender(self).sendToBrowser( 107 'Mib Node Added', 108 'Node %s was created with oid %s.' % (id, oid) 109 ) 110 else: 111 messaging.IMessageSender(self).sendToBrowser( 112 'Invalid OID', 113 'OID %s is invalid.' % oid, 114 priority=messaging.WARNING 115 ) 116 return self.callZenScreen(REQUEST)117 118120 """Create a MibNotification 121 """ 122 from MibNode import MibNode 123 if self.oid2name(kwargs['oid'], exactMatch=True, strip=False): 124 return None 125 node = MibNode(id, **kwargs) 126 self.nodes._setObject(node.id, node) 127 node = self.nodes._getOb(node.id) 128 return node129 130132 """Delete MibNotifications 133 """ 134 for notification in self.notifications(): 135 id = getattr(notification, 'id', None) 136 if id in ids: 137 self.notifications._delObject(id) 138 if REQUEST: 139 messaging.IMessageSender(self).sendToBrowser( 140 'Traps Deleted', 141 'Traps deleted: %s' % (', '.join(ids)) 142 ) 143 return self.callZenScreen(REQUEST)144 145147 """Add a MibNotification 148 """ 149 notification = self.createMibNotification(id, oid=oid, nodetype=nodetype) 150 if REQUEST: 151 if notification: 152 messaging.IMessageSender(self).sendToBrowser( 153 'Trap added', 154 'Trap %s was created with oid %s.' % (id, oid) 155 ) 156 else: 157 messaging.IMessageSender(self).sendToBrowser( 158 'Invalid OID', 159 'OID %s is invalid.' % oid, 160 priority=messaging.WARNING 161 ) 162 return self.callZenScreen(REQUEST)163 164166 """Create a MibNotification 167 """ 168 from MibNotification import MibNotification 169 if self.oid2name(kwargs['oid'], exactMatch=True, strip=False): 170 return None 171 node = MibNotification(id, **kwargs) 172 self.notifications._setObject(node.id, node) 173 node = self.notifications._getOb(node.id) 174 return node175 176178 """ 179 Device only propagates afterAdd if it is the added object. 180 """ 181 super(MibModule,self).manage_afterAdd(item, container) 182 self.index_object()183 184186 """Not really sure when this is called.""" 187 super(MibModule,self).manage_afterClone(item) 188 self.index_object()189 190192 """ 193 Device only propagates beforeDelete if we are being deleted or copied. 194 Moving and renaming don't propagate. 195 """ 196 super(MibModule,self).manage_beforeDelete(item, container) 197 self.unindex_object()198 199 200 InitializeClass(MibModule) 201
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu May 7 11:46:39 2009 | http://epydoc.sourceforge.net |