From 949bdabea1ccd4ef88a4bd695a5c566a154d1f35 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Wed, 15 Apr 2009 11:11:12 +0000
Subject: [PATCH] A bunch of doc and other small fixes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch adds a couple of both externally and internally reported
issues:
  - missing SGML tags (Issue 54), report and patch by superdupont
  - wrong variable used in the init.d script, report and patch by
    Karsten Keil <karsten-keil@t-online.de>
  - man page for gnt-instance reinstall needs clarification (Issue 56)
  - gnt-instance man page missing --disks documentation for
    replace-disks
  - gnt-node modify help output is unclear about the -C/-D/-O input
    format, and the man page doesn't document this command at all
  - β€œgnt-node modify -C yes” for offline or drained nodes had wrong
    error message
  - β€œgnt-instance reinstall --select-os” has wrong prompt, we only
    accept a number for the OS and not the template name

Reviewed-by: ultrotter
---
 doc/examples/ganeti.initd.in |  2 +-
 lib/cmdlib.py                |  2 +-
 man/gnt-backup.sgml          |  1 +
 man/gnt-debug.sgml           |  1 +
 man/gnt-instance.sgml        | 30 +++++++++++++++++-------
 man/gnt-node.sgml            | 45 ++++++++++++++++++++++++++++++++++++
 scripts/gnt-instance         |  8 +++----
 scripts/gnt-node             |  6 +++--
 8 files changed, 79 insertions(+), 16 deletions(-)

diff --git a/doc/examples/ganeti.initd.in b/doc/examples/ganeti.initd.in
index 8a9662ca1..10bc684da 100644
--- a/doc/examples/ganeti.initd.in
+++ b/doc/examples/ganeti.initd.in
@@ -64,7 +64,7 @@ check_exitcode() {
 start_action() {
     # called as start_action daemon pidfile
     local daemon="$1"; shift
-    local pidfile="$2"; shift
+    local pidfile="$1"; shift
     log_action_begin_msg "$daemon"
     start-stop-daemon --start --quiet --exec "$daemon" --pidfile "$pidfile" \
         -- "$@"
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 3ad5b1a60..01a8c93b4 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -2335,7 +2335,7 @@ class LUSetNodeParams(LogicalUnit):
         ((node.offline and not self.op.offline == False) or
          (node.drained and not self.op.drained == False))):
       raise errors.OpPrereqError("Node '%s' is offline or drained, can't set"
-                                 " to master_candidate")
+                                 " to master_candidate" % node.name)
 
     return
 
diff --git a/man/gnt-backup.sgml b/man/gnt-backup.sgml
index da01af234..f7efd7836 100644
--- a/man/gnt-backup.sgml
+++ b/man/gnt-backup.sgml
@@ -331,6 +331,7 @@
 <screen>
 # gnt-backup list --nodes node1 --nodes node2
 </screen>
+      </para>
     </refsect2>
 
     <refsect2>
diff --git a/man/gnt-debug.sgml b/man/gnt-debug.sgml
index 26639d564..2e624b053 100644
--- a/man/gnt-debug.sgml
+++ b/man/gnt-debug.sgml
@@ -107,6 +107,7 @@
         for more details about this framework, see the HTML or PDF
         documentation.
       </para>
+    </refsect2>
 
     <refsect2>
       <title>DELAY</title>
diff --git a/man/gnt-instance.sgml b/man/gnt-instance.sgml
index 4191a44be..f74f398c3 100644
--- a/man/gnt-instance.sgml
+++ b/man/gnt-instance.sgml
@@ -1225,10 +1225,16 @@ instance5: 11225
         </cmdsynopsis>
 
         <para>
-          Reinstalls the operating system on the given instance. The instance
-          must be stopped when running this command. If the
-          <option>--os-type</option> is specified, the operating system is
-          changed.
+          Reinstalls the operating system on the given instance. The
+          instance must be stopped when running this command. If the
+          <option>--os-type</option> is specified, the operating
+          system is changed.
+        </para>
+
+        <para>
+          Since reinstall is potentially dangerous command, the user
+          will be required to confirm this action, unless the
+          <option>-f</option> flag is passed.
         </para>
 
         <para>
@@ -1547,6 +1553,7 @@ instance5: 11225
           <command>replace-disks</command>
           <arg>--submit</arg>
           <arg choice="req">-p</arg>
+          <arg>--disks <replaceable>idx</replaceable></arg>
           <arg choice="req"><replaceable>instance</replaceable></arg>
         </cmdsynopsis>
 
@@ -1554,6 +1561,7 @@ instance5: 11225
           <command>replace-disks</command>
           <arg>--submit</arg>
           <arg choice="req">-s</arg>
+          <arg>--disks <replaceable>idx</replaceable></arg>
           <arg choice="req"><replaceable>instance</replaceable></arg>
         </cmdsynopsis>
 
