Search in sources :

Example 16 with VdsDynamic

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

the class AddVdsCommand method addVdsDynamicToDb.

private void addVdsDynamicToDb() {
    VdsDynamic vdsDynamic = new VdsDynamic();
    vdsDynamic.setId(getParameters().getVdsStaticData().getId());
    // TODO: oVirt type - here oVirt behaves like power client?
    if (getParameters().isPending()) {
        vdsDynamic.setStatus(VDSStatus.PendingApproval);
    } else if (getParameters().isProvisioned()) {
        vdsDynamic.setStatus(VDSStatus.InstallingOS);
    } else if (Config.<Boolean>getValue(ConfigValues.InstallVds)) {
        vdsDynamic.setStatus(VDSStatus.Installing);
    }
    vdsDynamicDao.save(vdsDynamic);
    getCompensationContext().snapshotNewEntity(vdsDynamic);
}
Also used : VdsDynamic(org.ovirt.engine.core.common.businessentities.VdsDynamic)

Example 17 with VdsDynamic

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

the class RecoveryStartupBean method updateHostsResources.

/**
 * Clean pending memory and CPUs
 * (meaning we tried to start a VM and the engine crashed before telling VDSM about it).
 */
private void updateHostsResources(List<VDS> hosts) {
    final List<VdsDynamic> updatedEntities = new ArrayList<>();
    for (VDS host : hosts) {
        boolean hostDynamicDataTobeSaved = false;
        if (host.getPendingVcpusCount() != 0) {
            host.setPendingVcpusCount(0);
            hostDynamicDataTobeSaved = true;
        }
        if (host.getPendingVmemSize() != 0) {
            host.setPendingVmemSize(0);
            hostDynamicDataTobeSaved = true;
        }
        if (hostDynamicDataTobeSaved) {
            updatedEntities.add(host.getDynamicData());
        }
    }
    hostDynamicDao.updateAllInBatch(updatedEntities);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsDynamic(org.ovirt.engine.core.common.businessentities.VdsDynamic) ArrayList(java.util.ArrayList)

Example 18 with VdsDynamic

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

the class InClusterUpgradeFilterPolicyUnit method filter.

@Override
public List<VDS> filter(Cluster cluster, List<VDS> hosts, VM vm, Map<String, String> parameters, PerHostMessages messages) {
    final VdsDynamic sourceHost = getLastHost(vm);
    if (sourceHost == null) {
        return hosts;
    }
    final OS lastHostOs = OS.fromPackageVersionString(sourceHost.getHostOs());
    if (!lastHostOs.isValid()) {
        log.debug("Source host {} does not provide a valid and complete OS identifier. Found {}.", sourceHost.getId(), sourceHost.getHostOs());
        return hosts;
    }
    final List<VDS> notOlderHosts = new ArrayList();
    for (VDS host : hosts) {
        final OS hostOs = OS.fromPackageVersionString(host.getHostOs());
        if (!hostOs.isValid()) {
            log.debug("Host {} does not provide a valid OS identifier. Found {}.", host.getId(), host.getHostOs());
            messages.addMessage(host.getId(), EngineMessage.VAR__DETAIL__INVALID_OS.name());
            messages.addMessage(host.getId(), String.format("$os %1$s", host.getHostOs()));
        } else if (!hostOs.isSameOsFamily(lastHostOs)) {
            log.debug("Host {} does not run the same operating system. Expected {}, found {}", host.getId(), lastHostOs.getName(), hostOs.getName());
            messages.addMessage(host.getId(), EngineMessage.VAR__DETAIL__WRONG_OS.name());
            messages.addMessage(host.getId(), String.format("$expected %1$s", lastHostOs.getName()));
            messages.addMessage(host.getId(), String.format("$found %1$s", hostOs.getName()));
        } else if (hostOs.isOlderThan(lastHostOs) && !hostOs.isSameMajorVersion(lastHostOs)) {
            log.debug("Host {} runs a too old OS version. Found {}", host.getId(), host.getHostOs());
            messages.addMessage(host.getId(), EngineMessage.VAR__DETAIL__OLD_OS.name());
            messages.addMessage(host.getId(), String.format("$found %1$s", hostOs.getName()));
        } else {
            notOlderHosts.add(host);
        }
    }
    return notOlderHosts;
}
Also used : OS(org.ovirt.engine.core.utils.OS) VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsDynamic(org.ovirt.engine.core.common.businessentities.VdsDynamic) ArrayList(java.util.ArrayList)

Example 19 with VdsDynamic

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

the class InClusterUpgradeWeightPolicyUnit method score.

@Override
public List<Pair<Guid, Integer>> score(Cluster cluster, List<VDS> hosts, VM vm, Map<String, String> parameters) {
    VdsDynamic referenceHost = getLastHost(vm);
    boolean isVmStartup = false;
    // Check if the VM is starting
    if (referenceHost == null) {
        isVmStartup = true;
        final Map<String, Version> highestVersions = new HashMap<>();
        for (VDS host : hosts) {
            OS os = OS.fromPackageVersionString(host.getHostOs());
            if (!os.isValid()) {
                continue;
            }
            Version version = highestVersions.get(os.getOsFamily());
            if (version == null || version.getMajor() < os.getVersion().getMajor()) {
                highestVersions.put(os.getOsFamily(), os.getVersion());
                referenceHost = host.getDynamicData();
            }
        }
        if (highestVersions.isEmpty()) {
            log.debug("No valid OS descriptors detected. Will not weight hosts on VM startup.");
            return noWeights(hosts);
        } else if (highestVersions.size() > 1) {
            log.debug("More than one OS family detected. Will not weight hosts on VM startup.");
            return noWeights(hosts);
        }
    }
    final OS lastHostOs = OS.fromPackageVersionString(referenceHost.getHostOs());
    if (!lastHostOs.isValid()) {
        log.debug("Reference host {} provides an invalid or incomplete OS identifier. Found {}.", referenceHost.getId(), referenceHost.getHostOs());
        return noWeights(hosts);
    }
    final List<Pair<Guid, Integer>> weights = new ArrayList<>();
    for (final VDS host : hosts) {
        final OS hostOs = OS.fromPackageVersionString(host.getHostOs());
        if (!hostOs.isValid()) {
            log.debug("Host {} does not provide an valid OS identifier. Found {}.", host.getId(), host.getHostOs());
            weights.add(toWeight(host, BAD_WEIGHT));
        } else if (!hostOs.isSameOsFamily(lastHostOs)) {
            log.debug("Host {} does not run the same operating system. Expected {}, found {}", host.getId(), lastHostOs.getName(), hostOs.getName());
            weights.add(toWeight(host, BAD_WEIGHT));
        } else if (hostOs.isOlderThan(lastHostOs) && !hostOs.isSameMajorVersion(lastHostOs)) {
            weights.add(toWeight(host, BAD_WEIGHT));
        } else if (hostOs.isSameMajorVersion(lastHostOs) && !isVmStartup) {
            weights.add(toWeight(host, BETTER_WEIGHT));
        } else {
            weights.add(toWeight(host, BEST_WEIGHT));
        }
    }
    return weights;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) OS(org.ovirt.engine.core.utils.OS) Version(org.ovirt.engine.core.compat.Version) HashMap(java.util.HashMap) VdsDynamic(org.ovirt.engine.core.common.businessentities.VdsDynamic) ArrayList(java.util.ArrayList) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 20 with VdsDynamic

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

the class ImageSpmCommand method validate.

@Override
protected boolean validate() {
    if (getPoolSpmId() == null) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_NO_SPM);
    }
    setStoragePool(null);
    StoragePoolValidator spValidator = new StoragePoolValidator(getStoragePool());
    if (!validate(spValidator.exists())) {
        return false;
    }
    if (!getPoolSpmId().equals(getStoragePool().getSpmVdsId())) {
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_SPM_CHANGED);
    }
    VdsDynamic vdsDynamic = vdsDynamicDao.get(getPoolSpmId());
    if (vdsDynamic == null || vdsDynamic.getStatus() != VDSStatus.Up) {
        addValidationMessage(EngineMessage.VAR__HOST_STATUS__UP);
        return failValidation(EngineMessage.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL);
    }
    setVdsId(vdsDynamic.getId());
    if (!commandSpecificValidate()) {
        return false;
    }
    return true;
}
Also used : StoragePoolValidator(org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator) VdsDynamic(org.ovirt.engine.core.common.businessentities.VdsDynamic)

Aggregations

VdsDynamic (org.ovirt.engine.core.common.businessentities.VdsDynamic)27 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)4 Before (org.junit.Before)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)3 VDSStatus (org.ovirt.engine.core.common.businessentities.VDSStatus)2 OS (org.ovirt.engine.core.utils.OS)2 HashMap (java.util.HashMap)1 PermissionSubject (org.ovirt.engine.core.bll.utils.PermissionSubject)1 StoragePoolValidator (org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator)1 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)1 MaintenanceVdsParameters (org.ovirt.engine.core.common.action.MaintenanceVdsParameters)1 UpgradeHostParameters (org.ovirt.engine.core.common.action.hostdeploy.UpgradeHostParameters)1 NonOperationalReason (org.ovirt.engine.core.common.businessentities.NonOperationalReason)1 ServerCpu (org.ovirt.engine.core.common.businessentities.ServerCpu)1 VdsTransparentHugePagesState (org.ovirt.engine.core.common.businessentities.VdsTransparentHugePagesState)1 Bond (org.ovirt.engine.core.common.businessentities.network.Bond)1 DnsResolverConfiguration (org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration)1