use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class VolumeBrickListModel method onReplaceConfirmation.
private void onReplaceConfirmation() {
cancelConfirmation();
ReplaceBrickModel replaceBrickModel = (ReplaceBrickModel) getWindow();
GlusterVolumeEntity volumeEntity = getEntity();
GlusterBrickEntity existingBrick = getSelectedItem();
if (replaceBrickModel == null || volumeEntity == null || existingBrick == null) {
return;
}
if (!replaceBrickModel.validate()) {
return;
}
VDS server = replaceBrickModel.getServers().getSelectedItem();
if (server == null) {
return;
}
GlusterBrickEntity newBrick = new GlusterBrickEntity();
newBrick.setVolumeId(volumeEntity.getId());
newBrick.setServerId(server.getId());
newBrick.setServerName(server.getHostName());
newBrick.setBrickDirectory(replaceBrickModel.getBrickDirectory().getEntity());
replaceBrickModel.startProgress();
GlusterVolumeReplaceBrickActionParameters parameter = new GlusterVolumeReplaceBrickActionParameters(volumeEntity.getId(), existingBrick, newBrick);
Frontend.getInstance().runAction(ActionType.ReplaceGlusterVolumeBrick, parameter, result -> {
ReplaceBrickModel localModel = (ReplaceBrickModel) result.getState();
localModel.stopProgress();
setWindow(null);
}, replaceBrickModel);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class VolumeBrickListModel method updateActionAvailability.
private void updateActionAvailability() {
GlusterVolumeEntity volumeEntity = getEntity();
boolean allowRemove = true;
boolean allowReplace = true;
boolean allowAdvanced = true;
boolean allowAdd = true;
boolean allowReset = true;
if (volumeEntity == null || volumeEntity.getVolumeType().isDispersedType() || !volumeEntity.getVolumeType().isSupported()) {
allowRemove = false;
allowAdd = false;
}
if (volumeEntity == null || getSelectedItems() == null || getSelectedItems().size() == 0) {
allowRemove = false;
allowReplace = false;
allowAdvanced = false;
allowReset = false;
} else {
if (getSelectedItems().size() == 1) {
allowAdvanced = volumeEntity.isOnline() && getSelectedItems().get(0).isOnline();
} else {
allowReplace = false;
allowAdvanced = false;
allowReset = false;
}
GlusterAsyncTask volumeTask = volumeEntity.getAsyncTask();
if (volumeTask != null && (volumeTask.getStatus() == JobExecutionStatus.STARTED || volumeTask.getType() == GlusterTaskType.REMOVE_BRICK && volumeTask.getStatus() == JobExecutionStatus.FINISHED)) {
allowRemove = false;
allowReplace = false;
allowReset = false;
} else if (volumeEntity.getVolumeType() == GlusterVolumeType.STRIPE || getSelectedItems().size() == volumeEntity.getBricks().size()) {
allowRemove = false;
} else if (volumeEntity.getVolumeType() == GlusterVolumeType.REPLICATE && (volumeEntity.getBricks().size() == VolumeListModel.REPLICATE_COUNT_DEFAULT || getSelectedItems().size() > 1)) {
allowRemove = false;
}
}
getRemoveBricksCommand().setIsExecutionAllowed(allowRemove);
getReplaceBrickCommand().setIsExecutionAllowed(allowReplace);
getBrickAdvancedDetailsCommand().setIsExecutionAllowed(allowAdvanced);
getAddBricksCommand().setIsExecutionAllowed(allowAdd);
getResetBrickCommand().setIsExecutionAllowed(allowReset);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class VolumeBrickListModel method commitRemoveBricks.
private void commitRemoveBricks() {
if (getConfirmWindow() != null) {
return;
}
ConfirmationModel model = new ConfirmationModel();
setConfirmWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().commitRemoveBricksTitle());
model.setMessage(ConstantsManager.getInstance().getConstants().commitRemoveBricksMessage());
model.setHelpTag(HelpTag.volume_remove_bricks_commit);
// $NON-NLS-1$
model.setHashName("volume_remove_bricks_commit");
GlusterVolumeEntity volumeEntity = getVolumeEntity();
GlusterAsyncTask volumeTask = volumeEntity.getAsyncTask();
ArrayList<String> list = new ArrayList<>();
for (GlusterBrickEntity brick : volumeEntity.getBricks()) {
if (brick.getAsyncTask() != null && volumeTask != null && brick.getAsyncTask().getTaskId() != null && brick.getAsyncTask().getTaskId().equals(volumeTask.getTaskId()) && volumeTask.getStatus() == JobExecutionStatus.FINISHED) {
list.add(brick.getQualifiedName());
}
}
model.setItems(list);
// $NON-NLS-1$
UICommand okCommand = UICommand.createDefaultOkUiCommand("OnCommitRemoveBricks", this);
model.getCommands().add(okCommand);
// $NON-NLS-1$
UICommand cancelCommand = UICommand.createCancelUiCommand("CancelConfirmation", this);
model.getCommands().add(cancelCommand);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class VolumeBrickListModel method showRemoveBricksStatus.
private void showRemoveBricksStatus() {
final GlusterVolumeEntity volumeEntity = getVolumeEntity();
final ArrayList<GlusterBrickEntity> bricks = new ArrayList<>();
for (GlusterBrickEntity brick : volumeEntity.getBricks()) {
if (brick.getAsyncTask() != null && brick.getAsyncTask().getTaskId() != null) {
bricks.add(brick);
}
}
final ConfirmationModel cModel = new ConfirmationModel();
cModel.setHelpTag(HelpTag.volume_remove_bricks_status);
// //$NON-NLS-1$
cModel.setHashName("volume_remove_bricks_status");
// $NON-NLS-1$
UICommand removeBrickStatusOk = new UICommand("CancelConfirmation", VolumeBrickListModel.this);
removeBrickStatusOk.setTitle(ConstantsManager.getInstance().getConstants().ok());
removeBrickStatusOk.setIsCancel(true);
cModel.startProgress(ConstantsManager.getInstance().getConstants().fetchingDataMessage());
cModel.getCommands().add(removeBrickStatusOk);
cModel.setTitle(ConstantsManager.getInstance().getConstants().removeBricksStatusTitle());
setConfirmWindow(cModel);
// $NON-NLS-1$
final UICommand stopRemoveBrickFromStatus = new UICommand("StopRemoveBricksOnStatus", this);
stopRemoveBrickFromStatus.setTitle(ConstantsManager.getInstance().getConstants().stopRemoveBricksButton());
stopRemoveBrickFromStatus.setIsExecutionAllowed(false);
// $NON-NLS-1$
final UICommand commitRemoveBrickFromStatus = new UICommand("CommitRemoveBricksOnStatus", this);
commitRemoveBrickFromStatus.setTitle(ConstantsManager.getInstance().getConstants().commitRemoveBricksButton());
commitRemoveBrickFromStatus.setIsExecutionAllowed(false);
// $NON-NLS-1$
final UICommand retainBricksFromStatus = new UICommand("RetainBricksOnStatus", this);
retainBricksFromStatus.setTitle(ConstantsManager.getInstance().getConstants().retainBricksButton());
retainBricksFromStatus.setIsExecutionAllowed(false);
// $NON-NLS-1$
final UICommand cancelCommand = new UICommand("CancelRemoveBricksStatus", this);
cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().close());
cancelCommand.setIsCancel(true);
AsyncDataProvider.getInstance().getGlusterRemoveBricksStatus(new AsyncQuery<>(returnValue -> {
cModel.stopProgress();
if (returnValue.getSucceeded() && returnValue.getReturnValue() != null) {
cancelConfirmation();
RemoveBrickStatusModel removeBrickStatusModel;
GlusterVolumeTaskStatusEntity removeBrickStatusEntity = returnValue.getReturnValue();
if (getWindow() == null) {
removeBrickStatusModel = new RemoveBrickStatusModel(volumeEntity, bricks);
removeBrickStatusModel.setTitle(ConstantsManager.getInstance().getConstants().removeBricksStatusTitle());
removeBrickStatusModel.setHelpTag(HelpTag.volume_remove_bricks_status);
// //$NON-NLS-1$
removeBrickStatusModel.setHashName("volume_remove_bricks_status");
setWindow(removeBrickStatusModel);
removeBrickStatusModel.getVolume().setEntity(volumeEntity.getName());
removeBrickStatusModel.getCluster().setEntity(volumeEntity.getClusterName());
removeBrickStatusModel.addStopRemoveBricksCommand(stopRemoveBrickFromStatus);
removeBrickStatusModel.addCommitRemoveBricksCommand(commitRemoveBrickFromStatus);
removeBrickStatusModel.addRetainBricksCommand(retainBricksFromStatus);
removeBrickStatusModel.getCommands().add(cancelCommand);
} else {
removeBrickStatusModel = (RemoveBrickStatusModel) getWindow();
}
removeBrickStatusModel.showStatus(removeBrickStatusEntity);
} else {
cModel.setMessage(ConstantsManager.getInstance().getMessages().removeBrickStatusFailed(volumeEntity.getName()));
}
}), volumeEntity.getClusterId(), volumeEntity.getId(), bricks);
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity in project ovirt-engine by oVirt.
the class GlusterVolumeSnapshotListModel method createNewSnapshot.
private void createNewSnapshot(final GlusterVolumeSnapshotModel snapshotModel) {
GlusterVolumeEntity volumeEntity = getEntity();
final GlusterVolumeSnapshotEntity snapshot = new GlusterVolumeSnapshotEntity();
snapshot.setClusterId(volumeEntity.getClusterId());
snapshot.setSnapshotName(snapshotModel.getSnapshotName().getEntity());
snapshot.setVolumeId(volumeEntity.getId());
snapshot.setDescription(snapshotModel.getDescription().getEntity());
CreateGlusterVolumeSnapshotParameters parameter = new CreateGlusterVolumeSnapshotParameters(snapshot, false);
snapshotModel.startProgress();
Frontend.getInstance().runAction(ActionType.CreateGlusterVolumeSnapshot, parameter, result -> {
GlusterVolumeSnapshotListModel localModel = (GlusterVolumeSnapshotListModel) result.getState();
snapshotModel.stopProgress();
localModel.postSnapshotAction(result.getReturnValue());
}, this);
}
Aggregations