Search in sources :

Example 86 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase 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 87 with QueryParametersBase

use of org.ovirt.engine.core.common.queries.QueryParametersBase 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 88 with QueryParametersBase

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

Example 89 with QueryParametersBase

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

the class ImportVmsModel method initDataCenterCpuArchitectureMap.

private void initDataCenterCpuArchitectureMap() {
    final AsyncQuery<QueryReturnValue> callback = new AsyncQuery<>(new AsyncCallback<QueryReturnValue>() {

        @Override
        public void onSuccess(QueryReturnValue returnValue) {
            List<Cluster> allClusters = returnValue.getReturnValue();
            clusterArchitecturesInDataCenters = new HashMap<>();
            for (Cluster cluster : allClusters) {
                if (cluster.supportsVirtService() && cluster.getArchitecture() != null) {
                    addArchitecture(cluster.getStoragePoolId(), cluster.getArchitecture());
                }
            }
        }

        private void addArchitecture(Guid dataCenterId, ArchitectureType architecture) {
            Set<ArchitectureType> architectures = clusterArchitecturesInDataCenters.get(dataCenterId);
            if (architectures == null) {
                architectures = new HashSet<>();
                clusterArchitecturesInDataCenters.put(dataCenterId, architectures);
            }
            architectures.add(architecture);
        }
    });
    Frontend.getInstance().runQuery(QueryType.GetAllClusters, new QueryParametersBase(), callback);
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Guid(org.ovirt.engine.core.compat.Guid) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) List(java.util.List) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Aggregations

QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)89 ArrayList (java.util.ArrayList)41 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)40 QueryType (org.ovirt.engine.core.common.queries.QueryType)37 Test (org.junit.Test)33 StorageServerConnectionQueryParametersBase (org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)22 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)18 List (java.util.List)15 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)15 Guid (org.ovirt.engine.core.compat.Guid)13 HashMap (java.util.HashMap)11 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)9 HashSet (java.util.HashSet)7 Map (java.util.Map)6 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 Frontend (org.ovirt.engine.ui.frontend.Frontend)6 Collection (java.util.Collection)5 Quota (org.ovirt.engine.core.common.businessentities.Quota)5 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)5 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)5