Search in sources :

Example 36 with GlusterGeoRepSession

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

the class GlusterGeoRepDaoTest method testGetGeoRepSessionBySlaveVolume.

@Test
public void testGetGeoRepSessionBySlaveVolume() {
    GlusterGeoRepSession session = dao.getGeoRepSessionBySlaveVolume(FixturesTool.GLUSTER_GEOREP_SESSION_SLAVE_VOLUME_ID);
    assertNotNull(session);
    assertEquals(FixturesTool.GLUSTER_GEOREP_SESSION_ID, session.getId());
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) Test(org.junit.Test)

Example 37 with GlusterGeoRepSession

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

the class ResetDefaultGeoRepConfigCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterGeoRepSession session = getGeoRepSession();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.SetGlusterVolumeGeoRepConfigDefault, new GlusterVolumeGeoRepConfigVdsParameters(upServer.getId(), session.getMasterVolumeName(), session.getSlaveHostName(), session.getSlaveVolumeName(), getParameters().getConfigKey(), null, session.getUserName()));
    glusterGeoRepSyncJob.updateDiscoveredSessionConfig(getCluster(), session);
    setSucceeded(returnValue.getSucceeded());
    if (!getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_GEOREP_CONFIG_SET_DEFAULT_FAILED, returnValue.getVdsError().getMessage());
        return;
    }
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) GlusterVolumeGeoRepConfigVdsParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepConfigVdsParameters)

Example 38 with GlusterGeoRepSession

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

the class RestoreGlusterVolumeSnapshotCommand method startGeoRepSessions.

private boolean startGeoRepSessions(List<GlusterGeoRepSession> geoRepSessions) {
    for (GlusterGeoRepSession session : geoRepSessions) {
        try (EngineLock lock = acquireGeoRepSessionLock(session.getId())) {
            ActionReturnValue retVal = runInternalAction(ActionType.StartGlusterVolumeGeoRep, new GlusterVolumeGeoRepSessionParameters(getGlusterVolumeId(), session.getId()));
            if (!retVal.getSucceeded()) {
                handleVdsError(AuditLogType.GLUSTER_VOLUME_GEO_REP_START_FAILED_EXCEPTION, retVal.getExecuteFailedMessages().toString());
                setSucceeded(false);
                return false;
            }
        }
    }
    return true;
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GlusterVolumeGeoRepSessionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) EngineLock(org.ovirt.engine.core.utils.lock.EngineLock)

Example 39 with GlusterGeoRepSession

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

the class GetGeoRepSessionsForStorageDomainQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    StorageDomainStatic domain = storageDomainDao.get(getParameters().getId());
    StorageServerConnections connection = storageServerConnectionDao.get(domain.getStorage());
    getQueryReturnValue().setReturnValue(new ArrayList<GlusterGeoRepSession>());
    if (connection.getStorageType() != StorageType.GLUSTERFS) {
        // return empty
        getQueryReturnValue().setSucceeded(false);
        return;
    }
    Guid glusterVolumeId = connection.getGlusterVolumeId();
    if (glusterVolumeId == null) {
        // retrieve the gluster volume associated with path
        String path = connection.getConnection();
        String[] pathElements = path.split(StorageConstants.GLUSTER_VOL_SEPARATOR);
        String volumeName = pathElements[1];
        String hostName = pathElements[0];
        List<VDS> vdsList = vdsDao.getAll();
        VDS vds = vdsList.stream().filter(v -> v.getName().equals(hostName) || interfaceDao.getAllInterfacesForVds(v.getId()).stream().anyMatch(iface -> iface.getIpv4Address().equals(hostName))).findFirst().orElse(null);
        if (vds == null) {
            // return empty
            getQueryReturnValue().setSucceeded(false);
            return;
        }
        GlusterVolumeEntity vol = glusterVolumeDao.getByName(vds.getClusterId(), volumeName);
        if (vol == null) {
            getQueryReturnValue().setSucceeded(false);
            return;
        }
        glusterVolumeId = vol.getId();
    }
    getQueryReturnValue().setReturnValue(glusterGeoRepDao.getGeoRepSessions(glusterVolumeId));
    getQueryReturnValue().setSucceeded(true);
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) Guid(org.ovirt.engine.core.compat.Guid)

Example 40 with GlusterGeoRepSession

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

the class StartGlusterVolumeGeoRepCommand method executeCommand.

@Override
protected void executeCommand() {
    GlusterGeoRepSession session = getGeoRepSession();
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.StartGlusterVolumeGeoRep, new GlusterVolumeGeoRepSessionVDSParameters(upServer.getId(), getGlusterVolumeName(), session.getSlaveHostName(), session.getSlaveVolumeName(), session.getUserName(), getParameters().isForce()));
    setSucceeded(returnValue.getSucceeded());
    if (getSucceeded()) {
        session.setStatus(GeoRepSessionStatus.INITIALIZING);
        glusterGeoRepDao.updateSession(session);
    } else {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_GEO_REP_START_FAILED_EXCEPTION, returnValue.getVdsError().getMessage());
        return;
    }
}
Also used : GlusterGeoRepSession(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession) GlusterVolumeGeoRepSessionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

GlusterGeoRepSession (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession)49 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)12 EngineLock (org.ovirt.engine.core.utils.lock.EngineLock)9 GlusterVolumeGeoRepSessionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeGeoRepSessionParameters)8 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)8 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 VDS (org.ovirt.engine.core.common.businessentities.VDS)6 Guid (org.ovirt.engine.core.compat.Guid)6 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)5 GlusterVolumeGeoRepSessionVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeGeoRepSessionVDSParameters)5 GlusterGeoRepSessionDetails (org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionDetails)3 GlusterVolumeSnapshotEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity)3 HashMap (java.util.HashMap)2 Callable (java.util.concurrent.Callable)2 StorageDomainDR (org.ovirt.engine.core.common.businessentities.StorageDomainDR)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)2 EngineException (org.ovirt.engine.core.common.errors.EngineException)2 CreateGlusterVolumeSnapshotVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.CreateGlusterVolumeSnapshotVDSParameters)2