Commit eb28ecf6 authored by Guido Trotter's avatar Guido Trotter
Browse files

Merge the common options between import and add



The "I always wanted to do this" commit.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 04367e70
......@@ -207,6 +207,7 @@ __all__ = [
"SplitNodeOption",
"CalculateOSNames",
"ParseFields",
"COMMON_CREATE_OPTS",
]
NO_PREFIX = "no_"
......@@ -1103,6 +1104,29 @@ PREALLOC_WIPE_DISKS_OPT = cli_option("--prealloc-wipe-disks", default=None,
#: Options provided by all commands
COMMON_OPTS = [DEBUG_OPT]
# common options for creating instances. add and import then add their own
# specific ones.
COMMON_CREATE_OPTS = [
BACKEND_OPT,
DISK_OPT,
DISK_TEMPLATE_OPT,
FILESTORE_DIR_OPT,
FILESTORE_DRIVER_OPT,
HYPERVISOR_OPT,
IALLOCATOR_OPT,
NET_OPT,
NODE_PLACEMENT_OPT,
NOIPCHECK_OPT,
NONAMECHECK_OPT,
NONICS_OPT,
NWSYNC_OPT,
OSPARAMS_OPT,
OS_SIZE_OPT,
SUBMIT_OPT,
DRY_RUN_OPT,
PRIORITY_OPT,
]
def _ParseArgs(argv, commands, aliases):
"""Parser for the command line arguments.
......
......@@ -18,7 +18,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
"""Empty file for package definition.
"""Common command line client code.
"""
......@@ -115,27 +115,9 @@ def RemoveExport(opts, args):
# this is defined separately due to readability only
import_opts = [
BACKEND_OPT,
DISK_OPT,
DISK_TEMPLATE_OPT,
FILESTORE_DIR_OPT,
FILESTORE_DRIVER_OPT,
HYPERVISOR_OPT,
IALLOCATOR_OPT,
IDENTIFY_DEFAULTS_OPT,
NET_OPT,
NODE_PLACEMENT_OPT,
NOIPCHECK_OPT,
NONAMECHECK_OPT,
NONICS_OPT,
NWSYNC_OPT,
OSPARAMS_OPT,
OS_SIZE_OPT,
SRC_DIR_OPT,
SRC_NODE_OPT,
SUBMIT_OPT,
DRY_RUN_OPT,
PRIORITY_OPT,
]
......@@ -152,7 +134,7 @@ commands = {
"-n <target_node> [opts...] <name>",
"Exports an instance to an image"),
'import': (
ImportInstance, ARGS_ONE_INSTANCE, import_opts,
ImportInstance, ARGS_ONE_INSTANCE, COMMON_CREATE_OPTS + import_opts,
"[...] -t disk-type -n node[:secondary-node] <name>",
"Imports an instance from an exported image"),
'remove': (
......
......@@ -1377,33 +1377,15 @@ m_inst_tags_opt = cli_option("--tags", dest="multi_mode",
# this is defined separately due to readability only
add_opts = [
BACKEND_OPT,
DISK_OPT,
DISK_TEMPLATE_OPT,
FILESTORE_DIR_OPT,
FILESTORE_DRIVER_OPT,
HYPERVISOR_OPT,
IALLOCATOR_OPT,
NET_OPT,
NODE_PLACEMENT_OPT,
NOIPCHECK_OPT,
NONAMECHECK_OPT,
NONICS_OPT,
NOSTART_OPT,
NWSYNC_OPT,
OSPARAMS_OPT,
OS_OPT,
FORCE_VARIANT_OPT,
NO_INSTALL_OPT,
OS_SIZE_OPT,
SUBMIT_OPT,
DRY_RUN_OPT,
PRIORITY_OPT,
]
commands = {
'add': (
AddInstance, [ArgHost(min=1, max=1)], add_opts,
AddInstance, [ArgHost(min=1, max=1)], COMMON_CREATE_OPTS + add_opts,
"[...] -t disk-type -n node[:secondary-node] -o os-type <name>",
"Creates and adds a new instance to the cluster"),
'batch-create': (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment