Search in sources :

Example 6 with VdsIdVDSCommandParametersBase

use of org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase in project ovirt-engine by oVirt.

the class CommitNetworkChangesCommand method executeCommand.

@Override
protected void executeCommand() {
    VDSReturnValue retVal = runVdsCommand(VDSCommandType.SetSafeNetworkConfig, new VdsIdVDSCommandParametersBase(getParameters().getVdsId()));
    vdsDynamicDao.updateNetConfigDirty(getParameters().getVdsId(), false);
    setSucceeded(retVal.getSucceeded());
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 7 with VdsIdVDSCommandParametersBase

use of org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase in project ovirt-engine by oVirt.

the class InitGlusterCommandHelper method syncGlusterWebhook.

private void syncGlusterWebhook(VDS vds) {
    try {
        // check if there's a server that's online other than the one being added.
        VDS newUpServer = getNewUpServer(vds, vds);
        if (newUpServer == null) {
            log.debug("No alternate up server to sync webhook for server '{}' ", vds.getHostName());
            return;
        }
        VDSReturnValue returnValue = runVdsCommand(VDSCommandType.SyncGlusterWebhook, new VdsIdVDSCommandParametersBase(newUpServer.getId()));
        if (!returnValue.getSucceeded()) {
            log.error("Could not sync webhooks to gluster server '{}': {}", vds.getHostName(), returnValue.getExceptionString());
        }
    } catch (Exception e) {
        log.error("Could not sync webhooks to gluster server '{}': {}", vds.getHostName(), e.getMessage());
        log.debug("Exception", e);
    }
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) VDS(org.ovirt.engine.core.common.businessentities.VDS) EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 8 with VdsIdVDSCommandParametersBase

use of org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase in project ovirt-engine by oVirt.

the class InitGlusterCommandHelper method getGlusterPeers.

@SuppressWarnings("unchecked")
private List<GlusterServerInfo> getGlusterPeers(VDS upServer) {
    List<GlusterServerInfo> glusterServers = new ArrayList<>();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GlusterServersList, new VdsIdVDSCommandParametersBase(upServer.getId()));
    if (!returnValue.getSucceeded()) {
        AuditLogable logable = GlusterEventFactory.createEvent(upServer, returnValue);
        auditLogDirector.log(logable, AuditLogType.GLUSTER_SERVERS_LIST_FAILED);
    } else {
        glusterServers = (List<GlusterServerInfo>) returnValue.getReturnValue();
    }
    return glusterServers;
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) ArrayList(java.util.ArrayList) GlusterServerInfo(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 9 with VdsIdVDSCommandParametersBase

use of org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase in project ovirt-engine by oVirt.

the class GetGlusterHostPublicKeysQuery method executeQueryCommand.

@SuppressWarnings("unchecked")
@Override
protected void executeQueryCommand() {
    VDSReturnValue readPubKeyReturnValue = runVdsCommand(VDSCommandType.GetGlusterHostsPubKey, new VdsIdVDSCommandParametersBase(getParameters().getId()));
    getQueryReturnValue().setReturnValue(readPubKeyReturnValue.getReturnValue());
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 10 with VdsIdVDSCommandParametersBase

use of org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase in project ovirt-engine by oVirt.

the class SpmStopVDSCommand method executeVdsBrokerCommand.

@Override
protected void executeVdsBrokerCommand() {
    boolean lockAcquired = false;
    try {
        if (canVdsBeReached()) {
            lockAcquired = lockManager.acquireLock(retrieveVdsExecutionLock()).getFirst();
            if (!lockAcquired) {
                getVDSReturnValue().setVdsError(new VDSError(EngineError.ENGINE, "Failed to acquire vds execution lock - related operation is under execution"));
                getVDSReturnValue().setSucceeded(false);
                return;
            }
            boolean performSpmStop = true;
            Map<Guid, AsyncTaskStatus> unclearedTasks = null;
            try {
                VDSReturnValue vdsReturnValue = resourceManager.runVdsCommand(VDSCommandType.HSMGetAllTasksStatuses, new VdsIdVDSCommandParametersBase(getVds().getId()));
                if (isNotSPM(vdsReturnValue)) {
                    return;
                }
                getVDSReturnValue().setSucceeded(vdsReturnValue.getSucceeded());
                getVDSReturnValue().setVdsError(vdsReturnValue.getVdsError());
                if (vdsReturnValue.getReturnValue() != null) {
                    unclearedTasks = (HashMap<Guid, AsyncTaskStatus>) vdsReturnValue.getReturnValue();
                    performSpmStop = unclearedTasks.isEmpty();
                }
            } catch (Exception e) {
                performSpmStop = false;
                log.info("SpmStopVDSCommand::Could not get tasks on vds '{}': {}", getVds().getName(), e.getMessage());
                log.debug("Exception", e);
            }
            if (performSpmStop) {
                log.info("SpmStopVDSCommand::Stopping SPM on vds '{}', pool id '{}'", getVds().getName(), getParameters().getStoragePoolId());
                status = getBroker().spmStop(getParameters().getStoragePoolId().toString());
                proceedProxyReturnValue();
            } else {
                getVDSReturnValue().setSucceeded(false);
                if (getVDSReturnValue().getVdsError() == null) {
                    String unclearedTasksDetails = unclearedTasks.entrySet().stream().map(entry -> String.format("Task '%s', status '%s'", entry.getKey(), entry.getValue().getStatus())).collect(Collectors.joining("\n"));
                    log.error("SpmStopVDSCommand::Not stopping SPM on vds '{}', pool id '{}' as there are uncleared tasks '{}'", getVds().getName(), getParameters().getStoragePoolId(), unclearedTasksDetails);
                    VDSError error = new VDSError(EngineError.TaskInProgress, unclearedTasksDetails);
                    getVDSReturnValue().setVdsError(error);
                } else if (getVDSReturnValue().getVdsError().getCode() == EngineError.VDS_NETWORK_ERROR) {
                    log.info("SpmStopVDSCommand::Could not get tasks on vds '{}' - network exception, not stopping spm! pool id '{}'", getVds().getName(), getParameters().getStoragePoolId());
                }
            }
        } else {
            log.info("SpmStopVDSCommand:: vds '{}' is in '{}' status - not performing spm stop, pool id '{}'", getVds().getName(), getVds().getStatus(), getParameters().getStoragePoolId());
            getVDSReturnValue().setVdsError(new VDSError(EngineError.VDS_NETWORK_ERROR, "Vds is in incorrect status"));
            getVDSReturnValue().setSucceeded(false);
        }
    } catch (RuntimeException exp) {
        log.warn("Could not stop spm of pool '{}' on vds '{}': {}", getParameters().getStoragePoolId(), getParameters().getVdsId(), exp.getMessage());
        log.debug("Exception", exp);
        getVDSReturnValue().setExceptionObject(exp);
        getVDSReturnValue().setSucceeded(false);
    } finally {
        if (lockAcquired) {
            lockManager.releaseLock(retrieveVdsExecutionLock());
        }
    }
}
Also used : VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Guid(org.ovirt.engine.core.compat.Guid) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) LockManager(org.ovirt.engine.core.utils.lock.LockManager) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) DbFacade(org.ovirt.engine.core.dal.dbbroker.DbFacade) EngineError(org.ovirt.engine.core.common.errors.EngineError) Inject(javax.inject.Inject) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Map(java.util.Map) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) Collections(java.util.Collections) VDSError(org.ovirt.engine.core.common.errors.VDSError) Pair(org.ovirt.engine.core.common.utils.Pair) SpmStopVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStopVDSCommandParameters) VdsIdVDSCommandParametersBase(org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase) VDSError(org.ovirt.engine.core.common.errors.VDSError) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

VdsIdVDSCommandParametersBase (org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase)17 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)15 VDS (org.ovirt.engine.core.common.businessentities.VDS)6 List (java.util.List)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Guid (org.ovirt.engine.core.compat.Guid)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)3 Collections (java.util.Collections)2 Map (java.util.Map)2 Callable (java.util.concurrent.Callable)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)2 Pair (org.ovirt.engine.core.common.utils.Pair)2 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)2 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)2 MessageFormat (java.text.MessageFormat)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1