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

# Source Code for Module Products.ZenModel.Hardware

     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__="""Hardware
    15
    16  Hardware represents a hardware vendor's product.
    17
    18  $Id: Hardware.py,v 1.5 2003/03/08 18:34:24 edahl Exp $"""
    19
    20  __version__ = "$Revision: 1.5 $"[11:-2]
    21
    22  from Globals import DTMLFile
    23  from Globals import InitializeClass
    24  from AccessControl import ClassSecurityInfo
    25  from Products.ZenWidgets import messaging
    26
    27  from Products.ZenRelations.RelSchema import *
    28
    29  from MEProduct import MEProduct
    30
    31 -def manage_addHardware(context, id, title = None, REQUEST = None):
    32      """make a Hardware"""
    33      d = Hardware(id, title)
    34      context._setObject(id, d)
    35
    36      if REQUEST is not None:
    37          REQUEST['RESPONSE'].redirect(context.absolute_url()
    38                                       +'/manage_main')
    39
    40  addHardware = DTMLFile('dtml/addHardware',globals())
    41
    42 -class Hardware(MEProduct):
    43      """Hardware object"""
    44      portal_type = meta_type = 'Hardware'
    45
    46      tag = ""
    47      serialNumber = ""
    48
    49      _properties = MEProduct._properties + (
    50          {'id':'tag', 'type':'string', 'mode':'w'},
    51          {'id':'serialNumber', 'type':'string', 'mode':'w'},
    52      )
    53
    54      security = ClassSecurityInfo()
    55
    56      security.declareProtected('Change Device', 'setProduct')
    57 -    def setProduct(self, productName,  manufacturer="Unknown",
    58                      newProductName="", REQUEST=None, **kwargs):
    59          """Set the product class of this software.
    60          """
    61          if not manufacturer: manufacturer = "Unknown"
    62          if newProductName: productName = newProductName
    63          prodobj = self.getDmdRoot("Manufacturers").createHardwareProduct(
    64                                          productName, manufacturer, **kwargs)
    65          self.productClass.addRelation(prodobj)
    66          if REQUEST:
    67              messaging.IMessageSender(self).sendToBrowser(
    68                  'Product Set',
    69                  'Manufacturer %s and product %s set.' % (manufacturer,
    70                                                           productName)
    71              )
    72              return self.callZenScreen(REQUEST)
    73
    74
    75 -    def setProductKey(self, prodKey, manufacturer=None):
    76          """Set the product class of this software by its productKey.
    77          """
    78          if prodKey:
    79              # Store these so we can return the proper value from getProductKey
    80              self._prodKey = prodKey
    81              self._manufacturer = manufacturer
    82
    83              if manufacturer is None:
    84                  manufacturer = 'Unknown'
    85
    86              manufs = self.getDmdRoot("Manufacturers")
    87              prodobj = manufs.createHardwareProduct(prodKey, manufacturer)
    88              self.productClass.addRelation(prodobj)
    89          else:
    90              self.productClass.removeRelation()
    91
    92
    93  InitializeClass(Hardware)
    94