On Thu, Aug 5, 2021 at 5:12 PM KK CHN <kkchn...@gmail.com> wrote:
> I have installed the  ovirt-engine-sdk-python using pip3  in my python3 
> virtaul environment in my personal laptop

I'm not sure this is the right version. Use the rpms provided by ovirt instead.

...
> and Created file  in the user kris home directory in the same laptop  // Is 
> what I am doing right ?
>
> (base) kris@my-ThinkPad-X270:~$ cat ~/.config/ovirt.conf
> [engine-dev]

This can be any name you like for this setup.

> engine_url=https://engine-dev   // what is this engine url ? its the rhevm 
> ovirt url this our service provider may can provide right ?

This is your engine url, the same url you access engine UI.

> username=admin@internal
> password=mypassword
> cafile=/etc/pki/vdsm/certs/cacert.pem     // I dont have any cacert.pem file  
> in my laptop's /etc/pki/vdsm/certs/cacert.pem  no folder at all like this

This path works on ovirt host. You can download engine cafile from your
engine using:

    curl -k 
'https://engine-dev/ovirt-engine/services/pki-resource?resource=ca-certificate&format=X509-PEM-CA'
> engine-dev.pem

and use the path to the cafile:

    cafile=/home/kris/engine-dev.pem

...
> But  I couldn't find any examples folder where I can find the 
> download_disk.py   // So I have downloaded files for 
> ovirt-engne-sdk-python-4.1.3.tar.gz
>
> and untarred the files where I am able to find the  download_disk.py

You need to use ovirt sdk from 4.4. 4.1 sdk is too old.

Also if  you try to run this on another host, you need to install
more packages.

1. Install ovirt release rpm

    dnf install https://resources.ovirt.org/pub/yum-repo/ovirt-release44.rpm

2. Install required packages

    dnf install python3-ovirt-engine-sdk4 ovirt-imageio-client

$ rpm -q python3-ovirt-engine-sdk4 ovirt-imageio-client
python3-ovirt-engine-sdk4-4.4.13-1.el8.x86_64
ovirt-imageio-client-2.2.0-1.el8.x86_64

$ find /usr/share/ -name download_disk.py
/usr/share/doc/python3-ovirt-engine-sdk4/examples/download_disk.py

Now you can use download_disk.py to download images from ovirt setup.

...
> Can I execute now the following from my laptop ? so that it will connect to 
> the rhevm host node and download the disks ?

Yes

> (base) kris@my-ThinkPad-X270:$ python3 download_disk.py  -c engine-dev 
> MY_vm_blah_Id /var/tmp/disk1.raw      //is this correct ?

Almost, see the help:

$ python3 /usr/share/doc/python3-ovirt-engine-sdk4/examples/download_disk.py -h
usage: download_disk.py [-h] -c CONFIG [--debug] [--logfile LOGFILE]
                        [-f {raw,qcow2}] [--use-proxy]
                        [--max-workers MAX_WORKERS]
                        [--buffer-size BUFFER_SIZE]
                        [--timeout-policy {legacy,pause,cancel}]
                        disk_uuid filename

Download disk

positional arguments:
  disk_uuid             Disk UUID to download.
  filename              Path to write downloaded image.

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        Use engine connection details from [CONFIG] section in
                        ~/.config/ovirt.conf.
  --debug               Log debug level messages to logfile.
  --logfile LOGFILE     Log file name (default example.log).
  -f {raw,qcow2}, --format {raw,qcow2}
                        Downloaded file format. For best compatibility, use
                        qcow2 (default qcow2).
  --use-proxy           Download via proxy on the engine host (less
                        efficient).
  --max-workers MAX_WORKERS
                        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.
  --buffer-size BUFFER_SIZE
                        Buffer size per worker. The default (4194304) gives
                        good performance with the default number of workers.
                        If you use smaller number of workers you may want use
                        larger value.
  --timeout-policy {legacy,pause,cancel}
                        The action to be made for a timed out transfer


Example command to download disk id 3649d84b-6f35-4314-900a-5e8024e3905c
from engine configuration myengine to file disk.img, converting the
format to raw:

    $ python3 /usr/share/doc/python3-ovirt-engine-sdk4/examples/download_disk.py
-c myengine --format raw 3649d84b-6f35-4314-900a-5e8024e3905c disk.img
    [   0.0 ] Connecting...
    [   0.5 ] Creating image transfer...
    [   2.8 ] Transfer ID: 62c99f08-e58c-4cc2-8c72-9aa9be835d0f
    [   2.8 ] Transfer host name: host4
    [   2.8 ] Downloading image...
    [ 100.00% ] 6.00 GiB, 11.62 seconds, 528.83 MiB/s
    [  14.4 ] Finalizing image transfer...

You can check the image with qemu-img info:

    $ qemu-img info disk.img
    image: disk.img
    file format: raw
    virtual size: 6 GiB (6442450944 bytes)
    disk size: 1.69 GiB

> My laptop doesn't have space to accommodate 300 GB  so can I attache a usb 
> harddisk and can I specify its mount point ?

This will work, or you can mount NFS server and download to the mountpoint, e.g:

    $ mount | grep storage
    storage:/export/02 on /tmp/export type nfs4
(rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.122.52,local_lock=none,addr=192.168.122.32)

    $ python3 /usr/share/doc/python3-ovirt-engine-sdk4/examples/download_disk.py
-c myengine --format raw 3649d84b-6f35-4314-900a-5e8024e3905c
/tmp/export/disk.img
    [   0.0 ] Connecting...
    [   0.2 ] Creating image transfer...
    [   2.4 ] Transfer ID: cb9d5a0f-1c3c-4d1f-aa49-85a1aedd0108
    [   2.4 ] Transfer host name: host4
    [   2.4 ] Downloading image...
    [ 100.00% ] 6.00 GiB, 11.19 seconds, 549.27 MiB/s
    [  13.6 ] Finalizing image transfer...

 or any other suggestions or correcton ?  Because its a live host. I
can't do trail and error on service maintainer's rhevm host machines.

It makes sense to do all this on a vm, but downloading the image on the
actual host can be much faster, since we avoid the network.

However there is one big issue, I noticed that you mentioned ovirt 4.1 in your
original mail. This version is too old, you cannot use downoad_disk.py
from ovirt
4.4. to download images from ovirt 4.1.

In 4.1 you can download images from the UI, but only if the vm has no snapshots,
and only in the actual format of the disk (e.g. qcow2). If you need a
raw image you
will have to convert the image later using:

    qemu-img convert -f qcow2 -O raw disk.qcow2 disk.raw

You can upgrade this system or at least part of it to 4.4 (engine and
one host) and
then you can download all the disk using the sdk, or use export ova if ova works
better for your use case.

Nir
_______________________________________________
Users mailing list -- users@ovirt.org
To unsubscribe send an email to users-le...@ovirt.org
Privacy Statement: https://www.ovirt.org/privacy-policy.html
oVirt Code of Conduct: 
https://www.ovirt.org/community/about/community-guidelines/
List Archives: 
https://lists.ovirt.org/archives/list/users@ovirt.org/message/L4YV2IEHFDGNCV6EFRJ3ZOFMAEZTMNGG/

Reply via email to