1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""FileSystem
15
16 FileSystem is a file system on a server
17
18 $Id: FileSystem.py,v 1.12 2004/04/06 22:33:23 edahl Exp $"""
19
20 __version__ = "$Revision: 1.12 $"[11:-2]
21 from Globals import DTMLFile
22 from Globals import InitializeClass
23 from AccessControl import ClassSecurityInfo
24
25 from Products.ZenUtils.Utils import convToUnits
26 from Products.ZenRelations.RelSchema import *
27
28 from OSComponent import OSComponent
29 from Products.ZenUtils.Utils import prepId
30 from Products.ZenWidgets import messaging
31
32 from Products.ZenModel.ZenossSecurity import *
33
44
45 addFileSystem = DTMLFile('dtml/addFileSystem',globals())
46
48 """
49 FileSystem object
50 """
51
52 portal_type = meta_type = 'FileSystem'
53
54 manage_editFileSystemForm = DTMLFile('dtml/manageEditFileSystem',globals())
55
56 mount = ""
57 storageDevice = ""
58 type = ""
59 blockSize = 0
60 totalBlocks = 0L
61 totalFiles = 0L
62 capacity = 0
63 inodeCapacity = 0
64 maxNameLen = 0
65
66 security = ClassSecurityInfo()
67
68 _properties = OSComponent._properties + (
69 {'id':'mount', 'type':'string', 'mode':''},
70 {'id':'storageDevice', 'type':'string', 'mode':''},
71 {'id':'type', 'type':'string', 'mode':''},
72 {'id':'blockSize', 'type':'int', 'mode':''},
73 {'id':'totalBlocks', 'type':'long', 'mode':''},
74 {'id':'totalFiles', 'type':'long', 'mode':''},
75 {'id':'maxNameLen', 'type':'int', 'mode':''},
76 )
77 _relations = OSComponent._relations + (
78 ("os", ToOne(ToManyCont, "Products.ZenModel.OperatingSystem", "filesystems")),
79 )
80
81
82 factory_type_information = (
83 {
84 'id' : 'FileSystem',
85 'meta_type' : 'FileSystem',
86 'description' : """Arbitrary device grouping class""",
87 'icon' : 'FileSystem_icon.gif',
88 'product' : 'ZenModel',
89 'factory' : 'manage_addFileSystem',
90 'immediate_view' : 'viewFileSystem',
91 'actions' :
92 (
93 { 'id' : 'status'
94 , 'name' : 'Status'
95 , 'action' : 'viewFileSystem'
96 , 'permissions' : (ZEN_VIEW,)
97 },
98 { 'id' : 'events'
99 , 'name' : 'Events'
100 , 'action' : 'viewEvents'
101 , 'permissions' : (ZEN_VIEW, )
102 },
103 { 'id' : 'perfConf'
104 , 'name' : 'Template'
105 , 'action' : 'objTemplates'
106 , 'permissions' : ("Change Device", )
107 },
108 { 'id' : 'viewHistory'
109 , 'name' : 'Modifications'
110 , 'action' : 'viewHistory'
111 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,)
112 },
113 )
114 },
115 )
116
117
121
122
128
129
131 """
132 Return the number of total bytes in human readable from ie 10MB
133 """
134 return convToUnits(self.totalBytes())
135
136
138 """
139 Return the number of used bytes on a filesytem.
140 """
141 blocks = self.usedBlocks()
142 if blocks is not None:
143 return self.blockSize * blocks
144 return None
145
146
148 """
149 Return the number of used bytes in human readable form ie 10MB
150 """
151 __pychecker__='no-constCond'
152 ub = self.usedBytes()
153 return ub is None and "unknown" or convToUnits(ub)
154
155
157 """
158 Return the number of availible bytes for this filesystem
159 """
160 blocks = self.usedBlocks()
161 if blocks is not None:
162 return self.blockSize * (self.getTotalBlocks() - self.usedBlocks())
163 return None
164
165
167 """
168 Return the number of availible bytes in human readable form ie 10MB
169 """
170 __pychecker__='no-constCond'
171 ab = self.availBytes()
172 return ab is None and "unknown" or convToUnits(ab)
173
174
176 """
177 Not implemented returns 0
178 """
179 return 0
180
181
191
192
194 """
195 Not implemented returns 0
196 """
197 return 0
198
199
201 """
202 Return the number of used blocks stored in the filesystem's rrd file
203 """
204 blocks = self.cacheRRDValue('usedBlocks', default)
205 if blocks is not None:
206 return long(blocks)
207 elif self.blockSize:
208
209
210
211 freeMB = self.cacheRRDValue('FreeMegabytes', default)
212 if freeMB is not None:
213 usedBytes = self.totalBytes() - long(freeMB) * 1024 * 1024
214 return usedBytes / self.blockSize
215 return None
216
217
219 """
220 Return the number of used blocks in human readable form ie 10MB
221 """
222 __pychecker__='no-constCond'
223 ub = self.usedBlocks()
224 return ub is None and "unknown" or convToUnits(ub)
225
226
228 """
229 Return the datapoint name of this filesystem 'usedBlocks_usedBlocks'
230 """
231 return ['usedBlocks_usedBlocks']
232
233
235 """
236 Return the mount point name of a filesystem '/boot'
237 """
238 return self.mount
239 name = viewName
240
241
242 security.declareProtected(ZEN_MANAGE_DEVICE, 'manage_editFileSystem')
243 - def manage_editFileSystem(self, monitor=False,
244 mount=None, storageDevice=None,
245 type=None, blockSize=None,
246 totalFiles=None, maxNameLen=None,
247 snmpindex=None, REQUEST=None):
269
270
271 InitializeClass(FileSystem)
272