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 or (at your 8 # option) any later version as published by 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 ) 66 }, 67 ) 68 69 security = ClassSecurityInfo() 70 72 return self.id73 7476 return self.nodes.countObjects()77 7880 return self.notifications.countObjects()81 8284 """Delete MibNodes 85 """ 86 for node in self.nodes(): 87 id = getattr(node, 'id', None) 88 if id in ids: 89 self.nodes._delObject(id) 90 if REQUEST: 91 messaging.IMessageSender(self).sendToBrowser( 92 'Mappings Deleted', 93 'Mib nodes deleted: %s' % (', '.join(ids)) 94 ) 95 return self.callZenScreen(REQUEST)96 9799 """Add a MibNode 100 """ 101 node = self.createMibNode(id, oid=oid, nodetype=nodetype) 102 if REQUEST: 103 if node: 104 messaging.IMessageSender(self).sendToBrowser( 105 'Mib Node Added', 106 'Node %s was created with oid %s.' % (id, oid) 107 ) 108 else: 109 messaging.IMessageSender(self).sendToBrowser( 110 'Invalid OID', 111 'OID %s is invalid.' % oid, 112 priority=messaging.WARNING 113 ) 114 return self.callZenScreen(REQUEST)115 116118 """Create a MibNotification 119 """ 120 from MibNode import MibNode 121 if self.oid2name(kwargs['oid'], exactMatch=True, strip=False): 122 return None 123 node = MibNode(id, **kwargs) 124 self.nodes._setObject(node.id, node) 125 node = self.nodes._getOb(node.id) 126 return node127 128130 """Delete MibNotifications 131 """ 132 for notification in self.notifications(): 133 id = getattr(notification, 'id', None) 134 if id in ids: 135 self.notifications._delObject(id) 136 if REQUEST: 137 messaging.IMessageSender(self).sendToBrowser( 138 'Traps Deleted', 139 'Traps deleted: %s' % (', '.join(ids)) 140 ) 141 return self.callZenScreen(REQUEST)142 143145 """Add a MibNotification 146 """ 147 notification = self.createMibNotification(id, oid=oid, nodetype=nodetype) 148 if REQUEST: 149 if notification: 150 messaging.IMessageSender(self).sendToBrowser( 151 'Trap added', 152 'Trap %s was created with oid %s.' % (id, oid) 153 ) 154 else: 155 messaging.IMessageSender(self).sendToBrowser( 156 'Invalid OID', 157 'OID %s is invalid.' % oid, 158 priority=messaging.WARNING 159 ) 160 return self.callZenScreen(REQUEST)161 162164 """Create a MibNotification 165 """ 166 from MibNotification import MibNotification 167 if self.oid2name(kwargs['oid'], exactMatch=True, strip=False): 168 return None 169 node = MibNotification(id, **kwargs) 170 self.notifications._setObject(node.id, node) 171 node = self.notifications._getOb(node.id) 172 return node173 174 175 InitializeClass(MibModule) 176
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1.1812 on Tue Oct 11 12:51:49 2011 | http://epydoc.sourceforge.net |