vNic Profiles – one profile to rule them all

oVirt-engine 3.3 introduced a new concept of managing the vm network interfaces.
Previously, the network used to be assigned directly to the vnic, and any specific configuration (i.e. port mirroring) would have to be defined on the vnic level, for each vm.

In oVirt-engine 3.3 a couple of features were introduced: Network QoS and Device Custom Properties which would make the previous method of configuring the same network settings over-and-over for each nic tedious, and needless to mention the maintenance aspect of such.
Using the previous method, the admin would have to iterate all over the vms and their eligible vnics to modify the QoS values.

The Vnic Profiles were designed to simplify the management of the vnic configuration: A profile is defined once per network. Each network may have as many profiles as wishes. The profiles are being assigned to the vm network interface. Using the profiles, the admin controls the way a vm is using the network.

Once the admin wishes to modify a specific vnic profile, the change will be reflected to all of the vms using it, as soon as they are being either restarted or the relevant vnics are being unplugged and plugged.

vNic Profile Dialog

The vNic Profiles are also accessible via the Restful API and also supported by the ovirt-engine Python SDK (since 3.3.0.4-1) and the Java SDK (since 1.0.0.14-1).

The previous api which relies on the network name as the parameter to be assigned on the vnic is still supported, but planned to be removed in ovirt-engine-4.0.

In order to utilize the new vNic Profiles api in ovirt-engine-3.3, the user should provide the vnic profile id instead of the network name.

The following examples executes the same logic: updating a vm nic to use a specific profile.

Python SDK example:

vm1 = api.vms.get('vm1')
nic = vm1.nics.get('nic1')
nic.vnic_profile = api.vnicprofiles.get('a-vnic-profile')
nic.update()

Java SDK example:

VnicProfile profile = api.getVnicProfiles().get("a-vnic-profile");
VM vm = api.getVMs().get("vm1");
VMNIC vnic = vm.getNics().get("nic1");
vnic.setVnicProfile(profile);
vnic.update();

Unlinking a vnic from its network/profile using the vnic profile filed:

vm1 = api.vms.get('vm1')
nic = vm1.nics.get('nic1')
nic.vnic_profile = params.VnicProfile()
nic.update()

Attaching a vnic to a network using the deprecated network name attribute.
This action will select any eligible vnic profile to be assigned for that vnic:

vm1 = api.vms.get('vm1')
nic = vm1.nics.get('nic1')
nic.network = params.Network(name = 'ovirtmgmt')
nic.update()

Unlink a vnic from its network by the deprecated network attribute:

vm1 = api.vms.get('vm1')
nic = vm1.nics.get('nic1')
nic.network = params.Network()
nic.update()

Adding new vnic with network name and port mirroring by the deprecated api:

net = params.Network(name="ovirtmgmt")
port_mirroring_nets = params.Networks(network = [net])
nic = params.NIC(name="new", network=net, 
                 port_mirroring = params.PortMirroring(port_mirroring_nets))
vm1.nics.add(nic)

Adding new vnic with network name and port mirroring by providing a suitable vnic profile configured for port mirroring:

nic = params.NIC(name="new", vnic_profile = params.VnicProfile(id ="...")
vm1.nics.add(nic)

Updaing a vnic which currently uses a profile with port mirroring requires either clearing the port mirroring attribute of the vnic if intended to modify the network or providing the new vnic profile:

The preferred method:

nic.vnic_profile = api.vnicprofiles.get('no_port_mirroring')
nic.update()

The deprecated method:

nic.network = params.Network(name = 'net_with_no_port_mirroring')
nic.port_mirroring  = params.PortMirroring()
nic.update()

The same backward compatibility logic applies also to template’s vnics.

Leave a comment