Search in sources :

Example 6 with DiskInterface

use of org.ovirt.engine.core.common.businessentities.storage.DiskInterface in project ovirt-engine by oVirt.

the class LibvirtVmXmlBuilder method writeDevices.

private void writeDevices() {
    List<VmDevice> devices = vmInfoBuildUtils.getVmDevices(vm.getId());
    // replacement of some devices in run-once mode should eventually be done by the run-command
    devices = overrideDevicesForRunOnce(devices);
    devices = processPayload(devices);
    devices.stream().filter(d -> d.getSpecParams() == null).forEach(d -> d.setSpecParams(Collections.emptyMap()));
    writer.writeStartElement("devices");
    if (vm.getClusterArch() != ArchitectureType.s390x && !(vm.getClusterArch().getFamily() == ArchitectureType.ppc && vm.getVmType() == VmType.HighPerformance)) {
        // no mouse or tablet for s390x and for HP VMS with ppc architecture type
        writeInput();
    }
    writeGuestAgentChannels();
    if (vm.getClusterArch() == ArchitectureType.ppc64 || vm.getClusterArch() == ArchitectureType.ppc64le) {
        writeEmulator();
    }
    Map<DiskInterface, Integer> controllerIndexMap = ArchStrategyFactory.getStrategy(vm.getClusterArch()).run(new GetControllerIndices()).returnValue();
    int virtioScsiIndex = controllerIndexMap.get(DiskInterface.VirtIO_SCSI);
    List<VmDevice> interfaceDevices = new ArrayList<>();
    List<VmDevice> diskDevices = new ArrayList<>();
    List<VmDevice> cdromDevices = new ArrayList<>();
    VmDevice floppyDevice = null;
    boolean spiceExists = false;
    boolean balloonExists = false;
    boolean forceRefreshDevices = false;
    for (VmDevice device : devices) {
        if (!device.isPlugged()) {
            continue;
        }
        switch(device.getType()) {
            case BALLOON:
                balloonExists = true;
                writeBalloon(device);
                break;
            case SMARTCARD:
                writeSmartcard(device);
                break;
            case WATCHDOG:
                writeWatchdog(device);
                break;
            case MEMORY:
                // memory devices are only used for hot-plug
                break;
            case VIDEO:
                writeVideo(device);
                break;
            case CONTROLLER:
                switch(device.getDevice()) {
                    case "virtio-serial":
                        device.getSpecParams().put("index", 0);
                        device.getSpecParams().put("ports", 16);
                        break;
                    case "virtio-scsi":
                        device.setDevice(VdsProperties.Scsi);
                        device.getSpecParams().put("index", virtioScsiIndex++);
                        device.getSpecParams().put("model", "virtio-scsi");
                        break;
                }
                writeController(device);
                break;
            case GRAPHICS:
                writeGraphics(device);
                spiceExists = spiceExists || device.getDevice().equals("spice");
                break;
            case SOUND:
                writeSound(device);
                break;
            case RNG:
                writeRng(device);
                break;
            case CONSOLE:
                writeConsole(device);
                if ("serial".equals(device.getSpecParams().get("consoleType"))) {
                    serialConsolePath = getSerialConsolePath(device);
                }
                break;
            case DISK:
                switch(VmDeviceType.getByName(device.getDevice())) {
                    case CDROM:
                        cdromDevices.add(device);
                        break;
                    case DISK:
                        diskDevices.add(device);
                        break;
                    case FLOPPY:
                        if (floppyDevice == null || !VmPayload.isPayload(floppyDevice.getSpecParams())) {
                            floppyDevice = device;
                        }
                        break;
                    default:
                }
                break;
            case INTERFACE:
                interfaceDevices.add(device);
                break;
            case REDIR:
                writeRedir(device);
                break;
            case REDIRDEV:
                break;
            case CHANNEL:
                break;
            case HOSTDEV:
                HostDevice hostDevice = hostDevicesSupplier.get().get(device.getDevice());
                if (hostDevice == null) {
                    if (!"mdev".equals(device.getDevice())) {
                        log.info("skipping VM host device {} for VM {}, no corresponding host device was found", device.getDevice(), device.getVmId());
                    }
                    forceRefreshDevices = true;
                    break;
                }
                writeHostDevice(device, hostDevice);
                break;
            case UNKNOWN:
                break;
            default:
                break;
        }
    }
    if (forceRefreshDevices) {
        vmInfoBuildUtils.refreshVmDevices(vm.getId());
    }
    if (!balloonExists) {
        writeDefaultBalloon();
    }
    writeSerialConsole(serialConsolePath);
    if (spiceExists) {
        writeSpiceVmcChannel();
    }
    updateBootOrder(diskDevices, cdromDevices, interfaceDevices);
    writeInterfaces(interfaceDevices);
    writeCdRom(cdromDevices);
    writeFloppy(floppyDevice);
    // we must write the disk after writing cd-rom and floppy to know reserved indices
    writeDisks(diskDevices);
    writeLeases();
    writer.writeEndElement();
}
Also used : Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) VmType(org.ovirt.engine.core.common.businessentities.VmType) PropagateErrors(org.ovirt.engine.core.common.businessentities.storage.PropagateErrors) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LoggerFactory(org.slf4j.LoggerFactory) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) VmCpuCountHelper(org.ovirt.engine.core.common.utils.VmCpuCountHelper) XmlTextWriter(org.ovirt.engine.core.utils.ovf.xml.XmlTextWriter) HugePageUtils(org.ovirt.engine.core.common.utils.HugePageUtils) ChipsetType(org.ovirt.engine.core.common.businessentities.ChipsetType) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) Map(java.util.Map) VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) StringMapUtils(org.ovirt.engine.core.utils.StringMapUtils) VmDeviceCommonUtils.updateVmDevicesBootOrder(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils.updateVmDevicesBootOrder) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) VdsStatistics(org.ovirt.engine.core.common.businessentities.VdsStatistics) Version(org.ovirt.engine.core.compat.Version) MemoizingSupplier(org.ovirt.engine.core.utils.MemoizingSupplier) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) Collection(java.util.Collection) VmPayload(org.ovirt.engine.core.common.businessentities.VmPayload) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) List(java.util.List) Stream(java.util.stream.Stream) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) Entry(java.util.Map.Entry) Optional(java.util.Optional) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) NumaSettingFactory(org.ovirt.engine.core.vdsbroker.vdsbroker.NumaSettingFactory) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) NetworkUtils(org.ovirt.engine.core.utils.NetworkUtils) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) VmPropertiesUtils(org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils) HashSet(java.util.HashSet) ArchStrategyFactory(org.ovirt.engine.core.utils.archstrategy.ArchStrategyFactory) VdsProperties(org.ovirt.engine.core.vdsbroker.vdsbroker.VdsProperties) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Network(org.ovirt.engine.core.common.businessentities.network.Network) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) Pair(org.ovirt.engine.core.common.utils.Pair) Config(org.ovirt.engine.core.common.config.Config) Logger(org.slf4j.Logger) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmHostDevice(org.ovirt.engine.core.common.businessentities.VmHostDevice) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VM(org.ovirt.engine.core.common.businessentities.VM) NumaTuneMode(org.ovirt.engine.core.common.businessentities.NumaTuneMode) GetControllerIndices(org.ovirt.engine.core.vdsbroker.architecture.GetControllerIndices) IoTuneUtils.ioTuneListFrom(org.ovirt.engine.core.vdsbroker.vdsbroker.IoTuneUtils.ioTuneListFrom) Comparator(java.util.Comparator) Collections(java.util.Collections) StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) VmHostDevice(org.ovirt.engine.core.common.businessentities.VmHostDevice) ArrayList(java.util.ArrayList) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) GetControllerIndices(org.ovirt.engine.core.vdsbroker.architecture.GetControllerIndices)

