Hi all,

I have installed the  ovirt-engine-sdk-python using pip3  in my python3 virtaul environment in my personal laptop


(base) kris@my-ThinkPad-X270:~$ pip install ovirt-engine-sdk-python
Collecting ovirt-engine-sdk-python
  Downloading ovirt-engine-sdk-python-4.4.14.tar.gz (335 kB)
     |████████████████████████████████| 335 kB 166 kB/s
Collecting pycurl>=7.19.0
  Downloading pycurl-7.43.0.6.tar.gz (222 kB)
     |████████████████████████████████| 222 kB 496 kB/s
Requirement already satisfied: six in ./training/lib/python3.7/site-packages (from ovirt-engine-sdk-python) (1.15.0)
Building wheels for collected packages: ovirt-engine-sdk-python, pycurl
  Building wheel for ovirt-engine-sdk-python (setup.py) ... done
  Created wheel for ovirt-engine-sdk-python: filename=ovirt_engine_sdk_python-4.4.14-cp37-cp37m-linux_x86_64.whl size=300970 sha256=128ee03642c36094d62a04435bf5def1e5f8eb2c800f97132e8da02665d227a8
  Stored in directory: /home/kris/.cache/pip/wheels/2f/65/60/6a222dcdec777ae59bacb3f51a0a93e6cf9547b82cb0102db6
  Building wheel for pycurl (setup.py) ... done
  Created wheel for pycurl: filename=pycurl-7.43.0.6-cp37-cp37m-linux_x86_64.whl size=269770 sha256=2cf705a2246041f9eaa5cbb19c530470edad7f476a0a7eb04c4877931699bea9
  Stored in directory: /home/kris/.cache/pip/wheels/f2/32/dc/9ccf4566cfe0a7a11ee304c11af36a1e341a16fa30e74fb26e
Successfully built ovirt-engine-sdk-python pycurl
Installing collected packages: pycurl, ovirt-engine-sdk-python
Successfully installed ovirt-engine-sdk-python-4.4.14 pycurl-7.43.0.6
WARNING: You are using pip version 21.0.1; however, version 21.2.2 is available.
You should consider upgrading via the '/home/kris/training/bin/python3.7 -m pip install --upgrade pip' command.
(base) kris@my-ThinkPad-X270:~$ which pip
/home/kris/anaconda3/bin/pip
(base) kris@my-ThinkPad-X270:~$ pip --version
pip 21.0.1 from /home/kris/training/lib/python3.7/site-packages/pip (python 3.7)
(base) kris@my-ThinkPad-X270:~$ pwd
/home/kris


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]
engine_url=https://engine-dev   // what is this engine url ? its the rhevm ovirt url this our service provider may can provide right ?
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
(base) kris@my-ThinkPad-X270:~$ pwd
/home/kris
(base) kris@my-ThinkPad-X270:~$


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

#####

(base) kris@my-ThinkPad-X270:~/OVIRT_PYTON_SDK_SOURCE_FILES/ovirt-engine-sdk-python-4.1.3/examples$ ls
add_affinity_label.py            add_vm_from_template_version.py    follow_vm_links.py       set_vm_lease_storage_domain.py
add_bond.py                      add_vm_nic.py                      get_display_ticket.py    set_vm_serial_number.py
add_cluster.py                   add_vm.py                          import_external_vm.py    show_summary.py
add_data_center.py               add_vm_snapshot.py                 import_vm.py             start_vm.py
add_floating_disk.py             add_vm_with_sysprep.py             list_affinity_labels.py  start_vm_with_boot_devices.py
add_group.py                     add_vnc_console.py                 list_glance_images.py    start_vm_with_cloud_init.py
add_host.py                      assign_affinity_label_to_vm.py     list_roles.py            stop_vm.py
add_independet_vm.py             assign_permission.py               list_tags_of_vm.py       test_connection.py
add_instance_type.py             assign_tag_to_vm.py                list_tags.py             unassign_tag_to_vm.py
add_mac_pool.py                  attach_nfs_data_storage_domain.py  list_vm_disks.py         update_data_center.py
add_nfs_data_storage_domain.py   attach_nfs_iso_storage_domain.py   list_vm_snapshots.py     update_fencing_options.py
add_nfs_iso_storage_domain.py    change_vm_cd.py                    list_vms.py              update_quota_limits.py
add_openstack_image_provider.py  clone_vm_from_snapshot.py          page_vms.py              upload_disk.py
add_role.py                      connection_builder.py              remove_host.py           vm_backup.py
add_tag.py                       disable_compression.py             remove_tag.py
add_user_ssh_public_key.py       download_disk.py                   remove_vm.py
add_vm_disk.py                   enable_serial_console.py           search_vms.py
(base) kris@my-ThinkPad-X270:~/OVIRT_PYTON_SDK_SOURCE_FILES/ovirt-engine-sdk-python-4.1.3/examples$

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

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

