def parse_args(): parser = common.ArgumentParser(description="Upload disk from OVA") # Image options. parser.add_argument("ova_file", help="Path to OVA file.") parser.add_argument("--sd-name", required=True, help="Name of the storage domain.") parser.add_argument( "--disk-format", choices=("raw", "qcow2"), help="Format of the created disk (default image format).") parser.add_argument( "--enable-backup", action="store_true", help="Creates a disk that can be used for incremental backup. " "Allowed for qcow2 format only.") parser.add_argument("--cluster-name", required=True, help="Name of the cluster.") parser.add_argument( "--template", action="store_true", help="Create template or Virtual Machine from an ova file.") return parser.parse_args()
def parse_args(): parser = common.ArgumentParser(description="Upload images") parser.add_argument("filename", help="Path to image (e.g. /path/to/image.raw). " "Supported formats: raw, qcow2, iso.") parser.add_argument( "--disk-format", choices=("raw", "qcow2"), help="Format of the created disk (default image format).") parser.add_argument( "--disk-sparse", action="store_true", help="Create sparse disk. Cannot be used with raw format on " "block storage.") parser.add_argument( "--enable-backup", action="store_true", help="Creates a disk that can be used for incremental backup. " "Allowed for disk with qcow2 format only.") parser.add_argument("--sd-name", required=True, help="Name of the storage domain.") parser.add_argument( "--use-proxy", dest="use_proxy", default=False, action="store_true", help="Upload via proxy on the engine host (less efficient).") parser.add_argument( "--max-workers", type=int, default=4, help="Maximum number of workers to use for upload. The default " "(4) improves performance when uploading a single disk. " "You may want to use lower number if you upload many disks " "in the same time.") parser.add_argument( "--buffer-size", type=units.humansize, default=client.BUFFER_SIZE, help="Buffer size per worker. The default ({}) gives good " "performance with the default number of workers. If you use " "smaller number of workers you may want use larger value.".format( client.BUFFER_SIZE)) parser.add_argument("--timeout-policy", choices=('legacy', 'pause', 'cancel'), default='cancel', help="The action to be made for a timed out transfer") return parser.parse_args()
def parse_args(): parser = common.ArgumentParser(description="Download disk snapshot") parser.add_argument("sd_name", help="Storage domain name.") parser.add_argument("disk_snapshot_uuid", help="Disk snapshot UUID to download.") parser.add_argument("filename", help="Path to downloaded image.") parser.add_argument( "--backing-file", help="Download selected disks snapshot data, rebasing on the " "given backing file. Specified backing file must include " "data from disk snapshot parent disk snapshot.") parser.add_argument( "--use-proxy", dest="use_proxy", default=False, action="store_true", help="Download via proxy on the engine host (less efficient).") parser.add_argument( "--max-workers", type=int, default=4, help="Maximum number of workers to use for download. The default " "(4) improves performance when downloading a single disk. " "You may want to use lower number if you download many disks " "in the same time.") parser.add_argument( "--buffer-size", type=units.humansize, default=client.BUFFER_SIZE, help="Buffer size per worker. The default ({}) gives good " "performance with the default number of workers. If you use " "smaller number of workers you may want use larger value.".format( client.BUFFER_SIZE)) parser.add_argument("--timeout-policy", choices=('legacy', 'pause', 'cancel'), default='cancel', help="The action to be made for a timed out transfer") return parser.parse_args()
def parse_args(): parser = common.ArgumentParser(description="Download disk") parser.add_argument("disk_uuid", help="Disk UUID to download.") parser.add_argument("filename", help="Path to write downloaded image.") parser.add_argument( "-f", "--format", choices=("raw", "qcow2"), default="qcow2", help=("Downloaded file format. For best compatibility, use qcow2 " "(default qcow2).")) parser.add_argument( "--use-proxy", dest="use_proxy", default=False, action="store_true", help="Download via proxy on the engine host (less efficient).") parser.add_argument( "--max-workers", type=int, default=4, help="Maximum number of workers to use for download. The default " "(4) improves performance when downloading a single disk. " "You may want to use lower number if you download many disks " "in the same time.") parser.add_argument( "--buffer-size", type=units.humansize, default=client.BUFFER_SIZE, help="Buffer size per worker. The default ({}) gives good " "performance with the default number of workers. If you use " "smaller number of workers you may want use larger value.".format( client.BUFFER_SIZE)) parser.add_argument("--timeout-policy", choices=('legacy', 'pause', 'cancel'), default='cancel', help="The action to be made for a timed out transfer") return parser.parse_args()
def parse_args(): parser = common.ArgumentParser(description="Upload disk from OVA") # Image options. parser.add_argument( "ova_file", help="Path to OVA file.") parser.add_argument( "--ova-disk-name", required=True, help="Name of the disk in the OVA file.") # Disk options. parser.add_argument( "--sd-name", required=True, help="Name of the storage domain.") parser.add_argument( "--disk-format", choices=("raw", "qcow2"), help="Format of the created disk (default image format).") parser.add_argument( "--disk-sparse", action="store_true", help="Create sparse disk (raw sparse not supported on block storage).") parser.add_argument( "--enable-backup", action="store_true", help="Creates a disk that can be used for incremental backup. " "Allowed for qcow2 format only.") return parser.parse_args()
Requires ovirt-imageio-client >= 2.0.10-1 """ import json import ssl 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)
VM checkpoint. Note that this feature API is supported from version 4.4 but the feature is currently in tech-preview until libvirt will release official release that contains the support for incremental backup. """ import time from contextlib import closing import ovirtsdk4 as sdk from helpers import common from helpers.common import progress parser = common.ArgumentParser(description="Remove VM checkpoint") parser.add_argument("vm_uuid", help="VM UUID for removing checkpoint.") args = parser.parse_args() common.configure_logging(args) progress("Removing root checkpoint for VM %r" % args.vm_uuid) # Create a connection to the server connection = common.create_connection(args) with closing(connection): progress("Looking up checkpoints %s" % args.vm_uuid) system_service = connection.system_service() vm_service = system_service.vms_service().vm_service(id=args.vm_uuid) checkpoints_service = vm_service.checkpoints_service() # Validate that the VM has checkpoints
def main(): parser = common.ArgumentParser(description="Backup VM disks") subparsers = parser.add_subparsers(title="commands") full_parser = subparsers.add_parser( "full", help="Run full backup.") full_parser.set_defaults(command=cmd_full) add_download_args(full_parser) full_parser.add_argument( "vm_uuid", help="UUID of the VM to backup.") full_parser.add_argument( "--disk-uuid", action="append", help="Disk UUID to backup. May be used multiple times to backup " "multiple disks. If not specified, backup all VM disks."), incremental_parser = subparsers.add_parser( "incremental", help="Run incremental backup.") incremental_parser.set_defaults(command=cmd_incremental) add_download_args(incremental_parser) incremental_parser.add_argument( "vm_uuid", help="UUID of the VM to backup.") incremental_parser.add_argument( "--from-checkpoint-uuid", required=True, help="Perform incremental backup since the specified checkpoint " "UUID.") incremental_parser.add_argument( "--disk-uuid", action="append", help="Disk UUID to backup. May be used multiple times to backup " "multiple disks. If not specified, backup all VM disks."), start_parser = subparsers.add_parser( "start", help="Start VM backup.") start_parser.set_defaults(command=cmd_start) start_parser.add_argument( "vm_uuid", help="UUID of the VM to backup.") start_parser.add_argument( "--disk-uuid", action="append", help="Disk UUID to backup. May be used multiple times to backup " "multiple disks. If not specified, backup all VM disks.") start_parser.add_argument( "--from-checkpoint-uuid", help="Perform incremental backup since the specified checkpoint " "UUID.") download_parser = subparsers.add_parser( "download", help="Download VM backup disk.") download_parser.set_defaults(command=cmd_download) add_download_args(download_parser) download_parser.add_argument( "vm_uuid", help="UUID of the VM for the backup.") download_parser.add_argument( "--backup-uuid", required=True, help="UUID of the backup to finalize.") download_parser.add_argument( "--incremental", action="store_true", help="Download incremental backup data in qcow2 format. The " "downloaded disk should be rebased on the previous backup " "to restore the disk contents. Can be used only if the " "backup was started with --from-checkpoint-uuid.") stop_parser = subparsers.add_parser( "stop", help="Stop VM backup.") stop_parser.set_defaults(command=cmd_stop) stop_parser.add_argument( "vm_uuid", help="UUID of the VM for the backup.") stop_parser.add_argument( "backup_uuid", help="UUID of the backup to finalize.") args = parser.parse_args() common.configure_logging(args) args.command(args)
# limitations under the License. # import logging import time from contextlib import closing import ovirtsdk4 as sdk import ovirtsdk4.types as types from helpers import common # This example will connect to the server and change CD of the virtual machine. parser = common.ArgumentParser(description="Change VM CD-ROM disk") parser.add_argument( "vm_name", help="Name of VM.") parser.add_argument( "--disk-id", help="ID of the disk to be loaded into CD-ROM. If not specified " "the current CD will be ejected.") parser.add_argument( "--permanent", dest="current", action="store_false", help="If specified CD should be changed only after next boot."
# limitations under the License. # """ Show how to create many disks quickly. """ import time from contextlib import closing from ovirtsdk4 import types from helpers import common from helpers.common import progress from helpers.units import humansize, GiB parser = common.ArgumentParser(description="Create disks") parser.add_argument("--sd-name", required=True, help="Name of the storage domain.") parser.add_argument("--size", type=humansize, default=1 * GiB, help="Size of the disk") parser.add_argument("--format", choices=("raw", "qcow2"), help="Format of the created disk (default raw).") parser.add_argument(
Requires ovirt-imageio-client >= 2.0.10-1 """ import time from contextlib import closing from ovirtsdk4 import types from helpers import common from helpers import imagetransfer from helpers.common import progress from ovirt_imageio.client import ImageioClient parser = common.ArgumentParser(description="Run an image transfer") parser.add_argument("direction", choices=["upload", "download"], help="Transfer direction.") parser.add_argument("disk_uuid", help="Disk UUID for transfer.") parser.add_argument( "--shallow", action="store_true", help="Transfer only specified image instead of entire image chain.") parser.add_argument( "--inactivity-timeout", type=int,
- Moving a VM disk to another storage domain while a VM is running. - In some cases, after sparsifying a disk. If a Disk is attached to a VM, the VM must be powered off to reduce the disk. """ import time from contextlib import closing import ovirtsdk4 as sdk from ovirtsdk4 import types from helpers import common from helpers.common import progress parser = common.ArgumentParser(description="Reduce disk") parser.add_argument( "disk_id", help="disk UUID to reduce") args = parser.parse_args() common.configure_logging(args) progress("Connecting...") connection = common.create_connection(args) with closing(connection): # Locate the disk service. disks_service = connection.system_service().disks_service()
def parse_args(): parser = common.ArgumentParser(description="List disk snapshots") parser.add_argument("disk_id", help="Disk ID to query.") return parser.parse_args()