Search in sources :

Example 1 with LabelActionParameters

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);
}
Also used : LabelActionParameters(org.ovirt.engine.core.common.action.LabelActionParameters) ArrayList(java.util.ArrayList) Label(org.ovirt.engine.core.common.businessentities.Label) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 2 with LabelActionParameters

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);
    }
}
Also used : LabelActionParameters(org.ovirt.engine.core.common.action.LabelActionParameters)

Example 3 with LabelActionParameters

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));
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) VDS(org.ovirt.engine.core.common.businessentities.VDS) LabelActionParameters(org.ovirt.engine.core.common.action.LabelActionParameters) Label(org.ovirt.engine.core.common.businessentities.Label) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder)

Example 4 with LabelActionParameters

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));
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) LabelActionParameters(org.ovirt.engine.core.common.action.LabelActionParameters) Guid(org.ovirt.engine.core.compat.Guid)

Example 5 with LabelActionParameters

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);
}
Also used : LabelActionParameters(org.ovirt.engine.core.common.action.LabelActionParameters) Label(org.ovirt.engine.core.common.businessentities.Label)

Aggregations

LabelActionParameters (org.ovirt.engine.core.common.action.LabelActionParameters)10 Label (org.ovirt.engine.core.common.businessentities.Label)7 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)6 Guid (org.ovirt.engine.core.compat.Guid)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 PathParam (javax.ws.rs.PathParam)1 Response (javax.ws.rs.core.Response)1 AffinityLabel (org.ovirt.engine.api.model.AffinityLabel)1 AffinityLabels (org.ovirt.engine.api.model.AffinityLabels)1 Host (org.ovirt.engine.api.model.Host)1 Vm (org.ovirt.engine.api.model.Vm)1 AssignedAffinityLabelResource (org.ovirt.engine.api.resource.AssignedAffinityLabelResource)1 AssignedAffinityLabelsResource (org.ovirt.engine.api.resource.AssignedAffinityLabelsResource)1 GuidUtils (org.ovirt.engine.api.restapi.utils.GuidUtils)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1