My laptop doesn't have space to accommodate 300 GB  so can I attache a usb harddisk and can I specify its mount point ? 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.

kindly correct me if any thing wrong in my steps .  I have to perform this script running on mylaptop to  rhevm host machines without breaking anything.

Kindly guide me. 

Kris

On Wed, Aug 4, 2021 at 1:38 AM Nir Soffer <nsoffer@redhat.com> wrote:
On Tue, Aug 3, 2021 at 7:29 PM KK CHN <kkchn.in@gmail.com> wrote:
>
> I have asked our VM maintainer to run the  command
>
> # virsh -r dumpxml vm-name_blah    //as Super user
>
> But no output :   No matching domains found that was the TTY  output on  that rhevm node when I executed the command.
>
> Then I tried to execute #  virsh list     //  it doesn't list any VMs  !!!   ( How come this ? Does the Rhevm node need to enable any CLI  with License key or something to list Vms or  to dumpxml   with   virsh ? or its CLI commands ?

RHV undefine the vms when they are not running.

> Any way I want to know what I have to ask the   maintainer    to provide a working a working  CLI   or ? which do the tasks expected to do with command line utilities in rhevm.
>
If the vm is not running you can get the vm configuration from ovirt
using the API:

    GET /api/vms/{vm-id}

You may need more API calls to get info about the disks, follow the <links>
in the returned xml.

> I have one more question :    Which command can I execute on an rhevm node  to manually export ( not through GUI portal) a   VMs to   required format  ?
>
> For example;   1.  I need to get  one  VM and disks attached to it  as raw images.  Is this possible how?
>
> and another    2. VM and disk attached to it as  Ova or( what other good format) which suitable to upload to glance ?

Arik can add more info on exporting.

>   Each VMs are around 200 to 300 GB with disk volumes ( so where should be the images exported to which path to specify ? to the host node(if the host doesn't have space  or NFS mount ? how to specify the target location where the VM image get stored in case of NFS mount ( available ?)

You have 2 options:
- Download the disks using the SDK
- Export the VM to OVA

When exporting to OVA, you will always get qcow2 images, which you can later
convert to raw using "qemu-img convert"

When downloading the disks, you control the image format, for example
this will download
the disk in any format, collapsing all snapshots to the raw format:

 $ python3 /usr/share/doc/python3-ovirt-engine-sdk4/examples/download_disk.py
-c engine-dev 3649d84b-6f35-4314-900a-5e8024e3905c /var/tmp/disk1.raw

This requires ovirt.conf file:

$ cat ~/.config/ovirt.conf
[engine-dev]
engine_url = https://engine-dev
username = admin@internal
password = mypassword
cafile = /etc/pki/vdsm/certs/cacert.pem

Nir

> Thanks in advance
>
>
> On Mon, Aug 2, 2021 at 8:22 PM Nir Soffer <nsoffer@redhat.com> wrote:
>>
>> On Mon, Aug 2, 2021 at 12:22 PM <kkchn.in@gmail.com> wrote:
>> >
>> > I have  few VMs in   Redhat Virtualisation environment  RHeV ( using Rhevm4.1 ) managed by a third party
>> >
>> > Now I am in the process of migrating  those VMs to  my cloud setup with  OpenStack ussuri  version  with KVM hypervisor and Glance storage.
>> >
>> > The third party is making down each VM and giving the each VM image  with their attached volume disks along with it.
>> >
>> > There are three folders  which contain images for each VM .
>> > These folders contain the base OS image, and attached LVM disk images ( from time to time they added hard disks  and used LVM for storing data ) where data is stored.
>> >
>> > Is there a way to  get all these images to be exported as  Single image file Instead of  multiple image files from Rhevm it self.  Is this possible ?
>> >
>> > If possible how to combine e all these disk images to a single image and that image  can upload to our  cloud  glance storage as a single image ?
>>
>> It is not clear what is the vm you are trying to export. If you share
>> the libvirt xml
>> of this vm it will be more clear. You can use "sudo virsh -r dumpxml vm-name".
>>
>> RHV supports download of disks to one image per disk, which you can move
>> to another system.
>>
>> We also have export to ova, which creates one tar file with all exported disks,
>> if this helps.
>>
>> Nir
>>