def cmd_stop(args): """ Stop backup using the backup UUID printed by the start command. """ progress("Finalizing backup %s" % args.backup_uuid) connection = common.create_connection(args) with closing(connection): stop_backup(connection, args.backup_uuid, args) progress("Backup %s has finalized" % args.backup_uuid)
def cmd_download(args): """ Download backup using the backup UUID printed by the start command. """ progress("Downloading VM %s disks" % args.vm_uuid) connection = common.create_connection(args) with closing(connection): download_backup( connection, args.backup_uuid, args, incremental=args.incremental) progress("Finished downloading disks")
def cmd_incremental(args): """ Run incremental backup flow - start_incremental, download and stop backup. """ progress("Starting incremental backup for VM %s" % args.vm_uuid) connection = common.create_connection(args) with closing(connection): backup = start_backup(connection, args) try: download_backup(connection, backup.id, args, incremental=True) finally: stop_backup(connection, backup.id, args) progress("Incremental backup completed successfully")
def cmd_full(args): """ Run full backup flow - start, download and stop backup. """ progress("Starting full backup for VM %s" % args.vm_uuid) connection = common.create_connection(args) with closing(connection): args.from_checkpoint_uuid = None backup = start_backup(connection, args) try: download_backup(connection, backup.id, args) finally: stop_backup(connection, backup.id, args) progress("Full backup completed successfully")
def cmd_start(args): """ Start backup, printing backup UUID. To download the backup run download command. To stop the backup run the stop command. """ if args.from_checkpoint_uuid: progress("Starting incremental backup since checkpoint %r for VM %r" % (args.from_checkpoint_uuid, args.vm_uuid)) else: progress("Starting full backup for VM %r" % args.vm_uuid) connection = common.create_connection(args) with closing(connection): backup = start_backup(connection, args) progress("Backup %s is ready" % backup.id)
from contextlib import closing from http import client from urllib.parse import urlparse from ovirtsdk4 import types from helpers import common from helpers import imagetransfer parser = common.ArgumentParser(description="Compute disk checksum") parser.add_argument("disk_uuid", help="Disk UUID.") args = parser.parse_args() common.configure_logging(args) connection = common.create_connection(args) with closing(connection): system_service = connection.system_service() disks_service = connection.system_service().disks_service() disk_service = disks_service.disk_service(args.disk_uuid) disk = disk_service.get() transfer = imagetransfer.create_transfer( connection, disk, types.ImageTransferDirection.DOWNLOAD) try: url = urlparse(transfer.transfer_url) con = client.HTTPSConnection( url.netloc, context=ssl.create_default_context(cafile=args.cafile)) with closing(con): con.request("GET", url.path + "/checksum") res = con.getresponse()