Revision fe7b0351 scripts/gnt-instance
b/scripts/gnt-instance | ||
---|---|---|
22 | 22 |
import sys |
23 | 23 |
import os |
24 | 24 |
from optparse import make_option |
25 |
import textwrap |
|
26 | 25 |
from cStringIO import StringIO |
27 | 26 |
|
28 | 27 |
from ganeti.cli import * |
... | ... | |
96 | 95 |
return 0 |
97 | 96 |
|
98 | 97 |
|
98 |
def ReinstallInstance(opts, args): |
|
99 |
"""Reinstall an instance. |
|
100 |
|
|
101 |
Args: |
|
102 |
opts - class with options as members |
|
103 |
args - list containing a single element, the instance name |
|
104 |
|
|
105 |
""" |
|
106 |
instance_name = args[0] |
|
107 |
|
|
108 |
if not opts.force: |
|
109 |
usertext = ("This will reinstall the instance %s and remove " |
|
110 |
"all data. Continue?") % instance_name |
|
111 |
if not opts._ask_user(usertext): |
|
112 |
return 1 |
|
113 |
|
|
114 |
op = opcodes.OpReinstallInstance(instance_name=instance_name) |
|
115 |
SubmitOpCode(op) |
|
116 |
|
|
117 |
return 0 |
|
118 |
|
|
119 |
|
|
99 | 120 |
def RemoveInstance(opts, args): |
100 | 121 |
"""Remove an instance. |
101 | 122 |
|
... | ... | |
244 | 265 |
usertext = ("Failover will happen to image %s." |
245 | 266 |
" This requires a shutdown of the instance. Continue?" % |
246 | 267 |
(instance_name,)) |
247 |
usertext = textwrap.fill(usertext) |
|
248 | 268 |
if not opts._ask_user(usertext): |
249 | 269 |
return 1 |
250 | 270 |
|
... | ... | |
400 | 420 |
# options used in more than one cmd |
401 | 421 |
node_opt = make_option("-n", "--node", dest="node", help="Target node", |
402 | 422 |
metavar="<node>") |
403 |
force_opt = make_option("-f", "--force", dest="force", action="store_true", |
|
404 |
default=False, help="Force the operation") |
|
405 | 423 |
|
406 | 424 |
# this is defined separately due to readability only |
407 | 425 |
add_opts = [ |
... | ... | |
448 | 466 |
"<instance>", |
449 | 467 |
"Opens a console on the specified instance"), |
450 | 468 |
'failover': (FailoverInstance, ARGS_ONE, |
451 |
[DEBUG_OPT, force_opt,
|
|
469 |
[DEBUG_OPT, FORCE_OPT,
|
|
452 | 470 |
make_option("--ignore-consistency", dest="ignore_consistency", |
453 | 471 |
action="store_true", default=False, |
454 | 472 |
help="Ignore the consistency of the disks on" |
... | ... | |
462 | 480 |
'list': (ListInstances, ARGS_NONE, |
463 | 481 |
[DEBUG_OPT, NOHDR_OPT, SEP_OPT, USEUNITS_OPT, FIELDS_OPT], |
464 | 482 |
"", "Lists the instances and their status"), |
465 |
'remove': (RemoveInstance, ARGS_ONE, [DEBUG_OPT, force_opt], |
|
483 |
'reinstall': (ReinstallInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT], |
|
484 |
"[-f] <instance>", "Reinstall the instance"), |
|
485 |
'remove': (RemoveInstance, ARGS_ONE, [DEBUG_OPT, FORCE_OPT], |
|
466 | 486 |
"[-f] <instance>", "Shuts down the instance and removes it"), |
467 | 487 |
'remove-mirror': (RemoveMDDRBDComponent, ARGS_ONE, |
468 | 488 |
[DEBUG_OPT, node_opt, |
... | ... | |
484 | 504 |
" change the secondary)"))], |
485 | 505 |
"[-n NODE] <instance>", |
486 | 506 |
"Replaces all disks for the instance"), |
487 |
|
|
488 | 507 |
'modify': (SetInstanceParms, ARGS_ONE, |
489 |
[DEBUG_OPT, force_opt,
|
|
508 |
[DEBUG_OPT, FORCE_OPT,
|
|
490 | 509 |
cli_option("-m", "--memory", dest="mem", |
491 | 510 |
help="Memory size", |
492 | 511 |
default=None, type="unit", metavar="<mem>"), |
... | ... | |
504 | 523 |
'shutdown': (ShutdownInstance, ARGS_ONE, [DEBUG_OPT], |
505 | 524 |
"<instance>", "Stops an instance"), |
506 | 525 |
'startup': (StartupInstance, ARGS_ONE, |
507 |
[DEBUG_OPT, force_opt,
|
|
526 |
[DEBUG_OPT, FORCE_OPT,
|
|
508 | 527 |
make_option("-e", "--extra", dest="extra_args", |
509 | 528 |
help="Extra arguments for the instance's kernel", |
510 | 529 |
default=None, type="string", metavar="<PARAMS>"), |
Also available in: Unified diff