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