@@ -1569,16 +1577,22 @@ instance5: 11225
         </cmdsynopsis>
 
         <para>
-          This command is a generalized form for adding and replacing
-          disks. It is currently only valid for the mirrored (DRBD)
-          disk template.
+          This command is a generalized form for replacing disks. It
+          is currently only valid for the mirrored (DRBD) disk
+          template.
         </para>
 
         <para>
           The first form (when passing the <option>-p</option> option)
           will replace the disks on the primary, while the second form
           (when passing the <option>-s</option> option will replace
-          the disks on the secondary node.
+          the disks on the secondary node. For these two cases (as the
+          node doesn't change), it is possible to only run the replace
+          for a subset of the disks, using the option
+          <option>--disks</option> which takes a list of
+          comma-delimited disk indices (zero-based),
+          e.g. <userinput>0,2</userinput> to replace only the first
+          and third disks.
         </para>
 
         <para>
diff --git a/man/gnt-node.sgml b/man/gnt-node.sgml
index 62355f089..b3c4f3e26 100644
--- a/man/gnt-node.sgml
+++ b/man/gnt-node.sgml
@@ -502,6 +502,51 @@
 
     </refsect2>
 
+    <refsect2>
+      <title>MODIFY</title>
+      <cmdsynopsis>
+        <command>modify</command>
+        <arg>-f</arg>
+        <arg>--submit</arg>
+        <arg>--master-candidate=<option>yes|no</option></arg>
+        <arg>--drained=<option>yes|no</option></arg>
+        <arg>--offline=<option>yes|no</option></arg>
+        <arg choice="req"><replaceable>node</replaceable></arg>
+      </cmdsynopsis>
+
+      <para>
+        This command changes the role of the node. Each options takes
+        either a literal <literal>yes</literal> or
+        <literal>no</literal>, and only one option should be given as
+        <literal>yes</literal>. The meaning of the roles are described
+        in the manpage <citerefentry>
+        <refentrytitle>ganeti</refentrytitle> <manvolnum>7</manvolnum>
+        </citerefentry>.
+      </para>
+
+      <para>
+        In case a node is demoted from the master candidate role, but
+        there are not enough new nodes for this case, the operation
+        will be refused. To override this check, pass the
+        <option>--force</option> option.
+      </para>
+
+      <para>
+        Example (setting a node offline, which will demote it from
+        master candidate role if is in that role):
+        <screen>
+# gnt-node modify --offline=yes node1.example.com
+        </screen>
+      </para>
+
+      <para>Example (setting the node back to online and master candidate):
+        <screen>
+# gnt-node modify --offline=no --master-candidate=yes node1.example.com
+        </screen>
+      </para>
+
+    </refsect2>
+
     <refsect2>
       <title>REMOVE</title>
 
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index 8e4da17d4..9572e5863 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -543,7 +543,7 @@ def ReinstallInstance(opts, args):
       number = number + 1
 
     choices.append(('x', 'exit', 'Exit gnt-instance reinstall'))
-    selected = AskUser("Enter OS template name or number (or x to abort):",
+    selected = AskUser("Enter OS template number (or x to abort):",
                        choices)
 
     if selected == 'exit':
@@ -1416,9 +1416,9 @@ commands = {
                                  help=("Replace the disk(s) on the secondary"
                                        " node (only for the drbd template)")),
                      make_option("--disks", dest="disks", default=None,
-                                 help=("Comma-separated list of disks"
-                                       " to replace (e.g. sda) (optional,"
-                                       " defaults to all disks")),
+                                 help="Comma-separated list of disks"
+                                 " indices to replace (e.g. 0,2) (optional,"
+                                 " defaults to all disks)"),
                      make_option("-I", "--iallocator", metavar="<NAME>",
                                  help="Select new secondary for the instance"
                                  " automatically using the"
diff --git a/scripts/gnt-node b/scripts/gnt-node
index c421096df..5259678cd 100755
--- a/scripts/gnt-node
+++ b/scripts/gnt-node
@@ -541,11 +541,13 @@ commands = {
               SUBMIT_OPT,
               make_option("-C", "--master-candidate", dest="master_candidate",
                           choices=('yes', 'no'), default=None,
+                          metavar="yes|no",
                           help="Set the master_candidate flag on the node"),
-              make_option("-O", "--offline", dest="offline",
+
+              make_option("-O", "--offline", dest="offline", metavar="yes|no",
                           choices=('yes', 'no'), default=None,
                           help="Set the offline flag on the node"),
-              make_option("-D", "--drained", dest="drained",
+              make_option("-D", "--drained", dest="drained", metavar="yes|no",
                           choices=('yes', 'no'), default=None,
                           help="Set the drained flag on the node"),
               ],
-- 
GitLab