Search in sources :

Example 96 with EngineException

use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.

the class ChangeVDSClusterCommand method configureNetworks.

private void configureNetworks() {
    final PersistentHostSetupNetworksParameters params;
    try {
        params = changeClusterParametersBuilder.buildParameters(getVdsId(), getSourceCluster().getId(), getTargetCluster().getId());
    } catch (EngineException e) {
        auditLogDirector.log(this, AuditLogType.CONFIGURE_NETWORK_BY_LABELS_WHEN_CHANGING_CLUSTER_FAILED);
        return;
    }
    ThreadPoolUtil.execute(() -> runInternalAction(ActionType.PersistentHostSetupNetworks, params, cloneContextAndDetachFromParent()));
}
Also used : PersistentHostSetupNetworksParameters(org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 97 with EngineException

use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.

the class HibernateVmCommand method addDisk.

private void addDisk(DiskImage disk) {
    ActionReturnValue returnValue = runInternalActionWithTasksContext(ActionType.AddDisk, buildAddDiskParameters(disk));
    if (!returnValue.getSucceeded()) {
        throw new EngineException(returnValue.getFault().getError(), String.format("Failed to create disk! %s", disk.getDiskAlias()));
    }
    getTaskIdList().addAll(returnValue.getInternalVdsmTaskIdList());
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineException(org.ovirt.engine.core.common.errors.EngineException)

Example 98 with EngineException

use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.

the class HibernateVmCommand method endSuccessfully.

@Override
protected void endSuccessfully() {
    if (getVm().getStatus() != VMStatus.Up) {
        log.warn("VM '{}' is not up, cannot Hibernate.", getVm().getName());
        endWithFailure();
        return;
    }
    List<ActionReturnValue> addDiskReturnValues = endActionOnDisks();
    DiskImage dumpDisk = getMemoryDumpDisk(addDiskReturnValues);
    DiskImage metadataDisk = getMemoryMetadataDisk(addDiskReturnValues);
    String hiberVol = MemoryUtils.createMemoryStateString(getStorageDomainId(), getStoragePoolId(), dumpDisk.getId(), dumpDisk.getImageId(), metadataDisk.getId(), metadataDisk.getImageId());
    try {
        runVdsCommand(VDSCommandType.Hibernate, new HibernateVDSCommandParameters(getVm().getRunOnVds(), getVmId(), hiberVol));
        snapshotDao.updateHibernationMemory(getVmId(), dumpDisk.getId(), metadataDisk.getId());
    } catch (EngineException e) {
        hibernateVdsProblematic = true;
        endWithFailure();
        return;
    }
    setSucceeded(true);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) HibernateVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.HibernateVDSCommandParameters) EngineException(org.ovirt.engine.core.common.errors.EngineException) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 99 with EngineException

use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.

the class GetVmFromOvaQuery method runAnsibleQueryOvaInfoPlaybook.

private String runAnsibleQueryOvaInfoPlaybook() {
    String hostname = vdsStaticDao.get(getParameters().getVdsId()).getHostName();
    AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(hostname).variables(new Pair<>("ovirt_query_ova_path", getParameters().getPath())).logFileDirectory(ExtractOvaCommand.IMPORT_OVA_LOG_DIRECTORY).logFilePrefix("ovirt-query-ova-ansible").logFileName(hostname).verboseLevel(AnsibleVerbosity.LEVEL0).stdoutCallback(AnsibleConstants.OVA_QUERY_CALLBACK_PLUGIN).playbook(AnsibleConstants.QUERY_OVA_PLAYBOOK);
    boolean succeeded = false;
    AnsibleReturnValue ansibleReturnValue = null;
    try {
        ansibleReturnValue = ansibleExecutor.runCommand(command);
        succeeded = ansibleReturnValue.getAnsibleReturnCode() == AnsibleReturnCode.OK;
    } catch (IOException | InterruptedException e) {
        log.debug("Failed to query OVA info", e);
    }
    if (!succeeded) {
        log.error("Failed to query OVA info");
        throw new EngineException(EngineError.GeneralException, "Failed to query OVA info");
    }
    return ansibleReturnValue.getStdout();
}
Also used : AnsibleReturnValue(org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue) AnsibleCommandBuilder(org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder) EngineException(org.ovirt.engine.core.common.errors.EngineException) IOException(java.io.IOException)

Example 100 with EngineException

use of org.ovirt.engine.core.common.errors.EngineException in project ovirt-engine by oVirt.

the class GetSignedWebsocketProxyTicketQuery method getGraphicsInfo.

private GraphicsInfo getGraphicsInfo() {
    final VM vm = vmDao.get(getParameters().getVmId(), getUserID(), getParameters().isFiltered());
    if (vm == null) {
        throw new EngineException(EngineError.VMCantBeObtained, String.format("vmid=%s", getParameters().getVmId()));
    }
    final GraphicsInfo graphicsInfo = vm.getGraphicsInfos().get(getParameters().getGraphicsType());
    if (graphicsInfo == null) {
        throw new EngineException(EngineError.GraphicsConsoleCantBeObtained, String.format("vmid=%s console=%s", getParameters().getVmId(), getParameters().getGraphicsType()));
    }
    return graphicsInfo;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) EngineException(org.ovirt.engine.core.common.errors.EngineException) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo)

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