use of org.ovirt.engine.core.common.action.LabelActionParameters in project ovirt-engine by oVirt.
the class AffinityLabelListModel method onRemove.
private void onRemove() {
ConfirmationModel model = (ConfirmationModel) getConfirmWindow();
if (model.getProgress() != null) {
return;
}
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
for (Label affinityLabel : getSelectedItems()) {
parameters.add(new LabelActionParameters(affinityLabel));
}
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.RemoveLabel, parameters, result -> {
ConfirmationModel localModel = (ConfirmationModel) result.getState();
localModel.stopProgress();
cancel();
}, model);
}
use of org.ovirt.engine.core.common.action.LabelActionParameters in project ovirt-engine by oVirt.
the class LabelActionParametersTest method validateLabelNameLength.
private void validateLabelNameLength(Label label, boolean isValidLabelName) {
LabelActionParameters parameters = new LabelActionParameters(label);
List<String> validationMessages = ValidationUtils.validateInputs(new ArrayList<>(), parameters);
if (isValidLabelName) {
Assertions.assertThat(validationMessages).isEmpty();
} else {
Assertions.assertThat(validationMessages).contains(EngineMessage.AFFINITY_LABEL_NAME_SIZE_INVALID.name()).contains("$min 1").contains("$max " + BusinessEntitiesDefinitions.TAG_NAME_SIZE);
}
}
use of org.ovirt.engine.core.common.action.LabelActionParameters in project ovirt-engine by oVirt.
the class BackendAffinityLabelHostResource method remove.
public Response remove() {
// First we need to check if the label contains the host:
Label label = BackendAffinityLabelHelper.getLabel(this, labelId);
if (!label.getHosts().contains(guid)) {
throw new WebApplicationException(Response.Status.NOT_FOUND);
}
// Remove the host from the label:
VDS entity = new VDS();
entity.setId(guid);
Label updatedLabel = new LabelBuilder(label).removeEntity(entity).build();
return performAction(ActionType.UpdateLabel, new LabelActionParameters(updatedLabel));
}
use of org.ovirt.engine.core.common.action.LabelActionParameters in project ovirt-engine by oVirt.
the class BackendAffinityLabelsResource method add.
@Override
public Response add(AffinityLabel label) {
validateParameters(label, "name");
org.ovirt.engine.core.common.businessentities.Label newLabel = map(label);
LabelActionParameters params = new LabelActionParameters(newLabel);
return performCreate(ActionType.AddLabel, params, new QueryIdResolver<Guid>(QueryType.GetLabelById, IdQueryParameters.class));
}
use of org.ovirt.engine.core.common.action.LabelActionParameters in project ovirt-engine by oVirt.
the class AffinityLabelModel method onSave.
void onSave() {
if (!validate() || (getProgress() != null)) {
return;
}
Label label = getAffinityLabel();
label.setName(getName().getEntity());
label.setVms(new HashSet<>(getVmsSelectionModel().getSelectedVmIds()));
label.setHosts(new HashSet<>(getHostsSelectionModel().getSelectedHostIds()));
startProgress();
Frontend.getInstance().runAction(saveActionType, new LabelActionParameters(label), result -> {
stopProgress();
if (result != null && result.getReturnValue() != null && result.getReturnValue().getSucceeded()) {
cancel();
}
}, this);
}
Aggregations