diff --git a/lib/cli.py b/lib/cli.py index feb0fe41a0e6cd0e9088381824112dbd45ba2f61..63642e1d3f2c51cee3612d9e3bd3355767a0cb12 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -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") diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py index c6dfd69e3e07e2dd5a61b03956a1f5979f959335..819bd5740848297b6e51c9ed439a1f364aeb0c32 100644 --- a/lib/client/gnt_instance.py +++ b/lib/client/gnt_instance.py @@ -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, diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst index 77bec0d5435e5537e46e1a9442d04ff605c5c4af..b71643a15253ca93079da3024922792c400fa711 100644 --- a/man/gnt-instance.rst +++ b/man/gnt-instance.rst @@ -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.