1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""Software
15
16 Software represents a software vendor's product.
17
18 $Id: Software.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 AccessControl import Permissions as permissions
27 from Products.ZenModel.ZenossSecurity import *
28
29 from Products.ZenRelations.RelSchema import *
30 from Products.ZenWidgets import messaging
31
32 from MEProduct import MEProduct
33 from ZenDate import ZenDate
34
41
42
43 addSoftware = DTMLFile('dtml/addSoftware',globals())
44
45
47 """Software object"""
48 portal_type = meta_type = 'Software'
49
50 procRegex = ""
51 monitorProc = False
52
53 _properties = (
54 {'id':'procRegex', 'type':'string', 'mode':'w'},
55 {'id':'monitorProc', 'type':'boolean', 'mode':'w'},
56 {'id':'installDate', 'type':'date', 'mode':''},
57 )
58
59 _relations = MEProduct._relations + (
60 ("os", ToOne(ToManyCont, "Products.ZenModel.OperatingSystem", "software")),
61 )
62
63 factory_type_information = (
64 {
65 'id' : 'Software',
66 'meta_type' : 'Software',
67 'description' : """Class to manage product information""",
68 'icon' : 'Software_icon.gif',
69 'product' : 'ZenModel',
70 'factory' : 'manage_addSoftware',
71 'immediate_view' : 'viewProductOverview',
72 'actions' :
73 (
74 { 'id' : 'overview'
75 , 'name' : 'Overview'
76 , 'action' : 'viewSoftwareOverview'
77 , 'permissions' : (
78 permissions.view, )
79 },
80 )
81 },
82 )
83
84 security = ClassSecurityInfo()
85
89
90
92 if name == 'installDate':
93 return self._installDate.getDate()
94 else:
95 raise AttributeError, name
96
97
105
106
107 security.declareProtected('Change Device', 'setProduct')
108 - def setProduct(self, productName, manufacturer="Unknown",
109 newProductName="", REQUEST=None, **kwargs):
124
125
127 """Set the product class of this software by its productKey.
128 """
129 if prodKey:
130
131 self._prodKey = prodKey
132 self._manufacturer = manufacturer
133
134 if manufacturer is None:
135 manufacturer = 'Unknown'
136
137 manufs = self.getDmdRoot("Manufacturers")
138 prodobj = manufs.createSoftwareProduct(prodKey, manufacturer)
139 self.productClass.addRelation(prodobj)
140 else:
141 self.productClass.removeRelation()
142
143
145 """Return the name of this software (from its softwareClass)
146 """
147 pclass = self.productClass()
148 if pclass: return pclass.name
149 return ""
150
151
153 """Return the version of this software (from its softwareClass)
154 """
155 pclass = self.productClass()
156 if pclass: return pclass.version
157 return ""
158
159
161 """Return the build of this software (from its softwareClass)
162 """
163 pclass = self.productClass()
164 if pclass: return pclass.build
165 return ""
166
167
169 """Return the install date as a DateTime object.
170 """
171 return self._installDate.getDate()
172
173
175 """Return the install date in the form 'YYYY/MM/DD HH:MM:SS'
176 """
177
178 if self._installDate.getStringSecsResolution() != "1968/01/08 00:00:00":
179 return self._installDate.getStringSecsResolution()
180 else:
181 return "Unknown"
182
183
185 """Set the install date should be string in form 'YYYY/MM/DD HH:MM:SS'
186 """
187 self._installDate.setDate(value)
188
189
191 """Return our Device for DeviceResultInt.
192 """
193 return self.os().device()
194
195
196 InitializeClass(Software)
197