Revision 53c776b5 scripts/gnt-instance
b/scripts/gnt-instance | ||
---|---|---|
821 | 821 |
return 0 |
822 | 822 |
|
823 | 823 |
|
824 |
def MigrateInstance(opts, args): |
|
825 |
"""Migrate an instance. |
|
826 |
|
|
827 |
The migrate is done without shutdown. |
|
828 |
|
|
829 |
Args: |
|
830 |
opts - class with options as members |
|
831 |
args - list with a single element, the instance name |
|
832 |
Opts used: |
|
833 |
force - whether to migrate without asking questions. |
|
834 |
|
|
835 |
""" |
|
836 |
instance_name = args[0] |
|
837 |
force = opts.force |
|
838 |
|
|
839 |
if not force: |
|
840 |
if opts.cleanup: |
|
841 |
usertext = ("Instance %s will be recovered from a failed migration." |
|
842 |
" Note that the migration procedure (including cleanup)" % |
|
843 |
(instance_name,)) |
|
844 |
else: |
|
845 |
usertext = ("Instance %s will be migrated. Note that migration" % |
|
846 |
(instance_name,)) |
|
847 |
usertext += (" is **experimental** in this version." |
|
848 |
" This might impact the instance if anything goes wrong." |
|
849 |
" Continue?") |
|
850 |
if not AskUser(usertext): |
|
851 |
return 1 |
|
852 |
|
|
853 |
op = opcodes.OpMigrateInstance(instance_name=instance_name, live=opts.live, |
|
854 |
cleanup=opts.cleanup) |
|
855 |
SubmitOpCode(op) |
|
856 |
return 0 |
|
857 |
|
|
858 |
|
|
824 | 859 |
def ConnectToInstanceConsole(opts, args): |
825 | 860 |
"""Connect to the console of an instance. |
826 | 861 |
|
... | ... | |
1269 | 1304 |
"[-f] <instance>", |
1270 | 1305 |
"Stops the instance and starts it on the backup node, using" |
1271 | 1306 |
" the remote mirror (only for instances of type drbd)"), |
1307 |
'migrate': (MigrateInstance, ARGS_ONE, |
|
1308 |
[DEBUG_OPT, FORCE_OPT, |
|
1309 |
make_option("--non-live", dest="live", |
|
1310 |
default=True, action="store_false", |
|
1311 |
help="Do a non-live migration (this usually means" |
|
1312 |
" freeze the instance, save the state," |
|
1313 |
" transfer and only then resume running on the" |
|
1314 |
" secondary node)"), |
|
1315 |
make_option("--cleanup", dest="cleanup", |
|
1316 |
default=False, action="store_true", |
|
1317 |
help="Instead of performing the migration, try to" |
|
1318 |
" recover from a failed cleanup. This is safe" |
|
1319 |
" to run even if the instance is healthy, but it" |
|
1320 |
" will create extra replication traffic and " |
|
1321 |
" disrupt briefly the replication (like during the" |
|
1322 |
" migration"), |
|
1323 |
], |
|
1324 |
"[-f] <instance>", |
|
1325 |
"Migrate instance to its secondary node" |
|
1326 |
" (only for instances of type drbd)"), |
|
1272 | 1327 |
'info': (ShowInstanceConfig, ARGS_ANY, |
1273 | 1328 |
[DEBUG_OPT, |
1274 | 1329 |
make_option("-s", "--static", dest="static", |
Also available in: Unified diff