Example 7 with DiskInterface

use of org.ovirt.engine.core.common.businessentities.storage.DiskInterface in project ovirt-engine by oVirt.

the class LibvirtVmXmlBuilder method writeDisks.

private void writeDisks(List<VmDevice> devices) {
    Map<VmDeviceId, VmDevice> deviceIdToDevice = devices.stream().collect(Collectors.toMap(VmDevice::getId, dev -> dev));
    Map<Integer, Map<VmDevice, Integer>> vmDeviceSpaprVscsiUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForSpaprScsiDisks(vm);
    Map<Integer, Map<VmDevice, Integer>> vmDeviceVirtioScsiUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForVirtioScsiDisks(vm);
    int hdIndex = -1;
    int sdIndex = -1;
    int vdIndex = -1;
    int pinnedDriveIndex = 0;
    Map<Disk, VmDevice> vmDisksToDevices = vm.getDiskMap().values().stream().map(d -> new Pair<>(d, deviceIdToDevice.get(new VmDeviceId(d.getId(), vm.getId())))).filter(p -> p.getSecond() != null && p.getSecond().isManaged()).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond));
    for (Entry<Disk, VmDevice> diskAndDevice : vmInfoBuildUtils.getSortedDisks(vmDisksToDevices, vm.getId())) {
        Disk disk = diskAndDevice.getKey();
        VmDevice device = diskAndDevice.getValue();
        DiskVmElement dve = disk.getDiskVmElementForVm(vm.getId());
        DiskInterface diskInterface = dve.getDiskInterface();
        int index = 0;
        int pinTo = 0;
        switch(diskInterface) {
            case IDE:
                index = hdIndex = skipCdIndices(++hdIndex, diskInterface);
                break;
            case VirtIO:
                pinTo = vmInfoBuildUtils.pinToIoThreads(vm, pinnedDriveIndex++);
                index = vdIndex = skipCdIndices(++vdIndex, diskInterface);
                break;
            case SPAPR_VSCSI:
            case VirtIO_SCSI:
                vmInfoBuildUtils.calculateAddressForScsiDisk(vm, disk, device, vmDeviceSpaprVscsiUnitMap, vmDeviceVirtioScsiUnitMap);
            case SATA:
                index = sdIndex = skipCdIndices(++sdIndex, diskInterface);
                break;
        }
        String dev = vmInfoBuildUtils.makeDiskName(dve.getDiskInterface().getName(), index);
        writeDisk(device, disk, dve, dev, pinTo);
    }
}
Also used : Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) VmType(org.ovirt.engine.core.common.businessentities.VmType) PropagateErrors(org.ovirt.engine.core.common.businessentities.storage.PropagateErrors) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LoggerFactory(org.slf4j.LoggerFactory) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) VmCpuCountHelper(org.ovirt.engine.core.common.utils.VmCpuCountHelper) XmlTextWriter(org.ovirt.engine.core.utils.ovf.xml.XmlTextWriter) HugePageUtils(org.ovirt.engine.core.common.utils.HugePageUtils) ChipsetType(org.ovirt.engine.core.common.businessentities.ChipsetType) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) Map(java.util.Map) VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) StringMapUtils(org.ovirt.engine.core.utils.StringMapUtils) VmDeviceCommonUtils.updateVmDevicesBootOrder(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils.updateVmDevicesBootOrder) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) VdsStatistics(org.ovirt.engine.core.common.businessentities.VdsStatistics) Version(org.ovirt.engine.core.compat.Version) MemoizingSupplier(org.ovirt.engine.core.utils.MemoizingSupplier) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) Collection(java.util.Collection) VmPayload(org.ovirt.engine.core.common.businessentities.VmPayload) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) List(java.util.List) Stream(java.util.stream.Stream) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) Entry(java.util.Map.Entry) Optional(java.util.Optional) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) NumaSettingFactory(org.ovirt.engine.core.vdsbroker.vdsbroker.NumaSettingFactory) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) NetworkUtils(org.ovirt.engine.core.utils.NetworkUtils) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) VmPropertiesUtils(org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils) HashSet(java.util.HashSet) ArchStrategyFactory(org.ovirt.engine.core.utils.archstrategy.ArchStrategyFactory) VdsProperties(org.ovirt.engine.core.vdsbroker.vdsbroker.VdsProperties) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Network(org.ovirt.engine.core.common.businessentities.network.Network) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) Pair(org.ovirt.engine.core.common.utils.Pair) Config(org.ovirt.engine.core.common.config.Config) Logger(org.slf4j.Logger) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmHostDevice(org.ovirt.engine.core.common.businessentities.VmHostDevice) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) VM(org.ovirt.engine.core.common.businessentities.VM) NumaTuneMode(org.ovirt.engine.core.common.businessentities.NumaTuneMode) GetControllerIndices(org.ovirt.engine.core.vdsbroker.architecture.GetControllerIndices) IoTuneUtils.ioTuneListFrom(org.ovirt.engine.core.vdsbroker.vdsbroker.IoTuneUtils.ioTuneListFrom) Comparator(java.util.Comparator) Collections(java.util.Collections) StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) Map(java.util.Map) HashMap(java.util.HashMap) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 8 with DiskInterface

