478
494
slurm_perror ("slurm_shutdown error");
481
else if (strncasecmp (argv[0], "all", 3) == 0)
497
else if (strncasecmp (tag, "all", MAX(taglen, 2)) == 0)
483
else if (strncasecmp (argv[0], "completing", 3) == 0) {
499
else if (strncasecmp (tag, "completing", MAX(taglen, 2)) == 0) {
487
503
"too many arguments for keyword:%s\n",
490
506
scontrol_print_completing();
492
else if (strncasecmp (argv[0], "exit", 1) == 0) {
508
else if (strncasecmp (tag, "create", MAX(taglen, 2)) == 0) {
511
fprintf (stderr, "too few arguments for %s keyword\n",
515
_create_it ((argc - 1), &argv[1]);
517
else if (strncasecmp (tag, "exit", MAX(taglen, 1)) == 0) {
496
521
"too many arguments for keyword:%s\n",
501
else if (strncasecmp (argv[0], "help", 2) == 0) {
526
else if (strncasecmp (tag, "help", MAX(taglen, 2)) == 0) {
505
530
"too many arguments for keyword:%s\n",
510
else if (strncasecmp (argv[0], "hide", 2) == 0)
535
else if (strncasecmp (tag, "hide", MAX(taglen, 2)) == 0)
512
else if (strncasecmp (argv[0], "oneliner", 1) == 0) {
537
else if (strncasecmp (tag, "oneliner", MAX(taglen, 1)) == 0) {
516
541
"too many arguments for keyword:%s\n",
521
else if (strncasecmp (argv[0], "pidinfo", 3) == 0) {
546
else if (strncasecmp (tag, "pidinfo", MAX(taglen, 3)) == 0) {
525
550
"too many arguments for keyword:%s\n",
527
552
} else if (argc < 2) {
530
555
"missing argument for keyword:%s\n",
533
558
scontrol_pid_info ((pid_t) atol (argv[1]) );
535
else if (strncasecmp (argv[0], "ping", 3) == 0) {
560
else if (strncasecmp (tag, "ping", MAX(taglen, 3)) == 0) {
539
564
"too many arguments for keyword:%s\n",
544
else if ((strncasecmp (argv[0], "\\q", 2) == 0) ||
545
(strncasecmp (argv[0], "quiet", 4) == 0)) {
569
else if ((strncasecmp (tag, "\\q", 2) == 0) ||
570
(strncasecmp (tag, "quiet", MAX(taglen, 4)) == 0)) {
548
573
fprintf (stderr, "too many arguments for keyword:%s\n",
553
else if (strncasecmp (argv[0], "quit", 4) == 0) {
578
else if (strncasecmp (tag, "quit", MAX(taglen, 4)) == 0) {
557
582
"too many arguments for keyword:%s\n",
562
else if (strncasecmp (argv[0], "reconfigure", 3) == 0) {
587
else if (strncasecmp (tag, "reconfigure", MAX(taglen, 3)) == 0) {
565
590
fprintf (stderr, "too many arguments for keyword:%s\n",
568
593
error_code = slurm_reconfigure ();
569
594
if (error_code) {
572
597
slurm_perror ("slurm_reconfigure error");
575
else if (strncasecmp (argv[0], "checkpoint", 5) == 0) {
600
else if (strncasecmp (tag, "checkpoint", MAX(taglen, 2)) == 0) {
578
603
if (quiet_flag != 1)
580
605
"too many arguments for keyword:%s\n",
583
608
else if (argc < 3) {
585
610
if (quiet_flag != 1)
587
612
"too few arguments for keyword:%s\n",
591
error_code = scontrol_checkpoint(argv[1], argv[2]);
616
error_code = scontrol_checkpoint(argv[1], argv[2],
592
618
if (error_code) {
594
620
if (quiet_flag != 1)
595
slurm_perror ("slurm_checkpoint error");
621
slurm_perror ("scontrol_checkpoint error");
599
else if (strncasecmp (argv[0], "requeue", 3) == 0) {
625
else if (strncasecmp (tag, "requeue", MAX(taglen, 3)) == 0) {
602
628
if (quiet_flag != 1)
604
630
"too many arguments for keyword:%s\n",
606
632
} else if (argc < 2) {
608
634
if (quiet_flag != 1)
610
636
"too few arguments for keyword:%s\n",
613
639
error_code = scontrol_requeue(argv[1]);
614
640
if (error_code) {
646
else if (strncasecmp (argv[0], "setdebug", 4) == 0) {
672
else if (strncasecmp (tag, "setdebug", MAX(taglen, 2)) == 0) {
649
675
if (quiet_flag != 1)
650
fprintf(stderr, "too many arguments for keyword:%s\n",
677
"too many arguments for keyword:%s\n",
652
679
} else if (argc < 2) {
654
681
if (quiet_flag != 1)
655
fprintf(stderr, "too few arguments for keyword:%s\n",
683
"too few arguments for keyword:%s\n",
660
688
char *levels[] = {
661
689
"quiet", "fatal", "error", "info", "verbose",
662
"debug", "debug2", "debug3", "debug4", "debug5", NULL};
690
"debug", "debug2", "debug3", "debug4",
664
693
while (levels[index]) {
665
694
if (strcasecmp(argv[1], levels[index]) == 0) {
691
else if (strncasecmp (argv[0], "show", 3) == 0) {
696
"too many arguments for keyword:%s\n",
703
"too few arguments for keyword:%s\n",
706
else if (strncasecmp (argv[1], "config", 3) == 0) {
708
_print_config (argv[2]);
710
_print_config (NULL);
712
else if (strncasecmp (argv[1], "daemons", 3) == 0) {
721
else if (strncasecmp (tag, "show", MAX(taglen, 3)) == 0) {
722
_show_it (argc, argv);
724
else if (strncasecmp (tag, "takeover", MAX(taglen, 8)) == 0) {
725
char *secondary = NULL;
726
slurm_ctl_conf_info_msg_t *slurm_ctl_conf_ptr = NULL;
728
slurm_ctl_conf_ptr = slurm_conf_lock();
729
secondary = xstrdup(slurm_ctl_conf_ptr->backup_controller);
732
if ( secondary && secondary[0] != '\0' ) {
733
error_code = slurm_takeover();
715
736
if (quiet_flag != 1)
717
"too many arguments for keyword:%s\n",
737
slurm_perror("slurm_takeover error");
722
else if (strncasecmp (argv[1], "jobs", 3) == 0) {
724
scontrol_print_job (argv[2]);
726
scontrol_print_job (NULL);
728
else if (strncasecmp (argv[1], "hostnames", 5) == 0) {
730
scontrol_print_hosts(argv[2]);
732
scontrol_print_hosts(getenv("SLURM_NODELIST"));
734
else if (strncasecmp (argv[1], "hostlist", 5) == 0) {
737
fprintf(stderr, "invalid encode argument\n");
739
} else if (scontrol_encode_hostlist(argv[2]))
742
else if (strncasecmp (argv[1], "nodes", 3) == 0) {
744
scontrol_print_node_list (argv[2]);
746
scontrol_print_node_list (NULL);
748
else if (strncasecmp (argv[1], "partitions", 3) == 0) {
750
scontrol_print_part (argv[2]);
752
scontrol_print_part (NULL);
754
else if (strncasecmp (argv[1], "slurmd", 6) == 0) {
756
_print_slurmd(argv[2]);
760
else if (strncasecmp (argv[1], "steps", 3) == 0) {
762
scontrol_print_step (argv[2]);
764
scontrol_print_step (NULL);
770
"invalid entity:%s for keyword:%s \n",
740
fprintf(stderr, "slurm_takeover error: no backup "
741
"controller defined\n");
775
else if (strncasecmp (argv[0], "shutdown", 8) == 0) {
745
else if (strncasecmp (tag, "shutdown", MAX(taglen, 8)) == 0) {
776
746
/* require full command name */
777
747
uint16_t options = 0;
804
else if (strncasecmp (argv[0], "update", 1) == 0) {
774
else if (strncasecmp (tag, "update", MAX(taglen, 1)) == 0) {
807
777
fprintf (stderr, "too few arguments for %s keyword\n",
811
781
_update_it ((argc - 1), &argv[1]);
813
else if (strncasecmp (argv[0], "delete", 3) == 0) {
783
else if (strncasecmp (tag, "delete", MAX(taglen, 1)) == 0) {
816
786
fprintf (stderr, "too few arguments for %s keyword\n",
820
790
_delete_it ((argc - 1), &argv[1]);
822
else if (strncasecmp (argv[0], "verbose", 4) == 0) {
792
else if (strncasecmp (tag, "verbose", MAX(taglen, 4)) == 0) {
826
796
"too many arguments for %s keyword\n",
831
else if (strncasecmp (argv[0], "version", 4) == 0) {
801
else if (strncasecmp (tag, "version", MAX(taglen, 4)) == 0) {
835
805
"too many arguments for %s keyword\n",
838
808
_print_version();
840
else if (strncasecmp (argv[0], "listpids", 8) == 0) {
810
else if (strncasecmp (tag, "listpids", MAX(taglen, 1)) == 0) {
844
814
"too many arguments for keyword:%s\n",
847
817
scontrol_list_pids (argc == 1 ? NULL : argv[1],
848
818
argc <= 2 ? NULL : argv[2]);
851
else if (strncasecmp (argv[0], "notify", 6) == 0) {
821
else if (strncasecmp (tag, "notify", MAX(taglen, 1)) == 0) {
855
825
"too few arguments for keyword:%s\n",
857
827
} else if (scontrol_job_notify(argc-1, &argv[1])) {
859
829
slurm_perror("job notify failure");
864
fprintf (stderr, "invalid keyword: %s\n", argv[0]);
834
fprintf (stderr, "invalid keyword: %s\n", tag);
871
* _delete_it - delete the slurm the specified slurm entity
842
* _create_it - create a slurm configuration per the supplied arguments
843
* IN argc - count of arguments
844
* IN argv - list of arguments
847
_create_it (int argc, char *argv[])
849
/* Scan for "res" first, anywhere in the args. When creating
850
a reservation there is a partition= option, which we don't
851
want to mistake for a requestion to create a partition. */
852
int i, error_code = SLURM_SUCCESS;
853
for (i=0; i<argc; i++) {
855
char *val = strchr(argv[i], '=');
859
taglen = val - argv[i];
862
taglen = strlen(tag);
864
if (!strncasecmp(tag, "ReservationName", MAX(taglen, 3))) {
865
error_code = scontrol_create_res(argc, argv);
867
} else if (!strncasecmp(tag, "PartitionName", MAX(taglen, 3))) {
868
error_code = scontrol_create_part(argc, argv);
875
error("Invalid creation entity: %s\n", argv[0]);
876
} else if (error_code)
884
* _delete_it - delete the specified slurm entity
872
885
* IN argc - count of arguments
873
886
* IN argv - list of arguments
876
889
_delete_it (int argc, char *argv[])
878
delete_part_msg_t part_msg;
891
char *tag = NULL, *val = NULL;
895
error("Only one option follows delete. %d given.\n", argc);
901
val = strchr(argv[0], '=');
903
taglen = val - argv[0];
906
error("Proper format is 'delete Partition=p'"
907
" or 'delete Reservation=r'\n");
880
912
/* First identify the entity type to delete */
881
if (strncasecmp (argv[0], "PartitionName=", 14) == 0) {
882
part_msg.name = argv[0] + 14;
913
if (strncasecmp (tag, "PartitionName", MAX(taglen, 1)) == 0) {
914
delete_part_msg_t part_msg;
883
916
if (slurm_delete_partition(&part_msg)) {
885
918
snprintf(errmsg, 64, "delete_partition %s", argv[0]);
886
919
slurm_perror(errmsg);
890
fprintf(stderr, "Invalid deletion entity: %s\n", argv[1]);
921
} else if (strncasecmp (tag, "ReservationName", MAX(taglen, 1)) == 0) {
922
reservation_name_msg_t res_msg;
924
if (slurm_delete_reservation(&res_msg)) {
926
snprintf(errmsg, 64, "delete_reservation %s", argv[0]);
927
slurm_perror(errmsg);
931
fprintf(stderr, "Invalid deletion entity: %s\n", argv[0]);
937
* _show_it - print a description of the specified slurm entity
938
* IN argc - count of arguments
939
* IN argv - list of arguments
942
_show_it (int argc, char *argv[])
944
char *tag = NULL, *val = NULL;
951
"too many arguments for keyword:%s\n",
959
"too few arguments for keyword:%s\n", argv[0]);
964
taglen = strlen(tag);
965
val = strchr(argv[1], '=');
967
taglen = val - argv[1];
969
} else if (argc == 3) {
975
if (strncasecmp (tag, "config", MAX(taglen, 1)) == 0) {
978
else if (strncasecmp (tag, "daemons", MAX(taglen, 1)) == 0) {
983
"too many arguments for keyword:%s\n",
988
else if (strncasecmp (tag, "jobs", MAX(taglen, 1)) == 0 ||
989
strncasecmp (tag, "jobid", MAX(taglen, 1)) == 0 ) {
990
scontrol_print_job (val);
992
else if (strncasecmp (tag, "hostnames", MAX(taglen, 5)) == 0) {
994
scontrol_print_hosts(val);
996
scontrol_print_hosts(getenv("SLURM_NODELIST"));
998
else if (strncasecmp (tag, "hostlist", MAX(taglen, 5)) == 0) {
1001
fprintf(stderr, "invalid encode argument\n");
1003
} else if (scontrol_encode_hostlist(val))
1006
else if (strncasecmp (tag, "nodes", MAX(taglen, 1)) == 0) {
1007
scontrol_print_node_list (val);
1009
else if (strncasecmp (tag, "partitions", MAX(taglen, 1)) == 0 ||
1010
strncasecmp (tag, "partitionname", MAX(taglen, 1)) == 0) {
1011
scontrol_print_part (val);
1013
else if (strncasecmp (tag, "reservations", MAX(taglen, 1)) == 0 ||
1014
strncasecmp (tag, "reservationname", MAX(taglen, 1)) == 0) {
1015
scontrol_print_res (val);
1017
else if (strncasecmp (tag, "slurmd", MAX(taglen, 2)) == 0) {
1018
_print_slurmd (val);
1020
else if (strncasecmp (tag, "steps", MAX(taglen, 2)) == 0) {
1021
scontrol_print_step (val);
1023
else if (strncasecmp (tag, "topology", MAX(taglen, 1)) == 0) {
1024
scontrol_print_topo (val);
1028
if (quiet_flag != 1)
1030
"invalid entity:%s for keyword:%s \n",
901
1044
_update_it (int argc, char *argv[])
903
1046
int i, error_code = SLURM_SUCCESS;
1047
int nodetag=0, partag=0, jobtag=0;
1048
int blocktag=0, subtag=0, restag=0;
905
1050
/* First identify the entity to update */
906
1051
for (i=0; i<argc; i++) {
907
if (strncasecmp (argv[i], "NodeName=", 9) == 0) {
908
error_code = scontrol_update_node (argc, argv);
910
} else if (strncasecmp (argv[i], "PartitionName=", 14) == 0) {
911
error_code = scontrol_update_part (argc, argv);
913
} else if (strncasecmp (argv[i], "JobId=", 6) == 0) {
914
error_code = scontrol_update_job (argc, argv);
916
} else if (strncasecmp (argv[i], "BlockName=", 10) == 0) {
917
error_code = _update_bluegene_block (argc, argv);
919
} else if (strncasecmp (argv[i], "SubBPName=", 10) == 0) {
920
error_code = _update_bluegene_subbp (argc, argv);
1052
char *tag = argv[i];
1054
char *val = strchr(argv[i], '=');
1057
taglen = val - argv[i];
1060
if (strncasecmp (tag, "NodeName", MAX(taglen, 5)) == 0) {
1062
} else if (strncasecmp (tag, "PartitionName", MAX(taglen, 3)) == 0) {
1064
} else if (strncasecmp (tag, "JobId", MAX(taglen, 3)) == 0) {
1066
} else if (strncasecmp (tag, "BlockName", MAX(taglen, 3)) == 0) {
1068
} else if (strncasecmp (tag, "SubBPName", MAX(taglen, 3)) == 0) {
1070
} else if (strncasecmp (tag, "ReservationName", MAX(taglen, 3)) == 0) {
1075
/* The order of tests matters here. An update job request can include
1076
partition and reservation tags, possibly before the jobid tag, but
1077
none of the other updates have a jobid tag, so check jobtag first.
1078
Likewise, check restag next, because reservations can have a
1079
partition tag. The order of the rest doesn't matter because there
1080
aren't any other duplicate tags. */
1083
error_code = scontrol_update_job (argc, argv);
1085
error_code = scontrol_update_res (argc, argv);
1087
error_code = scontrol_update_node (argc, argv);
1089
error_code = scontrol_update_part (argc, argv);
1091
error_code = _update_bluegene_block (argc, argv);
1093
error_code = _update_bluegene_subbp (argc, argv);
928
1096
fprintf(stderr, "No valid entity in update command\n");
929
1097
fprintf(stderr, "Input line must include \"NodeName\", ");
959
1129
part_msg.hidden = (uint16_t)INFINITE;
961
1131
for (i=0; i<argc; i++) {
962
if (strncasecmp(argv[i], "BlockName=", 10) == 0)
963
part_msg.name = &argv[i][10];
964
else if (strncasecmp(argv[i], "State=", 6) == 0) {
965
if (strcasecmp(&argv[i][6], "ERROR") == 0)
1132
char *tag = argv[i];
1133
char *val = strchr(argv[i], '=');
1134
int taglen = 0, vallen = 0;
1137
taglen = val - argv[i];
1139
vallen = strlen(val);
1142
error("Invalid input for BlueGene block update %s", argv[i]);
1146
if (strncasecmp(tag, "BlockName", MAX(taglen, 2)) == 0) {
1147
part_msg.name = val;
1148
} else if (strncasecmp(tag, "State", MAX(taglen, 2)) == 0) {
1149
if (strncasecmp(val, "ERROR", MAX(vallen, 1)) == 0)
966
1150
part_msg.state_up = 0;
967
else if (strcasecmp(&argv[i][6], "FREE") == 0)
1151
else if (strncasecmp(val, "FREE", MAX(vallen, 1)) == 0)
968
1152
part_msg.state_up = 1;
1012
1201
part_msg.root_only = (uint16_t)INFINITE;
1014
1203
for (i=0; i<argc; i++) {
1015
if (strncasecmp(argv[i], "SubBPName=", 10) == 0)
1016
part_msg.name = &argv[i][10];
1017
else if (strncasecmp(argv[i], "State=", 6) == 0) {
1018
if (strcasecmp(&argv[i][6], "ERROR") == 0)
1204
char *tag = argv[i];
1205
char *val = strchr(argv[i], '=');
1206
int taglen = 0, vallen = 0;
1209
taglen = val - argv[i];
1211
vallen = strlen(val);
1214
error("Invalid input for BlueGene SubBPName update %s",
1219
if (strncasecmp(tag, "SubBPName", MAX(taglen, 2)) == 0)
1220
part_msg.name = val;
1221
else if (strncasecmp(tag, "State", MAX(taglen, 2)) == 0) {
1222
if (strncasecmp(val, "ERROR", MAX(vallen, 1)) == 0)
1019
1223
part_msg.state_up = 0;
1020
else if (strcasecmp(&argv[i][6], "FREE") == 0)
1224
else if (strncasecmp(val, "FREE", MAX(vallen, 1)) == 0)
1021
1225
part_msg.state_up = 1;
1095
1306
show <ENTITY> [<ID>] display state of identified entity, default \n\
1096
1307
is all records. \n\
1097
1308
shutdown <OPTS> shutdown slurm daemons \n\
1309
takeover ask slurm backup controller to take over \n\
1310
(the primary controller will be stopped) \n\
1098
1311
suspend <job_id> susend specified job \n\
1099
1312
resume <job_id> resume previously suspended job \n\
1100
update <SPECIFICATIONS> update job, node, partition, or bluegene \n\
1101
block/subbp configuration \n\
1313
update <SPECIFICATIONS> update job, node, partition, reservation, or \n\
1314
bluegene block/subbp configuration \n\
1102
1315
verbose enable detailed logging. \n\
1103
1316
version display tool version number. \n\
1104
1317
!! Repeat the last command entered. \n\
1106
1319
<ENTITY> may be \"config\", \"daemons\", \"job\", \"node\", \"partition\"\n\
1107
\"hostlist\", \"hostnames\", \"slurmd\", \n\
1108
(for BlueGene only: \"block\", \"subbp\" or \"step\"). \n\
1320
\"reservation\", \"hostlist\", \"hostnames\", \"slurmd\", \n\
1321
\"topology\", or \"step\" \n\
1322
(also for BlueGene only: \"block\" or \"subbp\"). \n\
1110
1324
<ID> may be a configuration parameter name, job id, node name, partition \n\
1111
name, job step id, or hostlist or pathname to a list of host names. \n\
1325
name, reservation name, job step id, or hostlist or pathname to a \n\
1326
list of host names. \n\
1113
1328
<HOSTLIST> may either be a comma separated list of host names or the \n\
1114
1329
absolute pathname of a file (with leading '/' containing host names \n\