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;
}
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");
}
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);
}
}
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();
}
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;
}
Aggregations