Search in sources :

Example 16 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class GlusterAsyncTaskStatusQueryBase method updateHostIP.

private void updateHostIP(GlusterVolumeTaskStatusEntity taskStatus) {
    if (taskStatus != null) {
        for (GlusterVolumeTaskStatusForHost hostStatus : taskStatus.getHostwiseStatusDetails()) {
            GlusterServer glusterServer = glusterServerDao.getByGlusterServerUuid(hostStatus.getHostUuid());
            if (glusterServer != null) {
                VDS host = vdsDao.get(glusterServer.getId());
                if (host != null) {
                    hostStatus.setHostName(host.getName());
                    hostStatus.setHostId(host.getId());
                }
            }
        }
    }
}
Also used : GlusterServer(org.ovirt.engine.core.common.businessentities.gluster.GlusterServer) GlusterVolumeTaskStatusForHost(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusForHost) VDS(org.ovirt.engine.core.common.businessentities.VDS)

Example 17 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class GlusterGeoRepSyncJob method getSessionDetailFromCLI.

private List<GlusterGeoRepSessionDetails> getSessionDetailFromCLI(Cluster cluster, GlusterGeoRepSession session) {
    VDS upServer = glusterUtil.getRandomUpServer(cluster.getId());
    if (upServer == null) {
        log.debug("No UP server found in cluster: {} for geo-rep monitoring", cluster.getName());
        return null;
    }
    try {
        VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeGeoRepSessionStatus, new GlusterVolumeGeoRepSessionVDSParameters(upServer.getId(), session.getMasterVolumeName(), session.getSlaveHostName(), session.getSlaveVolumeName(), session.getUserName()));
        if (returnValue.getSucceeded()) {
            return (List<GlusterGeoRepSessionDetails>) returnValue.getReturnValue();
        } else {
            log.error("VDS error {}", returnValue.getVdsError().getMessage());
            log.debug("VDS error", returnValue.getVdsError());
            return null;
        }
    } catch (Exception e) {
        log.error("Exception getting geo-rep status from vds {}", e.getMessage());
        log.debug("Exception", e);
        return null;
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeGeoRepSessionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters) ArrayList(java.util.ArrayList) List(java.util.List) EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 18 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class GlusterGeoRepSyncJob method getSessionConfigFromCLI.

private List<GlusterGeoRepSessionConfiguration> getSessionConfigFromCLI(Cluster cluster, GlusterGeoRepSession session) {
    VDS upServer = glusterUtil.getRandomUpServer(cluster.getId());
    if (upServer == null) {
        log.debug("No UP server found in cluster: {} for geo-rep monitoring", cluster.getName());
        return null;
    }
    try {
        VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeGeoRepConfigList, new GlusterVolumeGeoRepSessionVDSParameters(upServer.getId(), session.getMasterVolumeName(), session.getSlaveHostName(), session.getSlaveVolumeName(), session.getUserName()));
        if (returnValue.getSucceeded()) {
            return (List<GlusterGeoRepSessionConfiguration>) returnValue.getReturnValue();
        } else {
            log.error("VDS error {}", returnValue.getVdsError().getMessage());
            log.debug("VDS error", returnValue.getVdsError());
            return null;
        }
    } catch (Exception e) {
        log.error("Exception getting geo-rep status from vds {}", e.getMessage());
        log.debug("Exception", e);
        return null;
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeGeoRepSessionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters) ArrayList(java.util.ArrayList) List(java.util.List) EngineException(org.ovirt.engine.core.common.errors.EngineException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 19 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class GlusterHookStatusChangeCommand method executeCommand.

@Override
protected void executeCommand() {
    entity = getGlusterHook();
    addCustomValue(GlusterConstants.HOOK_NAME, entity.getName());
    if (getAllUpServers().size() < clusterUtils.getServerCount(getGlusterHook().getClusterId())) {
        errors.add(EngineMessage.CLUSTER_ALL_SERVERS_NOT_UP.toString());
    }
    List<Callable<Pair<VDS, VDSReturnValue>>> taskList = new ArrayList<>();
    for (final VDS upServer : getAllUpServers()) {
        taskList.add(() -> {
            VDSReturnValue returnValue = runVdsCommand(getStatusChangeVDSCommand(), new GlusterHookVDSParameters(upServer.getId(), entity.getGlusterCommand(), entity.getStage(), entity.getName()));
            return new Pair<>(upServer, returnValue);
        });
    }
    boolean atLeastOneSuccess = false;
    List<Pair<VDS, VDSReturnValue>> pairResults = ThreadPoolUtil.invokeAll(taskList);
    for (Pair<VDS, VDSReturnValue> pairResult : pairResults) {
        VDSReturnValue retValue = pairResult.getSecond();
        if (retValue.getSucceeded()) {
            atLeastOneSuccess = true;
            // update status in database
            updateServerHookStatusInDb(getGlusterHook().getId(), pairResult.getFirst().getId(), getNewStatus());
        } else {
            errors.add(retValue.getVdsError().getMessage());
        }
    }
    setSucceeded(atLeastOneSuccess);
    if (errors.size() > 0) {
        // conflict in status
        entity.addStatusConflict();
        handleVdsErrors(getAuditLogTypeValue(), errors);
        addCustomValue(GlusterConstants.FAILURE_MESSAGE, StringUtils.join(errors, System.lineSeparator()));
    }
    // The intention was to enable/disable hook. So we update the entity with new status if command succeeded
    if (getSucceeded()) {
        entity.setStatus(getNewStatus());
        // no longer conflicts as all hooks have same status
        entity.removeStatusConflict();
        updateHookInDb(entity);
        if (entity.getConflictStatus() == 0) {
            // all conflicts have been resolved, remove server hooks
            glusterHooksDao.removeGlusterServerHooks(entity.getId());
        }
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) GlusterHookVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterHookVDSParameters) Callable(java.util.concurrent.Callable) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 20 with VDS

use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.

the class CreateGlusterVolumeGeoRepSessionCommand method fetchRemoteServers.

private Set<VDS> fetchRemoteServers() {
    Set<VDS> remoteServers = new HashSet<>();
    List<GlusterBrickEntity> slaveBricks = slaveVolume.getBricks();
    for (GlusterBrickEntity currentBrick : slaveBricks) {
        remoteServers.add(vdsDao.get(currentBrick.getServerId()));
    }
    return remoteServers;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) VDS(org.ovirt.engine.core.common.businessentities.VDS) HashSet(java.util.HashSet)

Aggregations

VDS (org.ovirt.engine.core.common.businessentities.VDS)578 ArrayList (java.util.ArrayList)160 Test (org.junit.Test)138 Guid (org.ovirt.engine.core.compat.Guid)132 List (java.util.List)78 VM (org.ovirt.engine.core.common.businessentities.VM)65 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)55 HashMap (java.util.HashMap)53 HashSet (java.util.HashSet)48 Map (java.util.Map)45 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)42 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)42 Set (java.util.Set)40 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)39 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)39 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)39 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)38 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)38 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)37 Frontend (org.ovirt.engine.ui.frontend.Frontend)35