Trees | Indices | Help |
|
---|
|
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 2527 28 security = ClassSecurityInfo() 29 30 security.declareProtected('View', 'getDeviceName')170 171 172 InitializeClass(DeviceResultInt) 17332 '''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')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')51 '''Get the primary link for the device''' 52 d = self.device() 53 if d: 54 if self.checkRemotePerm("View", d): 55 return "<a href='%s/%s'>%s</a>" % ( 56 d.getPrimaryUrlPath(), screen, d.getId()) 57 else: 58 return d.getId() 59 return ""60 61 62 security.declareProtected('View', 'getDeviceClassPath')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')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')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 -196 security.declareProtected('View', 'getPingStatusNumber') 97 getPingStatusNumber = getPingStatus 98 99 100 security.declareProtected('View', 'getSnmpStatus')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 -1112 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 False123 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 False131 132 security.declareProtected('View', 'sendEventWhenResultBlocked')134 """Return the send event flag""" 135 d = self.device() 136 if d: 137 return d.sendEventWhenBlocked() 138 return False139 140 141 security.declareProtected('View', 'getDeviceIp')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')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')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 ""
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:34 2007 | http://epydoc.sourceforge.net |