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);
}
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();
});
}
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();
}
}
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();
});
}
Aggregations