Search in sources :

Example 1 with AffinityGroup

use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.

the class AffinityGroupListModel method edit.

private void edit() {
    if (getWindow() != null) {
        return;
    }
    AffinityGroup affinityGroup = getSelectedItem();
    if (affinityGroup == null) {
        return;
    }
    AffinityGroupModel model = new EditAffinityGroupModel(affinityGroup, this, getClusterId(), getClusterName());
    model.init();
    setWindow(model);
}
Also used : EditAffinityGroupModel(org.ovirt.engine.ui.uicommonweb.models.configure.scheduling.affinity_groups.model.EditAffinityGroupModel) AffinityGroupModel(org.ovirt.engine.ui.uicommonweb.models.configure.scheduling.affinity_groups.model.AffinityGroupModel) EditAffinityGroupModel(org.ovirt.engine.ui.uicommonweb.models.configure.scheduling.affinity_groups.model.EditAffinityGroupModel) NewAffinityGroupModel(org.ovirt.engine.ui.uicommonweb.models.configure.scheduling.affinity_groups.model.NewAffinityGroupModel) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup)

Example 2 with AffinityGroup

use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.

the class AffinityGroupListModel method onRemove.

private void onRemove() {
    ConfirmationModel model = (ConfirmationModel) getConfirmWindow();
    if (model.getProgress() != null) {
        return;
    }
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    for (AffinityGroup affinityGroup : getSelectedItems()) {
        parameters.add(new AffinityGroupCRUDParameters(affinityGroup.getId(), affinityGroup));
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.RemoveAffinityGroup, parameters, result -> {
        ConfirmationModel localModel = (ConfirmationModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, model);
}
Also used : ArrayList(java.util.ArrayList) AffinityGroupCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.AffinityGroupCRUDParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup)

Example 3 with AffinityGroup

use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.

the class VmAffinityGroupListModel method getNewAffinityGroup.

@Override
protected AffinityGroup getNewAffinityGroup() {
    AffinityGroup affinityGroup = super.getNewAffinityGroup();
    affinityGroup.setVmIds(new ArrayList<Guid>());
    affinityGroup.getVmIds().add(getEntity().getId());
    return affinityGroup;
}
Also used : Guid(org.ovirt.engine.core.compat.Guid) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup)

Example 4 with AffinityGroup

use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.

the class AffinityGroupModel method onSave.

void onSave() {
    if (!validate()) {
        return;
    }
    if (getProgress() != null) {
        return;
    }
    AffinityGroup group = getAffinityGroup();
    group.setName(getName().getEntity());
    group.setDescription(getDescription().getEntity());
    group.setClusterId(clusterId);
    // Save VM details
    group.setVmEnforcing(getVmAffinityEnforcing().getEntity());
    group.setVmAffinityRule(getVmAffinityRule().getSelectedItem());
    group.setVmIds(getVmsSelectionModel().getSelectedVmIds());
    // Save host details
    group.setVdsEnforcing(getHostAffinityEnforcing().getEntity());
    group.setVdsAffinityRule(getHostAffinityRule().getSelectedItem());
    group.setVdsIds(getHostsSelectionModel().getSelectedHostIds());
    startProgress();
    Frontend.getInstance().runAction(saveActionType, new AffinityGroupCRUDParameters(group.getId(), group), result -> {
        stopProgress();
        if (result != null && result.getReturnValue() != null && result.getReturnValue().getSucceeded()) {
            cancel();
        }
    }, this);
}
Also used : AffinityGroupCRUDParameters(org.ovirt.engine.core.common.scheduling.parameters.AffinityGroupCRUDParameters) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup)

Example 5 with AffinityGroup

use of org.ovirt.engine.core.common.scheduling.AffinityGroup 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)

Aggregations

AffinityGroup (org.ovirt.engine.core.common.scheduling.AffinityGroup)49 Test (org.junit.Test)20 Guid (org.ovirt.engine.core.compat.Guid)12 ArrayList (java.util.ArrayList)11 VM (org.ovirt.engine.core.common.businessentities.VM)11 HashSet (java.util.HashSet)9 HashMap (java.util.HashMap)7 List (java.util.List)5 Map (java.util.Map)5 Set (java.util.Set)5 Collectors (java.util.stream.Collectors)5 Inject (javax.inject.Inject)5 PerHostMessages (org.ovirt.engine.core.common.scheduling.PerHostMessages)5 AffinityGroupDao (org.ovirt.engine.core.dao.scheduling.AffinityGroupDao)5 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)4 AffinityGroupCRUDParameters (org.ovirt.engine.core.common.scheduling.parameters.AffinityGroupCRUDParameters)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Collections (java.util.Collections)3