use of org.ovirt.engine.api.resource.VnicProfileResource in project ovirt-engine by oVirt.
the class V3NICHelper method setNetworkAndPortMirroring.
/**
* Populates the {@code network} and {@code port_mirroring} attributes used in V3.
*
* @param v4Nic the V4 NIC where the details of the NIC profile will be extracted from
* @param v3Nic the V3 NIC object that will be populated
*/
public static void setNetworkAndPortMirroring(Nic v4Nic, V3NIC v3Nic) {
// Do nothing if the V4 NIC doesn't specify a profile:
VnicProfile v4Profile = v4Nic.getVnicProfile();
if (v4Profile == null) {
return;
}
// Retrieve the complete representation of the profile, as we need it to compute the "network" and
// "port_mirroring" attributes used in V3:
BackendApiResource systemService = BackendApiResource.getInstance();
VnicProfilesResource profilesService = systemService.getVnicProfilesResource();
VnicProfileResource profileService = profilesService.getProfileResource(v4Profile.getId());
v4Profile = profileService.get();
// Populate the "network" and "port_mirroring" attributes of the V3 object:
Network v4Network = v4Profile.getNetwork();
V3Network v3Network = new V3Network();
v3Network.setId(v4Network.getId());
v4Network.setHref(v4Network.getHref());
v3Nic.setNetwork(v3Network);
if (v4Profile.isSetPortMirroring() && v4Profile.isPortMirroring()) {
V3PortMirroring v3PortMirroring = new V3PortMirroring();
V3Networks v3PortMirroringNetworks = new V3Networks();
V3Network v3PortMirroringNetwork = new V3Network();
v3PortMirroringNetwork.setId(v4Network.getId());
v3PortMirroringNetwork.setHref(v4Network.getHref());
v3PortMirroringNetworks.getNetworks().add(v3PortMirroringNetwork);
v3PortMirroring.setNetworks(v3PortMirroringNetworks);
v3Nic.setPortMirroring(v3PortMirroring);
}
}
Aggregations