Skip to content
Snippets Groups Projects
Commit 0a0efdf2 authored by Moe Jette's avatar Moe Jette
Browse files

sprio: add support for the SLURM_CLUSTERS environment variable

This adds support for the SLURM_CLUSTERS environment variable also for sprio.
It also makes the test for the priority plugin type dependent on whether
running with multiple cluster support or not.
parent c7045c83
No related branches found
No related tags found
No related merge requests found
...@@ -141,6 +141,14 @@ Print version information and exit. ...@@ -141,6 +141,14 @@ Print version information and exit.
factor. This is for information purposes only. Actual job data is factor. This is for information purposes only. Actual job data is
suppressed. suppressed.
.SH "ENVIRONMENT VARIABLES"
.PP
If no corresponding commandline option is specified, \fBsprio\fR will use the value of
the following environment variables.
.TP 20
\fBSLURM_CLUSTERS\fR
Same as \fB\-\-clusters\fR
.SH "EXAMPLES" .SH "EXAMPLES"
.eo .eo
Print the list of all pending jobs with their weighted priorities Print the list of all pending jobs with their weighted priorities
......
...@@ -76,6 +76,18 @@ static void _parse_token( char *token, char *field, int *field_size, ...@@ -76,6 +76,18 @@ static void _parse_token( char *token, char *field, int *field_size,
static void _print_options( void ); static void _print_options( void );
static void _usage( void ); static void _usage( void );
static void _opt_env(void)
{
char *env_val;
if ((env_val = getenv("SLURM_CLUSTERS"))) {
if (!(params.clusters = slurmdb_get_info_cluster(env_val))) {
error("'%s' invalid entry for SLURM_CLUSTERS", env_val);
exit(1);
}
}
}
/* /*
* parse_command_line * parse_command_line
*/ */
...@@ -102,6 +114,9 @@ parse_command_line( int argc, char* argv[] ) ...@@ -102,6 +114,9 @@ parse_command_line( int argc, char* argv[] )
{NULL, 0, 0, 0} {NULL, 0, 0, 0}
}; };
/* get defaults from environment */
_opt_env();
while((opt_char = getopt_long(argc, argv, "hj::lM:no:u:vVw", while((opt_char = getopt_long(argc, argv, "hj::lM:no:u:vVw",
long_options, &option_index)) != -1) { long_options, &option_index)) != -1) {
switch (opt_char) { switch (opt_char) {
...@@ -131,7 +146,6 @@ parse_command_line( int argc, char* argv[] ) ...@@ -131,7 +146,6 @@ parse_command_line( int argc, char* argv[] )
optarg); optarg);
exit(1); exit(1);
} }
working_cluster_rec = list_peek(params.clusters);
break; break;
case (int) 'n': case (int) 'n':
params.normalized = true; params.normalized = true;
...@@ -175,8 +189,10 @@ parse_command_line( int argc, char* argv[] ) ...@@ -175,8 +189,10 @@ parse_command_line( int argc, char* argv[] )
} }
} }
if ( params.verbose ) if (params.verbose)
_print_options(); _print_options();
if (params.clusters)
working_cluster_rec = list_peek(params.clusters);
} }
/* /*
......
...@@ -75,24 +75,12 @@ static int _get_info(priority_factors_request_msg_t *factors_req, ...@@ -75,24 +75,12 @@ static int _get_info(priority_factors_request_msg_t *factors_req,
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
char *temp = NULL; char *prio_type = NULL;
int error_code = SLURM_SUCCESS; int error_code = SLURM_SUCCESS;
priority_factors_request_msg_t req_msg; priority_factors_request_msg_t req_msg;
priority_factors_response_msg_t *resp_msg = NULL; priority_factors_response_msg_t *resp_msg = NULL;
log_options_t opts = LOG_OPTS_STDERR_ONLY ; log_options_t opts = LOG_OPTS_STDERR_ONLY ;
/* Check to see if we are running a supported accounting plugin */
temp = slurm_get_priority_type();
if(strcasecmp(temp, "priority/multifactor")) {
fprintf (stderr, "You are not running a supported "
"priority plugin\n(%s).\n"
"Only 'priority/multifactor' is supported.\n",
temp);
xfree(temp);
exit(1);
}
xfree(temp);
log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_USER, NULL); log_init(xbasename(argv[0]), opts, SYSLOG_FACILITY_USER, NULL);
parse_command_line( argc, argv ); parse_command_line( argc, argv );
...@@ -115,6 +103,7 @@ int main (int argc, char *argv[]) ...@@ -115,6 +103,7 @@ int main (int argc, char *argv[])
weight_js = slurm_ctl_conf_ptr->priority_weight_js; weight_js = slurm_ctl_conf_ptr->priority_weight_js;
weight_part = slurm_ctl_conf_ptr->priority_weight_part; weight_part = slurm_ctl_conf_ptr->priority_weight_part;
weight_qos = slurm_ctl_conf_ptr->priority_weight_qos; weight_qos = slurm_ctl_conf_ptr->priority_weight_qos;
prio_type = xstrdup(slurm_ctl_conf_ptr->priority_type);
slurm_free_ctl_conf(slurm_ctl_conf_ptr); slurm_free_ctl_conf(slurm_ctl_conf_ptr);
} else { } else {
weight_age = slurm_get_priority_weight_age(); weight_age = slurm_get_priority_weight_age();
...@@ -122,8 +111,20 @@ int main (int argc, char *argv[]) ...@@ -122,8 +111,20 @@ int main (int argc, char *argv[])
weight_js = slurm_get_priority_weight_job_size(); weight_js = slurm_get_priority_weight_job_size();
weight_part = slurm_get_priority_weight_partition(); weight_part = slurm_get_priority_weight_partition();
weight_qos = slurm_get_priority_weight_qos(); weight_qos = slurm_get_priority_weight_qos();
prio_type = slurm_get_priority_type();
} }
/* Check to see if we are running a supported accounting plugin */
if (strcasecmp(prio_type, "priority/multifactor")) {
fprintf (stderr, "You are not running a supported "
"priority plugin\n(%s).\n"
"Only 'priority/multifactor' is supported.\n",
prio_type);
exit(1);
}
xfree(prio_type);
memset(&req_msg, 0, sizeof(priority_factors_request_msg_t)); memset(&req_msg, 0, sizeof(priority_factors_request_msg_t));
if (params.jobs) if (params.jobs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment