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

# Source Code for Module Products.ZenModel.PowerSupply

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