Search in sources :

Example 36 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class VmValidator method checkPciAndIdeLimit.

/**
 * This method checks that with the given parameters, the max PCI and IDE limits defined are not passed.
 */
public static ValidationResult checkPciAndIdeLimit(int osId, Version clusterVersion, int monitorsNumber, List<? extends VmNic> interfaces, List<DiskVmElement> diskVmElements, boolean virtioScsiEnabled, boolean hasWatchdog, boolean isBalloonEnabled, boolean isSoundDeviceEnabled) {
    // this adds: monitors + 2 * (interfaces with type rtl_pv) + (all other
    // interfaces) + (all disks that are not IDE)
    int pciInUse = monitorsNumber;
    for (VmNic a : interfaces) {
        if (a.getType() != null && VmInterfaceType.forValue(a.getType()) == VmInterfaceType.rtl8139_pv) {
            pciInUse += 2;
        } else if (a.getType() != null && VmInterfaceType.forValue(a.getType()) == VmInterfaceType.spaprVlan) {
        // Do not count sPAPR VLAN devices since they are not PCI
        } else {
            pciInUse += 1;
        }
    }
    pciInUse += diskVmElements.stream().filter(dve -> dve.getDiskInterface() == DiskInterface.VirtIO).count();
    // VirtIO SCSI controller requires one PCI slot
    pciInUse += virtioScsiEnabled ? 1 : 0;
    // VmWatchdog controller requires one PCI slot
    pciInUse += hasWatchdog ? 1 : 0;
    // Balloon controller requires one PCI slot
    pciInUse += isBalloonEnabled ? 1 : 0;
    // Sound device controller requires one PCI slot
    pciInUse += isSoundDeviceEnabled ? 1 : 0;
    OsRepository osRepository = Injector.get(OsRepository.class);
    int maxPciSlots = osRepository.getMaxPciDevices(osId, clusterVersion);
    ArrayList<EngineMessage> messages = new ArrayList<>();
    if (pciInUse > maxPciSlots) {
        messages.add(EngineMessage.ACTION_TYPE_FAILED_EXCEEDED_MAX_PCI_SLOTS);
    } else if (VmCommand.MAX_IDE_SLOTS < diskVmElements.stream().filter(a -> a.getDiskInterface() == DiskInterface.IDE).count()) {
        messages.add(EngineMessage.ACTION_TYPE_FAILED_EXCEEDED_MAX_IDE_SLOTS);
    } else if (VmCommand.MAX_VIRTIO_SCSI_DISKS < diskVmElements.stream().filter(a -> a.getDiskInterface() == DiskInterface.VirtIO_SCSI).count()) {
        messages.add(EngineMessage.ACTION_TYPE_FAILED_EXCEEDED_MAX_VIRTIO_SCSI_DISKS);
    } else if (VmCommand.MAX_SPAPR_SCSI_DISKS < diskVmElements.stream().filter(a -> a.getDiskInterface() == DiskInterface.SPAPR_VSCSI).count()) {
        messages.add(EngineMessage.ACTION_TYPE_FAILED_EXCEEDED_MAX_SPAPR_VSCSI_DISKS);
    }
    if (!messages.isEmpty()) {
        return new ValidationResult(messages);
    }
    return ValidationResult.VALID;
}
Also used : Arrays(java.util.Arrays) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) VmInterfaceType(org.ovirt.engine.core.common.businessentities.network.VmInterfaceType) Guid(org.ovirt.engine.core.compat.Guid) ReplacementUtils(org.ovirt.engine.core.utils.ReplacementUtils) OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository) DbFacade(org.ovirt.engine.core.dal.dbbroker.DbFacade) ArrayList(java.util.ArrayList) VmPropertiesUtils(org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils) ActionType(org.ovirt.engine.core.common.action.ActionType) DisksFilter(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter) Map(java.util.Map) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic) ONLY_ACTIVE(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_ACTIVE) Version(org.ovirt.engine.core.compat.Version) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) VmCommand(org.ovirt.engine.core.bll.VmCommand) Config(org.ovirt.engine.core.common.config.Config) ActionUtils(org.ovirt.engine.core.common.ActionUtils) DiskImagesValidator(org.ovirt.engine.core.bll.validator.storage.DiskImagesValidator) VmBase(org.ovirt.engine.core.common.businessentities.VmBase) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Predicate(java.util.function.Predicate) Collection(java.util.Collection) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) HostDeviceManager(org.ovirt.engine.core.bll.hostdev.HostDeviceManager) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskVmElementDao(org.ovirt.engine.core.dao.DiskVmElementDao) Collectors(java.util.stream.Collectors) SnapshotType(org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType) ONLY_NOT_SHAREABLE(org.ovirt.engine.core.bll.storage.disk.image.DisksFilter.ONLY_NOT_SHAREABLE) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) DiskDao(org.ovirt.engine.core.dao.DiskDao) Injector(org.ovirt.engine.core.di.Injector) DiskInterface(org.ovirt.engine.core.common.businessentities.storage.DiskInterface) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) MigrationSupport(org.ovirt.engine.core.common.businessentities.MigrationSupport) Collections(java.util.Collections) FeatureSupported(org.ovirt.engine.core.common.FeatureSupported) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) ArrayList(java.util.ArrayList) OsRepository(org.ovirt.engine.core.common.osinfo.OsRepository) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

