Search in sources :

Example 1 with GlusterVolumeSnapshotActionVDSParameters

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

the class DeactivateGlusterVolumeSnapshotCommand method executeCommand.

@Override
public void executeCommand() {
    VDSReturnValue retVal = runVdsCommand(VDSCommandType.DeactivateGlusterVolumeSnapshot, new GlusterVolumeSnapshotActionVDSParameters(getUpServer().getId(), getGlusterVolumeName(), getParameters().getSnapshotName()));
    setSucceeded(retVal.getSucceeded());
    if (!getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DEACTIVATE_FAILED, retVal.getVdsError().getMessage());
    } else {
        glusterVolumeSnapshotDao.updateSnapshotStatus(getSnapshot().getId(), GlusterSnapshotStatus.DEACTIVATED);
    }
}
Also used : GlusterVolumeSnapshotActionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 2 with GlusterVolumeSnapshotActionVDSParameters

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

the class DeleteGlusterVolumeSnapshotCommand method deleteGlusterVolumeSnapshot.

private boolean deleteGlusterVolumeSnapshot(Guid serverId, String volumeName, String snapshotName) {
    VDSReturnValue retVal = runVdsCommand(VDSCommandType.DeleteGlusterVolumeSnapshot, new GlusterVolumeSnapshotActionVDSParameters(serverId, volumeName, snapshotName));
    setSucceeded(retVal.getSucceeded());
    if (!getSucceeded()) {
        handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DELETE_FAILED, retVal.getVdsError().getMessage());
        return false;
    } else {
        glusterVolumeSnapshotDao.remove(getSnapshot().getId());
    }
    return true;
}
Also used : GlusterVolumeSnapshotActionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 3 with GlusterVolumeSnapshotActionVDSParameters

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

the class RestoreGlusterVolumeSnapshotCommand method restoreVolumeToSnapshot.

private boolean restoreVolumeToSnapshot(Guid upServerId, GlusterVolumeEntity volume, String snapshotName) {
    if (volume != null) {
        VDSReturnValue retVal = runVdsCommand(VDSCommandType.RestoreGlusterVolumeSnapshot, new GlusterVolumeSnapshotActionVDSParameters(upServerId, volume.getName(), snapshotName));
        if (!retVal.getSucceeded()) {
            handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_RESTORE_FAILED, retVal.getVdsError().getMessage());
            setSucceeded(false);
            return false;
        } else {
            glusterVolumeSnapshotDao.removeByName(volume.getId(), snapshotName);
            // Sync the new bricks of the volume immediately
            VDS upServer = glusterUtil.getRandomUpServer(volume.getClusterId());
            VDSReturnValue volDetailsRetVal = runVdsCommand(VDSCommandType.GetGlusterVolumeInfo, new GlusterVolumeInfoVDSParameters(upServer.getId(), volume.getClusterId(), volume.getName()));
            GlusterVolumeEntity fetchedVolume = ((Map<Guid, GlusterVolumeEntity>) volDetailsRetVal.getReturnValue()).get(volume.getId());
            List<GlusterBrickEntity> fetchedBricks = fetchedVolume.getBricks();
            if (fetchedBricks != null) {
                glusterBrickDao.removeAllInBatch(volume.getBricks());
                for (GlusterBrickEntity fetchdBrick : fetchedVolume.getBricks()) {
                    if (fetchdBrick.getServerId() != null) {
                        fetchdBrick.setStatus(GlusterStatus.UP);
                        glusterBrickDao.save(fetchdBrick);
                    } else {
                        log.warn("Invalid server details for brick " + fetchdBrick.getName() + ". Not adding now.");
                    }
                }
            }
        }
    }
    return true;
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterVolumeInfoVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeInfoVDSParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterVolumeSnapshotActionVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters) Map(java.util.Map) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)3 GlusterVolumeSnapshotActionVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeSnapshotActionVDSParameters)3 Map (java.util.Map)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)1 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)1 GlusterVolumeInfoVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeInfoVDSParameters)1