use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.
the class CreateGlusterVolumeSnapshotCommand method pauseAndCreateSnapshotForGeoRepSessions.
private boolean pauseAndCreateSnapshotForGeoRepSessions() {
if (georepSessions != null && georepSessions.size() > 0) {
for (GlusterGeoRepSession session : georepSessions) {
final GlusterVolumeEntity slaveVolume = glusterVolumeDao.getById(session.getSlaveVolumeId());
if (slaveVolume == null) {
// Continue to other geo-rep sessions and pause them for snapshot purpose
continue;
}
VDS slaveUpServer = glusterUtil.getRandomUpServer(slaveVolume.getClusterId());
if (slaveUpServer == null) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, "No up server found in slave cluster of geo-rep session");
setSucceeded(false);
return false;
}
// Pause the geo-rep session if required
if (!(session.getStatus() == GeoRepSessionStatus.CREATED || session.getStatus() == GeoRepSessionStatus.PAUSED || session.getStatus() == GeoRepSessionStatus.STOPPED)) {
ActionReturnValue sessionPauseRetVal = null;
try (EngineLock lock = acquireEngineLock(slaveVolume.getId(), LockingGroup.GLUSTER_SNAPSHOT)) {
sessionPauseRetVal = runInternalAction(ActionType.PauseGlusterVolumeGeoRepSession, new GlusterVolumeGeoRepSessionParameters(getGlusterVolumeId(), session.getId()));
}
if (sessionPauseRetVal != null && !sessionPauseRetVal.getSucceeded()) {
handleVdsErrors(AuditLogType.GLUSTER_VOLUME_GEO_REP_PAUSE_FAILED, sessionPauseRetVal.getExecuteFailedMessages());
setSucceeded(false);
return false;
}
session.setStatus(GeoRepSessionStatus.PAUSED);
enginePausedSessions.add(session);
}
// Create snapshot for slave volume
VDSReturnValue snapCreationRetVal = runVdsCommand(VDSCommandType.CreateGlusterVolumeSnapshot, new CreateGlusterVolumeSnapshotVDSParameters(slaveUpServer.getId(), session.getSlaveVolumeName(), snapshot.getSnapshotName(), snapshot.getDescription(), force));
if (!snapCreationRetVal.getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, snapCreationRetVal.getVdsError().getMessage());
setSucceeded(false);
return false;
} else {
// Persist the snapshot details
GlusterVolumeSnapshotEntity slaveVolumeSnapshot = (GlusterVolumeSnapshotEntity) snapCreationRetVal.getReturnValue();
slaveVolumeSnapshot.setClusterId(slaveVolume.getClusterId());
slaveVolumeSnapshot.setVolumeId(slaveVolume.getId());
slaveVolumeSnapshot.setDescription(snapshot.getDescription());
slaveVolumeSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
glusterVolumeSnapshotDao.save(slaveVolumeSnapshot);
// check if the snapshot soft limit reached now for the volume and alert
glusterUtil.alertVolumeSnapshotLimitsReached(slaveVolume);
}
}
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.
the class DeleteAllGlusterVolumeSnapshotsCommand method executeCommand.
@Override
public void executeCommand() {
if (georepSessions != null) {
for (GlusterGeoRepSession session : georepSessions) {
GlusterVolumeEntity slaveVolume = glusterVolumeDao.getById(session.getSlaveVolumeId());
if (slaveVolume == null) {
// continue with other sessions and try to pause
continue;
}
VDS slaveUpServer = glusterUtil.getRandomUpServer(slaveVolume.getClusterId());
if (slaveUpServer == null) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_ALL_SNAPSHOTS_DELETE_FAILED, EngineError.NoUpServerFoundInRemoteCluster.name());
setSucceeded(false);
return;
}
List<GlusterVolumeSnapshotEntity> slaveVolumeSnapshots = glusterVolumeSnapshotDao.getAllByVolumeId(slaveVolume.getId());
try (EngineLock lock = acquireEngineLock(session.getSlaveVolumeId(), LockingGroup.GLUSTER_SNAPSHOT)) {
if (!deleteAllGlusterVolumeSnapshots(slaveUpServer.getId(), slaveVolume.getName(), slaveVolumeSnapshots)) {
return;
}
// Check and remove soft limit alert for the volume
glusterUtil.checkAndRemoveVolumeSnapshotLimitsAlert(slaveVolume);
}
}
}
deleteAllGlusterVolumeSnapshots(getUpServer().getId(), getGlusterVolumeName(), snapshots);
// Check and remove soft limit alert for the volume
glusterUtil.checkAndRemoveVolumeSnapshotLimitsAlert(getGlusterVolume());
}
use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.
the class DeleteGlusterVolumeSnapshotCommand method executeCommand.
@Override
public void executeCommand() {
if (georepSessions != null) {
for (GlusterGeoRepSession session : georepSessions) {
GlusterVolumeEntity slaveVolume = glusterVolumeDao.getById(session.getSlaveVolumeId());
if (slaveVolume == null) {
// continue with other sessions and try to pause
continue;
}
VDS slaveUpServer = glusterUtil.getRandomUpServer(slaveVolume.getClusterId());
if (slaveUpServer == null) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_DELETE_FAILED, EngineError.NoUpServerFoundInRemoteCluster.name());
setSucceeded(false);
return;
}
try (EngineLock lock = acquireEngineLock(session.getSlaveVolumeId(), LockingGroup.GLUSTER_SNAPSHOT)) {
if (!deleteGlusterVolumeSnapshot(slaveUpServer.getId(), slaveVolume.getName(), getSnapshot().getSnapshotName())) {
return;
}
// Check and remove soft limit alert for the volume
glusterUtil.checkAndRemoveVolumeSnapshotLimitsAlert(slaveVolume);
}
}
}
deleteGlusterVolumeSnapshot(getUpServer().getId(), getGlusterVolumeName(), getSnapshot().getSnapshotName());
// Check and remove soft limit alert for the volume
glusterUtil.checkAndRemoveVolumeSnapshotLimitsAlert(getGlusterVolume());
}
use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.
the class GetAddedGlusterServersQuery method executeQueryCommand.
@Override
@SuppressWarnings("unchecked")
protected void executeQueryCommand() {
Map<String, String> glusterServers = new HashMap<>();
VDS upServer = glusterUtil.getUpServer(getParameters().getClusterId());
if (upServer != null) {
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GlusterServersList, new VdsIdVDSCommandParametersBase(upServer.getId()));
glusterServers = getAddedGlusterServers((List<GlusterServerInfo>) returnValue.getReturnValue());
}
getQueryReturnValue().setReturnValue(glusterServers);
}
use of org.ovirt.engine.core.common.businessentities.VDS in project ovirt-engine by oVirt.
the class RestartVdsCommand method validate.
@Override
protected boolean validate() {
VDS host = getVds();
List<String> messages = getReturnValue().getValidationMessages();
boolean valid = fenceValidator.isHostExists(host, messages) && fenceValidator.isPowerManagementEnabledAndLegal(host, getCluster(), messages) && (previousHostedEngineHost.isPreviousHostId(host.getId()) || fenceValidator.isStartupTimeoutPassed(messages) || host.isInFenceFlow()) && isQuietTimeFromLastActionPassed() && fenceValidator.isProxyHostAvailable(host, messages);
if (!valid) {
handleError();
}
getReturnValue().setSucceeded(valid);
return valid;
}
Aggregations