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

# Source Code for Module Products.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 or (at your
      8  # option) any later version as published by 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              )
     73            },
     74          )
     75
     76
     77 -    def wattsString(self):
     78          """
     79          Return a string representation of the watts
     80          """
     81          return self.watts is None and "unknown" or str(self.watts)
     82
     83
     84 -    def millivolts(self, default=None):
     85          """
     86          Return the current millivolts for the power supply
     87          """
     88          millivolts = self.cacheRRDValue('millivolts', default)
     89          if millivolts is not None:
     90              return long(millivolts)
     91          return None
     92
     93
     94 -    def millivoltsString(self):
     95          """
     96          Return the current millivolts as a string
     97          """
     98          millivolts = self.millivolts()
     99          return millivolts is None and "unknown" or "%dmv" % (millivolts,)
    100
    101
    102 -    def viewName(self):
    103          return self.id
    104      name = viewName
    105
    106
    107  InitializeClass(PowerSupply)
    108