Revision 55efe6da
b/man/gnt-instance.sgml | ||
---|---|---|
1229 | 1229 |
<cmdsynopsis> |
1230 | 1230 |
<command>reinstall</command> |
1231 | 1231 |
<arg choice="opt">-o <replaceable>os-type</replaceable></arg> |
1232 |
<arg choice="opt">-f <replaceable>force</replaceable></arg> |
|
1233 | 1232 |
<arg>--select-os</arg> |
1233 |
<arg choice="opt">-f <replaceable>force</replaceable></arg> |
|
1234 |
<arg>--force-multiple</arg> |
|
1235 |
<sbr> |
|
1236 |
<group choice="opt"> |
|
1237 |
<arg>--instance</arg> |
|
1238 |
<arg>--node</arg> |
|
1239 |
<arg>--primary</arg> |
|
1240 |
<arg>--secondary</arg> |
|
1241 |
<arg>--all</arg> |
|
1242 |
</group> |
|
1234 | 1243 |
<arg>--submit</arg> |
1235 |
<arg choice="req"><replaceable>instance</replaceable></arg>
|
|
1244 |
<arg choice="opt" rep="repeat"><replaceable>instance</replaceable></arg>
|
|
1236 | 1245 |
</cmdsynopsis> |
1237 | 1246 |
|
1238 | 1247 |
<para> |
1239 |
Reinstalls the operating system on the given instance. The |
|
1240 |
instance must be stopped when running this command. If the |
|
1248 |
Reinstalls the operating system on the given instance(s). The
|
|
1249 |
instance(s) must be stopped when running this command. If the
|
|
1241 | 1250 |
<option>--os-type</option> is specified, the operating |
1242 | 1251 |
system is changed. |
1243 | 1252 |
</para> |
1244 | 1253 |
|
1245 | 1254 |
<para> |
1246 |
Since reinstall is potentially dangerous command, the user |
|
1247 |
will be required to confirm this action, unless the |
|
1248 |
<option>-f</option> flag is passed. |
|
1249 |
</para> |
|
1250 |
|
|
1251 |
<para> |
|
1252 | 1255 |
The <option>--select-os</option> option switches to an |
1253 | 1256 |
interactive OS reinstall. The user is prompted to select the OS |
1254 | 1257 |
template from the list of available OS templates. |
1255 | 1258 |
</para> |
1256 | 1259 |
|
1257 | 1260 |
<para> |
1261 |
Since this is a potentially dangerous command, the user will |
|
1262 |
be required to confirm this action, unless the |
|
1263 |
<option>-f</option> flag is passed. When multiple instances |
|
1264 |
are selected (either by passing multiple arguments or by |
|
1265 |
using the <option>--node</option>, |
|
1266 |
<option>--primary</option>, <option>--secondary</option> or |
|
1267 |
<option>--all</option> options), the user must pass both the |
|
1268 |
<option>--force</option> and |
|
1269 |
<option>--force-multiple</option> options to skip the |
|
1270 |
interactive confirmation. |
|
1271 |
</para> |
|
1272 |
|
|
1273 |
<para> |
|
1258 | 1274 |
The <option>--submit</option> option is used to send the job to |
1259 | 1275 |
the master daemon but not wait for its completion. The job |
1260 | 1276 |
ID will be shown so that it can be examined via |
b/scripts/gnt-instance | ||
---|---|---|
116 | 116 |
return inames |
117 | 117 |
|
118 | 118 |
|
119 |
def _ConfirmOperation(inames, text): |
|
119 |
def _ConfirmOperation(inames, text, extra=""):
|
|
120 | 120 |
"""Ask the user to confirm an operation on a list of instances. |
121 | 121 |
|
122 | 122 |
This function is used to request confirmation for doing an operation |
... | ... | |
133 | 133 |
|
134 | 134 |
""" |
135 | 135 |
count = len(inames) |
136 |
msg = ("The %s will operate on %d instances.\n" |
|
137 |
"Do you want to continue?" % (text, count)) |
|
136 |
msg = ("The %s will operate on %d instances.\n%s"
|
|
137 |
"Do you want to continue?" % (text, count, extra))
|
|
138 | 138 |
affected = ("\nAffected instances:\n" + |
139 | 139 |
"\n".join([" %s" % name for name in inames])) |
140 | 140 |
|
... | ... | |
505 | 505 |
@return: the desired exit code |
506 | 506 |
|
507 | 507 |
""" |
508 |
instance_name = args[0] |
|
508 |
# first, compute the desired name list |
|
509 |
if opts.multi_mode is None: |
|
510 |
opts.multi_mode = _SHUTDOWN_INSTANCES |
|
511 |
|
|
512 |
inames = _ExpandMultiNames(opts.multi_mode, args) |
|
513 |
if not inames: |
|
514 |
raise errors.OpPrereqError("Selection filter does not match any instances") |
|
509 | 515 |
|
516 |
# second, if requested, ask for an OS |
|
510 | 517 |
if opts.select_os is True: |
511 | 518 |
op = opcodes.OpDiagnoseOS(output_fields=["name", "valid"], names=[]) |
512 | 519 |
result = SubmitOpCode(op) |
... | ... | |
528 | 535 |
choices) |
529 | 536 |
|
530 | 537 |
if selected == 'exit': |
531 |
ToStdout("User aborted reinstall, exiting")
|
|
538 |
ToStderr("User aborted reinstall, exiting")
|
|
532 | 539 |
return 1 |
533 | 540 |
|
534 | 541 |
os_name = selected |
535 | 542 |
else: |
536 | 543 |
os_name = opts.os |
537 | 544 |
|
538 |
if not opts.force: |
|
539 |
usertext = ("This will reinstall the instance %s and remove" |
|
540 |
" all data. Continue?") % instance_name |
|
541 |
if not AskUser(usertext): |
|
545 |
# third, get confirmation: multi-reinstall requires --force-multi |
|
546 |
# *and* --force, single-reinstall just --force |
|
547 |
multi_on = opts.multi_mode != _SHUTDOWN_INSTANCES or len(inames) > 1 |
|
548 |
if multi_on: |
|
549 |
warn_msg = "Note: this will remove *all* data for the below instances!\n" |
|
550 |
if not ((opts.force_multi and opts.force) or |
|
551 |
_ConfirmOperation(inames, "reinstall", extra=warn_msg)): |
|
542 | 552 |
return 1 |
553 |
else: |
|
554 |
if not opts.force: |
|
555 |
usertext = ("This will reinstall the instance %s and remove" |
|
556 |
" all data. Continue?") % instance_name |
|
557 |
if not AskUser(usertext): |
|
558 |
return 1 |
|
559 |
|
|
560 |
jex = JobExecutor(verbose=multi_on) |
|
561 |
for instance_name in inames: |
|
562 |
op = opcodes.OpReinstallInstance(instance_name=instance_name, |
|
563 |
os_type=os_name) |
|
564 |
jex.QueueJob(instance_name, op) |
|
543 | 565 |
|
544 |
op = opcodes.OpReinstallInstance(instance_name=instance_name, |
|
545 |
os_type=os_name) |
|
546 |
SubmitOrSend(op, opts) |
|
547 |
|
|
566 |
jex.WaitOrShow(not opts.submit_only) |
|
548 | 567 |
return 0 |
549 | 568 |
|
550 | 569 |
|
... | ... | |
1372 | 1391 |
" The default field" |
1373 | 1392 |
" list is (in order): %s." % ", ".join(_LIST_DEF_FIELDS), |
1374 | 1393 |
), |
1375 |
'reinstall': (ReinstallInstance, ARGS_ONE,
|
|
1394 |
'reinstall': (ReinstallInstance, ARGS_ANY,
|
|
1376 | 1395 |
[DEBUG_OPT, FORCE_OPT, os_opt, |
1396 |
m_force_multi, |
|
1397 |
m_node_opt, m_pri_node_opt, m_sec_node_opt, |
|
1398 |
m_clust_opt, m_inst_opt, |
|
1377 | 1399 |
make_option("--select-os", dest="select_os", |
1378 | 1400 |
action="store_true", default=False, |
1379 | 1401 |
help="Interactive OS reinstall, lists available" |
Also available in: Unified diff