Add --wait-for-sync in gnt-instance
authorIustin Pop <iustin@google.com>
Thu, 5 Jul 2012 13:27:02 +0000 (15:27 +0200)
committerIustin Pop <iustin@google.com>
Thu, 5 Jul 2012 16:11:04 +0000 (18:11 +0200)
Note that this needs (like for the opcode) a new option, with the
default reverted (False instead of True).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenĂ© Nussbaumer <rn@google.com>

lib/cli.py
lib/client/gnt_instance.py
man/gnt-instance.rst

index feb0fe4..63642e1 100644 (file)
@@ -195,6 +195,7 @@ __all__ = [
   "USE_REPL_NET_OPT",
   "VERBOSE_OPT",
   "VG_NAME_OPT",
+  "WFSYNC_OPT",
   "YES_DOIT_OPT",
   "DISK_STATE_OPT",
   "HV_STATE_OPT",
@@ -747,6 +748,10 @@ NWSYNC_OPT = cli_option("--no-wait-for-sync", dest="wait_for_sync",
                         default=True, action="store_false",
                         help="Don't wait for sync (DANGEROUS!)")
 
+WFSYNC_OPT = cli_option("--wait-for-sync", dest="wait_for_sync",
+                        default=False, action="store_true",
+                        help="Wait for disks to sync")
+
 ONLINE_INST_OPT = cli_option("--online", dest="online_inst",
                              action="store_true", default=False,
                              help="Enable offline instance")
index c6dfd69..819bd57 100644 (file)
@@ -566,7 +566,8 @@ def ActivateDisks(opts, args):
   """
   instance_name = args[0]
   op = opcodes.OpInstanceActivateDisks(instance_name=instance_name,
-                                       ignore_size=opts.ignore_size)
+                                       ignore_size=opts.ignore_size,
+                                       wait_for_sync=opts.wait_for_sync)
   disks_info = SubmitOrSend(op, opts)
   for host, iname, nname in disks_info:
     ToStdout("%s:%s:%s", host, iname, nname)
@@ -1620,7 +1621,7 @@ commands = {
     "<instance>", "Reboots an instance"),
   "activate-disks": (
     ActivateDisks, ARGS_ONE_INSTANCE,
-    [SUBMIT_OPT, IGNORE_SIZE_OPT, PRIORITY_OPT],
+    [SUBMIT_OPT, IGNORE_SIZE_OPT, PRIORITY_OPT, WFSYNC_OPT],
     "<instance>", "Activate an instance's disks"),
   "deactivate-disks": (
     DeactivateDisks, ARGS_ONE_INSTANCE,
index 77bec0d..b71643a 100644 (file)
@@ -1301,7 +1301,7 @@ options.
 ACTIVATE-DISKS
 ^^^^^^^^^^^^^^
 
-**activate-disks** [\--submit] [\--ignore-size] {*instance*}
+**activate-disks** [\--submit] [\--ignore-size] [\--wait-for-sync] {*instance*}
 
 Activates the block devices of the given instance. If successful, the
 command will show the location and name of the block devices::
@@ -1323,6 +1323,13 @@ where the configuration has gotten out of sync with the real-world
 in LVM devices). This should not be used in normal cases, but only
 when activate-disks fails without it.
 
+The ``--wait-for-sync`` option will ensure that the command returns only
+after the instance's disks are synchronised (mostly for DRBD); this can
+be useful to ensure consistency, as otherwise there are no commands that
+can wait until synchronisation is done. However when passing this
+option, the command will have additional output, making it harder to
+parse the disk information.
+
 Note that it is safe to run this command while the instance is already
 running.