Search in sources :

Example 6 with VDSError

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

the class UpdateGlusterHookCommandTest method mockBackend.

private void mockBackend(boolean succeeded, EngineError errorCode) {
    VDSReturnValue vdsReturnValue = new VDSReturnValue();
    vdsReturnValue.setSucceeded(succeeded);
    if (!succeeded) {
        vdsReturnValue.setVdsError(new VDSError(errorCode, ""));
    }
    when(vdsBrokerFrontend.runVdsCommand(eq(VDSCommandType.UpdateGlusterHook), any())).thenReturn(vdsReturnValue);
}
Also used : VDSError(org.ovirt.engine.core.common.errors.VDSError) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 7 with VDSError

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

the class UpdateGlusterHookCommandTest method mockForReadContent.

private void mockForReadContent(boolean succeeded, EngineError errorCode) {
    when(hooksDao.getGlusterServerHook(HOOK_ID, SERVER_ID)).thenReturn(getGlusterServerHook(0, GlusterHookStatus.ENABLED));
    mockBackend(succeeded, errorCode);
    VDSReturnValue vdsReturnValue = new VDSReturnValue();
    vdsReturnValue.setReturnValue(CONTENT);
    vdsReturnValue.setSucceeded(succeeded);
    if (!succeeded) {
        vdsReturnValue.setVdsError(new VDSError(errorCode, ""));
    }
    when(vdsBrokerFrontend.runVdsCommand(eq(VDSCommandType.GetGlusterHookContent), any())).thenReturn(vdsReturnValue);
}
Also used : VDSError(org.ovirt.engine.core.common.errors.VDSError) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 8 with VDSError

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

the class InitVdsOnUpCommand method runConnectHostToPoolEvent.

private EventResult runConnectHostToPoolEvent(final Guid storagePoolId, final VDS vds) {
    EventResult result = new EventResult(true, EventType.VDSCONNECTTOPOOL);
    StoragePool storagePool = storagePoolDao.get(storagePoolId);
    StorageDomain masterDomain = storageDomainDao.getStorageDomains(storagePoolId, StorageDomainType.Master).get(0);
    List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(storagePoolId);
    boolean masterDomainInactiveOrUnknown = masterDomain.getStatus() == StorageDomainStatus.Inactive || masterDomain.getStatus() == StorageDomainStatus.Unknown;
    VDSError error = null;
    try {
        VDSReturnValue vdsReturnValue = runVdsCommand(VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters(vds, storagePool, masterDomain.getId(), storagePoolIsoMap));
        if (!vdsReturnValue.getSucceeded()) {
            error = vdsReturnValue.getVdsError();
        }
    } catch (EngineException e) {
        error = e.getVdsError();
    }
    if (error != null) {
        if (error.getCode() != EngineError.CannotConnectMultiplePools && masterDomainInactiveOrUnknown) {
            log.info("Could not connect host '{}' to pool '{}', as the master domain is in inactive/unknown" + " status - not failing the operation", vds.getName(), storagePool.getName());
        } else {
            log.error("Could not connect host '{}' to pool '{}': {}", vds.getName(), storagePool.getName(), error.getMessage());
            result.setSuccess(false);
        }
    }
    if (result.isSuccess()) {
        Pair<Boolean, List<StorageDomainStatic>> vdsStatsResults = proceedVdsStats(!masterDomainInactiveOrUnknown, storagePool);
        result.setSuccess(vdsStatsResults.getFirst());
        if (!result.isSuccess()) {
            result.setResultData(vdsStatsResults.getSecond());
            auditLogDirector.log(this, AuditLogType.VDS_STORAGE_VDS_STATS_FAILED);
        }
    }
    return result;
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) EventResult(org.ovirt.engine.core.common.eventqueue.EventResult) VDSError(org.ovirt.engine.core.common.errors.VDSError) List(java.util.List) ArrayList(java.util.ArrayList) ConnectStoragePoolVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters)

Example 9 with VDSError

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

the class GlusterHookCommandTest method mockBackendStatusChange.

protected void mockBackendStatusChange(boolean succeeded, EngineError errorCode) {
    VDSReturnValue vdsReturnValue = new VDSReturnValue();
    vdsReturnValue.setReturnValue(succeeded);
    vdsReturnValue.setSucceeded(succeeded);
    if (!succeeded) {
        vdsReturnValue.setVdsError(new VDSError(errorCode, ""));
    }
    when(vdsBrokerFrontend.runVdsCommand(any(), any())).thenReturn(vdsReturnValue);
}
Also used : VDSError(org.ovirt.engine.core.common.errors.VDSError) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 10 with VDSError

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

the class RemoveGlusterHookCommandTest method mockBackend.

private void mockBackend(boolean succeeded, EngineError errorCode) {
    VDSReturnValue vdsReturnValue = new VDSReturnValue();
    vdsReturnValue.setSucceeded(succeeded);
    if (!succeeded) {
        vdsReturnValue.setVdsError(new VDSError(errorCode, ""));
    }
    when(vdsBrokerFrontend.runVdsCommand(eq(VDSCommandType.RemoveGlusterHook), any())).thenReturn(vdsReturnValue);
}
Also used : VDSError(org.ovirt.engine.core.common.errors.VDSError) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

VDSError (org.ovirt.engine.core.common.errors.VDSError)24 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)13 EngineError (org.ovirt.engine.core.common.errors.EngineError)7 Guid (org.ovirt.engine.core.compat.Guid)3 Map (java.util.Map)2 GlusterVolumeTaskStatusEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 SocketException (java.net.SocketException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)1 HostJobInfo (org.ovirt.engine.core.common.businessentities.HostJobInfo)1 HostJobStatus (org.ovirt.engine.core.common.businessentities.HostJobInfo.HostJobStatus)1 HostJobType (org.ovirt.engine.core.common.businessentities.HostJobInfo.HostJobType)1 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1