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 )
112 },
113 )
114
115
119
120
126
127
129 """
130 Return the number of total bytes in human readable from ie 10MB
131 """
132 return convToUnits(self.totalBytes())
133
134
136 """
137 Return the number of used bytes on a filesytem.
138 """
139 blocks = self.usedBlocks()
140 if blocks is not None:
141 return self.blockSize * blocks
142 return None
143
144
146 """
147 Return the number of used bytes in human readable form ie 10MB
148 """
149 __pychecker__='no-constCond'
150 ub = self.usedBytes()
151 return ub is None and "unknown" or convToUnits(ub)
152
153
155 """
156 Return the number of availible bytes for this filesystem
157 """
158 blocks = self.availBlocks()
159 if blocks is not None:
160 return self.blockSize * blocks
161 return None
162
163
165 """
166 Return the number of availible bytes in human readable form ie 10MB
167 """
168 __pychecker__='no-constCond'
169 ab = self.availBytes()
170 return ab is None and "unknown" or convToUnits(ab)
171
172
174 """
175 Not implemented returns 0
176 """
177 return 0
178
179
192
193
195 """
196 Not implemented returns 0
197 """
198 return 0
199
200
217
218
230
231
233 """
234 Return the number of used blocks in human readable form ie 10MB
235 """
236 __pychecker__='no-constCond'
237 ub = self.usedBlocks()
238 return ub is None and "unknown" or convToUnits(ub)
239
240
242 """
243 Return the datapoint name of this filesystem 'usedBlocks_usedBlocks'
244 """
245 return ['usedBlocks_usedBlocks']
246
247
249 """
250 Return the mount point name of a filesystem '/boot'
251 """
252 return self.mount
253 name = viewName
254
255
256 security.declareProtected(ZEN_MANAGE_DEVICE, 'manage_editFileSystem')
257 - def manage_editFileSystem(self, monitor=False,
258 mount=None, storageDevice=None,
259 type=None, blockSize=None,
260 totalFiles=None, maxNameLen=None,
261 snmpindex=None, REQUEST=None):
283
284
285 InitializeClass(FileSystem)
286