Package ZenModel :: Module System
[hide private]
[frames] | no frames]

Source Code for Module ZenModel.System

  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__="""System 
 15   
 16  $Id: System.py,v 1.45 2004/04/14 22:11:48 edahl Exp $""" 
 17   
 18  __version__ = "$Revision: 1.45 $"[11:-2] 
 19   
 20  from Acquisition import aq_parent 
 21  from AccessControl import ClassSecurityInfo 
 22  from Globals import DTMLFile 
 23  from Globals import InitializeClass 
 24   
 25  from AccessControl import Permissions as permissions 
 26   
 27  from Products.ZenRelations.RelSchema import * 
 28   
 29  from Products.ZenUtils.Utils import travAndColl 
 30   
 31  from DeviceOrganizer import DeviceOrganizer 
 32  from ZenPackable import ZenPackable 
 33   
 34   
35 -def manage_addSystem(context, id, description = None, REQUEST = None):
36 """make a System""" 37 d = System(id, description) 38 context._setObject(id, d) 39 40 if REQUEST is not None: 41 REQUEST['RESPONSE'].redirect(context.absolute_url() 42 +'/manage_main')
43 44 45 addSystem = DTMLFile('dtml/addSystem',globals()) 46 47 48
49 -class System(DeviceOrganizer, ZenPackable):
50 """ 51 System class is a device organizer that represents a business system. 52 May need to manage "services" as well so that more sophisticated 53 dependencies can be tracked. 54 """ 55 56 # Organizer configuration 57 dmdRootName = "Systems" 58 59 portal_type = meta_type = 'System' 60 61 event_key = "System" 62 63 default_catalog = 'systemSearch' 64 65 _properties = ( 66 {'id':'systemClass', 'type':'string', 'mode':'w'}, 67 {'id':'description', 'type':'text', 'mode':'w'}, 68 ) 69 _relations = DeviceOrganizer._relations + ZenPackable._relations + ( 70 ("devices", ToMany(ToMany, "Products.ZenModel.Device", "systems")), 71 ) 72 73 # Screen action bindings (and tab definitions) 74 factory_type_information = ( 75 { 76 'id' : 'System', 77 'meta_type' : 'System', 78 'description' : """Base class for all devices""", 79 'icon' : 'System_icon.gif', 80 'product' : 'ZenModel', 81 'factory' : 'manage_addSystem', 82 'immediate_view' : 'deviceOrganizerStatus', 83 'actions' : 84 ( 85 { 'id' : 'status' 86 , 'name' : 'Status' 87 , 'action' : 'deviceOrganizerStatus' 88 , 'permissions' : ( 89 permissions.view, ) 90 }, 91 { 'id' : 'performance' 92 , 'name' : 'Performance' 93 , 'action' : 'viewSystemPerformance' 94 , 'permissions' : ( 95 permissions.view, ) 96 }, 97 { 'id' : 'events' 98 , 'name' : 'Events' 99 , 'action' : 'viewEvents' 100 , 'permissions' : ( 101 permissions.view, ) 102 }, 103 { 'id' : 'historyEvents' 104 , 'name' : 'History' 105 , 'action' : 'viewHistoryEvents' 106 , 'permissions' : ( 107 permissions.view, ) 108 }, 109 { 'id' : 'manage' 110 , 'name' : 'Administration' 111 , 'action' : 'deviceOrganizerManage' 112 , 'permissions' : ('Manage DMD',) 113 }, 114 ) 115 }, 116 ) 117 118 119 security = ClassSecurityInfo() 120 121 122 security.declareProtected('View', 'omniPingStatus')
123 - def omniPingStatus(self):
124 """pingStatus() -> return the number of devices that are down""" 125 status = -1 126 try: 127 status = self.netcool.getPingStatus(system=self.getOrganizerName()) 128 status = self.convertStatus(status) 129 except: pass 130 return status
131 132 133 security.declareProtected('View', 'omniCmtsPingStatus')
134 - def omniCmtsPingStatus(self):
135 """omniCmtsPingStatus() -> return the number of ubrs that are down""" 136 status = -1 137 try: 138 status = self.netcool.getOmniStatus( 139 systemName=self.getOrganizerName(), 140 where=" Class=100 and Severity=5 and Node like '.*cmts.*'") 141 status = self.convertStatus(status) 142 except: pass 143 return status
144 145 146 security.declareProtected('View', 'omniSnmpStatus')
147 - def omniSnmpStatus(self):
148 """snmpStatus() -> return the number of devices with snmp problems""" 149 status = -1 150 try: 151 status = self.netcool.getSnmpStatus(system=self.getOrganizerName()) 152 status = self.convertStatus(status) 153 except: pass 154 return status
155 156 157 security.declareProtected('View', 'omniXmlRpcStatus')
158 - def omniXmlRpcStatus(self):
159 """xmlRpcStatus() -> return the number of devices with xmlrpc problems""" 160 status = -1 161 try: 162 status = self.netcool.getXmlRpcStatus(system=self.getOrganizerName()) 163 status = self.convertStatus(status) 164 except: pass 165 return status
166 167 168 security.declareProtected('View', 'omniEventCount')
169 - def omniEventCount(self):
170 """eventCount() -> return the number of devices with snmp problems""" 171 status = 0 172 try: 173 status = self.netcool.getEventCount(system=self.getOrganizerName()) 174 except: pass 175 return status
176 177
178 - def summary(self):
179 """text summary of object for indexing""" 180 return self.getOrganizerName() + " " + self.description
181 182 183 security.declareProtected('View', 'convertProdState')
184 - def convertProdState(self, prodState):
185 '''convert a numeric production state to a 186 textual representation using the prodStateConversions 187 map''' 188 189 if self.prodStateConversions: 190 for line in self.prodStateConversions: #aq 191 line = line.rstrip() 192 (sev, num) = line.split(':') 193 if int(num) == prodState: 194 return sev 195 return "Unknown"
196 197 198 InitializeClass(System) 199