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 zope.interface import implements 18 19 from Products.ZenRelations.RelSchema import * 20 from Products.ZenWidgets import messaging 21 22 from Products.ZenModel.interfaces import IIndexed 23 from Products.ZenModel.ZenossSecurity import * 24 from ZenModelRM import ZenModelRM 25 from ZenPackable import ZenPackable 26 2729 30 implements(IIndexed) 31 types = ('COUNTER', 'GAUGE', 'DERIVE', 'ABSOLUTE') 32 33 language = "" 34 contact = "" 35 description = "" 36 37 _properties = ( 38 {'id':'language', 'type':'string', 'mode':'w'}, 39 {'id':'contact', 'type':'string', 'mode':'w'}, 40 {'id':'description', 'type':'string', 'mode':'w'}, 41 ) 42 43 _relations = ZenPackable._relations + ( 44 ("miborganizer", ToOne(ToManyCont, "Products.ZenModel.MibOrganizer", "mibs")), 45 ("nodes", ToManyCont(ToOne, "Products.ZenModel.MibNode", "module")), 46 ("notifications", ToManyCont(ToOne, "Products.ZenModel.MibNotification", "module")), 47 ) 48 49 # Screen action bindings (and tab definitions) 50 factory_type_information = ( 51 { 52 'immediate_view' : 'viewMibModule', 53 'actions' : 54 ( 55 { 'id' : 'overview' 56 , 'name' : 'Overview' 57 , 'action' : 'viewMibModule' 58 , 'permissions' : ( Permissions.view, ) 59 }, 60 { 'id' : 'edit' 61 , 'name' : 'Edit' 62 , 'action' : 'editMibModule' 63 , 'permissions' : ( Permissions.view, ) 64 }, 65 { 'id' : 'viewHistory' 66 , 'name' : 'Modifications' 67 , 'action' : 'viewHistory' 68 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,) 69 }, 70 ) 71 }, 72 ) 73 74 security = ClassSecurityInfo() 75 77 return self.id78 7981 return self.nodes.countObjects()82 8385 return self.notifications.countObjects()86 8789 """Delete MibNodes 90 """ 91 for node in self.nodes(): 92 id = getattr(node, 'id', None) 93 if id in ids: 94 self.nodes._delObject(id) 95 if REQUEST: 96 messaging.IMessageSender(self).sendToBrowser( 97 'Mappings Deleted', 98 'Mib nodes deleted: %s' % (', '.join(ids)) 99 ) 100 return self.callZenScreen(REQUEST)101 102104 """Add a MibNode 105 """ 106 node = self.createMibNode(id, oid=oid, nodetype=nodetype) 107 if REQUEST: 108 if node: 109 messaging.IMessageSender(self).sendToBrowser( 110 'Mib Node Added', 111 'Node %s was created with oid %s.' % (id, oid) 112 ) 113 else: 114 messaging.IMessageSender(self).sendToBrowser( 115 'Invalid OID', 116 'OID %s is invalid.' % oid, 117 priority=messaging.WARNING 118 ) 119 return self.callZenScreen(REQUEST)120 121123 """Create a MibNotification 124 """ 125 from MibNode import MibNode 126 if self.oid2name(kwargs['oid'], exactMatch=True, strip=False): 127 return None 128 node = MibNode(id, **kwargs) 129 self.nodes._setObject(node.id, node) 130 node = self.nodes._getOb(node.id) 131 return node132 133135 """Delete MibNotifications 136 """ 137 for notification in self.notifications(): 138 id = getattr(notification, 'id', None) 139 if id in ids: 140 self.notifications._delObject(id) 141 if REQUEST: 142 messaging.IMessageSender(self).sendToBrowser( 143 'Traps Deleted', 144 'Traps deleted: %s' % (', '.join(ids)) 145 ) 146 return self.callZenScreen(REQUEST)147 148150 """Add a MibNotification 151 """ 152 notification = self.createMibNotification(id, oid=oid, nodetype=nodetype) 153 if REQUEST: 154 if notification: 155 messaging.IMessageSender(self).sendToBrowser( 156 'Trap added', 157 'Trap %s was created with oid %s.' % (id, oid) 158 ) 159 else: 160 messaging.IMessageSender(self).sendToBrowser( 161 'Invalid OID', 162 'OID %s is invalid.' % oid, 163 priority=messaging.WARNING 164 ) 165 return self.callZenScreen(REQUEST)166 167169 """Create a MibNotification 170 """ 171 from MibNotification import MibNotification 172 if self.oid2name(kwargs['oid'], exactMatch=True, strip=False): 173 return None 174 node = MibNotification(id, **kwargs) 175 self.notifications._setObject(node.id, node) 176 node = self.notifications._getOb(node.id) 177 return node178 179 180 InitializeClass(MibModule) 181
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Mon Oct 19 14:44:25 2009 | http://epydoc.sourceforge.net |