# disk is locked: disk_service = disks_service.disk_service(disk.id) while True: time.sleep(1) disk = disk_service.get() if disk.status == types.DiskStatus.OK: break progress("Disk ID: %s" % disk.id) progress("Creating image transfer...") # Find a host for this transfer. This is an optional step allowing optimizing # the transfer using unix socket when running this code on a oVirt hypervisor # in the same data center. host = imagetransfer.find_host(connection, args.sd_name) transfer = imagetransfer.create_transfer(connection, disk, types.ImageTransferDirection.UPLOAD, host=host) progress("Transfer ID: %s" % transfer.id) progress("Transfer host name: %s" % transfer.host.name) # At this stage, the SDK granted the permission to start transferring the disk, and the # user should choose its preferred tool for doing it. We use the recommended # way, ovirt-imageio client library. extra_args = {}
connection = common.create_connection(args) # Get the reference to the disks service: disks_service = connection.system_service().disks_service() # Find the disk we want to download by the id: disk_service = disks_service.disk_service(args.disk_uuid) disk = disk_service.get() # Find a host for this transfer. This is an optional step allowing optimizing # the transfer using unix socket when running this code on a oVirt hypervisor # in the same data center. sd_id = disk.storage_domains[0].id sds_service = connection.system_service().storage_domains_service() storage_domain = sds_service.storage_domain_service(sd_id).get() host = imagetransfer.find_host(connection, storage_domain.name) progress("Creating image transfer...") transfer = imagetransfer.create_transfer(connection, disk, types.ImageTransferDirection.DOWNLOAD, host=host) progress("Transfer ID: %s" % transfer.id) progress("Transfer host name: %s" % transfer.host.name) # At this stage, the SDK granted the permission to start transferring the disk, and the # user should choose its preferred tool for doing it. We use the recommended # way, ovirt-imageio client library.