use of org.ovirt.engine.core.common.businessentities.storage.DiskInterface in project ovirt-engine by oVirt.

the class VmInfoBuildUtils method calculateAddressForScsiDisk.

public void calculateAddressForScsiDisk(VM vm, Disk disk, VmDevice device, Map<Integer, Map<VmDevice, Integer>> vmDeviceSpaprVscsiUnitMap, Map<Integer, Map<VmDevice, Integer>> vmDeviceVirtioScsiUnitMap) {
    Map<DiskInterface, Integer> controllerIndexMap = ArchStrategyFactory.getStrategy(vm.getClusterArch()).run(new GetControllerIndices()).returnValue();
    int defaultSpaprVscsiControllerIndex = controllerIndexMap.get(DiskInterface.SPAPR_VSCSI);
    int defaultVirtioScsiControllerIndex = controllerIndexMap.get(DiskInterface.VirtIO_SCSI);
    Integer unitIndex = null;
    switch(disk.getDiskVmElementForVm(vm.getId()).getDiskInterface()) {
        case SPAPR_VSCSI:
            if (StringUtils.isEmpty(device.getAddress())) {
                unitIndex = vmDeviceSpaprVscsiUnitMap.get(defaultSpaprVscsiControllerIndex).get(device);
                device.setAddress(createAddressForScsiDisk(defaultSpaprVscsiControllerIndex, unitIndex).toString());
            }
            break;
        case VirtIO_SCSI:
            int controllerIndex = defaultVirtioScsiControllerIndex;
            VmDevice deviceFromMap = device;
            for (Map.Entry<Integer, Map<VmDevice, Integer>> controllerToDevices : vmDeviceVirtioScsiUnitMap.entrySet()) {
                Optional<VmDevice> maybeDeviceFromMap = controllerToDevices.getValue().keySet().stream().filter(d -> d.getId().equals(device.getId())).findFirst();
                if (maybeDeviceFromMap.isPresent()) {
                    deviceFromMap = maybeDeviceFromMap.get();
                    controllerIndex = controllerToDevices.getKey();
                    unitIndex = controllerToDevices.getValue().get(deviceFromMap);
                    break;
                }
            }
            if (StringUtils.isEmpty(deviceFromMap.getAddress())) {
                if (unitIndex == null) {
                    // should never get here, but for safety having this fallback and generating a new unit id
                    unitIndex = getAvailableUnitForScsiDisk(vmDeviceVirtioScsiUnitMap.get(controllerIndex), false, false);
                    log.debug("The unit was null for disk '{}' on controller '{}', generating a new one '{}'", disk.getId(), controllerIndex, unitIndex);
                }
                device.setAddress(createAddressForScsiDisk(controllerIndex, unitIndex).toString());
            }
            break;
    }
}
Also used : Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Base64(org.apache.commons.codec.binary.Base64) OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository) VmNicFilterParameterDao(org.ovirt.engine.core.dao.network.VmNicFilterParameterDao) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter) Matcher(java.util.regex.Matcher) ChipsetType(org.ovirt.engine.core.common.businessentities.ChipsetType) VmDeviceCommonUtils(org.ovirt.engine.core.common.utils.VmDeviceCommonUtils) Map(java.util.Map) VdsNumaNode(org.ovirt.engine.core.common.businessentities.VdsNumaNode) StringMapUtils(org.ovirt.engine.core.utils.StringMapUtils) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) VdsStatistics(org.ovirt.engine.core.common.businessentities.VdsStatistics) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) DisplayType(org.ovirt.engine.core.common.businessentities.DisplayType) ComparatorUtils(org.ovirt.engine.core.utils.collections.ComparatorUtils) NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter) CinderVolumeDriver(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeDriver) VmPayload(org.ovirt.engine.core.common.businessentities.VmPayload) Set(java.util.Set) NetworkDao(org.ovirt.engine.core.dao.network.NetworkDao) StandardCharsets(java.nio.charset.StandardCharsets) HostDevice(org.ovirt.engine.core.common.businessentities.HostDevice) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) VnicProfileDao(org.ovirt.engine.core.dao.network.VnicProfileDao) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) IoTuneUtils(org.ovirt.engine.core.vdsbroker.vdsbroker.IoTuneUtils) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) Guid(org.ovirt.engine.core.compat.Guid) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) NetworkUtils(org.ovirt.engine.core.utils.NetworkUtils) ArrayList(java.util.ArrayList) VmDeviceGeneralType(org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType) StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) VdsProperties(org.ovirt.engine.core.vdsbroker.vdsbroker.VdsProperties) StorageServerConnectionDao(org.ovirt.engine.core.dao.StorageServerConnectionDao) LinkedHashSet(java.util.LinkedHashSet) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) SupportedAdditionalClusterFeature(org.ovirt.engine.core.common.businessentities.SupportedAdditionalClusterFeature) VM(org.ovirt.engine.core.common.businessentities.VM) ClusterFeatureDao(org.ovirt.engine.core.dao.ClusterFeatureDao) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) VmType(org.ovirt.engine.core.common.businessentities.VmType) PropagateErrors(org.ovirt.engine.core.common.businessentities.storage.PropagateErrors) VdsNumaNodeDao(org.ovirt.engine.core.dao.VdsNumaNodeDao) Date(java.util.Date) NetworkQoS(org.ovirt.engine.core.common.businessentities.network.NetworkQoS) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType) LoggerFactory(org.slf4j.LoggerFactory) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) VmDeviceDao(org.ovirt.engine.core.dao.VmDeviceDao) Version(org.ovirt.engine.core.compat.Version) MemoizingSupplier(org.ovirt.engine.core.utils.MemoizingSupplier) VmDevicesMonitoring(org.ovirt.engine.core.vdsbroker.monitoring.VmDevicesMonitoring) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) VmNumaNode(org.ovirt.engine.core.common.businessentities.VmNumaNode) TimeZone(java.util.TimeZone) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) NetworkQoSDao(org.ovirt.engine.core.dao.network.NetworkQoSDao) Objects(java.util.Objects) List(java.util.List) WindowsJavaTimezoneMapping(org.ovirt.engine.core.compat.WindowsJavaTimezoneMapping) Entry(java.util.Map.Entry) Optional(java.util.Optional) AuditLogType(org.ovirt.engine.core.common.AuditLogType) Pattern(java.util.regex.Pattern) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) NetworkClusterDao(org.ovirt.engine.core.dao.network.NetworkClusterDao) NetworkQosMapper(org.ovirt.engine.core.vdsbroker.vdsbroker.NetworkQosMapper) IntStream(java.util.stream.IntStream) VmDeviceType(org.ovirt.engine.core.common.utils.VmDeviceType) VdsStatisticsDao(org.ovirt.engine.core.dao.VdsStatisticsDao) ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) PDIVMapBuilder(org.ovirt.engine.core.common.utils.PDIVMapBuilder) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ArchStrategyFactory(org.ovirt.engine.core.utils.archstrategy.ArchStrategyFactory) CollectionUtils(org.apache.commons.collections.CollectionUtils) LexoNumericNameableComparator(org.ovirt.engine.core.common.businessentities.comparators.LexoNumericNameableComparator) Network(org.ovirt.engine.core.common.businessentities.network.Network) VolumeFormat(org.ovirt.engine.core.common.businessentities.storage.VolumeFormat) LinkedList(java.util.LinkedList) StorageDomainStaticDao(org.ovirt.engine.core.dao.StorageDomainStaticDao) Config(org.ovirt.engine.core.common.config.Config) Logger(org.slf4j.Logger) ValidationUtils(org.ovirt.engine.core.common.utils.ValidationUtils) MapUtils(org.apache.commons.collections.MapUtils) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) CinderConnectionInfo(org.ovirt.engine.core.common.businessentities.storage.CinderConnectionInfo) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) HostDeviceDao(org.ovirt.engine.core.dao.HostDeviceDao) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) NetworkFilterDao(org.ovirt.engine.core.dao.network.NetworkFilterDao) GetControllerIndices(org.ovirt.engine.core.vdsbroker.architecture.GetControllerIndices) VmNumaNodeDao(org.ovirt.engine.core.dao.VmNumaNodeDao) Comparator(java.util.Comparator) StorageQosDao(org.ovirt.engine.core.dao.qos.StorageQosDao) Collections(java.util.Collections) StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) Map(java.util.Map) HashMap(java.util.HashMap) GetControllerIndices(org.ovirt.engine.core.vdsbroker.architecture.GetControllerIndices)

