6
6
* Copyright (C) 2002-2007 The Regents of the University of California.
7
7
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
8
8
* Written by Danny Auble <da@llnl.gov>
9
* CODE-OCEC-09-009. All rights reserved.
11
11
* This file is part of SLURM, a resource management program.
12
* For details, see <http://www.llnl.gov/linux/slurm/>.
12
* For details, see <https://computing.llnl.gov/linux/slurm/>.
13
* Please also read the included file: DISCLAIMER.
14
15
* SLURM is free software; you can redistribute it and/or modify it under
15
16
* the terms of the GNU General Public License as published by the Free
71
73
} else if(!end || !strncasecmp (argv[i], "Names",
72
74
MAX(command_len, 1))
73
75
|| !strncasecmp (argv[i], "Clusters",
74
MAX(command_len, 1))) {
76
MAX(command_len, 3))) {
76
78
if(slurm_addto_char_list(cluster_list,
82
} else if (!strncasecmp (argv[i], "Classification",
83
MAX(command_len, 3))) {
86
str_2_classification(argv[i]+end);
80
90
} else if (!strncasecmp (argv[i], "Format",
81
91
MAX(command_len, 1))) {
96
106
static int _set_rec(int *start, int argc, char *argv[],
98
acct_association_rec_t *assoc)
108
acct_association_rec_t *assoc,
109
uint16_t *classification)
126
137
|| !strncasecmp (argv[i], "Names",
127
138
MAX(command_len, 1))
128
139
|| !strncasecmp (argv[i], "Clusters",
129
MAX(command_len, 1))) {
140
MAX(command_len, 3))) {
131
slurm_addto_char_list(name_list, argv[i]+end);
142
slurm_addto_char_list(name_list,
144
} else if (!strncasecmp (argv[i], "Classification",
145
MAX(command_len, 3))) {
148
str_2_classification(argv[i]+end);
132
152
} else if (!strncasecmp (argv[i], "FairShare",
133
153
MAX(command_len, 1))
134
154
|| !strncasecmp (argv[i], "Shares",
135
155
MAX(command_len, 1))) {
136
if (get_uint(argv[i]+end, &assoc->fairshare,
156
if (get_uint(argv[i]+end, &assoc->shares_raw,
137
157
"FairShare") == SLURM_SUCCESS)
139
159
} else if (!strncasecmp (argv[i], "GrpCPUMins",
140
160
MAX(command_len, 7))) {
141
if (get_uint64(argv[i]+end,
142
&assoc->grp_cpu_mins,
143
"GrpCPUMins") == SLURM_SUCCESS)
162
fprintf(stderr, "GrpCPUMins is not a valid option "
163
"for the root association of a cluster.\n");
145
165
} else if (!strncasecmp (argv[i], "GrpCpus",
146
166
MAX(command_len, 7))) {
147
167
if (get_uint(argv[i]+end, &assoc->grp_cpus,
165
185
} else if (!strncasecmp (argv[i], "GrpWall",
166
186
MAX(command_len, 4))) {
167
mins = time_str2mins(argv[i]+end);
168
if (mins != NO_VAL) {
169
assoc->grp_wall = (uint32_t) mins;
174
" Bad GrpWall time format: %s\n",
188
fprintf(stderr, "GrpWall is not a valid option "
189
"for the root association of a cluster.\n");
177
190
} else if (!strncasecmp (argv[i], "MaxCPUMinsPerJob",
178
191
MAX(command_len, 7))) {
179
192
if (get_uint64(argv[i]+end,
257
270
int limit_set = 0;
258
271
ListIterator itr = NULL, itr_c = NULL;
259
272
char *name = NULL;
261
275
init_acct_association_rec(&start_assoc);
263
for (i=0; i<argc; i++)
264
limit_set = _set_rec(&i, argc, argv, name_list, &start_assoc);
277
for (i=0; i<argc; i++) {
278
int command_len = strlen(argv[i]);
279
if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))
280
|| !strncasecmp (argv[i], "Set", MAX(command_len, 3)))
282
limit_set += _set_rec(&i, argc, argv,
283
name_list, &start_assoc, &class);
267
286
list_destroy(name_list);
268
287
return SLURM_ERROR;
279
298
memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
280
299
cluster_cond.cluster_list = name_list;
300
cluster_cond.classification = class;
282
302
temp_list = acct_storage_g_get_clusters(db_conn, my_uid,
323
343
list_append(cluster_list, cluster);
324
344
cluster->name = xstrdup(name);
345
cluster->classification = class;
325
346
cluster->root_assoc = xmalloc(sizeof(acct_association_rec_t));
326
347
init_acct_association_rec(cluster->root_assoc);
327
348
printf(" Name = %s\n", cluster->name);
349
if(cluster->classification)
350
printf(" Classification= %s\n",
351
get_classification_str(cluster->classification));
329
cluster->root_assoc->fairshare = start_assoc.fairshare;
353
cluster->root_assoc->shares_raw = start_assoc.shares_raw;
331
cluster->root_assoc->grp_cpu_mins = start_assoc.grp_cpu_mins;
332
355
cluster->root_assoc->grp_cpus = start_assoc.grp_cpus;
333
356
cluster->root_assoc->grp_jobs = start_assoc.grp_jobs;
334
357
cluster->root_assoc->grp_nodes = start_assoc.grp_nodes;
335
358
cluster->root_assoc->grp_submit_jobs =
336
359
start_assoc.grp_submit_jobs;
337
cluster->root_assoc->grp_wall = start_assoc.grp_wall;
339
361
cluster->root_assoc->max_cpu_mins_pj =
340
362
start_assoc.max_cpu_mins_pj;
429
455
cluster_cond->cluster_list = list_create(slurm_destroy_char);
430
_set_cond(&i, argc, argv, cluster_cond->cluster_list, format_list);
456
for (i=0; i<argc; i++) {
457
int command_len = strlen(argv[i]);
458
if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))
459
|| !strncasecmp (argv[i], "Set", MAX(command_len, 3)))
461
_set_cond(&i, argc, argv, cluster_cond->cluster_list,
463
&cluster_cond->classification);
432
467
destroy_acct_cluster_cond(cluster_cond);
433
468
list_destroy(format_list);
465
500
} else if(!strncasecmp("ControlHost", object,
466
501
MAX(command_len, 8))) {
467
502
field->type = PRINT_CHOST;
468
field->name = xstrdup("Control Host");
503
field->name = xstrdup("ControlHost");
470
505
field->print_routine = print_fields_str;
471
506
} else if(!strncasecmp("ControlPort", object,
472
507
MAX(command_len, 8))) {
473
508
field->type = PRINT_CPORT;
474
field->name = xstrdup("Control Port");
509
field->name = xstrdup("ControlPort");
476
511
field->print_routine = print_fields_uint;
512
} else if(!strncasecmp("Classification", object,
513
MAX(command_len, 2))) {
514
field->type = PRINT_CPUS;
515
field->name = xstrdup("Class");
517
field->print_routine = print_fields_str;
518
} else if(!strncasecmp("CPUCount", object,
519
MAX(command_len, 2))) {
520
field->type = PRINT_CPUS;
521
field->name = xstrdup("CPUCount");
523
field->print_routine = print_fields_str;
477
524
} else if(!strncasecmp("FairShare", object,
478
525
MAX(command_len, 1))) {
479
526
field->type = PRINT_FAIRSHARE;
480
527
field->name = xstrdup("FairShare");
482
529
field->print_routine = print_fields_uint;
483
} else if(!strncasecmp("GrpCPUMins", object,
484
MAX(command_len, 8))) {
485
field->type = PRINT_GRPCM;
486
field->name = xstrdup("GrpCPUMins");
488
field->print_routine = print_fields_uint64;
489
530
} else if(!strncasecmp("GrpCPUs", object,
490
531
MAX(command_len, 8))) {
491
532
field->type = PRINT_GRPC;
510
551
field->name = xstrdup("GrpSubmit");
512
553
field->print_routine = print_fields_uint;
513
} else if(!strncasecmp("GrpWall", object,
514
MAX(command_len, 4))) {
515
field->type = PRINT_GRPW;
516
field->name = xstrdup("GrpWall");
518
field->print_routine = print_fields_time;
519
554
} else if(!strncasecmp("MaxCPUMinsPerJob", object,
520
555
MAX(command_len, 7))) {
521
556
field->type = PRINT_MAXCM;
552
587
field->name = xstrdup("MaxWall");
554
589
field->print_routine = print_fields_time;
590
} else if(!strncasecmp("NodeCount", object,
591
MAX(command_len, 5))) {
592
field->type = PRINT_NODECNT;
593
field->name = xstrdup("NodeCount");
595
field->print_routine = print_fields_uint;
596
} else if(!strncasecmp("NodeNames", object,
597
MAX(command_len, 5))) {
598
field->type = PRINT_NODES;
599
field->name = xstrdup("NodeNames");
601
field->print_routine = print_fields_str;
555
602
} else if(!strncasecmp("QOSRAWLevel", object,
556
603
MAX(command_len, 4))) {
557
604
field->type = PRINT_QOS_RAW;
633
680
cluster->control_port,
634
681
(curr_inx == field_count));
684
field->print_routine(field,
685
get_classification_str(
688
(curr_inx == field_count));
693
convert_num_unit((float)cluster->cpu_count,
694
tmp_char, sizeof(tmp_char),
696
field->print_routine(field,
698
(curr_inx == field_count));
636
701
case PRINT_FAIRSHARE:
637
702
field->print_routine(
639
cluster->root_assoc->fairshare,
640
(curr_inx == field_count));
643
field->print_routine(
646
705
(curr_inx == field_count));
703
756
assoc->max_wall_pj,
704
757
(curr_inx == field_count));
762
hostlist_t hl = hostlist_create(cluster->nodes);
765
cnt = hostlist_count(hl);
766
hostlist_destroy(hl);
768
field->print_routine(
771
(curr_inx == field_count));
775
field->print_routine(
778
(curr_inx == field_count));
708
783
qos_list = acct_storage_g_get_qos(
756
831
xmalloc(sizeof(acct_association_cond_t));
757
832
int cond_set = 0, rec_set = 0, set = 0;
758
833
List ret_list = NULL;
834
uint16_t class_cond = 0, class_rec = 0;
761
836
init_acct_association_rec(assoc);
768
843
if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))) {
770
845
if(_set_cond(&i, argc, argv,
771
assoc_cond->cluster_list, NULL))
846
assoc_cond->cluster_list,
773
849
} else if (!strncasecmp (argv[i], "Set", MAX(command_len, 3))) {
775
if(_set_rec(&i, argc, argv, NULL, assoc))
851
if(_set_rec(&i, argc, argv, NULL, assoc, &class_rec))
778
854
if(_set_cond(&i, argc, argv,
779
assoc_cond->cluster_list, NULL))
855
assoc_cond->cluster_list,
800
877
destroy_acct_association_cond(assoc_cond);
801
878
return SLURM_ERROR;
882
List temp_list = NULL;
883
acct_cluster_cond_t cluster_cond;
885
memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
886
cluster_cond.cluster_list = assoc_cond->cluster_list;
887
cluster_cond.classification = class_cond;
889
temp_list = acct_storage_g_get_clusters(db_conn, my_uid,
894
" Problem getting clusters from database. "
895
"Contact your admin.\n");
896
destroy_acct_association_rec(assoc);
897
destroy_acct_association_cond(assoc_cond);
899
} else if(!list_count(temp_list)) {
901
" The class you gave %s didn't "
902
"return any clusters.\n",
903
get_classification_str(class_cond));
904
destroy_acct_association_rec(assoc);
905
destroy_acct_association_cond(assoc_cond);
906
list_destroy(temp_list);
909
/* we are only looking for the clusters returned from
910
this query, so we free the cluster_list and replace
912
if(assoc_cond->cluster_list)
913
list_destroy(assoc_cond->cluster_list);
914
assoc_cond->cluster_list = temp_list;
804
917
printf(" Setting\n");
806
919
printf(" Default Limits =\n");
807
920
sacctmgr_print_assoc_limits(assoc);
922
printf(" Cluster Classification = %s\n",
923
get_classification_str(class_rec));
810
926
list_append(assoc_cond->acct_list, "root");
833
949
list_destroy(ret_list);
952
acct_cluster_cond_t cluster_cond;
953
acct_cluster_rec_t cluster_rec;
955
memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
956
memset(&cluster_rec, 0, sizeof(acct_cluster_rec_t));
957
/* the class has already returned these clusters so
959
cluster_cond.cluster_list = assoc_cond->cluster_list;
961
cluster_rec.classification = class_rec;
963
ret_list = acct_storage_g_modify_clusters(
964
db_conn, my_uid, &cluster_cond, &cluster_rec);
966
if(ret_list && list_count(ret_list)) {
968
ListIterator itr = list_iterator_create(ret_list);
969
printf(" Modified cluster classifications...\n");
970
while((object = list_next(itr))) {
971
printf(" %s\n", object);
973
list_iterator_destroy(itr);
975
} else if(ret_list) {
976
printf(" Nothing modified\n");
979
fprintf(stderr, " Error with request\n");
984
list_destroy(ret_list);
834
987
notice_thread_fini();
854
1007
xmalloc(sizeof(acct_cluster_cond_t));
856
1009
List ret_list = NULL;
858
1012
cluster_cond->cluster_list = list_create(slurm_destroy_char);
860
if(!_set_cond(&i, argc, argv, cluster_cond->cluster_list, NULL)) {
1014
for (i=0; i<argc; i++) {
1015
int command_len = strlen(argv[i]);
1016
if (!strncasecmp (argv[i], "Where", MAX(command_len, 5))
1017
|| !strncasecmp (argv[i], "Set", MAX(command_len, 3)))
1019
cond_set += _set_cond(&i, argc, argv,
1020
cluster_cond->cluster_list,
1022
&cluster_cond->classification);
1026
destroy_acct_cluster_cond(cluster_cond);
1028
} else if(!cond_set) {
863
1031
" No conditions given to remove, not executing.\n");
865
1033
return SLURM_ERROR;
868
if(!list_count(cluster_cond->cluster_list)) {
1036
if(!list_count(cluster_cond->cluster_list)
1037
&& !cluster_cond->classification) {
1040
"problem with delete request. "
1041
"Nothing given to delete.\n");
869
1042
destroy_acct_cluster_cond(cluster_cond);
870
1043
return SLURM_SUCCESS;
966
1140
fprintf(stderr, " We need a cluster to dump.\n");
967
1141
return SLURM_ERROR;
1143
List temp_list = NULL;
1144
acct_cluster_cond_t cluster_cond;
1145
acct_cluster_rec_t *cluster_rec = NULL;
1147
memset(&cluster_cond, 0, sizeof(acct_cluster_cond_t));
1148
cluster_cond.cluster_list = list_create(NULL);
1149
list_push(cluster_cond.cluster_list, cluster_name);
1151
temp_list = acct_storage_g_get_clusters(db_conn, my_uid,
1153
list_destroy(cluster_cond.cluster_list);
1157
" Problem getting clusters from database. "
1158
"Contact your admin.\n");
1159
xfree(cluster_name);
1163
cluster_rec = list_peek(temp_list);
1166
fprintf(stderr, " Cluster %s doesn't exist.\n",
1168
xfree(cluster_name);
1169
list_destroy(temp_list);
1172
class_str = get_classification_str(cluster_rec->classification);
1173
list_destroy(temp_list);
970
1176
if(!file_name) {
1064
1272
"MaxWallDurationPerJob=1\n") < 0) {
1066
1274
fprintf(stderr, "Can't write to file");
1275
xfree(cluster_name);
1067
1276
return SLURM_ERROR;
1070
1279
line = xstrdup_printf("Cluster - %s", cluster_name);
1282
xstrfmtcat(line, ":Classification=%s", class_str);
1072
1284
acct_hierarchical_rec = list_peek(acct_hierarchical_rec_list);
1073
1285
assoc = acct_hierarchical_rec->assoc;
1074
1286
if(strcmp(assoc->acct, "root"))