use of org.ovirt.engine.core.common.businessentities.network.VmInterfaceType in project ovirt-engine by oVirt.
the class VmInfoBuilderImpl method buildVmNetworkInterfaces.
@Override
public void buildVmNetworkInterfaces(Map<Guid, String> passthroughVnicToVfMap) {
Map<VmDeviceId, VmDevice> devicesByDeviceId = Entities.businessEntitiesById(vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(vm.getId(), VmDeviceGeneralType.INTERFACE, VmDeviceType.BRIDGE));
devicesByDeviceId.putAll(Entities.businessEntitiesById(vmDeviceDao.getVmDeviceByVmIdTypeAndDevice(vm.getId(), VmDeviceGeneralType.INTERFACE, VmDeviceType.HOST_DEVICE)));
for (VmNic vmInterface : vm.getInterfaces()) {
// get vm device for this nic from DB
VmDevice vmDevice = devicesByDeviceId.get(new VmDeviceId(vmInterface.getId(), vmInterface.getVmId()));
if (vmDevice != null && vmDevice.isManaged() && vmDevice.isPlugged()) {
Map<String, Object> struct = new HashMap<>();
VmInterfaceType ifaceType = VmInterfaceType.rtl8139;
if (vmInterface.getType() != null) {
ifaceType = VmInterfaceType.forValue(vmInterface.getType());
}
if (vmInterface.isPassthrough()) {
String vfDeviceName = passthroughVnicToVfMap.get(vmInterface.getId());
vmInfoBuildUtils.addNetworkVirtualFunctionProperties(struct, vmInterface, vmDevice, vfDeviceName, vm);
} else {
addNetworkInterfaceProperties(struct, vmInterface, vmDevice, vmInfoBuildUtils.evaluateInterfaceType(ifaceType, vm.getHasAgent()));
}
devices.add(struct);
bootableDevices.add(vmDevice);
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.VmInterfaceType in project ovirt-engine by oVirt.
the class OvfReader method setDeviceByResource.
private void setDeviceByResource(XmlNode node, VmDevice vmDevice) {
String resourceType = selectSingleNode(node, VMD_RESOURCE_TYPE, _xmlNS).innerText;
XmlNode resourceSubTypeNode = selectSingleNode(node, VMD_SUB_RESOURCE_TYPE, _xmlNS);
if (resourceSubTypeNode == null) {
// we need special handling for Monitor to define it as vnc or spice
if (OvfHardware.Monitor.equals(adjustHardwareResourceType(resourceType))) {
// get number of monitors from VirtualQuantity in OVF
if (selectSingleNode(node, VMD_VIRTUAL_QUANTITY, _xmlNS) != null && !StringUtils.isEmpty(selectSingleNode(node, VMD_VIRTUAL_QUANTITY, _xmlNS).innerText)) {
int virtualQuantity = Integer.parseInt(selectSingleNode(node, VMD_VIRTUAL_QUANTITY, _xmlNS).innerText);
if (virtualQuantity > 1) {
vmDevice.setDevice(VmDeviceType.QXL.getName());
} else {
// get first supported display device
List<Pair<GraphicsType, DisplayType>> supportedGraphicsAndDisplays = osRepository.getGraphicsAndDisplays(vmBase.getOsId(), new Version(getVersion()));
if (!supportedGraphicsAndDisplays.isEmpty()) {
DisplayType firstDisplayType = supportedGraphicsAndDisplays.get(0).getSecond();
vmDevice.setDevice(firstDisplayType.getDefaultVmDeviceType().getName());
} else {
vmDevice.setDevice(VmDeviceType.QXL.getName());
}
}
} else {
// default to spice if quantity not found
vmDevice.setDevice(VmDeviceType.QXL.getName());
}
} else {
vmDevice.setDevice(VmDeviceType.getoVirtDevice(Integer.parseInt(resourceType)).getName());
}
} else if (OvfHardware.Network.equals(resourceType)) {
// handle interfaces with different sub types : we have 0-5 as the VmInterfaceType enum
Integer nicTypeValue = getVmInterfaceType(resourceSubTypeNode);
VmInterfaceType nicType = nicTypeValue != null ? VmInterfaceType.forValue(nicTypeValue) : null;
if (nicType != null) {
if (nicType == VmInterfaceType.pciPassthrough) {
vmDevice.setDevice(VmDeviceType.HOST_DEVICE.getName());
} else {
vmDevice.setDevice(VmDeviceType.BRIDGE.getName());
}
} else {
vmDevice.setDevice(VmDeviceType.getoVirtDevice(Integer.parseInt(resourceType)).getName());
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.VmInterfaceType in project ovirt-engine by oVirt.
the class VmNicValidator method isCompatibleWithOs.
/**
* @return An error if the network interface type is not compatible with the selected operating
* system.
*/
public ValidationResult isCompatibleWithOs() {
List<String> networkDevices = Injector.get(OsRepository.class).getNetworkDevices(osId, version);
List<VmInterfaceType> interfaceTypes = new ArrayList<>();
for (String networkDevice : networkDevices) {
interfaceTypes.add(VmInterfaceType.valueOf(networkDevice));
}
return !interfaceTypes.contains(VmInterfaceType.forValue(nic.getType())) ? new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VM_INTERFACE_TYPE_IS_NOT_SUPPORTED_BY_OS) : ValidationResult.VALID;
}
Aggregations