From 2f02b454c02a68c0feb252bbb54b382f6062b9c7 Mon Sep 17 00:00:00 2001
From: Don Lipari <lipari1@llnl.gov>
Date: Fri, 13 Nov 2009 21:00:12 +0000
Subject: [PATCH] -- Change the salloc/sbatch/srun -P option to -d (dependency)
 -- Removed the srun -d option; must use srun --slurmd-debug instead

---
 NEWS                      |  4 +++-
 doc/html/power_save.shtml |  4 ++--
 src/salloc/opt.c          | 11 +++++++----
 src/sbatch/opt.c          | 14 ++++++++------
 src/srun/opt.c            | 18 ++++++++++++------
 5 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index 74073e95f93..9c8ac6c6e88 100644
--- a/NEWS
+++ b/NEWS
@@ -3,7 +3,9 @@ documents those changes that are of interest to users and admins.
 
 * Changes in SLURM 2.1.0-pre8
 =============================
- -- Rearranged the "scontrol show job" output into functional groupings.
+ -- Rearranged the "scontrol show job" output into functional groupings
+ -- Change the salloc/sbatch/srun -P option to -d (dependency)
+ -- Removed the srun -d option; must use srun --slurmd-debug instead
 
 * Changes in SLURM 2.1.0-pre7
 =============================
diff --git a/doc/html/power_save.shtml b/doc/html/power_save.shtml
index 9fe17d3d1d4..b8094d10adb 100644
--- a/doc/html/power_save.shtml
+++ b/doc/html/power_save.shtml
@@ -128,7 +128,7 @@ scripts.</p>
 <pre>
 #!/bin/bash
 # Example SuspendProgram
-logger "Suspend invoked $0 $*"
+echo "Suspend invoked $0 $*" >>/var/log/power_save.log
 hosts=`scontrol show hostnames $1`
 for host in "$hosts"
 do
@@ -137,7 +137,7 @@ done
 
 #!/bin/bash
 # Example ResumeProgram
-logger "Resume invoked $0 $*"
+echo "Resume invoked $0 $*" >>/var/log/power_save.log
 hosts=`scontrol show hostnames $1`
 for host in "$hosts"
 do
diff --git a/src/salloc/opt.c b/src/salloc/opt.c
index 5c1018c00a7..7ff825923ee 100644
--- a/src/salloc/opt.c
+++ b/src/salloc/opt.c
@@ -571,6 +571,7 @@ void set_options(const int argc, char **argv)
 		{"extra-node-info", required_argument, 0, 'B'},
 		{"cpus-per-task", required_argument, 0, 'c'},
 		{"constraint",    required_argument, 0, 'C'},
+		{"dependency",    required_argument, 0, 'd'},
 		{"chdir",         required_argument, 0, 'D'},
 		{"nodefile",      required_argument, 0, 'F'},
 		{"geometry",      required_argument, 0, 'g'},
@@ -587,7 +588,6 @@ void set_options(const int argc, char **argv)
 		{"nodes",         required_argument, 0, 'N'},
 		{"overcommit",    no_argument,       0, 'O'},
 		{"partition",     required_argument, 0, 'p'},
-		{"dependency",    required_argument, 0, 'P'},
 		{"quiet",         no_argument,       0, 'Q'},
 		{"no-rotate",     no_argument,       0, 'R'},
 		{"share",         no_argument,       0, 's'},
@@ -694,7 +694,10 @@ void set_options(const int argc, char **argv)
 			xfree(opt.constraints);
 			opt.constraints = xstrdup(optarg);
 			break;
-/* 		case 'd':	see 'P' below */
+		case 'd':
+			xfree(opt.dependency);
+			opt.dependency = xstrdup(optarg);
+			break;
 		case 'D':
 			xfree(opt.cwd);
 			opt.cwd = xstrdup(optarg);
@@ -775,8 +778,8 @@ void set_options(const int argc, char **argv)
 			xfree(opt.partition);
 			opt.partition = xstrdup(optarg);
 			break;
-		case 'd':
 		case 'P':
+			verbose("-P option is deprecated, use -d instead");
 			xfree(opt.dependency);
 			opt.dependency = xstrdup(optarg);
 			break;
@@ -1758,6 +1761,7 @@ static void _help(void)
 "      --bell                  ring the terminal bell when the job is allocated\n"
 "  -c, --cpus-per-task=ncpus   number of cpus required per task\n"
 "      --comment=name          arbitrary comment\n"
+"  -d, --dependency=type:jobid defer job until condition on jobid is satisfied\n"
 "  -D, --chdir=path            change working directory\n"
 "      --get-user-env          used by Moab.  See srun man page.\n"
 "      --gid=group_id          group ID to run job as (user root only)\n"
