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
22 from math import isnan
23
24 from Globals import DTMLFile
25 from Globals import InitializeClass
26 from AccessControl import ClassSecurityInfo
27
28 from Products.ZenUtils.Utils import convToUnits
29 from Products.ZenRelations.RelSchema import *
30
31 from OSComponent import OSComponent
32 from Products.ZenUtils.Utils import prepId
33 from Products.ZenWidgets import messaging
34
35 from Products.ZenModel.ZenossSecurity import *
36
47
48 addFileSystem = DTMLFile('dtml/addFileSystem',globals())
49
51 """
52 FileSystem object
53 """
54
55 portal_type = meta_type = 'FileSystem'
56
57 manage_editFileSystemForm = DTMLFile('dtml/manageEditFileSystem',globals())
58
59 mount = ""
60 storageDevice = ""
61 type = ""
62 blockSize = 0
63 totalBlocks = 0L
64 totalFiles = 0L
65 capacity = 0
66 inodeCapacity = 0
67 maxNameLen = 0
68
69 security = ClassSecurityInfo()
70
71 _properties = OSComponent._properties + (
72 {'id':'mount', 'type':'string', 'mode':''},
73 {'id':'storageDevice', 'type':'string', 'mode':''},
74 {'id':'type', 'type':'string', 'mode':''},
75 {'id':'blockSize', 'type':'int', 'mode':''},
76 {'id':'totalBlocks', 'type':'long', 'mode':''},
77 {'id':'totalFiles', 'type':'long', 'mode':''},
78 {'id':'maxNameLen', 'type':'int', 'mode':''},
79 )
80 _relations = OSComponent._relations + (
81 ("os", ToOne(ToManyCont, "Products.ZenModel.OperatingSystem", "filesystems")),
82 )
83
84
85 factory_type_information = (
86 {
87 'id' : 'FileSystem',
88 'meta_type' : 'FileSystem',
89 'description' : """Arbitrary device grouping class""",
90 'icon' : 'FileSystem_icon.gif',
91 'product' : 'ZenModel',
92 'factory' : 'manage_addFileSystem',
93 'immediate_view' : 'viewFileSystem',
94 'actions' :
95 (
96 { 'id' : 'status'
97 , 'name' : 'Status'
98 , 'action' : 'viewFileSystem'
99 , 'permissions' : (ZEN_VIEW,)
100 },
101 { 'id' : 'events'
102 , 'name' : 'Events'
103 , 'action' : 'viewEvents'
104 , 'permissions' : (ZEN_VIEW, )
105 },
106 { 'id' : 'perfConf'
107 , 'name' : 'Template'
108 , 'action' : 'objTemplates'
109 , 'permissions' : ("Change Device", )
110 },
111 { 'id' : 'viewHistory'
112 , 'name' : 'Modifications'
113 , 'action' : 'viewHistory'
114 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,)
115 },
116 )
117 },
118 )
119
120
124
125
131
132
134 """
135 Return the number of total bytes in human readable from ie 10MB
136 """
137 return convToUnits(self.totalBytes())
138
139
141 """
142 Return the number of used bytes on a filesytem.
143 """
144 blocks = self.usedBlocks()
145 if blocks is not None:
146 return self.blockSize * blocks
147 return None
148
149
151 """
152 Return the number of used bytes in human readable form ie 10MB
153 """
154 __pychecker__='no-constCond'
155 ub = self.usedBytes()
156 return ub is None and "unknown" or convToUnits(ub)
157
158
160 """
161 Return the number of availible bytes for this filesystem
162 """
163 blocks = self.availBlocks()
164 if blocks is not None:
165 return self.blockSize * blocks
166 return None
167
168
170 """
171 Return the number of availible bytes in human readable form ie 10MB
172 """
173 __pychecker__='no-constCond'
174 ab = self.availBytes()
175 return ab is None and "unknown" or convToUnits(ab)
176
177
179 """
180 Not implemented returns 0
181 """
182 return 0
183
184
197
198
200 """
201 Not implemented returns 0
202 """
203 return 0
204
205
222
223
235
236
238 """
239 Return the number of used blocks in human readable form ie 10MB
240 """
241 __pychecker__='no-constCond'
242 ub = self.usedBlocks()
243 return ub is None and "unknown" or convToUnits(ub)
244
245
247 """
248 Return the datapoint name of this filesystem 'usedBlocks_usedBlocks'
249 """
250 return ['usedBlocks_usedBlocks']
251
252
254 """
255 Return the mount point name of a filesystem '/boot'
256 """
257 return self.mount
258 name = viewName
259
260
261 security.declareProtected(ZEN_MANAGE_DEVICE, 'manage_editFileSystem')
262 - def manage_editFileSystem(self, monitor=False,
263 mount=None, storageDevice=None,
264 type=None, blockSize=None,
265 totalFiles=None, maxNameLen=None,
266 snmpindex=None, REQUEST=None):
288
289
290 InitializeClass(FileSystem)
291