use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class VdsBrokerCommand method initializeVdsBroker.
protected IVdsServer initializeVdsBroker(Guid vdsId) {
VdsManager vdsmanager = Injector.get(ResourceManager.class).getVdsManager(vdsId);
if (vdsmanager == null) {
throw new EngineException(EngineError.RESOURCE_MANAGER_VDS_NOT_FOUND, String.format("Vds with id: %1$s was not found", vdsId));
}
setVdsAndVdsStatic(vdsmanager.getCopyVds());
return vdsmanager.getVdsProxy();
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class RunVmCommand method createStatelessSnapshot.
private void createStatelessSnapshot() {
warnIfNotAllDisksPermitSnapshots();
log.info("Creating stateless snapshot for VM '{}' ({})", getVm().getName(), getVm().getId());
CreateSnapshotForVmParameters createAllSnapshotsFromVmParameters = buildCreateSnapshotParameters();
ActionReturnValue actionReturnValue = runInternalAction(ActionType.CreateSnapshotForVm, createAllSnapshotsFromVmParameters, createContextForStatelessSnapshotCreation());
// setting lock to null in order not to release lock twice
setLock(null);
setSucceeded(actionReturnValue.getSucceeded());
if (!actionReturnValue.getSucceeded()) {
if (areDisksLocked(actionReturnValue)) {
throw new EngineException(EngineError.IRS_IMAGE_STATUS_ILLEGAL);
}
getReturnValue().setFault(actionReturnValue.getFault());
log.error("Failed to create stateless snapshot for VM '{}' ({})", getVm().getName(), getVm().getId());
}
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class RunVmCommand method getVdsToRunOn.
protected boolean getVdsToRunOn() {
Optional<Guid> vdsToRunOn = schedulingManager.schedule(getCluster(), getVm(), getRunVdssList(), getVdsWhiteList(), getPredefinedVdsIdListToRunOn(), new ArrayList<>(), this, getCorrelationId());
setVdsId(vdsToRunOn.orElse(null));
if (vdsToRunOn.isPresent()) {
getRunVdssList().add(vdsToRunOn.get());
}
setVds(null);
setVdsName(null);
if (getVdsId().equals(Guid.Empty)) {
log.error("Can't find VDS to run the VM '{}' on, so this VM will not be run.", getVmId());
return false;
}
if (getVds() == null) {
EngineException outEx = new EngineException(EngineError.RESOURCE_MANAGER_VDS_NOT_FOUND);
log.error("VmHandler::{}: {}", getClass().getName(), outEx.getMessage());
return false;
}
return true;
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class UpdateVmCommand method executeVmCommand.
@Override
protected void executeVmCommand() {
// needs to be here for post-actions
oldVm = getVm();
if (isUpdateVmTemplateVersion) {
updateVmTemplateVersion();
// template version was changed, no more work is required
return;
}
newVmStatic = getParameters().getVmStaticData();
if (isRunningConfigurationNeeded()) {
vmHandler.createNextRunSnapshot(getVm(), getParameters().getVmStaticData(), getParameters(), getCompensationContext());
vmHandler.setVmDestroyOnReboot(getVm());
}
vmHandler.warnMemorySizeLegal(getParameters().getVm().getStaticData(), getEffectiveCompatibilityVersion());
vmStaticDao.incrementDbGeneration(getVm().getId());
newVmStatic.setCreationDate(oldVm.getStaticData().getCreationDate());
newVmStatic.setQuotaId(getQuotaId());
// save user selected value for hotplug before overriding with db values (when updating running vm)
VM userVm = new VM();
userVm.setStaticData(new VmStatic(newVmStatic));
if (newVmStatic.getCreationDate().equals(DateTime.getMinValue())) {
newVmStatic.setCreationDate(new Date());
}
if (getVm().isRunningOrPaused() && !getVm().isHostedEngine()) {
if (!vmHandler.copyNonEditableFieldsToDestination(oldVm.getStaticData(), newVmStatic, isHotSetEnabled(), oldVm.getStatus(), getParameters().isMemoryHotUnplugEnabled())) {
// fail update vm if some fields could not be copied
throw new EngineException(EngineError.FAILED_UPDATE_RUNNING_VM);
}
}
if ((getVm().isRunningOrPaused() || getVm().isPreviewSnapshot() || getVm().isSuspended()) && !getVm().isHostedEngine()) {
if (getVm().getCustomCompatibilityVersion() == null && getParameters().getClusterLevelChangeFromVersion() != null) {
// For backward compatibility after cluster version change
// When running/paused: Set temporary custom compatibility version till the NextRun is applied (VM cold reboot)
// When snapshot in preview: keep the custom compatibility version even after commit or roll back by undo
newVmStatic.setCustomCompatibilityVersion(getParameters().getClusterLevelChangeFromVersion());
}
}
updateVmNetworks();
updateVmNumaNodes();
updateAffinityLabels();
if (!updateVmLease()) {
return;
}
if (isHotSetEnabled()) {
hotSetCpus(userVm);
updateCurrentMemory(userVm);
}
final List<Guid> oldIconIds = iconUtils.updateVmIcon(oldVm.getStaticData(), newVmStatic, getParameters().getVmLargeIcon());
resourceManager.getVmManager(getVmId()).update(newVmStatic);
if (getVm().isNotRunning()) {
updateVmPayload();
getVmDeviceUtils().updateVmDevices(getParameters(), oldVm, this::getCluster);
updateWatchdog();
updateRngDevice();
updateGraphicsDevices();
updateVmHostDevices();
updateDeviceAddresses();
}
iconUtils.removeUnusedIcons(oldIconIds);
vmHandler.updateVmInitToDB(getParameters().getVmStaticData());
checkTrustedService();
liveUpdateCpuProfile();
setSucceeded(true);
}
use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.
the class UpdateMomPolicyCommand method executeCommand.
@Override
protected void executeCommand() {
boolean succeeded = false;
try {
succeeded = runVdsCommand(VDSCommandType.SetMOMPolicyParameters, new MomPolicyVDSParameters(getVds(), getCluster().isEnableBallooning(), getCluster().isEnableKsm(), getCluster().isKsmMergeAcrossNumaNodes())).getSucceeded();
} catch (EngineException e) {
log.error("Could not update MoM policy on host '{}': {}", getVdsName(), e.getMessage());
log.debug("Exception", e);
}
getReturnValue().setSucceeded(succeeded);
}
Aggregations