@@ -1780,7 +1784,6 @@ static void _help(void)
 "  -N, --nodes=N               number of nodes on which to run (N = min[-max])\n"
 "  -O, --overcommit            overcommit resources\n"
 "  -p, --partition=partition   partition requested\n"
-"  -P, --dependency=type:jobid defer job until condition on jobid is satisfied\n"
 "      --qos=qos               quality of service\n"
 "  -Q, --quiet                 quiet mode (suppress informational messages)\n"
 "  -s, --share                 share nodes with other jobs\n"
diff --git a/src/sbatch/opt.c b/src/sbatch/opt.c
index b82a45c31af..c6eafb93729 100644
--- a/src/sbatch/opt.c
+++ b/src/sbatch/opt.c
@@ -625,6 +625,7 @@ static struct option long_options[] = {
 	{"extra-node-info", required_argument, 0, 'B'},
 	{"cpus-per-task", required_argument, 0, 'c'},
 	{"constraint",    required_argument, 0, 'C'},
+	{"dependency",    required_argument, 0, 'd'},
 	{"workdir",       required_argument, 0, 'D'},
 	{"error",         required_argument, 0, 'e'},
 	{"nodefile",      required_argument, 0, 'F'},
@@ -637,13 +638,12 @@ static struct option long_options[] = {
 	{"no-kill",       no_argument,       0, 'k'},
 	{"licenses",      required_argument, 0, 'L'},
 	{"distribution",  required_argument, 0, 'm'},
-	{"tasks",         required_argument, 0, 'n'},	
+	{"tasks",         required_argument, 0, 'n'},
 	{"ntasks",        required_argument, 0, 'n'},
 	{"nodes",         required_argument, 0, 'N'},
 	{"output",        required_argument, 0, 'o'},
 	{"overcommit",    no_argument,       0, 'O'},
 	{"partition",     required_argument, 0, 'p'},
-	{"dependency",    required_argument, 0, 'P'},
 	{"quiet",         no_argument,       0, 'Q'},
 	{"no-rotate",     no_argument,       0, 'R'},
 	{"share",         no_argument,       0, 's'},
@@ -1112,7 +1112,10 @@ static void _set_options(int argc, char **argv)
 			xfree(opt.constraints);
 			opt.constraints = xstrdup(optarg);
 			break;
-/*		case 'd': See 'P' below */
+		case 'd':
+			xfree(opt.dependency);
+			opt.dependency = xstrdup(optarg);
+			break;
 		case 'D':
 			xfree(opt.cwd);
 			opt.cwd = xstrdup(optarg);
@@ -1205,9 +1208,8 @@ static void _set_options(int argc, char **argv)
 			xfree(opt.partition);
 			opt.partition = xstrdup(optarg);
 			break;
-		case 'd':
 		case 'P':
-			/* use -P instead of -d (deprecated) */
+			verbose("-P option is deprecated, use -d instead");
 			xfree(opt.dependency);
 			opt.dependency = xstrdup(optarg);
 			break;
@@ -2612,6 +2614,7 @@ static void _help(void)
 "      --begin=time            defer job until HH:MM DD/MM/YY\n"
 "  -c, --cpus-per-task=ncpus   number of cpus required per task\n"
 "      --comment=name          arbitrary comment\n"
+"  -d, --dependency=type:jobid defer job until condition on jobid is satisfied\n"
 "  -D, --workdir=directory     set working directory for batch script\n"
 "  -e, --error=err             file for batch script's standard error\n"
 "      --get-user-env          used by Moab.  See srun man page.\n"
@@ -2637,7 +2640,6 @@ static void _help(void)
 "  -O, --overcommit            overcommit resources\n"
 "  -p, --partition=partition   partition requested\n"
 "      --propagate[=rlimits]   propagate all [or specific list of] rlimits\n"
-"  -P, --dependency=type:jobid defer job until condition on jobid is satisfied\n"
 "      --qos=qos               quality of service\n"
 "  -Q, --quiet                 quiet mode (suppress informational messages)\n"
 "      --requeue               if set, permit the job to be requeued\n"
diff --git a/src/srun/opt.c b/src/srun/opt.c
index 4bc248c5469..67e42f48577 100644
--- a/src/srun/opt.c
+++ b/src/srun/opt.c
@@ -181,6 +181,7 @@
 #define LONG_OPT_RESERVATION     0x14c
 #define LONG_OPT_RESTART_DIR     0x14d
 #define LONG_OPT_SIGNAL          0x14e
+#define LONG_OPT_DEBUG_SLURMD    0x14f
 
 /*---- global variables, defined in opt.h ----*/
 int _verbose;
@@ -714,7 +715,7 @@ static void set_options(const int argc, char **argv)
 		{"extra-node-info", required_argument, 0, 'B'},
 		{"cpus-per-task", required_argument, 0, 'c'},
 		{"constraint",    required_argument, 0, 'C'},
-		{"slurmd-debug",  required_argument, 0, 'd'},
+		{"dependency",    required_argument, 0, 'd'},
 		{"chdir",         required_argument, 0, 'D'},
 		{"error",         required_argument, 0, 'e'},
 		{"preserve-env",  no_argument,       0, 'E'},
@@ -735,7 +736,6 @@ static void set_options(const int argc, char **argv)
 		{"output",        required_argument, 0, 'o'},
 		{"overcommit",    no_argument,       0, 'O'},
 		{"partition",     required_argument, 0, 'p'},
-		{"dependency",    required_argument, 0, 'P'},
 		{"quit-on-interrupt", no_argument,   0, 'q'},
 		{"quiet",            no_argument,    0, 'Q'},
 		{"relative",      required_argument, 0, 'r'},
@@ -804,6 +804,7 @@ static void set_options(const int argc, char **argv)
 		{"restart-dir",      required_argument, 0, LONG_OPT_RESTART_DIR},
 		{"resv-ports",       optional_argument, 0, LONG_OPT_RESV_PORTS},
 		{"signal",	     required_argument, 0, LONG_OPT_SIGNAL},
+		{"slurmd-debug",     required_argument, 0, LONG_OPT_DEBUG_SLURMD},
 		{"sockets-per-node", required_argument, 0, LONG_OPT_SOCKETSPERNODE},
 		{"task-epilog",      required_argument, 0, LONG_OPT_TASK_EPILOG},
 		{"task-prolog",      required_argument, 0, LONG_OPT_TASK_PROLOG},
@@ -878,8 +879,8 @@ static void set_options(const int argc, char **argv)
 			opt.constraints = xstrdup(optarg);
 			break;
 		case (int)'d':
-			opt.slurmd_debug = 
-				_get_int(optarg, "slurmd-debug", false);
+			xfree(opt.dependency);
+			opt.dependency = xstrdup(optarg);
 			break;
 		case (int)'D':
 			opt.cwd_set = true;
@@ -994,6 +995,7 @@ static void set_options(const int argc, char **argv)
 			opt.partition = xstrdup(optarg);
 			break;
 		case (int)'P':
+			verbose("-P option is deprecated, use -d instead");
 			xfree(opt.dependency);
 			opt.dependency = xstrdup(optarg);
 			break;
@@ -1187,6 +1189,10 @@ static void set_options(const int argc, char **argv)
 				exit(error_exit);
 			}
 			break;
+		case LONG_OPT_DEBUG_SLURMD:
+			opt.slurmd_debug =
+				_get_int(optarg, "slurmd-debug", false);
+			break;
 		case LONG_OPT_DEBUG_TS:
 			opt.debugger_test    = true;
 			/* make other parameters look like debugger 
@@ -2233,7 +2239,7 @@ static void _help(void)
 "      --comment=name          arbitrary comment\n"
 "      --core=type             change default corefile format type\n"
 "                              (type=\"list\" to list of valid formats)\n"
-"  -d, --slurmd-debug=level    slurmd debug level\n"
+"  -d, --dependency=type:jobid defer job until condition on jobid is satisfied\n"
 "  -D, --chdir=path            change remote current working directory\n"
 "  -e, --error=err             location of stderr redirection\n"
 "      --epilog=program        run \"program\" after launching job step\n"
@@ -2270,7 +2276,6 @@ static void _help(void)
 #ifdef HAVE_PTY_H
 "      --pty                   run task zero in pseudo terminal\n"
 #endif
-"  -P, --dependency=type:jobid defer job until condition on jobid is satisfied\n"
 "  -q, --quit-on-interrupt     quit on single Ctrl-C\n"
 "      --qos=qos               quality of service\n"
 "  -Q, --quiet                 quiet mode (suppress informational messages)\n"
@@ -2278,6 +2283,7 @@ static void _help(void)
 "      --restart-dir=dir       directory of checkpoint image files to restart\n"
 "                              from\n"
 "  -s, --share                 share nodes with other jobs\n"
+"      --slurmd-debug=level    slurmd debug level\n"
 "  -t, --time=minutes          time limit\n"
 "      --task-epilog=program   run \"program\" after launching task\n"
 "      --task-prolog=program   run \"program\" before launching task\n"
-- 
GitLab