Search in sources :

Example 1 with Label

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

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

the class VmAffinityLabelListModel method getNewAffinityLabel.

@Override
protected Label getNewAffinityLabel() {
    Label affinityLabel = super.getNewAffinityLabel();
    affinityLabel.addVm(getEntity());
    return affinityLabel;
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label)

Example 3 with Label

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

the class ProcessOvfUpdateForStoragePoolCommand method populateVmsMetadataForOvfUpdate.

/**
 * Create and returns map contains valid vms metadata
 */
protected Map<Guid, KeyValuePairCompat<String, List<Guid>>> populateVmsMetadataForOvfUpdate(List<Guid> idsToProcess) {
    Map<Guid, KeyValuePairCompat<String, List<Guid>>> vmsAndTemplateMetadata = new HashMap<>();
    List<VM> vms = vmDao.getVmsByIds(idsToProcess);
    for (VM vm : vms) {
        if (VMStatus.ImageLocked != vm.getStatus()) {
            updateVmDisksFromDb(vm);
            if (!verifyImagesStatus(vm.getDiskList())) {
                continue;
            }
            ArrayList<DiskImage> vmImages = ovfUpdateProcessHelper.getVmImagesFromDb(vm);
            if (!verifyImagesStatus(vmImages)) {
                continue;
            }
            vm.setSnapshots(snapshotDao.getAllWithConfiguration(vm.getId()));
            if (!verifySnapshotsStatus(vm.getSnapshots())) {
                continue;
            }
            ovfUpdateProcessHelper.loadVmData(vm);
            Long currentDbGeneration = vmStaticDao.getDbGeneration(vm.getId());
            if (currentDbGeneration == null) {
                log.warn("currentDbGeneration of VM (name: '{}', id: '{}') is null, probably because the VM was deleted during the run of OvfDataUpdater.", vm.getName(), vm.getId());
                continue;
            }
            if (vm.getStaticData().getDbGeneration() == currentDbGeneration) {
                List<LunDisk> lunDisks = DisksFilter.filterLunDisks(vm.getDiskMap().values());
                for (LunDisk lun : lunDisks) {
                    lun.getLun().setLunConnections(new ArrayList<>(storageServerConnectionDao.getAllForLun(lun.getLun().getId())));
                }
                List<AffinityGroup> affinityGroups = affinityGroupDao.getAllAffinityGroupsByVmId(vm.getId());
                List<Label> affinityLabels = labelDao.getAllByEntityIds(Collections.singletonList(vm.getId()));
                Set<DbUser> dbUsers = new HashSet<>(dbUserDao.getAllForVm(vm.getId()));
                FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(vm);
                fullEntityOvfData.setDiskImages(vmImages);
                fullEntityOvfData.setLunDisks(lunDisks);
                fullEntityOvfData.setAffinityGroups(affinityGroups);
                fullEntityOvfData.setAffinityLabels(affinityLabels);
                fullEntityOvfData.setDbUsers(dbUsers);
                ovfHelper.populateUserToRoles(fullEntityOvfData, vm.getId());
                proccessedOvfConfigurationsInfo.add(ovfUpdateProcessHelper.buildMetadataDictionaryForVm(vm, vmsAndTemplateMetadata, fullEntityOvfData));
                proccessedIdsInfo.add(vm.getId());
                proccessedOvfGenerationsInfo.add(vm.getStaticData().getDbGeneration());
                proccessDisksDomains(vm.getDiskList());
            }
        }
    }
    return vmsAndTemplateMetadata;
}
Also used : KeyValuePairCompat(org.ovirt.engine.core.compat.KeyValuePairCompat) HashMap(java.util.HashMap) Label(org.ovirt.engine.core.common.businessentities.Label) Guid(org.ovirt.engine.core.compat.Guid) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) VM(org.ovirt.engine.core.common.businessentities.VM) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) HashSet(java.util.HashSet)

Example 4 with Label

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

the class LabelActionParametersTest method validateEmptyNameFails.

@Test
public void validateEmptyNameFails() throws Exception {
    Label label = createLabel("");
    validateLabelNameLength(label, false);
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) Test(org.junit.Test)

Example 5 with Label

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

the class LabelActionParametersTest method validateLongNameFails.

@Test
public void validateLongNameFails() throws Exception {
    Label label = createLabel("veryveryveryveryverylongnamewhichiswaytoolongforalabel");
    validateLabelNameLength(label, false);
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) Test(org.junit.Test)

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