2 // AFSPropertyManager.h
5 // Created by Claudio Bisegni on 21/05/07.
6 // Copyright 2007 INFN - National Institute of Nuclear Physics. All rights reserved.
9 #import <Cocoa/Cocoa.h>
10 #import "DBCellElement.h"
14 #define AFS_DAEMON_STARTUPSCRIPT "/Library/OpenAFS/Tools/root.client/usr/vice/etc/afs.rc"
15 #define AFS_DAEMON_PATH "/Library/LaunchDaemons/org.openafs.filesystems.afs.plist"
16 #define AFS_FS_MOUNT "AFS"
17 #define AFS_LAUNCHCTL_GREP_STR "org.openafs.filesystems.afs"
19 @class AFSPropertyManager
20 @abstract AFS Manage Class
21 @discussion This class manage the openafs param for celldbserv, cache param, group creation, get and release token
24 @interface AFSPropertyManager
: NSObject
{
25 NSString
*installationPath
;
27 NSMutableArray
*cellList
;
28 NSArray
*userDefaultCellArray
;
29 NSString
*afsRootMountPoint
;
41 BOOL useAfsdConfVersion
;
46 @abstract (brief description)
47 @discussion (comprehensive description)
52 @function initWithAfsPath
53 @abstract (description)
54 @discussion (description)
55 @param path Path di installazione afs
56 @result Istanza della classe di gestione delle propieta' afs
58 - (id
)initWithAfsPath
:(NSString
*)path
;
62 @abstract (brief description)
63 @discussion (comprehensive description)
68 @abstract (brief description)
69 @discussion (comprehensive description)
71 -(NSMutableArray
*) getCellList
;
76 @abstract (brief description)
77 @discussion (comprehensive description)
79 -(NSArray
*) getAllCellsName
;
82 @abstract (brief description)
83 @discussion (comprehensive description)
85 -(NSArray
*) getUserDefaultForTokenCells
;
88 @abstract (brief description)
89 @discussion (comprehensive description)
91 -(NSArray
*) getDefaultForTokenCellsName
;
94 @abstract (brief description)
95 @discussion (comprehensive description)
97 -(NSString
*) getDefaultCellName
;
100 @method setDefaultCellByName
101 @abstract set the cell named "name" to be se user default
102 @discussion first clean the last one selected as default and then set the cell named "name" as default user cell
104 -(void) setDefaultCellByName
:(NSString
*)name
;
108 @abstract (brief description)
109 @discussion (comprehensive description)
110 */- (void) setCellName
:(NSString
*)cell
;
114 @abstract Imposta Path
115 @discussion Imposta il path dove e' installato afs, in modo da leggere e scrivere le configurazioni
117 -(void) setPath
:(NSString
*)path
;
121 @abstract Return the afs base
122 @discussion Return the Afs base installation path
127 @function statCacheEntry
128 @abstract get the afs number of state cache entry
130 @result Number of stat cache entry
132 -(int) statCacheEntry
;
136 @function setStatCacheEntry
137 @abstract Set the afs number of state cache entry
139 @result Number of stat cache entry
141 -(void) setStatCacheEntry
:(int)statEntry
;
145 @abstract return the dCacheDim param value for cache manager
146 @result dCacheDim value
151 @function setDCacheDim
152 @abstract set the setDCacheDim value for cache manager param
153 @discussion <#(description)#>
154 @param dcacheDim cache param value
156 -(void) setDCacheDim
:(int)dcacheDim
;
159 @function cacheDimension
160 @abstract return the max size of the cache
161 @result Cache dimension
163 -(int) cacheDimension
;
166 @function setCacheDimension
167 @abstract Set the max cache dimension
169 @param cacheDim MAx Chace dimension
171 -(void) setCacheDimension
:(int)cacheDim
;
174 @function daemonNumber
175 @abstract Return the number of daemon for the cache manager
176 @result Number of daemon
181 @function setDaemonNumber
182 @abstract Set the daemon numbero for the cache manager
183 @param dNumber number of daemon
185 -(void) setDaemonNumber
:(int)dNumber
;
188 @function afsRootMountPoint
189 @abstract Return the path where afs root volume will be mounted
190 @result AFS mount point
192 -(NSString
*) afsRootMountPoint
;
195 @function setAfsRootMountPoint
196 @abstract Set the AFS mount point
197 @param mountPoint AFS mount point
199 -(void) setAfsRootMountPoint
:(NSString
*)mountPoint
;
203 @abstract Return the nVolEntry for cache manager
204 @result value for nVolEntry cache parameter
209 @function setNVolEntry
210 @abstract Set the nVolEntry parameter for cache manager
211 @param entry value for nVolEntry cache manager parameter
213 -(void) setNVolEntry
:(int)entry
;
217 @abstract Return the DynRoot parametr for cache manager
218 @result dynRoot parameter value
224 @abstract Set the DynRoot flag value for cache manager
225 @param flag dynRoot state (enable/disable)
227 -(void) setDynRoot
:(bool)flag
;
230 @abstract Get the afsdb flag value for cache manager
231 @result Return the value of the flag
237 @abstract Set the flag value for afsdb cache manager
238 @param flag AfsDB state (enable/disable)
240 -(void) setAfsDB
:(bool)flag
;
249 -(void) setVerbose
:(bool)flag
;
251 @function readCacheInfo
252 @abstract Read the cache info
253 @discussion The cache info is read from the file pointed by filePath param
254 @param filePath file location for the CacheInfo
256 -(int) readCacheInfo
:(NSString
*)filePath
;
259 @function writeCacheInfo
260 @abstract Write the cache info down the file
261 @param filePath where to write the CacheInfo
262 @result return the execution error
264 -(int) writeCacheInfo
:(NSString
*)filePath
;
267 @function readAfsdOption
268 @abstract Read the afs option
269 @discussion Read the afs option checking firt the afs version so it can read the old afsd.option or afs.conf file. If any error accour an NSException wil be trown
270 @param filePath file where the parameter are store for default afsd.option or afs.conf
272 -(void) readAfsdOption
:(NSString
*)filePath
;
275 @function readOldAfsdOption
276 @abstract Read the afsd.option file
277 @discussion Read the old afsd.option style afsd option file. If any error accour an NSException wil be trown22
278 @param filePath file path to afsd.option like file
279 @result <#(description)#>
281 -(int) readOldAfsdOption
:(NSString
*)filePath
;
283 @function readAFSDParamLineContent
284 @abstract Try to decode one line of afsd.option or afs.conf
285 @param paramLine one line of file afsd.option(the only one that is present) os afs.conf
287 -(int) readAFSDParamLineContent
:(NSString
*)paramLine
;
289 @function readNewAfsdOption
290 @abstract Read the new afs.conf file format
291 @discussion Scann every line f the afs.conf file ad for each one call the readAFSDParamLineContent with it's content
292 @param filePath path of the new file with afs.conf file format
294 -(int) readNewAfsdOption
:(NSString
*)filePath
;
296 @function writeAfsdOption
297 @abstract <#(description)#>
298 @discussion <#(description)#>
299 @param <#(name) (description)#>
300 @result <#(description)#>
302 -(int) writeAfsdOption
:(NSString
*)filePath
;
304 @function writeOldAfsdOption
305 @abstract Write the cache manager parameter to file
306 @discussion First chech the version of afs installed then choice to save old o new file version(afsd.option or afs.conf)
307 @param filePath file path for file to write into
308 @result <#(description)#>
310 -(int) writeOldAfsdOption
:(NSString
*)filePath
;
312 @function writeNewAfsdOption
313 @abstract Write the cache parameter to a file with the new format
314 @param filePath file path where write into
316 -(int) writeNewAfsdOption
:(NSString
*)filePath
;
318 @function getAfsVersion
319 @abstract Return the string representing the afs version
320 @result The Enteir string returned from the call of fs -version
322 -(NSString
*) getAfsVersion
;
324 @function getAfsMajorVersionVersion
325 @abstract Return the major version of afs Major.x.x
328 -(int) getAfsMajorVersionVersion
;
330 @function getAfsMinorVersionVersion
331 @abstract Return the major version of afs x.Minor.x
334 -(int) getAfsMinorVersionVersion
;
337 @function getAfsPatchVersionVersion
338 @abstract Return the major version of afs x.x.Patch
341 -(int) getAfsPatchVersionVersion
;
344 @method clearConfiguration
345 @abstract Clear all structure or array that contain value for afs client setting(cells cache param etch)
348 -(void) clearConfiguration
;
351 @function exceptionOnInvalidPath
352 @abstract Check the validity of afs path
353 @discussion If the installationPath variable don't point to a valid path, will be fired an NSException
355 -(void) exceptionOnInvalidPath
;
358 @method loadConfiguration
359 @abstract load the all afs configuration (ThisCell & CellServDB & cache parameter)
361 -(void) loadConfiguration
;
365 @abstract Read the Main Cell Name
367 -(void) readCellInfo
:(NSString
*) configFile
;
370 @abstract Read the CellServDB File
371 @discussion Read the file of all cellservbd ad make the NSArray containing a DBCellElement for aech cell found
373 -(void) readCellDB
:(NSString
*) configFile
;
375 @function readTheseCell
376 @abstract Read the "These Cell"
377 @discussion Read the "These Cell" file that contains all the cell from which the user want to get the token
378 @param configFile TheseCell file path
379 @result NSAray with the cells name
381 -(NSArray
*) readTheseCell
:(NSString
*) configFile
;
384 @abstract Stop The AFS
388 -(void) scanIpForCell
:(DBCellElement
*) cellElement allIP
:(NSString
*)allIP
;
389 -(void) backupConfigurationFiles
;
390 -(void) backupFile
:(NSString
*)localAfsFilePath
;
391 -(void) saveConfigurationFiles
:(BOOL
) makeBackup
;
392 -(void) saveCacheConfigurationFiles
:(BOOL
) makeBackup
;
393 -(void) installConfigurationFile
:(NSString
*)srcConfFile destPath
:(NSString
*) destPath
;
394 -(NSArray
*) getTokenList
;
395 -(BOOL
) checkAfsStatus
;
396 -(BOOL
) checkAfsStatusForStartup
;
397 -(void) klog
:(NSString
*)uName uPwd
:(NSString
*)uPwd cell
:(NSString
*)theCell
;
398 -(void) aklog
:(NSString
*)theCell noKerberosCall
:(BOOL
)krb5CallEnable
;
399 -(void) getTokens
:(BOOL
)klogAklogFlag usr
:(NSString
*)usr pwd
:(NSString
*)pwd
;
400 -(void) unlog
:(NSString
*)cell
;
401 -(NSString
*) makeChaceParamString
;
402 -(BOOL
) useAfsdConfConfigFile
;