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