"POWER_DELAY_OPT",
"PREALLOC_WIPE_DISKS_OPT",
"PRIMARY_IP_VERSION_OPT",
+ "PRIMARY_ONLY_OPT",
"PRIORITY_OPT",
"RAPI_CERT_OPT",
"READD_OPT",
"RESERVED_LVS_OPT",
"ROMAN_OPT",
"SECONDARY_IP_OPT",
+ "SECONDARY_ONLY_OPT",
"SELECT_OS_OPT",
"SEP_OPT",
"SHOWCMD_OPT",
"SRC_DIR_OPT",
"SRC_NODE_OPT",
"SUBMIT_OPT",
+ "STARTUP_PAUSED_OPT",
"STATIC_OPT",
"SYNC_OPT",
+ "TAG_ADD_OPT",
"TAG_SRC_OPT",
"TIMEOUT_OPT",
"UIDPOOL_OPT",
help=("Ignore offline nodes and do as much"
" as possible"))
+TAG_ADD_OPT = cli_option("--tags", dest="tags",
+ default=None, help="Comma-separated list of instance"
+ " tags")
+
TAG_SRC_OPT = cli_option("--from", dest="tags_source",
default=None, help="File with tag names")
help="Perform but do not record the change"
" in the configuration")
+PRIMARY_ONLY_OPT = cli_option("-p", "--primary-only",
+ default=False, action="store_true",
+ help="Evacuate primary instances only")
+
+SECONDARY_ONLY_OPT = cli_option("-s", "--secondary-only",
+ default=False, action="store_true",
+ help="Evacuate secondary instances only"
+ " (applies only to internally mirrored"
+ " disk templates, e.g. %s)" %
+ utils.CommaJoin(constants.DTS_INT_MIRROR))
+
+STARTUP_PAUSED_OPT = cli_option("--paused", dest="startup_paused",
+ action="store_true", default=False,
+ help="Pause instance at startup")
+
#: Options provided by all commands
COMMON_OPTS = [DEBUG_OPT]
OSPARAMS_OPT,
OS_SIZE_OPT,
SUBMIT_OPT,
+ TAG_ADD_OPT,
DRY_RUN_OPT,
PRIORITY_OPT,
]
" disk %d" % didx)
disks[didx] = ddict
+ if opts.tags is not None:
+ tags = opts.tags.split(",")
+ else:
+ tags = []
+
utils.ForceDictType(opts.beparams, constants.BES_PARAMETER_TYPES)
utils.ForceDictType(hvparams, constants.HVS_PARAMETER_TYPES)
force_variant=force_variant,
src_node=src_node,
src_path=src_path,
+ tags=tags,
no_install=no_install,
identify_defaults=identify_defaults)
self.feedback_fn = feedback_fn
self._counter = itertools.count()
+ @staticmethod
+ def _IfName(name, fmt):
+ """Helper function for formatting name.
+
+ """
+ if name:
+ return fmt % name
+
+ return ""
+
def QueueJob(self, name, *ops):
"""Record a job for later submit.
@type name: string
@param name: a description of the job, will be used in WaitJobSet
+
"""
SetGenericOpcodeOpts(ops, self.opts)
self.queue.append((self._counter.next(), name, ops))
+ def AddJobId(self, name, status, job_id):
+ """Adds a job ID to the internal queue.
+
+ """
+ self.jobs.append((self._counter.next(), status, job_id, name))
+
def SubmitPending(self, each=False):
"""Submit all pending jobs.
# first, remove any non-submitted jobs
self.jobs, failures = compat.partition(self.jobs, lambda x: x[1])
for idx, _, jid, name in failures:
- ToStderr("Failed to submit job for %s: %s", name, jid)
+ ToStderr("Failed to submit job%s: %s", self._IfName(name, " for %s"), jid)
results.append((idx, False, jid))
while self.jobs:
(idx, _, jid, name) = self._ChooseJob()
- ToStdout("Waiting for job %s for %s...", jid, name)
+ ToStdout("Waiting for job %s%s ...", jid, self._IfName(name, " for %s"))
try:
job_result = PollJob(jid, cl=self.cl, feedback_fn=self.feedback_fn)
success = True
except errors.JobLost, err:
_, job_result = FormatError(err)
- ToStderr("Job %s for %s has been archived, cannot check its result",
- jid, name)
+ ToStderr("Job %s%s has been archived, cannot check its result",
+ jid, self._IfName(name, " for %s"))
success = False
except (errors.GenericError, luxi.ProtocolError), err:
_, job_result = FormatError(err)
success = False
# the error message will always be shown, verbose or not
- ToStderr("Job %s for %s has failed: %s", jid, name, job_result)
+ ToStderr("Job %s%s has failed: %s",
+ jid, self._IfName(name, " for %s"), job_result)
results.append((idx, success, job_result))