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 -class DeviceResultInt:
27 28 security = ClassSecurityInfo() 29 30 security.declareProtected('View', 'getDeviceName')
31 - def getDeviceName(self):
32 '''Get the device name of this device or associated device''' 33 d = self.device() 34 if d: 35 return d.getId() 36 return "No Device"
37 38 39 security.declareProtected('View', 'getDeviceUrl')
40 - def getDeviceUrl(self):
41 '''Get the primary url path of the device in which this 42 interface is located''' 43 d = self.device() 44 if d: 45 return d.getPrimaryUrlPath() 46 return ""
47 48 49 security.declareProtected('View', 'getDeviceLink') 60 61 62 security.declareProtected('View', 'getDeviceClassPath')
63 - def getDeviceClassPath(self):
64 '''Get the device class for this device''' 65 d = self.device() 66 if d: 67 return d.deviceClass().getOrganizerName() 68 return "No Device"
69 security.declareProtected('View', 'getDeviceClassName') 70 getDeviceClassName = getDeviceClassPath 71 72 73 security.declareProtected('View', 'getProdState')
74 - def getProdState(self):
75 '''Get the production state of the device associated with 76 this interface''' 77 d = self.device() 78 if d: 79 return self.convertProdState(d.productionState) 80 return "None"
81 82 83 security.declareProtected('View', 'getPingStatus')
84 - def getPingStatus(self):
85 """get the ping status of the box if there is one""" 86 from Products.ZenEvents.ZenEventClasses import Status_Ping 87 dev = self.device() 88 if dev: 89 dev = dev.primaryAq() 90 if (dev.monitorDevice() and 91 not getattr(dev, 'zPingMonitorIgnore', False)): 92 return dev.getStatus(Status_Ping) 93 else: 94 return self.getStatus(Status_Ping) 95 return -1
96 security.declareProtected('View', 'getPingStatusNumber') 97 getPingStatusNumber = getPingStatus 98 99 100 security.declareProtected('View', 'getSnmpStatus')
101 - def getSnmpStatus(self):
102 """get the snmp status of the box if there is one""" 103 from Products.ZenEvents.ZenEventClasses import Status_Snmp 104 dev = self.device() 105 if dev: 106 dev = dev.primaryAq() 107 if (not getattr(dev, 'zSnmpMonitorIgnore', False) 108 and getattr(dev, 'zSnmpCommunity', "") 109 and dev.monitorDevice()): 110 return dev.getStatus(Status_Snmp) 111 return -1
112 getSnmpStatusNumber = getSnmpStatus 113 security.declareProtected('View', 'getSnmpStatusNumber') 114 115 116 security.declareProtected('View', 'isResultLockedFromUpdates')
118 """Return the locked from updates flag""" 119 d = self.device() 120 if d: 121 return d.isLockedFromUpdates() 122 return False
123 124 security.declareProtected('View', 'isResultLockedFromDeletion')
126 """Return the locked from deletion flag""" 127 d = self.device() 128 if d: 129 return d.isLockedFromDeletion() 130 return False
131 132 security.declareProtected('View', 'sendEventWhenResultBlocked')
134 """Return the send event flag""" 135 d = self.device() 136 if d: 137 return d.sendEventWhenBlocked() 138 return False
139 140 141 security.declareProtected('View', 'getDeviceIp')
142 - def getDeviceIp(self):
143 """Get the management ip (only) of a device""" 144 d = self.device() 145 if d: 146 return d.manageIp 147 return ""
148 149 150 security.declareProtected('View', 'getDeviceIpAddress')
151 - def getDeviceIpAddress(self):
152 """Get the management ip with netmask (1.1.1.1/24) of a device""" 153 d = self.device() 154 if d: 155 int = d.getManageInterface() 156 if int: 157 return int.getIpAddress() 158 return ""
159 160 161 security.declareProtected('View', 'getDeviceMacaddress')
162 - def getDeviceMacaddress(self):
163 """get the mac address if there is one of the primary interface""" 164 d = self.device() 165 if d: 166 int = d.getManageInterface() 167 if int: 168 return int.getInterfaceMacaddress() 169 return ""
170 171 172 InitializeClass(DeviceResultInt) 173