use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testGetOperationResult_One.
@Test
public void testGetOperationResult_One() {
VdcOperation<ActionType, ActionParametersBase> testOperation1 = new VdcOperation<>(ActionType.ActivateVds, new ActionParametersBase(), null);
List<VdcOperation<?, ?>> testOperationList = new ArrayList<>();
testOperationList.add(testOperation1);
List<VdcOperation<?, ?>> allOperationList = new ArrayList<>();
allOperationList.add(testOperation1);
ActionReturnValue testResult1 = new ActionReturnValue();
List<ActionReturnValue> allResults = new ArrayList<>();
allResults.add(testResult1);
List<?> result = testProvider.getOperationResult(testOperationList, allOperationList, allResults);
// $NON-NLS-1$
assertEquals("Result should have one results", 1, result.size());
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class OperationProcessorTest method testOnOperationAvailableSingle.
@Test
public void testOnOperationAvailableSingle() {
ActionParametersBase testParameter = new ActionParametersBase();
VdcOperation<ActionType, ActionParametersBase> testOperation = new VdcOperation<>(ActionType.AddEventSubscription, testParameter, mockCallback1);
when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation).thenReturn(null);
testProcessor.processAvailableOperations(mockOperationManager);
verify(mockProvider).transmitOperationList(operationListCaptor.capture());
// Test that we inserted the callback from the processor.
assertFalse(// $NON-NLS-1$
"The callbacks should not match.", operationListCaptor.getValue().get(0).getCallback().equals(mockCallback1));
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class ClusterGlusterHookListModel method onResolveConflicts.
/*
* If there are multiple types of conflicts found for a hook and the user choose to resolve them. The conflicts will
* be resolved in the following order 1)Content Conflict, 2)Status Conflict, 3)Missing Conflict
*
* If any conflict resolution is failed the next one will not be executed
*/
private void onResolveConflicts() {
final GlusterHookResolveConflictsModel resolveConflictsModel = (GlusterHookResolveConflictsModel) getWindow();
if (resolveConflictsModel == null) {
return;
}
if (!resolveConflictsModel.isAnyResolveActionSelected()) {
resolveConflictsModel.setMessage(ConstantsManager.getInstance().getConstants().noResolveActionSelectedGlusterHook());
return;
}
resolveConflictsModel.startProgress();
GlusterHookEntity hookEntity = resolveConflictsModel.getGlusterHookEntity();
ArrayList<ActionType> actionTypes = new ArrayList<>();
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
if (resolveConflictsModel.getResolveContentConflict().getEntity()) {
actionTypes.add(ActionType.UpdateGlusterHook);
GlusterServerHook serverHook = resolveConflictsModel.getServerHooksList().getSelectedItem();
Guid serverId = (serverHook == null) ? null : serverHook.getServerId();
parameters.add(new GlusterHookManageParameters(hookEntity.getId(), serverId));
IFrontendActionAsyncCallback callback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.getResolveContentConflict().setEntity(Boolean.FALSE);
resolveConflictsModel.getResolveContentConflict().setIsChangeable(Boolean.FALSE);
}
};
callbacks.add(callback);
}
if (resolveConflictsModel.getResolveStatusConflict().getEntity()) {
boolean isEnable = resolveConflictsModel.getResolveStatusConflictEnable().getEntity();
actionTypes.add(isEnable ? ActionType.EnableGlusterHook : ActionType.DisableGlusterHook);
parameters.add(new GlusterHookParameters(hookEntity.getId()));
IFrontendActionAsyncCallback callback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.getResolveStatusConflict().setEntity(Boolean.FALSE);
resolveConflictsModel.getResolveStatusConflict().setIsChangeable(Boolean.FALSE);
}
};
callbacks.add(callback);
}
if (resolveConflictsModel.getResolveMissingConflict().getEntity()) {
boolean isAdd = resolveConflictsModel.getResolveMissingConflictCopy().getEntity();
actionTypes.add(isAdd ? ActionType.AddGlusterHook : ActionType.RemoveGlusterHook);
parameters.add(new GlusterHookManageParameters(hookEntity.getId()));
IFrontendActionAsyncCallback callback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.getResolveMissingConflict().setEntity(Boolean.FALSE);
resolveConflictsModel.getResolveMissingConflict().setIsChangeable(Boolean.FALSE);
}
};
callbacks.add(callback);
}
IFrontendActionAsyncCallback onFinishCallback = result -> {
if (result.getReturnValue().getSucceeded()) {
resolveConflictsModel.stopProgress();
cancel();
syncSearch();
}
};
IFrontendActionAsyncCallback failureCallback = result -> resolveConflictsModel.stopProgress();
// Replacing the last callback with onFinishCallback, as we just want to close the dialog and execute the search
if (callbacks.size() > 0) {
callbacks.remove(callbacks.size() - 1);
callbacks.add(onFinishCallback);
Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, failureCallback, null);
}
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class ClusterListModel method onSaveInternalWithModel.
private void onSaveInternalWithModel(final ClusterModel model) {
Cluster cluster = buildCluster(model, model.getIsNew() ? new Cluster() : (Cluster) Cloner.clone(getSelectedItem()));
model.startProgress();
final Network managementNetwork = model.getManagementNetwork().getSelectedItem();
final ManagementNetworkOnClusterOperationParameters clusterOperationParameters = new ManagementNetworkOnClusterOperationParameters(cluster, managementNetwork.getId());
final ActionType actionType = model.getIsNew() ? ActionType.AddCluster : ActionType.UpdateCluster;
Frontend.getInstance().runAction(actionType, clusterOperationParameters, result -> {
ClusterListModel<Void> localModel = (ClusterListModel<Void>) result.getState();
if (model.getIsImportGlusterConfiguration().getEntity()) {
localModel.postOnSaveInternalWithImport(result.getReturnValue());
} else {
localModel.postOnSaveInternal(result.getReturnValue());
}
}, this);
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class QuotaListModel method onCreateQuotaInternal.
private void onCreateQuotaInternal(boolean isClone) {
QuotaModel model = (QuotaModel) getWindow();
if (!model.validate()) {
return;
}
Quota quota = model.getEntity();
quota.setQuotaName(model.getName().getEntity());
quota.setDescription(model.getDescription().getEntity());
quota.setStoragePoolId(model.getDataCenter().getSelectedItem().getId());
quota.setGraceClusterPercentage(model.getGraceClusterAsInteger());
quota.setGraceStoragePercentage(model.getGraceStorageAsInteger());
quota.setThresholdClusterPercentage(model.getThresholdClusterAsInteger());
quota.setThresholdStoragePercentage(model.getThresholdStorageAsInteger());
if (model.getGlobalClusterQuota().getEntity()) {
QuotaCluster quotaCluster;
for (QuotaCluster iter : model.getQuotaClusters().getItems()) {
quota.setGlobalQuotaCluster(new QuotaCluster());
quota.getGlobalQuotaCluster().setMemSizeMB(iter.getMemSizeMB());
quota.getGlobalQuotaCluster().setVirtualCpu(iter.getVirtualCpu());
quota.getQuotaClusters().clear();
}
} else {
quota.setGlobalQuotaCluster(null);
ArrayList<QuotaCluster> quotaClusterList = new ArrayList<>();
QuotaCluster quotaCluster;
for (QuotaCluster iter : model.getAllDataCenterClusters().getItems()) {
quotaCluster = iter;
if (quotaCluster.getMemSizeMB() != null) {
quotaClusterList.add(quotaCluster);
}
}
quota.setQuotaClusters(quotaClusterList);
}
if (model.getGlobalStorageQuota().getEntity()) {
QuotaStorage quotaStorage;
for (QuotaStorage iter : model.getQuotaStorages().getItems()) {
quota.setGlobalQuotaStorage(new QuotaStorage());
quota.getGlobalQuotaStorage().setStorageSizeGB(iter.getStorageSizeGB());
quota.getQuotaStorages().clear();
}
} else {
quota.setGlobalQuotaStorage(null);
ArrayList<QuotaStorage> quotaStorageList = new ArrayList<>();
QuotaStorage quotaStorage;
for (QuotaStorage iter : model.getAllDataCenterStorages().getItems()) {
quotaStorage = iter;
if (quotaStorage.getStorageSizeGB() != null) {
quotaStorageList.add(quotaStorage);
}
}
quota.setQuotaStorages(quotaStorageList);
}
Guid guid = quota.getId();
QuotaCRUDParameters parameters = new QuotaCRUDParameters(quota);
if (isClone) {
parameters.setCopyPermissions(model.getCopyPermissions().getEntity());
parameters.setQuotaId(quota.getId());
quota.setId(Guid.Empty);
}
ActionType actionType = ActionType.AddQuota;
if (!quota.getId().equals(Guid.Empty)) {
actionType = ActionType.UpdateQuota;
}
Frontend.getInstance().runAction(actionType, parameters, result -> setWindow(null));
quota.setId(guid);
}
Aggregations