Implement friendlier VM mirror commands
Adds two helper commands which automate sending and promoting VM snapshots as "vm mirror" commands. "vm mirror create" replicates the functionality of "snapshot create" and "snapshot send", performing both in one single task using an autogenerated dated snapshot name for automatic cross-cluster replication. "vm mirror promote" replicates the functionality of "vm shutdown", "snapshot create", "snapshot send", "vm start" (remote), and, optionally, "vm remove", performing in one single task an entire cross-cluster VM move with or without retaining the copy on the local cluster (if retained, the local copy becomes a snapshot mirror of the remote, flipping their statuses).
This commit is contained in:
@ -34,6 +34,8 @@ from daemon_lib.vm import (
|
||||
vm_worker_export_snapshot,
|
||||
vm_worker_import_snapshot,
|
||||
vm_worker_send_snapshot,
|
||||
vm_worker_create_mirror,
|
||||
vm_worker_promote_mirror,
|
||||
)
|
||||
from daemon_lib.ceph import (
|
||||
osd_worker_add_osd,
|
||||
@ -276,6 +278,90 @@ def vm_send_snapshot(
|
||||
)
|
||||
|
||||
|
||||
@celery.task(name="vm.create_mirror", bind=True, routing_key="run_on")
|
||||
def vm_create_mirror(
|
||||
self,
|
||||
domain=None,
|
||||
destination_api_uri="",
|
||||
destination_api_key="",
|
||||
destination_api_verify_ssl=True,
|
||||
destination_storage_pool=None,
|
||||
run_on="primary",
|
||||
):
|
||||
@ZKConnection(config)
|
||||
def run_vm_create_mirror(
|
||||
zkhandler,
|
||||
self,
|
||||
domain,
|
||||
destination_api_uri,
|
||||
destination_api_key,
|
||||
destination_api_verify_ssl=True,
|
||||
destination_storage_pool=None,
|
||||
):
|
||||
return vm_worker_create_mirror(
|
||||
zkhandler,
|
||||
self,
|
||||
domain,
|
||||
destination_api_uri,
|
||||
destination_api_key,
|
||||
destination_api_verify_ssl=destination_api_verify_ssl,
|
||||
destination_storage_pool=destination_storage_pool,
|
||||
)
|
||||
|
||||
return run_vm_create_mirror(
|
||||
self,
|
||||
domain,
|
||||
destination_api_uri,
|
||||
destination_api_key,
|
||||
destination_api_verify_ssl=destination_api_verify_ssl,
|
||||
destination_storage_pool=destination_storage_pool,
|
||||
)
|
||||
|
||||
|
||||
@celery.task(name="vm.promote_mirror", bind=True, routing_key="run_on")
|
||||
def vm_promote_mirror(
|
||||
self,
|
||||
domain=None,
|
||||
destination_api_uri="",
|
||||
destination_api_key="",
|
||||
destination_api_verify_ssl=True,
|
||||
destination_storage_pool=None,
|
||||
remove_on_source=False,
|
||||
run_on="primary",
|
||||
):
|
||||
@ZKConnection(config)
|
||||
def run_vm_promote_mirror(
|
||||
zkhandler,
|
||||
self,
|
||||
domain,
|
||||
destination_api_uri,
|
||||
destination_api_key,
|
||||
destination_api_verify_ssl=True,
|
||||
destination_storage_pool=None,
|
||||
remove_on_source=False,
|
||||
):
|
||||
return vm_worker_promote_mirror(
|
||||
zkhandler,
|
||||
self,
|
||||
domain,
|
||||
destination_api_uri,
|
||||
destination_api_key,
|
||||
destination_api_verify_ssl=destination_api_verify_ssl,
|
||||
destination_storage_pool=destination_storage_pool,
|
||||
remove_on_source=remove_on_source,
|
||||
)
|
||||
|
||||
return run_vm_promote_mirror(
|
||||
self,
|
||||
domain,
|
||||
destination_api_uri,
|
||||
destination_api_key,
|
||||
destination_api_verify_ssl=destination_api_verify_ssl,
|
||||
destination_storage_pool=destination_storage_pool,
|
||||
remove_on_source=remove_on_source,
|
||||
)
|
||||
|
||||
|
||||
@celery.task(name="osd.add", bind=True, routing_key="run_on")
|
||||
def osd_add(
|
||||
self,
|
||||
|
Reference in New Issue
Block a user