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

Source Code for Module ZenModel.DeviceResultInt

  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__="""DeviceResult 
 15   
 16  A mixin for objects that get listed like devices 
 17  The primary object must implement device. 
 18   
 19  $Id: DeviceResultInt.py,v 1.9 2004/04/23 01:24:48 edahl Exp $""" 
 20   
 21  __version__ = "$Revision: 1.9 $"[11:-2] 
 22   
 23  from AccessControl import ClassSecurityInfo 
 24  from Globals import InitializeClass 
 25   
 26   
27 -class DeviceResultInt:
28 29 security = ClassSecurityInfo() 30 31 security.declareProtected('View', 'getDeviceName')
32 - def getDeviceName(self):
33 '''Get the device name of this device or associated device''' 34 d = self.device() 35 if d: 36 return d.getId() 37 return "No Device"
38 39 40 security.declareProtected('View', 'getDeviceUrl')
41 - def getDeviceUrl(self):
42 '''Get the primary url path of the device in which this 43 interface is located''' 44 d = self.device() 45 if d: 46 return d.getPrimaryUrlPath() 47 return ""
48 49 50 security.declareProtected('View', 'getDeviceLink') 61 62 63 security.declareProtected('View', 'getDeviceClassPath')
64 - def getDeviceClassPath(self):
65 '''Get the device class for this device''' 66 d = self.device() 67 if d: 68 return d.deviceClass().getOrganizerName() 69 return "No Device"
70 security.declareProtected('View', 'getDeviceClassName') 71 getDeviceClassName = getDeviceClassPath 72 73 74 security.declareProtected('View', 'getProdState')
75 - def getProdState(self):
76 '''Get the production state of the device associated with 77 this interface''' 78 d = self.device() 79 if d: 80 return self.convertProdState(d.productionState) 81 return "None"
82 83 84 security.declareProtected('View', 'getPingStatus')
85 - def getPingStatus(self):
86 """get the ping status of the box if there is one""" 87 # this import must be deferred to this point to avoid circular imports 88 from Products.ZenEvents.ZenEventClasses import Status_Ping 89 dev = self.device() 90 if dev: 91 dev = dev.primaryAq() 92 if (dev.monitorDevice() and 93 not getattr(dev, 'zPingMonitorIgnore', False)): 94 return dev.getStatus(Status_Ping) 95 else: 96 return self.getStatus(Status_Ping) 97 return -1
98 security.declareProtected('View', 'getPingStatusNumber') 99 getPingStatusNumber = getPingStatus 100 101 102 security.declareProtected('View', 'getSnmpStatus')
103 - def getSnmpStatus(self):
104 """get the snmp status of the box if there is one""" 105 # this import must be deferred to this point to avoid circular imports 106 __pychecker__='no-shadow' 107 from Products.ZenEvents.ZenEventClasses import Status_Snmp 108 dev = self.device() 109 if dev: 110 dev = dev.primaryAq() 111 if (not getattr(dev, 'zSnmpMonitorIgnore', False) 112 and getattr(dev, 'zSnmpCommunity', "") 113 and dev.monitorDevice()): 114 return dev.getStatus(Status_Snmp) 115 return -1
116 getSnmpStatusNumber = getSnmpStatus 117 security.declareProtected('View', 'getSnmpStatusNumber') 118 119 120 security.declareProtected('View', 'isResultLockedFromUpdates')
122 """Return the locked from updates flag""" 123 d = self.device() 124 if d: 125 return d.isLockedFromUpdates() 126 return False
127 128 security.declareProtected('View', 'isResultLockedFromDeletion')
130 """Return the locked from deletion flag""" 131 d = self.device() 132 if d: 133 return d.isLockedFromDeletion() 134 return False
135 136 security.declareProtected('View', 'sendEventWhenResultBlocked')
138 """Return the send event flag""" 139 d = self.device() 140 if d: 141 return d.sendEventWhenBlocked() 142 return False
143 144 145 security.declareProtected('View', 'getDeviceIp')
146 - def getDeviceIp(self):
147 """Get the management ip (only) of a device""" 148 d = self.device() 149 if d: 150 return d.manageIp 151 return ""
152 153 154 security.declareProtected('View', 'getDeviceIpAddress')
155 - def getDeviceIpAddress(self):
156 """Get the management ip with netmask (1.1.1.1/24) of a device""" 157 d = self.device() 158 if d: 159 int = d.getManageInterface() 160 if int: 161 return int.getIpAddress() 162 return ""
163 164 165 security.declareProtected('View', 'getDeviceMacaddress')
166 - def getDeviceMacaddress(self):
167 """get the mac address if there is one of the primary interface""" 168 d = self.device() 169 if d: 170 int = d.getManageInterface() 171 if int: 172 return int.getInterfaceMacaddress() 173 return ""
174 175 176 InitializeClass(DeviceResultInt) 177