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

Source Code for Module ZenModel.Software

  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__="""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   
 28  from Products.ZenRelations.RelSchema import * 
 29   
 30  from MEProduct import MEProduct 
 31  from ZenDate import ZenDate 
 32   
33 -def manage_addSoftware(context, id, title = None, REQUEST = None):
34 """make a Software""" 35 d = Software(id, title) 36 context._setObject(id, d) 37 if REQUEST is not None: 38 REQUEST['RESPONSE'].redirect(context.absolute_url()+'/manage_main')
39 40 41 addSoftware = DTMLFile('dtml/addSoftware',globals()) 42 43
44 -class Software(MEProduct):
45 """Software object""" 46 portal_type = meta_type = 'Software' 47 48 procRegex = "" 49 monitorProc = False 50 51 _properties = ( 52 {'id':'procRegex', 'type':'string', 'mode':'w'}, 53 {'id':'monitorProc', 'type':'boolean', 'mode':'w'}, 54 {'id':'installDate', 'type':'date', 'mode':''}, 55 ) 56 57 _relations = MEProduct._relations + ( 58 ("os", ToOne(ToManyCont, "Products.ZenModel.OperatingSystem", "software")), 59 ) 60 61 factory_type_information = ( 62 { 63 'id' : 'Software', 64 'meta_type' : 'Software', 65 'description' : """Class to manage product information""", 66 'icon' : 'Software_icon.gif', 67 'product' : 'ZenModel', 68 'factory' : 'manage_addSoftware', 69 'immediate_view' : 'viewProductOverview', 70 'actions' : 71 ( 72 { 'id' : 'overview' 73 , 'name' : 'Overview' 74 , 'action' : 'viewSoftwareOverview' 75 , 'permissions' : ( 76 permissions.view, ) 77 }, 78 { 'id' : 'viewHistory' 79 , 'name' : 'Modifications' 80 , 'action' : 'viewHistory' 81 , 'permissions' : ( 82 permissions.view, ) 83 }, 84 ) 85 }, 86 ) 87 88 security = ClassSecurityInfo() 89
90 - def __init__(self, id, title=""):
91 MEProduct.__init__(self, id, title) 92 self._installDate = ZenDate("1968/1/8")
93 94
95 - def __getattr__(self, name):
96 if name == 'installDate': 97 return self._installDate.getDate() 98 else: 99 raise AttributeError, name
100 101
102 - def _setPropValue(self, id, value):
103 """override from PropertyManager to handle checks and ip creation""" 104 self._wrapperCheck(value) 105 if id == 'installDate': 106 self.setInstallDate(value) 107 else: 108 MEProduct._setPropValue(self, id, value)
109 110 111 security.declareProtected('Change Device', 'setProduct')
112 - def setProduct(self, productName, manufacturer="Unknown", 113 newProductName="", REQUEST=None, **kwargs):
114 """Set the product class of this software. 115 """ 116 if not manufacturer: manufacturer = "Unknown" 117 if newProductName: productName = newProductName 118 prodobj = self.getDmdRoot("Manufacturers").createSoftwareProduct( 119 productName, manufacturer, **kwargs) 120 self.productClass.addRelation(prodobj) 121 if REQUEST: 122 REQUEST['message'] = ("Set Manufacturer %s and Product %s at time:" 123 % (manufacturer, productName)) 124 return self.callZenScreen(REQUEST)
125 126
127 - def setProductKey(self, prodKey):
128 """Set the product class of this software by its productKey. 129 """ 130 if prodKey: 131 manufs = self.getDmdRoot("Manufacturers") 132 prodobj = manufs.createSoftwareProduct(prodKey) 133 self.productClass.addRelation(prodobj) 134 else: 135 self.productClass.removeRelation()
136 137
138 - def name(self):
139 """Return the name of this software (from its softwareClass) 140 """ 141 pclass = self.productClass() 142 if pclass: return pclass.name 143 return ""
144 145
146 - def version(self):
147 """Return the version of this software (from its softwareClass) 148 """ 149 pclass = self.productClass() 150 if pclass: return pclass.version 151 return ""
152 153
154 - def build(self):
155 """Return the build of this software (from its softwareClass) 156 """ 157 pclass = self.productClass() 158 if pclass: return pclass.build 159 return ""
160 161
162 - def getInstallDateObj(self):
163 """Return the install date as a DateTime object. 164 """ 165 return self._installDate.getDate()
166 167
168 - def getInstallDate(self):
169 """Return the install date in the form 'YYYY/MM/DD HH:MM:SS' 170 """ 171 return self._installDate.getStringSecsResolution()
172 173
174 - def setInstallDate(self, value):
175 """Set the install date should be string in form 'YYYY/MM/DD HH:MM:SS' 176 """ 177 self._installDate.setDate(value)
178 179 182 183
184 - def device(self):
185 """Return our Device for DeviceResultInt. 186 """ 187 return self.os().device()
188 189 190 InitializeClass(Software) 191