Search in sources :

Example 36 with QueryType

use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.

the class VmInterfaceListModel method updateNetworkFilterParameterMap.

private void updateNetworkFilterParameterMap(List<VmNetworkInterface> vmInterfaces) {
    List<QueryType> queryTypes = new ArrayList<>();
    List<QueryParametersBase> queryParametersBases = new ArrayList<>();
    vmInterfaces.stream().forEach(iface -> {
        queryTypes.add(QueryType.GetVmInterfaceFilterParametersByVmInterfaceId);
        queryParametersBases.add(new IdQueryParameters(iface.getId()));
    });
    final IFrontendMultipleQueryAsyncCallback callback = multiResult -> {
        Map<Guid, List<VmNicFilterParameter>> networkFilterMap = new HashMap<>(vmInterfaces.size());
        for (int i = 0; i < multiResult.getReturnValues().size(); i++) {
            List<VmNicFilterParameter> params = multiResult.getReturnValues().get(i).getReturnValue();
            networkFilterMap.put(vmInterfaces.get(i).getId(), params);
        }
        setMapNicFilterParameter(networkFilterMap);
        setItems(vmInterfaces);
    };
    if (vmInterfaces.isEmpty()) {
        setItems(vmInterfaces);
    }
    Frontend.getInstance().runMultipleQueries(queryTypes, queryParametersBases, callback);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) ActionUtils(org.ovirt.engine.core.common.ActionUtils) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Objects(java.util.Objects) VmGuestAgentInterface(org.ovirt.engine.core.common.businessentities.VmGuestAgentInterface) Scheduler(com.google.gwt.core.client.Scheduler) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) IFrontendMultipleQueryAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleQueryAsyncCallback) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) IFrontendMultipleQueryAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleQueryAsyncCallback) ArrayList(java.util.ArrayList) List(java.util.List) QueryType(org.ovirt.engine.core.common.queries.QueryType) HashMap(java.util.HashMap) Map(java.util.Map) VmNicFilterParameter(org.ovirt.engine.core.common.businessentities.network.VmNicFilterParameter)

Example 37 with QueryType

use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.

the class MoveDiskModel method onInitDisks.

@Override
protected void onInitDisks() {
    final ArrayList<DiskModel> disks = new ArrayList<>();
    List<QueryType> queries = new ArrayList<>();
    List<QueryParametersBase> params = new ArrayList<>();
    for (DiskImage disk : getDiskImages()) {
        disks.add(DiskModel.diskToModel(disk));
        queries.add(QueryType.GetVmsByDiskGuid);
        params.add(new IdQueryParameters(disk.getId()));
    }
    Frontend.getInstance().runMultipleQueries(queries, params, result -> {
        for (int i = 0; i < result.getReturnValues().size(); i++) {
            Map<Boolean, List<VM>> resultValue = result.getReturnValues().get(i).getReturnValue();
            disks.get(i).setPluggedToRunningVm(!isAllVmsDown(resultValue));
        }
        setDisks(disks);
        updateMoveWarning(disks);
        initStorageDomains();
    });
}
Also used : ArrayList(java.util.ArrayList) MoveOrCopyDiskModel(org.ovirt.engine.ui.uicommonweb.models.storage.MoveOrCopyDiskModel) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) ArrayList(java.util.ArrayList) List(java.util.List) QueryType(org.ovirt.engine.core.common.queries.QueryType) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 38 with QueryType

use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.

the class ImportVmFromExportDomainModel method initDisksStorageDomainsList.

