Search in sources :

Example 6 with Label

use of org.ovirt.engine.core.common.businessentities.Label 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 7 with Label

use of org.ovirt.engine.core.common.businessentities.Label in project ovirt-engine by oVirt.

the class BackendAffinityLabelHostsResource method list.

@Override
public Hosts list() {
    Hosts hosts = new Hosts();
    List<Host> list = hosts.getHosts();
    Label label = BackendAffinityLabelHelper.getLabel(this, labelId);
    label.getHosts().stream().map(BackendAffinityLabelHelper::makeHostLink).forEach(list::add);
    return hosts;
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) Label(org.ovirt.engine.core.common.businessentities.Label) Host(org.ovirt.engine.api.model.Host)

Example 8 with Label

use of org.ovirt.engine.core.common.businessentities.Label in project ovirt-engine by oVirt.

the class BackendAffinityLabelVmsResource method list.

@Override
public Vms list() {
    Vms vms = new Vms();
    List<Vm> list = vms.getVms();
    Label label = BackendAffinityLabelHelper.getLabel(this, labelId);
    label.getVms().stream().map(BackendAffinityLabelHelper::makeVmLink).forEach(list::add);
    return vms;
}
Also used : Vm(org.ovirt.engine.api.model.Vm) Label(org.ovirt.engine.core.common.businessentities.Label) Vms(org.ovirt.engine.api.model.Vms)

Example 9 with Label

use of org.ovirt.engine.core.common.businessentities.Label in project ovirt-engine by oVirt.

the class AffinityLabelListWidget method createItems.

@Override
protected void createItems() {
    List<Label> selectedLabels = getModel().getSelectedItems();
    boolean noLabelsSelected = selectedLabels == null || selectedLabels.isEmpty();
    if (noLabelsSelected) {
        addNoLabelsMessage();
        return;
    }
    itemList.clear();
    Collections.sort(selectedLabels, new NameableComparator());
    selectedLabels.forEach(label -> {
        ItemListItem labelListItem = new ItemListItem();
        labelListItem.init(label.getName());
        labelListItem.getDeactivationAnchor().addClickHandler(event -> {
            getModel().getSelectedItems().remove(label);
            refreshItems();
        });
        itemList.add(labelListItem);
    });
    itemListPanel.add(itemList);
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator)

Example 10 with Label

use of org.ovirt.engine.core.common.businessentities.Label in project ovirt-engine by oVirt.

the class UpdateLabelCommand method executeCommand.

@Override
protected void executeCommand() {
    Label label = labelDao.get(getLabelId());
    Collection changedVms = CollectionUtils.disjunction(label.getVms(), getParameters().getLabel().getVms());
    vmStaticDao.incrementDbGenerationForVms(new ArrayList<>(changedVms));
    labelDao.update(getParameters().getLabel());
    setActionReturnValue(getParameters().getLabel());
    setSucceeded(true);
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) Collection(java.util.Collection)

Aggregations

Label (org.ovirt.engine.core.common.businessentities.Label)47 Test (org.junit.Test)19 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)19 Guid (org.ovirt.engine.core.compat.Guid)14 LabelActionParameters (org.ovirt.engine.core.common.action.LabelActionParameters)7 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)3 VM (org.ovirt.engine.core.common.businessentities.VM)3 PerHostMessages (org.ovirt.engine.core.common.scheduling.PerHostMessages)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 AffinityLabel (org.ovirt.engine.api.model.AffinityLabel)2 Host (org.ovirt.engine.api.model.Host)2 Vm (org.ovirt.engine.api.model.Vm)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 FullEntityOvfData (org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)2 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)2