HTCondor Project List Archives



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Condor-devel] fun new option: LOCAL_CONFIG_DIR



I've always wanted this, so I wrote it.

If LOCAL_CONFIG_DIR is set in the global config file, we read the
contents of this directory and anything that's not a directory
we process as a config file. 

We read it before LOCAL_CONFIG_FILE, and check to see if the
value has changed when we read LOCAL_CONFIG_FILE, so a local
config file can include an additional directory. 

It's currently a single directory, though I might change that
to be a list of directories. 

Files in the directory are processed in lexigraphical order, 
ala /etc/rc.d/

My idea for this feature is to be able to drop files in a directory
to enable features easily - if you want your machine to be a central
manager, you just make sure that condor_config.central_manager is 
in /etc/condor.d/ or something. 

Comments?

For UWCS users who want to see it in context, 
/p/condor/workspaces/epaulson/src_tress/V67

-Erik

Index: condor_config.C
===================================================================
RCS file: /p/condor/repository/CONDOR_SRC/src/condor_c++_util/condor_config.C,v
retrieving revision 1.56.8.19.6.10.4.18
diff -r1.56.8.19.6.10.4.18 condor_config.C
92a93
> void process_directory( char*, char*);
394a396,399
> 	char *dirlist = param("LOCAL_CONFIG_DIR");
> 	if(dirlist) {
> 		process_directory(dirlist, host);
> 	}
396a402,411
> 	char* newdirlist = param("LOCAL_CONFIG_DIR");
> 	if(newdirlist && dirlist) {
> 		if(strcmp(dirlist, newdirlist) ) {
> 			process_directory(newdirlist, host);
> 		}
> 	}
> 
> 	if(dirlist) { free(dirlist); dirlist = NULL; }
> 	if(newdirlist) { free(newdirlist); newdirlist = NULL; }
> 
605a621,669
> int compareFiles(const void *a, const void *b) {
> 	 return strcmp(*(char **)a, *(char **)b);
> }
> // examine each file in a directory and treat it as a config file
> void
> process_directory( char* dirpath, char* host )
> {
> 	Directory *files;
> 	char *file;
> 	char **paths;
> 	char *tmp;
> 	int local_required;
> 	
> 	local_required = true;	
> 	tmp = param( "REQUIRE_LOCAL_CONFIG_FILE" );
> 	if( tmp ) {
> 		if( tmp[0] == 'f' || tmp[0] == 'F' ) {
> 			local_required = false;
> 		}
> 		free( tmp );
> 	}
> 
> 	paths = (char **)calloc(65536, sizeof(char *));
> 	files = new Directory(dirpath);
> 	int i = 0;
> 	if(files == NULL) { 
> 		fprintf(stderr, "Cannot open %s\n", dirpath);	 
> 	}
> 	else {
> 		while( (file = (char *)files->Next()) && i < 65536) {
> 			// don't consider directories
> 			// maybe we should squash symlinks here...
> 			if(! files->IsDirectory() ) {
> 				paths[i] = strdup((char *)files->GetFullPath());
> 				i++;
> 			}
> 		}
> 		delete files;
> 	}
> 	qsort(paths, i, sizeof(char *), compareFiles); 
> 	char **pathCopy = paths;
> 	while(*pathCopy) {
> 		process_file( *pathCopy, "config file", host, local_required );
> 		//fprintf(stderr, "We could be creating %s\n", *pathCopy);
> 		free(*pathCopy);
> 		pathCopy++;
> 	}
> 	free(paths);
> }