Example 9 with DiskInterface

use of org.ovirt.engine.core.common.businessentities.storage.DiskInterface in project ovirt-engine by oVirt.

the class AbstractDiskModel method flush.

public void flush() {
    switch(getDiskStorageType().getEntity()) {
        case LUN:
            LunDisk lunDisk = getLunDisk();
            DiskInterface diskInterface = getDiskInterface().getSelectedItem();
            if (DiskInterface.VirtIO_SCSI.equals(diskInterface)) {
                lunDisk.setSgio(!getIsScsiPassthrough().getEntity() ? null : getIsSgIoUnfiltered().getEntity() ? ScsiGenericIO.UNFILTERED : ScsiGenericIO.FILTERED);
                if (!getIsFloating()) {
                    getDiskVmElement().setUsingScsiReservation(getIsUsingScsiReservation().getEntity());
                }
            } else {
                getIsScsiPassthrough().setEntity(false);
                lunDisk.setSgio(null);
                if (!getIsFloating()) {
                    getDiskVmElement().setUsingScsiReservation(false);
                }
            }
            setDisk(lunDisk);
            break;
        case CINDER:
            CinderDisk cinderDisk = getCinderDisk();
            updateQuota(cinderDisk);
            updateDiskSize(cinderDisk);
            setDisk(cinderDisk);
            break;
        case IMAGE:
            DiskImage diskImage = getDiskImage();
            // For a long time it was possible to delete all disk profiles
            if (getDiskProfile().getSelectedItem() != null) {
                diskImage.setDiskProfileId(getDiskProfile().getSelectedItem().getId());
            }
            updateQuota(diskImage);
            updateDiskSize(diskImage);
            setDisk(diskImage);
            break;
    }
    getDisk().setDiskAlias(getAlias().getEntity());
    getDisk().setDiskDescription(getDescription().getEntity());
    getDisk().setWipeAfterDelete(getIsWipeAfterDelete().getEntity());
    getDisk().setShareable(getIsShareable().getEntity());
    getDisk().setPlugged(getIsPlugged().getEntity());
    getDisk().setPropagateErrors(PropagateErrors.Off);
    if (getVm() != null) {
        getDiskVmElement().setReadOnly(getIsReadOnly().getIsAvailable() ? getIsReadOnly().getEntity() : false);
        getDiskVmElement().setBoot(getIsBootable().getEntity());
        getDiskVmElement().setDiskInterface(getDiskInterface().getSelectedItem());
        getDiskVmElement().setPassDiscard(getPassDiscard().getEntity());
    }
}
Also used : DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 10 with DiskInterface

