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_DAEMON_LAUNCH_PATH "/private/var/db/openafs/etc/launchafs.sh"
18 @class AFSPropertyManager
19 @abstract AFS Manage Class
20 @discussion This class manage the openafs param for celldbserv, cache param, group creation, get and release token
23 @interface AFSPropertyManager : NSObject {
24 NSString *installationPath;
26 NSMutableArray *cellList;
27 NSArray *userDefaultCellArray;
28 NSString *afsRootMountPoint;
40 BOOL useAfsdConfVersion;
45 @abstract (brief description)
46 @discussion (comprehensive description)
51 @function initWithAfsPath
52 @abstract (description)
53 @discussion (description)
54 @param path Path di installazione afs
55 @result Istanza della classe di gestione delle propieta' afs
57 - (id)initWithAfsPath:(NSString*)path;
61 @abstract (brief description)
62 @discussion (comprehensive description)
67 @abstract (brief description)
68 @discussion (comprehensive description)
70 -(NSMutableArray*) getCellList;
75 @abstract (brief description)
76 @discussion (comprehensive description)
78 -(NSArray*) getAllCellsName;
81 @abstract (brief description)
82 @discussion (comprehensive description)
84 -(NSArray*) getUserDefaultForTokenCells;
87 @abstract (brief description)
88 @discussion (comprehensive description)
90 -(NSArray*) getDefaultForTokenCellsName;
93 @abstract (brief description)
94 @discussion (comprehensive description)
96 -(NSString*) getDefaultCellName;
99 @method setDefaultCellByName
100 @abstract set the cell named "name" to be se user default
101 @discussion first clean the last one selected as default and then set the cell named "name" as default user cell
103 -(void) setDefaultCellByName:(NSString*)name;
107 @abstract (brief description)
108 @discussion (comprehensive description)
109 */- (void) setCellName:(NSString*)cell;
113 @abstract Imposta Path
114 @discussion Imposta il path dove e' installato afs, in modo da leggere e scrivere le configurazioni
116 -(void) setPath:(NSString*)path;
120 @abstract Return the afs base
121 @discussion Return the Afs base installation path
126 @function statCacheEntry
127 @abstract get the afs number of state cache entry
129 @result Number of stat cache entry
131 -(int) statCacheEntry;
135 @function setStatCacheEntry
136 @abstract Set the afs number of state cache entry
138 @result Number of stat cache entry
140 -(void) setStatCacheEntry:(int)statEntry;
144 @abstract return the dCacheDim param value for cache manager
145 @result dCacheDim value
150 @function setDCacheDim
151 @abstract set the setDCacheDim value for cache manager param
152 @discussion <#(description)#>
153 @param dcacheDim cache param value
155 -(void) setDCacheDim:(int)dcacheDim;
158 @function cacheDimension
159 @abstract return the max size of the cache
160 @result Cache dimension
162 -(int) cacheDimension;
165 @function setCacheDimension
166 @abstract Set the max cache dimension
168 @param cacheDim MAx Chace dimension
170 -(void) setCacheDimension:(int)cacheDim;
173 @function daemonNumber
174 @abstract Return the number of daemon for the cache manager
175 @result Number of daemon
180 @function setDaemonNumber
181 @abstract Set the daemon numbero for the cache manager
182 @param dNumber number of daemon
184 -(void) setDaemonNumber:(int)dNumber;
187 @function afsRootMountPoint
188 @abstract Return the path where afs root volume will be mounted
189 @result AFS mount point
191 -(NSString*) afsRootMountPoint;
194 @function setAfsRootMountPoint
195 @abstract Set the AFS mount point
196 @param mountPoint AFS mount point
198 -(void) setAfsRootMountPoint:(NSString*)mountPoint;
202 @abstract Return the nVolEntry for cache manager
203 @result value for nVolEntry cache parameter
208 @function setNVolEntry
209 @abstract Set the nVolEntry parameter for cache manager
210 @param entry value for nVolEntry cache manager parameter
212 -(void) setNVolEntry:(int)entry;
216 @abstract Return the DynRoot parametr for cache manager
217 @result dynRoot parameter value
223 @abstract Set the DynRoot flag value for cache manager
224 @param flag dynRoot state (enable/disable)
226 -(void) setDynRoot:(bool)flag;
229 @abstract Get the afsdb flag value for cache manager
230 @result Return the value of the flag
236 @abstract Set the flag value for afsdb cache manager
237 @param flag AfsDB state (enable/disable)
239 -(void) setAfsDB:(bool)flag;
248 -(void) setVerbose:(bool)flag;
250 @function readCacheInfo
251 @abstract Read the cache info
252 @discussion The cache info is read from the file pointed by filePath param
253 @param filePath file location for the CacheInfo
255 -(void) readCacheInfo:(NSString*)filePath;
258 @function writeCacheInfo
259 @abstract Write the cache info down the file
260 @param filePath where to write the CacheInfo
261 @result return the execution error
263 -(int) writeCacheInfo:(NSString*)filePath;
266 @function readAfsdOption
267 @abstract Read the afs option
268 @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
269 @param filePath file where the parameter are store for default afsd.option or afs.conf
271 -(void) readAfsdOption:(NSString*)filePath;
274 @function readOldAfsdOption
275 @abstract Read the afsd.option file
276 @discussion Read the old afsd.option style afsd option file. If any error accour an NSException wil be trown22
277 @param filePath file path to afsd.option like file
278 @result <#(description)#>
280 -(void) readOldAfsdOption:(NSString*)filePath;
282 @function readAFSDParamLineContent
283 @abstract Try to decode one line of afsd.option or afs.conf
284 @param paramLine one line of file afsd.option(the only one that is present) os afs.conf
286 -(void) readAFSDParamLineContent:(NSString*)paramLine;
288 @function readNewAfsdOption
289 @abstract Read the new afs.conf file format
290 @discussion Scann every line f the afs.conf file ad for each one call the readAFSDParamLineContent with it's content
291 @param filePath path of the new file with afs.conf file format
293 -(void) readNewAfsdOption:(NSString*)filePath;
295 @function writeAfsdOption
296 @abstract <#(description)#>
297 @discussion <#(description)#>
298 @param <#(name) (description)#>
299 @result <#(description)#>
301 -(int) writeAfsdOption:(NSString*)filePath;
303 @function writeOldAfsdOption
304 @abstract Write the cache manager parameter to file
305 @discussion First chech the version of afs installed then choice to save old o new file version(afsd.option or afs.conf)
306 @param filePath file path for file to write into
307 @result <#(description)#>
309 -(int) writeOldAfsdOption:(NSString*)filePath;
311 @function writeNewAfsdOption
312 @abstract Write the cache parameter to a file with the new format
313 @param filePath file path where write into
315 -(int) writeNewAfsdOption:(NSString*)filePath;
317 @function getAfsVersion
318 @abstract Return the string representing the afs version
319 @result The Enteir string returned from the call of fs -version
321 -(NSString*) getAfsVersion;
323 @function getAfsMajorVersionVersion
324 @abstract Return the major version of afs Major.x.x
327 -(int) getAfsMajorVersionVersion;
329 @function getAfsMinorVersionVersion
330 @abstract Return the major version of afs x.Minor.x
333 -(int) getAfsMinorVersionVersion;
336 @function getAfsPatchVersionVersion
337 @abstract Return the major version of afs x.x.Patch
340 -(int) getAfsPatchVersionVersion;
343 @method clearConfiguration
344 @abstract Clear all structure or array that contain value for afs client setting(cells cache param etch)
347 -(void) clearConfiguration;
350 @function exceptionOnInvalidPath
351 @abstract Check the validity of afs path
352 @discussion If the installationPath variable don't point to a valid path, will be fired an NSException
354 -(void) exceptionOnInvalidPath;
357 @method loadConfiguration
358 @abstract load the all afs configuration (ThisCell & CellServDB & cache parameter)
360 -(void) loadConfiguration;
364 @abstract Read the Main Cell Name
366 -(void) readCellInfo:(NSString*) configFile;
369 @abstract Read the CellServDB File
370 @discussion Read the file of all cellservbd ad make the NSArray containing a DBCellElement for aech cell found
372 -(void) readCellDB:(NSString*) configFile;
374 @function readTheseCell
375 @abstract Read the "These Cell"
376 @discussion Read the "These Cell" file that contains all the cell from which the user want to get the token
377 @param configFile TheseCell file path
378 @result NSAray with the cells name
380 -(NSArray*) readTheseCell:(NSString*) configFile;
383 @abstract Stop The AFS
387 -(void) scanIpForCell:(DBCellElement*) cellElement allIP:(NSString*)allIP;
388 -(void) backupConfigurationFiles;
389 -(void) backupFile:(NSString*)localAfsFilePath;
390 -(void) saveConfigurationFiles:(BOOL) makeBackup;
391 -(void) saveCacheConfigurationFiles:(BOOL) makeBackup;
392 -(void) installConfigurationFile:(NSString*)srcConfFile destPath:(NSString*) destPath;
393 -(NSArray*) getTokenList;
394 -(BOOL) checkAfsStatus;
395 -(BOOL) checkAfsStatusForStartup;
396 -(void) klog:(NSString*)uName uPwd:(NSString*)uPwd cell:(NSString*)theCell;
397 -(void) aklog:(NSString*)theCell noKerberosCall:(BOOL)krb5CallEnable;
398 -(void) getTokens:(BOOL)klogAklogFlag usr:(NSString*)usr pwd:(NSString*)pwd;
399 -(void) unlog:(NSString*)cell;
400 -(NSString*) makeChaceParamString;
401 -(BOOL) useAfsdConfConfigFile;