|
| 1 | +.. _import_ova: |
| 2 | + |
| 3 | +================ |
| 4 | +OVA Import |
| 5 | +================ |
| 6 | + |
| 7 | +Requirements |
| 8 | +================================================================================ |
| 9 | + |
| 10 | +The import tool will assume that the provided OVA has been exported from a VMware environment, user must make sure that the provided OVA is compatible with VMware environments. Other sources are currently not supported (i.e. Xen or VirtualBox). |
| 11 | + |
| 12 | +When converting an OVA you will need enough space both in the ``/tmp`` folder and in the destination DS where the disk images are going to be imported. |
| 13 | + |
| 14 | +Windows VirtIO drivers |
| 15 | +-------------------------------------------------------------------------------- |
| 16 | + |
| 17 | +Before converting Windows VMs, download the required VirtIO drivers for the Windows VM distribution. These drivers can be downloaded from the `virtio-win repository <https://github.com/virtio-win/virtio-win-pkg-scripts/blob/master/README.md>`__. |
| 18 | + |
| 19 | +.. note:: The converted VM will reboot several times after instantiation in order to install and configure the VirtIO drivers. |
| 20 | + |
| 21 | +Usage |
| 22 | +================================================================================ |
| 23 | + |
| 24 | +It is possible to specify the target Datastore and VNET for the OVA to be imported. Refer to ``man oneswap`` for the complete documentation of the oneswap command. Available options for the ``oneswap import`` command are: |
| 25 | + |
| 26 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 27 | +| Parameter | Description | |
| 28 | ++============================================+=======================================================================+ |
| 29 | +| ``--ova file.ova | /path/to/ovf/files/`` | Path to the OVA file or folder containing the OVF files. | |
| 30 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 31 | +| ``--datastore name | ID`` | Name/ID of the Datastore to store the new Image. Accepts one or more | |
| 32 | +| | Datastores (i.e. ``--datastore 101,102``). When more than one | |
| 33 | +| | Datastore is provided, each disk will be allocated in a different one.| |
| 34 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 35 | +| ``--network name | ID`` | Name/ID of the VNET to assign in the VM Template. Accepts one or more | |
| 36 | +| | VNETs (i.e. ``--network 0,1``). When more than one VNET is provided, | |
| 37 | +| | each interface from the OVA will be assigned to each VNET. | |
| 38 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 39 | +| ``--virtio /path/to/virtio.iso`` | Path to the ISO file with the VirtIO drivers for the Windows version. | |
| 40 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 41 | + |
| 42 | +If multiple network interfaces are detected when importing an OVA and only one VNET ID or not enough VNET IDs are provided for all interfaces, using ``--network ID``, the last one will be used for the rest of the interfaces after the last coincidence. The same will apply to Datastores using the ``--datastore ID`` option. |
| 43 | + |
| 44 | +Example on importing OVF |
| 45 | +-------------------------------------------------------------------------------- |
| 46 | + |
| 47 | +Example command on how to import an OVF using the Datastore ID 101 and VNET ID 1: |
| 48 | + |
| 49 | +.. prompt:: text $ auto |
| 50 | + |
| 51 | + $ oneswap import --ova /ovas/vm-alma9/ --datastore 101 --network 1 |
| 52 | + Running: virt-v2v -v --machine-readable -i ova /ovas/vm-alma9/ -o local -os /tmp/vm-alma9/conversions/ -of qcow2 --root=first |
| 53 | + |
| 54 | + Setting up the source: -i ova /home/onepoc/ovas/vm-alma9/ |
| 55 | + |
| 56 | + (...) |
| 57 | + |
| 58 | + $ onetemplate list |
| 59 | + ID USER GROUP NAME REGTIME |
| 60 | + 63 onepoc oneadmin vm-alma9 03/24 16:34:34 |
| 61 | + |
| 62 | + $ onetemplate instantiate 63 |
| 63 | + VM ID: 103 |
| 64 | + |
| 65 | +Example on importing OVA with multiple DS and VNET |
| 66 | +-------------------------------------------------------------------------------- |
| 67 | + |
| 68 | +The source OVA has two disks and two NICs, as it can be seen from the .ovf file: |
| 69 | + |
| 70 | +.. prompt:: text $ auto |
| 71 | + |
| 72 | + <DiskSection> |
| 73 | + <Info>List of the virtual disks</Info> |
| 74 | + <Disk ovf:capacityAllocationUnits="byte" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:diskId="vmdisk1" ovf:capacity="8589934592" ovf:fileRef="file1"/> |
| 75 | + <Disk ovf:capacityAllocationUnits="byte" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:diskId="vmdisk2" ovf:capacity="2147483648" ovf:fileRef="file2"/> |
| 76 | + </DiskSection> |
| 77 | + <NetworkSection> |
| 78 | + <Info>The list of logical networks</Info> |
| 79 | + <Network ovf:name="VM Network 0"> |
| 80 | + <Description>The VM Network 0 network</Description> |
| 81 | + </Network> |
| 82 | + <Network ovf:name="VM Network 1"> |
| 83 | + <Description>The VM Network 1 network</Description> |
| 84 | + </Network> |
| 85 | + </NetworkSection> |
| 86 | + |
| 87 | +Example command on how to import an OVA with two disks and two network interfaces, importing each disk to a different Datastore and assigning each NIC to a different VNET: |
| 88 | + |
| 89 | +.. prompt:: text $ auto |
| 90 | + |
| 91 | + $ oneswap import --ova /home/onepoc/ovas/ubuntu2404.ova --datastore 1,101 --network 1,0 |
| 92 | + Running: virt-v2v -v --machine-readable -i ova /home/onepoc/ovas/ubuntu2404.ova -o local -os /tmp/ubuntu2404/conversions/ -of qcow2 --root=first |
| 93 | + |
| 94 | + Setting up the source: -i ova /home/onepoc/ovas/ubuntu2404.ova |
| 95 | + |
| 96 | + (...) |
| 97 | + |
| 98 | + $ onetemplate list |
| 99 | + ID USER GROUP NAME REGTIME |
| 100 | + 101 onepoc oneadmin ubuntu2404 04/10 12:55:03 |
| 101 | + |
| 102 | +The OS Image is imported in Datastore 1 and the Datablock Image is imported in Datastore 101, and the VM Template has one NIC using VNET 1 and a second NIC using VNET 0. |
| 103 | + |
| 104 | +.. prompt:: text $ auto |
| 105 | + |
| 106 | + $ oneimage list |
| 107 | + ID USER GROUP NAME DATASTORE SIZE TYPE PER STAT RVMS |
| 108 | + 151 onepoc oneadmin ubuntu2404_1 NFS image 2G DB No rdy 0 |
| 109 | + 150 onepoc oneadmin ubuntu2404_0 default 8G OS No rdy 0 |
| 110 | + |
| 111 | + $ onetemplate show 101 | grep NIC -A 1 |
| 112 | + NIC=[ |
| 113 | + NETWORK_ID="1" ] |
| 114 | + NIC=[ |
| 115 | + NETWORK_ID="0" ] |
| 116 | + |
| 117 | +Context injection |
| 118 | +================================================================================ |
| 119 | + |
| 120 | +OneSwap will detect the guest operating system and try to inject the context packages available from the `one-apps <https://github.com/opennebula/one-apps>`__ repository. |
| 121 | + |
| 122 | +Context injection will be performed following these steps: |
| 123 | + |
| 124 | +1. Install context using package manager for the distro. However, this step may fail and trigger the execution of the fallback context installation command: |
| 125 | + |
| 126 | +.. prompt:: text $ auto |
| 127 | + |
| 128 | + Inspecting disk...Done (3.92s) |
| 129 | + Injecting one-context...Running: virt-customize -q -a /tmp/vm-alma9/conversions/vm-alma9-sda --run-command 'subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms' --run-command 'yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm' --copy-in /var/lib/one/context//one-context-6.10.0-3.el9.noarch.rpm:/tmp --install /tmp/one-context-6.10.0-3.el9.noarch.rpm --delete /tmp/one-context-6.10.0-3.el9.noarch.rpm --run-command 'systemctl enable NetworkManager.service || exit 0' |
| 130 | + Failed (6.31s) |
| 131 | + |
| 132 | +2. Context will be installed using a fallback method of copying the context packages into the guest OS and installing it on the first boot in case the previous step fails. Sometimes it will be necessary to boot twice in order for this method to work. |
| 133 | + |
| 134 | +.. prompt:: text $ auto |
| 135 | + |
| 136 | + Running: virt-customize -q -a /tmp/vm-alma9/conversions/vm-alma9-sda --firstboot-install epel-release --copy-in /var/lib/one/context//one-context-6.10.0-3.el9.noarch.rpm:/tmp --firstboot-install /tmp/one-context-6.10.0-3.el9.noarch.rpm --run-command 'systemctl enable network.service || exit 0' |
| 137 | + Success (42.24s) |
| 138 | + Context will install on first boot, you may need to boot it twice. |
| 139 | + |
| 140 | +.. note:: If context injection does not work after importing, it is also possible to install one-context **before exporting the OVA** from VMware using the packages available in the one-apps repository and uninstalling VMware Tools. In this case it is important to be aware that the one-context service will get rid of any manual network configurations done to the guest OS and the VM won't be able to get the network configuration from VMware anymore. |
| 141 | + |
| 142 | +Additional virt-v2v options |
| 143 | +================================================================================ |
| 144 | + |
| 145 | +The following parameters can be tuned for virt-v2v, defaults will be applied if no options are provided. |
| 146 | + |
| 147 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 148 | +| Parameter | Description | |
| 149 | ++============================================+=======================================================================+ |
| 150 | +| ``--v2v-path /path/to/ovf/files/`` | Path to the OVA file or folder containing the OVF files. | |
| 151 | +| | Default: virt-v2v | |
| 152 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 153 | +| ``--work-dir | -w /path/to/work/dir`` | Directory where disk conversion takes place, will make subdir for each| |
| 154 | +| | VM. Default: /tmp | |
| 155 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 156 | +| ``--format | -f name [ qcow2 | raw]`` | Disk format [ qcow2 | raw ]. | |
| 157 | +| | Default: qcow2 | |
| 158 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 159 | +| ``--virtio /path/to/iso`` | Full path of the win-virtio ISO file. Required to inject VirtIO | |
| 160 | +| | drivers to Windows Guests. | |
| 161 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 162 | +| ``--win-qemu-ga /path/to/iso`` | Install QEMU Guest Agent to a Windows guest. | |
| 163 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 164 | +| ``--qemu-ga`` | Install qemu-guest-agent package to a Linux guest, useful with | |
| 165 | +| | --custom or --fallback. | |
| 166 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 167 | +| ``--delete-after`` | Removes the leftover conversion directory in the working directory | |
| 168 | +| | which contains the converted VM disks and descriptor files. | |
| 169 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 170 | +| ``--vddk /path/to/vddk/`` | Full path to the VDDK library, required for VDDK based transfer. | |
| 171 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 172 | +| ``--virt-tools /path/to/virt-tools`` | Path to the directory containing rhsrvany.exe, defaults to | |
| 173 | +| | /usr/local/share/virt-tools. See https://github.com/rwmjones/rhsrvany.| |
| 174 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
| 175 | +| ``--root option`` | Choose the root filesystem to be converted. Can be ask, single, first | |
| 176 | +| | or /dev/sdX. | |
| 177 | ++--------------------------------------------+-----------------------------------------------------------------------+ |
0 commit comments