Revision 5c5c73fd tools/move-instance
b/tools/move-instance | ||
---|---|---|
115 | 115 |
dest="dest_disk_template", default=None, |
116 | 116 |
help="Disk template to use on destination cluster") |
117 | 117 |
|
118 |
COMPRESS_OPT = \ |
|
119 |
cli.cli_option("--compress", action="store", type="string", |
|
120 |
dest="compress", default="none", |
|
121 |
help="Compression mode to use during the move (this mode has" |
|
122 |
" to be supported by both clusters)") |
|
123 |
|
|
118 | 124 |
PARALLEL_OPT = \ |
119 | 125 |
cli.cli_option("-p", "--parallel", action="store", type="int", default=1, |
120 | 126 |
dest="parallel", metavar="<number>", |
... | ... | |
276 | 282 |
|
277 | 283 |
""" |
278 | 284 |
def __init__(self, src_instance_name, dest_instance_name, |
279 |
dest_pnode, dest_snode, dest_iallocator, |
|
285 |
dest_pnode, dest_snode, compress, dest_iallocator,
|
|
280 | 286 |
dest_disk_template, hvparams, |
281 | 287 |
beparams, osparams, nics): |
282 | 288 |
"""Initializes this class. |
... | ... | |
289 | 295 |
@param dest_pnode: Name of primary node on destination cluster |
290 | 296 |
@type dest_snode: string or None |
291 | 297 |
@param dest_snode: Name of secondary node on destination cluster |
298 |
@type compress; string |
|
299 |
@param compress: Compression mode to use (has to be supported on both |
|
300 |
clusters) |
|
292 | 301 |
@type dest_iallocator: string or None |
293 | 302 |
@param dest_iallocator: Name of iallocator to use |
294 | 303 |
@type dest_disk_template: string or None |
... | ... | |
307 | 316 |
self.dest_instance_name = dest_instance_name |
308 | 317 |
self.dest_pnode = dest_pnode |
309 | 318 |
self.dest_snode = dest_snode |
319 |
self.compress = compress |
|
310 | 320 |
self.dest_iallocator = dest_iallocator |
311 | 321 |
self.dest_disk_template = dest_disk_template |
312 | 322 |
self.hvparams = hvparams |
... | ... | |
437 | 447 |
mrt.move.dest_instance_name) |
438 | 448 |
job_id = self._CreateInstance(dest_client, mrt.move.dest_instance_name, |
439 | 449 |
mrt.move.dest_pnode, mrt.move.dest_snode, |
450 |
mrt.move.compress, |
|
440 | 451 |
mrt.move.dest_iallocator, |
441 | 452 |
mrt.move.dest_disk_template, |
442 | 453 |
mrt.src_instinfo, mrt.src_expinfo, |
... | ... | |
464 | 475 |
mrt.dest_to_source.release() |
465 | 476 |
|
466 | 477 |
@staticmethod |
467 |
def _CreateInstance(cl, name, pnode, snode, iallocator, dest_disk_template,
|
|
468 |
instance, expinfo, override_hvparams, override_beparams,
|
|
469 |
override_osparams, override_nics): |
|
478 |
def _CreateInstance(cl, name, pnode, snode, compress, iallocator,
|
|
479 |
dest_disk_template, instance, expinfo, override_hvparams,
|
|
480 |
override_beparams, override_osparams, override_nics):
|
|
470 | 481 |
"""Starts the instance creation in remote import mode. |
471 | 482 |
|
472 | 483 |
@type cl: L{rapi.client.GanetiRapiClient} |
... | ... | |
477 | 488 |
@param pnode: Name of primary node on destination cluster |
478 | 489 |
@type snode: string or None |
479 | 490 |
@param snode: Name of secondary node on destination cluster |
491 |
@type compress: string |
|
492 |
@param compress: Compression mode to use |
|
480 | 493 |
@type iallocator: string or None |
481 | 494 |
@param iallocator: Name of iallocator to use |
482 | 495 |
@type dest_disk_template: string or None |
... | ... | |
561 | 574 |
hypervisor=instance["hypervisor"], |
562 | 575 |
source_handshake=expinfo["handshake"], |
563 | 576 |
source_x509_ca=expinfo["x509_ca"], |
577 |
compress=compress, |
|
564 | 578 |
source_instance_name=instance["name"], |
565 | 579 |
beparams=objects.FillDict(inst_beparams, |
566 | 580 |
override_beparams), |
... | ... | |
612 | 626 |
|
613 | 627 |
logging.info("Starting remote export on source cluster") |
614 | 628 |
self._ExportInstance(src_client, mrt.PollJob, mrt.move.src_instance_name, |
615 |
expinfo["x509_key_name"], mrt.dest_impinfo) |
|
629 |
expinfo["x509_key_name"], mrt.move.compress, |
|
630 |
mrt.dest_impinfo) |
|
616 | 631 |
|
617 | 632 |
logging.info("Export successful") |
618 | 633 |
|
... | ... | |
666 | 681 |
return poll_job_fn(cl, job_id)[0] |
667 | 682 |
|
668 | 683 |
@staticmethod |
669 |
def _ExportInstance(cl, poll_job_fn, name, x509_key_name, impinfo): |
|
684 |
def _ExportInstance(cl, poll_job_fn, name, x509_key_name, compress, impinfo):
|
|
670 | 685 |
"""Exports instance from source cluster. |
671 | 686 |
|
672 | 687 |
@type cl: L{rapi.client.GanetiRapiClient} |
... | ... | |
676 | 691 |
@type name: string |
677 | 692 |
@param name: Instance name |
678 | 693 |
@param x509_key_name: Source X509 key |
694 |
@type compress: string |
|
695 |
@param compress: Compression mode to use |
|
679 | 696 |
@param impinfo: Import information from destination cluster |
680 | 697 |
|
681 | 698 |
""" |
... | ... | |
683 | 700 |
impinfo["disks"], shutdown=True, |
684 | 701 |
remove_instance=True, |
685 | 702 |
x509_key_name=x509_key_name, |
686 |
destination_x509_ca=impinfo["x509_ca"]) |
|
703 |
destination_x509_ca=impinfo["x509_ca"], |
|
704 |
compress=compress) |
|
687 | 705 |
(fin_resu, dresults) = poll_job_fn(cl, job_id)[0] |
688 | 706 |
|
689 | 707 |
if not (fin_resu and compat.all(dresults)): |
... | ... | |
777 | 795 |
parser.add_option(DEST_PRIMARY_NODE_OPT) |
778 | 796 |
parser.add_option(DEST_SECONDARY_NODE_OPT) |
779 | 797 |
parser.add_option(DEST_DISK_TEMPLATE_OPT) |
798 |
parser.add_option(COMPRESS_OPT) |
|
780 | 799 |
parser.add_option(PARALLEL_OPT) |
781 | 800 |
|
782 | 801 |
(options, args) = parser.parse_args() |
... | ... | |
894 | 913 |
moves.append(InstanceMove(src_instance_name, dest_instance_name, |
895 | 914 |
options.dest_primary_node, |
896 | 915 |
options.dest_secondary_node, |
916 |
options.compress, |
|
897 | 917 |
options.iallocator, |
898 | 918 |
options.dest_disk_template, |
899 | 919 |
options.hvparams, |
Also available in: Unified diff