This is not straight-forward. First, gnt-cluster had
“--backend-parameters” wheres the rest of the script had just
“--backend”. I settled on the full form, since one can always abbreviate
options, but not vice-versa.
Second, the help in some cases was different, e.g. start instance
had “Temporary backend parameters” and modify had “Change backend
parameters”. I think this kind of distinctions are better served in the
man page. Alternatively, if we could copy options easily, one could
re-instantiate them with a changed help line.
---
lib/cli.py | 5 +++++
scripts/gnt-backup | 4 +---
scripts/gnt-cluster | 8 ++------
scripts/gnt-instance | 12 +++---------
4 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/lib/cli.py b/lib/cli.py
index dbea1d7..5898d06 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -44,6 +44,7 @@ from optparse import (OptionParser, TitledHelpFormatter,
__all__ = [
# Command line options
+ "BACKEND_OPT",
"CONFIRM_OPT",
"DEBUG_OPT",
"DEBUG_SIMERR_OPT",
@@ -511,6 +512,10 @@ OS_OPT = cli_option("-o", "--os-type", dest="os",
help="What OS to run",
metavar="<os>",
completion_suggest=OPT_COMPL_ONE_OS)
+BACKEND_OPT = cli_option("-B", "--backend-parameters", dest="beparams",
+ type="keyval", default={},
+ help="Backend parameters")
+
def _ParseArgs(argv, commands, aliases):
"""Parser for the command line arguments.
diff --git a/scripts/gnt-backup b/scripts/gnt-backup
index 8985c8a..0e404fa 100755
--- a/scripts/gnt-backup
+++ b/scripts/gnt-backup
@@ -215,9 +215,7 @@ import_opts = [
help="Target node and optional secondary node",
metavar="<pnode>[:<snode>]",
completion_suggest=OPT_COMPL_INST_ADD_NODES),
- cli_option("-B", "--backend", dest="beparams",
- type="keyval", default={},
- help="Backend parameters"),
+ BACKEND_OPT,
DISK_TEMPLATE_OPT,
cli_option("--disk", help="Disk information",
default=[], dest="disks",
diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster
index fb34cca..eeea8ee 100755
--- a/scripts/gnt-cluster
+++ b/scripts/gnt-cluster
@@ -641,9 +641,7 @@ commands = {
default=[],
action="append",
type="identkeyval"),
- cli_option("-B", "--backend-parameters", dest="beparams",
- type="keyval", default={},
- help="Backend parameters"),
+ BACKEND_OPT,
cli_option("-N", "--nic-parameters", dest="nicparams",
type="keyval", default={},
help="NIC parameters"),
@@ -743,9 +741,7 @@ commands = {
default=[],
action="append",
type="identkeyval"),
- cli_option("-B", "--backend-parameters", dest="beparams",
- type="keyval", default={},
- help="Backend parameters"),
+ BACKEND_OPT,
cli_option("-N", "--nic-parameters", dest="nicparams",
type="keyval", default={},
help="NIC parameters"),
diff --git a/scripts/gnt-instance b/scripts/gnt-instance
index d1c2b31..58a8750 100755
--- a/scripts/gnt-instance
+++ b/scripts/gnt-instance
@@ -1368,9 +1368,7 @@ add_opts = [
metavar="<pnode>[:<snode>]",
completion_suggest=OPT_COMPL_INST_ADD_NODES),
OS_OPT,
- cli_option("-B", "--backend", dest="beparams",
- type="keyval", default={},
- help="Backend parameters"),
+ BACKEND_OPT,
DISK_TEMPLATE_OPT,
cli_option("-s", "--os-size", dest="sd_size", help="Disk size for a"
" single-disk configuration, when not using the --disk option,"
@@ -1545,9 +1543,7 @@ commands = {
cli_option("-H", "--hypervisor", type="keyval",
default={}, dest="hypervisor",
help="Change hypervisor parameters"),
- cli_option("-B", "--backend", type="keyval",
- default={}, dest="beparams",
- help="Change backend parameters"),
+ BACKEND_OPT,
cli_option("--disk", help="Disk changes",
default=[], dest="disks",
action="append",
@@ -1573,9 +1569,7 @@ commands = {
cli_option("-H", "--hypervisor", type="keyval",
default={}, dest="hvparams",
help="Temporary hypervisor parameters"),
- cli_option("-B", "--backend", type="keyval",
- default={}, dest="beparams",
- help="Temporary backend parameters"),
+ BACKEND_OPT,
],
"<instance>", "Starts an instance"),
'reboot': (RebootInstance, [ArgInstance(min=1)],
--
1.6.3.3