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

Source Code for Module ZenModel.PowerSupply

  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__="""PowerSupply 
 15   
 16  PowerSupply is an abstraction of a power supply on a device. 
 17   
 18  $Id: PowerSupply.py,v 1.7 2004/04/06 22:33:24 edahl Exp $""" 
 19   
 20  __version__ = "$Revision: 1.7 $"[11:-2] 
 21   
 22  from Globals import InitializeClass 
 23   
 24  from Products.ZenRelations.RelSchema import * 
 25   
 26  from HWComponent import HWComponent 
 27   
 28  from Products.ZenModel.ZenossSecurity import * 
 29   
30 -class PowerSupply(HWComponent):
31 """PowerSupply object""" 32 33 portal_type = meta_type = 'PowerSupply' 34 35 watts = None 36 type = "unknown" 37 state = "unknown" 38 39 _properties = HWComponent._properties + ( 40 {'id':'watts', 'type':'int', 'mode':'w'}, 41 {'id':'type', 'type':'string', 'mode':'w'}, 42 {'id':'state', 'type':'string', 'mode':'w'}, 43 ) 44 45 _relations = HWComponent._relations + ( 46 ("hw", ToOne(ToManyCont, "Products.ZenModel.DeviceHW", 47 "powersupplies")), 48 ) 49 50 51 factory_type_information = ( 52 { 53 'id' : 'PowerSupply', 54 'meta_type' : 'PowerSupply', 55 'description' : """Arbitrary device grouping class""", 56 'icon' : 'PowerSupply_icon.gif', 57 'product' : 'ZenModel', 58 'factory' : 'manage_addPowerSupply', 59 'immediate_view' : 'viewPowerSupply', 60 'actions' : 61 ( 62 { 'id' : 'status' 63 , 'name' : 'Status' 64 , 'action' : 'viewPowerSupply' 65 , 'permissions' : ('View',) 66 }, 67 { 'id' : 'perfConf' 68 , 'name' : 'Template' 69 , 'action' : 'objTemplates' 70 , 'permissions' : ("Change Device", ) 71 }, 72 { 'id' : 'viewHistory' 73 , 'name' : 'Modifications' 74 , 'action' : 'viewHistory' 75 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,) 76 }, 77 ) 78 }, 79 ) 80 81
82 - def wattsString(self):
83 """ 84 Return a string representation of the watts 85 """ 86 return self.watts is None and "unknown" or str(self.watts)
87 88
89 - def millivolts(self, default=None):
90 """ 91 Return the current millivolts for the power supply 92 """ 93 millivolts = self.cacheRRDValue('millivolts', default) 94 if millivolts is not None: 95 return long(millivolts) 96 return None
97 98
99 - def millivoltsString(self):
100 """ 101 Return the current millivolts as a string 102 """ 103 millivolts = self.millivolts() 104 return millivolts is None and "unknown" or "%dmv" % (millivolts,)
105 106
107 - def viewName(self):
108 return self.id
109 name = viewName
110 111 112 InitializeClass(PowerSupply) 113