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

Source Code for Module 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   
26  from Products.ZenRelations.RelSchema import * 
27   
28  from MEProduct import MEProduct 
29   
30 -def manage_addHardware(context, id, title = None, REQUEST = None):
31 """make a Hardware""" 32 d = Hardware(id, title) 33 context._setObject(id, d) 34 35 if REQUEST is not None: 36 REQUEST['RESPONSE'].redirect(context.absolute_url() 37 +'/manage_main')
38 39 addHardware = DTMLFile('dtml/addHardware',globals()) 40
41 -class Hardware(MEProduct):
42 """Hardware object""" 43 portal_type = meta_type = 'Hardware' 44 45 tag = "" 46 serialNumber = "" 47 48 _properties = MEProduct._properties + ( 49 {'id':'tag', 'type':'string', 'mode':'w'}, 50 {'id':'serialNumber', 'type':'string', 'mode':'w'}, 51 ) 52 53 security = ClassSecurityInfo() 54 55 security.declareProtected('Change Device', 'setProduct')
56 - def setProduct(self, productName, manufacturer="Unknown", 57 newProductName="", REQUEST=None, **kwargs):
58 """Set the product class of this software. 59 """ 60 if not manufacturer: manufacturer = "Unknown" 61 if newProductName: productName = newProductName 62 prodobj = self.getDmdRoot("Manufacturers").createHardwareProduct( 63 productName, manufacturer, **kwargs) 64 self.productClass.addRelation(prodobj) 65 if REQUEST: 66 REQUEST['message'] = ("Set Manufacturer %s and Product %s at time:" 67 % (manufacturer, productName)) 68 return self.callZenScreen(REQUEST)
69 70
71 - def setProductKey(self, prodKey):
72 """Set the product class of this software by its productKey. 73 """ 74 if prodKey: 75 manufs = self.getDmdRoot("Manufacturers") 76 prodobj = manufs.createHardwareProduct(prodKey) 77 self.productClass.addRelation(prodobj) 78 else: 79 self.productClass.removeRelation()
80 81
84 85 86 InitializeClass(Hardware) 87