import sys
import textwrap
import os.path
-import copy
import time
import logging
from cStringIO import StringIO
"FIELDS_OPT",
"FILESTORE_DIR_OPT",
"FILESTORE_DRIVER_OPT",
+ "FORCE_OPT",
+ "FORCE_VARIANT_OPT",
"GLOBAL_FILEDIR_OPT",
"HVLIST_OPT",
"HVOPTS_OPT",
"IGNORE_FAILURES_OPT",
"IGNORE_SECONDARIES_OPT",
"IGNORE_SIZE_OPT",
- "FORCE_OPT",
"MAC_PREFIX_OPT",
"MASTER_NETDEV_OPT",
"MC_OPT",
"STATIC_OPT",
"SYNC_OPT",
"TAG_SRC_OPT",
+ "TIMEOUT_OPT",
"USEUNITS_OPT",
"VERBOSE_OPT",
"VG_NAME_OPT",
"OPT_COMPL_ONE_OS",
"cli_option",
"SplitNodeOption",
+ "CalculateOSNames",
]
NO_PREFIX = "no_"
metavar="<os>",
completion_suggest=OPT_COMPL_ONE_OS)
+FORCE_VARIANT_OPT = cli_option("--force-variant", dest="force_variant",
+ action="store_true", default=False,
+ help="Force an unknown variant")
+
BACKEND_OPT = cli_option("-B", "--backend-parameters", dest="beparams",
type="keyval", default={},
help="Backend parameters")
default=False, action="store_true",
help="Ignore errors from secondaries")
-NOSHUTDOWN_OPT = cli_option("","--noshutdown", dest="shutdown",
+NOSHUTDOWN_OPT = cli_option("--noshutdown", dest="shutdown",
action="store_false", default=True,
help="Don't shutdown the instance (unsafe)")
+TIMEOUT_OPT = cli_option("--timeout", dest="timeout", type="int",
+ default=constants.DEFAULT_SHUTDOWN_TIMEOUT,
+ help="Maximum time to wait")
def _ParseArgs(argv, commands, aliases):
return (value, None)
+def CalculateOSNames(os_name, os_variants):
+ """Calculates all the names an OS can be called, according to its variants.
+
+ @type os_name: string
+ @param os_name: base name of the os
+ @type os_variants: list or None
+ @param os_variants: list of supported variants
+ @rtype: list
+ @return: list of valid names
+
+ """
+ if os_variants:
+ return ['%s+%s' % (os_name, v) for v in os_variants]
+ else:
+ return [os_name]
+
+
def UsesRPC(fn):
def wrapper(*args, **kwargs):
rpc.Init()
args = []
if line is None:
line = ['-' for _ in fields]
- for idx in xrange(len(fields)):
+ for idx in range(len(fields)):
if separator is None:
args.append(mlens[idx])
args.append(line[idx])