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