def download_disk(connection, backup_uuid, disk, disk_path, args): transfer = create_transfer(connection, backup_uuid, disk) try: # We must use the daemon for downloading a backup disk. download_url = transfer.transfer_url with ui.ProgressBar() as pb: client.download(download_url, disk_path, args.cafile, secure=args.secure, progress=pb) finally: finalize_transfer(connection, transfer)
# At this stage, the SDK granted the permission to start transferring the disk, and the # user should choose its preferred tool for doing it - regardless of the SDK. # In this example, we will use Python's httplib.HTTPSConnection for transferring the data. if args.direct: if transfer.transfer_url is not None: destination_url = transfer.transfer_url else: print( "Direct upload to host not supported (requires ovirt-engine 4.2 or above)." ) sys.exit(1) else: destination_url = transfer.proxy_url image_size = os.path.getsize(args.filename) with ui.ProgressBar(image_size) as pb: client.upload(args.filename, destination_url, args.cafile, secure=args.secure, progress=pb.update) print("Finalizing transfer session...") # Successful cleanup transfer_service.finalize() connection.close() print("Upload completed successfully")
# After adding a new transfer for the disk, the transfer's status will be INITIALIZING. # Wait until the init phase is over. The actual transfer can start when its status is "Transferring". while transfer.phase == types.ImageTransferPhase.INITIALIZING: time.sleep(1) transfer = transfer_service.get() print("Uploading image...") # 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. if args.use_proxy: destination_url = transfer.proxy_url else: destination_url = transfer.transfer_url with ui.ProgressBar() as pb: client.upload(args.filename, destination_url, args.cafile, secure=args.secure, progress=pb) print("Finalizing transfer session...") # Successful cleanup transfer_service.finalize() connection.close() print("Upload completed successfully")