Example 37 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class CpuFlagsManagerHandler method initDictionaries.

@PostConstruct
public void initDictionaries() {
    log.info("Start initializing dictionaries");
    managersDictionary.clear();
    for (Version ver : Config.<HashSet<Version>>getValue(ConfigValues.SupportedClusterLevels)) {
        managersDictionary.put(ver, new CpuFlagsManager(ver));
    }
    log.info("Finished initializing dictionaries");
}
Also used : Version(org.ovirt.engine.core.compat.Version) HashSet(java.util.HashSet) PostConstruct(javax.annotation.PostConstruct)

Example 38 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class DataCenterCompatibilityChecker method checkCompatibility.

private void checkCompatibility() {
    try {
        Optional<Version> retVal = Config.<HashSet<Version>>getValue(ConfigValues.SupportedClusterLevels).stream().max(Comparator.naturalOrder());
        if (retVal.isPresent()) {
            Version version = retVal.get();
            storagePoolDao.getAll().stream().filter(storagePool -> version.compareTo(storagePool.getCompatibilityVersion()) > 0).forEach(storagePool -> logAlert(version, storagePool));
        }
    } catch (Throwable t) {
        log.error("Failed to check certification validity: {}", ExceptionUtils.getRootCauseMessage(t));
        log.debug("Exception", t);
    }
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Logger(org.slf4j.Logger) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) ExceptionUtils(org.apache.commons.lang.exception.ExceptionUtils) LoggerFactory(org.slf4j.LoggerFactory) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Singleton(javax.inject.Singleton) ThreadPools(org.ovirt.engine.core.utils.threadpool.ThreadPools) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) Inject(javax.inject.Inject) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) AuditLogType(org.ovirt.engine.core.common.AuditLogType) StoragePoolDao(org.ovirt.engine.core.dao.StoragePoolDao) Comparator(java.util.Comparator) BackendService(org.ovirt.engine.core.common.BackendService) Version(org.ovirt.engine.core.compat.Version) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) ManagedScheduledExecutorService(javax.enterprise.concurrent.ManagedScheduledExecutorService) Config(org.ovirt.engine.core.common.config.Config) Version(org.ovirt.engine.core.compat.Version) HashSet(java.util.HashSet)

Example 39 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class GetoVirtISOsQuery method isNewerVersion.

private boolean isNewerVersion(Version isoClusterVersion) {
    VDS vds = getVdsByVdsId(getParameters().getId());
    Version vdsClusterVersion = vds.getClusterCompatibilityVersion();
    log.debug("vdsClusterVersion '{}' isoClusterVersion '{}'", vdsClusterVersion, isoClusterVersion);
    return vdsClusterVersion.getMajor() == isoClusterVersion.getMajor() && vdsClusterVersion.getMinor() <= isoClusterVersion.getMinor();
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) RpmVersion(org.ovirt.engine.core.compat.RpmVersion) Version(org.ovirt.engine.core.compat.Version)

