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

Source Code for Module Products.ZenModel.System

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