use of org.ovirt.engine.core.common.businessentities.storage.DiskInterface in project ovirt-engine by oVirt.

the class AbstractDiskModel method updatePassDiscardAvailability.

protected void updatePassDiscardAvailability() {
    if (!AsyncDataProvider.getInstance().isPassDiscardFeatureSupported(getDataCenter().getSelectedItem().getCompatibilityVersion())) {
        getPassDiscard().setIsAvailable(false);
        return;
    }
    if (getIsFloating()) {
        getPassDiscard().setIsAvailable(false);
    } else {
        DiskInterface selectedInterface = getDiskInterface().getSelectedItem();
        DiskStorageType selectedDiskStorageType = getDiskStorageType().getEntity();
        boolean isApplicableInterface = selectedInterface == DiskInterface.VirtIO_SCSI || selectedInterface == DiskInterface.IDE;
        boolean isApplicableDiskStorageType = selectedDiskStorageType == DiskStorageType.LUN || selectedDiskStorageType == DiskStorageType.IMAGE;
        boolean isApplicableStorageType = selectedDiskStorageType == DiskStorageType.LUN || (getStorageDomain().getSelectedItem() != null && getStorageDomain().getSelectedItem().getStorageType().isInternal());
        if (isApplicableInterface && isApplicableDiskStorageType && isApplicableStorageType) {
            getPassDiscard().setIsAvailable(true);
            if (!getIsNew()) {
                getPassDiscard().setEntity(getDiskVmElement().isPassDiscard());
            }
        } else {
            // Reset PassDiscard's availability and value.
            getPassDiscard().setIsAvailable(false);
            getPassDiscard().setEntity(false);
        }
    }
}
Also used : DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface)

Aggregations

DiskInterface (org.ovirt.engine.core.common.businessentities.storage.DiskInterface)13 HashMap (java.util.HashMap)5 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)5 GetControllerIndices (org.ovirt.engine.core.vdsbroker.architecture.GetControllerIndices)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 VM (org.ovirt.engine.core.common.businessentities.VM)4 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)4 Arrays (java.util.Arrays)3 Collection (java.util.Collection)3 Collections (java.util.Collections)3 Comparator (java.util.Comparator)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Entry (java.util.Map.Entry)3 Objects (java.util.Objects)3 Optional (java.util.Optional)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 StringUtils (org.apache.commons.lang.StringUtils)3