Example 40 with Version

use of org.ovirt.engine.core.compat.Version in project ovirt-engine by oVirt.

the class ImagesHandler method prepareSnapshotConfigWithAlternateImage.

/**
 * Prepare a single {@link org.ovirt.engine.core.common.businessentities.Snapshot} object representing a snapshot of a given VM without the given disk,
 * substituting a new disk in its place if a new disk is provided to the method.
 */
public Snapshot prepareSnapshotConfigWithAlternateImage(Snapshot snapshot, Guid oldImageId, DiskImage newImage, OvfManager ovfManager) {
    if (snapshot == null) {
        return null;
    }
    try {
        String snapConfig = snapshot.getVmConfiguration();
        if (snapshot.isVmConfigurationAvailable() && snapConfig != null) {
            VM vmSnapshot = new VM();
            FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(vmSnapshot);
            ovfManager.importVm(snapConfig, vmSnapshot, fullEntityOvfData);
            // Remove the image from the disk list
            Iterator<DiskImage> diskIter = fullEntityOvfData.getDiskImages().iterator();
            while (diskIter.hasNext()) {
                DiskImage imageInList = diskIter.next();
                if (imageInList.getImageId().equals(oldImageId)) {
                    log.debug("Recreating vmSnapshot '{}' without the image '{}'", snapshot.getId(), oldImageId);
                    diskIter.remove();
                    break;
                }
            }
            if (newImage != null) {
                log.debug("Adding image '{}' to vmSnapshot '{}'", newImage.getImageId(), snapshot.getId());
                newImage.setDiskVmElements(Collections.singletonList(diskVmElementDao.get(new VmDeviceId(newImage.getId(), vmSnapshot.getId()))));
                fullEntityOvfData.getDiskImages().add(newImage);
            }
            final Version compatibilityVersion = Optional.ofNullable(vmSnapshot.getStaticData().getClusterCompatibilityVersionOrigin()).orElse(Version.getLowest());
            FullEntityOvfData fullEntityOvfDataForExport = new FullEntityOvfData(vmSnapshot);
            fullEntityOvfDataForExport.setDiskImages(fullEntityOvfData.getDiskImages());
            String newOvf = ovfManager.exportVm(vmSnapshot, fullEntityOvfDataForExport, compatibilityVersion);
            snapshot.setVmConfiguration(newOvf);
        }
    } catch (OvfReaderException e) {
        log.error("Can't remove image '{}' from snapshot '{}'", oldImageId, snapshot.getId());
    }
    return snapshot;
}
Also used : Version(org.ovirt.engine.core.compat.Version) VM(org.ovirt.engine.core.common.businessentities.VM) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId) OvfReaderException(org.ovirt.engine.core.utils.ovf.OvfReaderException)

Aggregations

Version (org.ovirt.engine.core.compat.Version)102 ArrayList (java.util.ArrayList)24 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)20 Guid (org.ovirt.engine.core.compat.Guid)20 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)17 Map (java.util.Map)16 List (java.util.List)15 HashSet (java.util.HashSet)14 VDS (org.ovirt.engine.core.common.businessentities.VDS)14 HashMap (java.util.HashMap)13 ServerCpu (org.ovirt.engine.core.common.businessentities.ServerCpu)12 VM (org.ovirt.engine.core.common.businessentities.VM)11 ConfigValues (org.ovirt.engine.core.common.config.ConfigValues)11 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)11 Arrays (java.util.Arrays)10 MigrationPolicy (org.ovirt.engine.core.common.migration.MigrationPolicy)10 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)10 Collection (java.util.Collection)9 Collections (java.util.Collections)9 ArchitectureType (org.ovirt.engine.core.common.businessentities.ArchitectureType)9