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

Source Code for Module ZenModel.DeviceHW

 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   
15  from Hardware import Hardware 
16   
17  from AccessControl import ClassSecurityInfo 
18  from Globals import DTMLFile 
19  from Globals import InitializeClass 
20  from Acquisition import aq_base 
21  from DateTime import DateTime 
22   
23  from AccessControl import Permissions as permissions 
24   
25  from Products.ZenUtils.Utils import convToUnits 
26  from Products.ZenRelations.RelSchema import * 
27   
28  from Exceptions import * 
29   
30   
31 -class DeviceHW(Hardware):
32 33 meta_type = "DeviceHW" 34 35 totalMemory = 0L 36 37 _properties = Hardware._properties + ( 38 {'id':'totalMemory', 'type':'long', 'mode':'w'}, 39 ) 40 41 _relations = Hardware._relations + ( 42 ("cpus", ToManyCont(ToOne, "Products.ZenModel.CPU", "hw")), 43 ("cards", ToManyCont(ToOne, "Products.ZenModel.ExpansionCard", "hw")), 44 ("harddisks", ToManyCont(ToOne, "Products.ZenModel.HardDisk", "hw")), 45 ) 46 47 security = ClassSecurityInfo() 48
49 - def __init__(self):
50 id = "hw" 51 Hardware.__init__(self, id)
52 53
54 - def __call__(self, REQUEST=None):
55 pp = self.getPrimaryParent() 56 screen = getattr(pp, "deviceHardwareDetail", False) 57 if not screen: return pp() 58 return screen()
59
60 - def totalMemoryString(self):
61 return self.totalMemory and convToUnits(self.totalMemory) or 'unknown'
62
63 - def device(self):
64 """Return our Device object for DeviceResultInt. 65 """ 66 return self.getPrimaryParent()
67 68 69 70 InitializeClass(DeviceHW) 71