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

# Source Code for Module Products.ZenModel.Hardware

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