protected void initDisksStorageDomainsList() {
    for (Object item : getItems()) {
        ImportVmData importVmData = (ImportVmData) item;
        VM vm = importVmData.getVm();
        if (!Guid.Empty.equals(vm.getVmtGuid())) {
            if (!templateDiskMap.containsKey(vm.getVmtGuid())) {
                templateDiskMap.put(vm.getVmtGuid(), new ArrayList<Disk>());
            }
            templateDiskMap.get(vm.getVmtGuid()).addAll(extractRootDisks(vm));
        }
        for (Disk disk : vm.getDiskMap().values()) {
            DiskImage diskImage = (DiskImage) disk;
            addDiskImportData(diskImage.getId(), filteredStorageDomains, diskImage.getVolumeType(), importVmData.getCollapseSnapshots());
        }
    }
    if (!templateDiskMap.isEmpty()) {
        ArrayList<QueryType> queryTypeList = new ArrayList<>();
        final ArrayList<QueryParametersBase> queryParamsList = new ArrayList<>();
        for (Guid templateId : templateDiskMap.keySet()) {
            queryTypeList.add(QueryType.GetVmTemplatesDisks);
            queryParamsList.add(new IdQueryParameters(templateId));
        }
        Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
            List<QueryReturnValue> returnValueList = result.getReturnValues();
            Map<Guid, List<StorageDomain>> templateDisksStorageDomains = new HashMap<>();
            for (QueryReturnValue returnValue : returnValueList) {
                for (DiskImage diskImage : (ArrayList<DiskImage>) returnValue.getReturnValue()) {
                    templateDisksStorageDomains.put(diskImage.getImageId(), getStorageDomainsByIds(diskImage.getStorageIds()));
                }
            }
            for (Entry<Guid, List<Disk>> guidListEntry : templateDiskMap.entrySet()) {
                for (Disk disk : guidListEntry.getValue()) {
                    DiskImage diskImage = (DiskImage) disk;
                    if (diskImage.getParentId() != null && !Guid.Empty.equals(diskImage.getParentId())) {
                        List<StorageDomain> storageDomains = templateDisksStorageDomains.get(diskImage.getParentId());
                        if (storageDomains == null) {
                            missingTemplateDiskMap.put(guidListEntry.getKey(), guidListEntry.getValue());
                        }
                    }
                }
            }
            if (!missingTemplateDiskMap.keySet().isEmpty()) {
                getTemplatesFromExportDomain();
            } else {
                postInitDisks();
            }
        });
    } else {
        postInitDisks();
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VM(org.ovirt.engine.core.common.businessentities.VM) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) ArrayList(java.util.ArrayList) List(java.util.List) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Example 39 with QueryType

use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.

the class ImportVmFromExportDomainModel method initQuotaForStorageDomains.

private void initQuotaForStorageDomains() {
    ArrayList<QueryType> queryTypeList = new ArrayList<>();
    ArrayList<QueryParametersBase> queryParamsList = new ArrayList<>();
    for (StorageDomain storage : filteredStorageDomains) {
        queryTypeList.add(QueryType.GetAllRelevantQuotasForStorage);
        queryParamsList.add(new IdQueryParameters(storage.getId()));
    }
    storageQuotaMap = new HashMap<>();
    Frontend.getInstance().runMultipleQueries(queryTypeList, queryParamsList, result -> {
        List<QueryReturnValue> returnValueList = result.getReturnValues();
        boolean noQuota = true;
        for (int i = 0; i < filteredStorageDomains.size(); i++) {
            ArrayList<Quota> quotaList = returnValueList.get(i).getReturnValue();
            if (noQuota && !quotaList.isEmpty()) {
                noQuota = false;
            }
            storageQuotaMap.put(filteredStorageDomains.get(i).getId(), quotaList);
        }
        if (noQuota && QuotaEnforcementTypeEnum.HARD_ENFORCEMENT.equals(storagePool.getQuotaEnforcementType())) {
            showCloseMessage(ConstantsManager.getInstance().getConstants().missingQuotaStorageEnforceMode());
        }
        initDisksStorageDomainsList();
    });
}
Also used : ArrayList(java.util.ArrayList) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Quota(org.ovirt.engine.core.common.businessentities.Quota) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType)

Aggregations

QueryType (org.ovirt.engine.core.common.queries.QueryType)39 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)33 ArrayList (java.util.ArrayList)32 Test (org.junit.Test)22 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)21 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)15 Guid (org.ovirt.engine.core.compat.Guid)9 List (java.util.List)8 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)6 HashMap (java.util.HashMap)5 ActionType (org.ovirt.engine.core.common.action.ActionType)5 Quota (org.ovirt.engine.core.common.businessentities.Quota)5 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)5 VM (org.ovirt.engine.core.common.businessentities.VM)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)4 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)3 Map (java.util.Map)3 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)3 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3