Search in sources :

Example 16 with EngineException

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();
}
Also used : VdsManager(org.ovirt.engine.core.vdsbroker.VdsManager) EngineException(org.ovirt.engine.core.common.errors.EngineException) ResourceManager(org.ovirt.engine.core.vdsbroker.ResourceManager)

Example 17 with EngineException

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());
    }
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException) CreateSnapshotForVmParameters(org.ovirt.engine.core.common.action.CreateSnapshotForVmParameters)

Example 18 with EngineException

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;
}
Also used : EngineException(org.ovirt.engine.core.common.errors.EngineException) Guid(org.ovirt.engine.core.compat.Guid)

Example 19 with EngineException

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);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) EngineException(org.ovirt.engine.core.common.errors.EngineException) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Guid(org.ovirt.engine.core.compat.Guid) Date(java.util.Date)

Example 20 with EngineException

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);
}
Also used : MomPolicyVDSParameters(org.ovirt.engine.core.common.vdscommands.MomPolicyVDSParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Aggregations

EngineException (org.ovirt.engine.core.common.errors.EngineException)107 Guid (org.ovirt.engine.core.compat.Guid)30 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)25 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)25 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)18 ArrayList (java.util.ArrayList)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)11 HashMap (java.util.HashMap)7 Pair (org.ovirt.engine.core.common.utils.Pair)7 HashSet (java.util.HashSet)6 List (java.util.List)6 Callable (java.util.concurrent.Callable)6 Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)6 IOException (java.io.IOException)5 EntityInfo (org.ovirt.engine.core.common.asynctasks.EntityInfo)5 Map (java.util.Map)4 PersistentHostSetupNetworksParameters (org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters)4 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 Set (java.util.Set)3 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)3