use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class BaseImportNetworksModel method onProviderChosen.
private void onProviderChosen() {
final Provider<?> provider = providers.getSelectedItem();
if (provider == null) {
return;
}
startProgress();
AsyncQuery<List<StoragePool>> dataCenterQuery = new AsyncQuery<>(returnValue -> {
final List<StoragePool> dataCenters = new LinkedList<>(returnValue);
Collections.sort(dataCenters, new NameableComparator());
AsyncQuery<QueryReturnValue> externalNetworksQuery = new AsyncQuery<>(queryReturnValue -> {
if (queryReturnValue.getSucceeded()) {
Map<Network, Set<Guid>> externalNetworkToDataCenters = queryReturnValue.getReturnValue();
providerNetworks.setItems(getExternalNetworks(externalNetworkToDataCenters, dataCenters));
importedNetworks.setItems(new LinkedList<ExternalNetwork>());
} else {
final ErrorPopupManager popupManager = (ErrorPopupManager) TypeResolver.getInstance().resolve(ErrorPopupManager.class);
popupManager.show(ConstantsManager.getInstance().getMessages().failedToListExternalNetworks(queryReturnValue.getExceptionMessage()));
}
stopProgress();
}, true);
AsyncDataProvider.getInstance().getExternalNetworksByProviderId(externalNetworksQuery, provider.getId());
});
AsyncDataProvider.getInstance().getDataCenterList(dataCenterQuery);
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class NetworkHostListModel method syncSearch.
@Override
protected void syncSearch() {
if (getEntity() == null) {
return;
}
final NetworkHostFilter filter = getViewFilterType();
AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(returnValue -> {
if (filter.equals(getViewFilterType())) {
final Iterable returnList = returnValue.getReturnValue();
if (NetworkHostFilter.unattached.equals(getViewFilterType())) {
final List<PairQueryable<VdsNetworkInterface, VDS>> items = new ArrayList<>();
for (Object obj : returnList) {
items.add(new PairQueryable<VdsNetworkInterface, VDS>(null, (VDS) obj));
}
setItems(items);
} else if (NetworkHostFilter.attached.equals(getViewFilterType())) {
initAttachedInterfaces((Collection<PairQueryable<VdsNetworkInterface, VDS>>) returnList);
}
}
});
IdQueryParameters params = new IdQueryParameters(getEntity().getId());
params.setRefresh(getIsQueryFirstTime());
if (NetworkHostFilter.unattached.equals(getViewFilterType())) {
Frontend.getInstance().runQuery(QueryType.GetVdsWithoutNetwork, params, asyncQuery);
} else if (NetworkHostFilter.attached.equals(getViewFilterType())) {
Frontend.getInstance().runQuery(QueryType.GetVdsAndNetworkInterfacesByNetworkId, params, asyncQuery);
}
setIsQueryFirstTime(false);
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class FenceAgentModel method test.
/**
* Execute the fence agent test.
*/
public void test() {
validatePmModels();
if (!isValid()) {
return;
}
setMessage(ConstantsManager.getInstance().getConstants().testingInProgressItWillTakeFewSecondsPleaseWaitMsg());
getTestCommand().setIsExecutionAllowed(false);
Cluster cluster = getHost().getCluster().getSelectedItem();
GetFenceAgentStatusParameters param = new GetFenceAgentStatusParameters();
FenceAgent agent = new FenceAgent();
if (getHost().getHostId() != null) {
param.setVdsId(getHost().getHostId());
}
agent.setOrder(getOrder().getEntity());
agent.setIp(getManagementIp().getEntity());
agent.setType(getPmType().getSelectedItem());
agent.setUser(getPmUserName().getEntity());
agent.setPassword(getPmPassword().getEntity());
agent.setPort(getPmPort().getEntity());
agent.setOptionsMap(getPmOptionsMap());
param.setAgent(agent);
param.setStoragePoolId(cluster.getStoragePoolId() != null ? cluster.getStoragePoolId() : Guid.Empty);
param.setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(getHost().getPmProxyPreferences()));
param.setVdsName(getHost().getName().getEntity());
param.setHostName(getHost().getHost().getEntity());
param.setClusterId(cluster.getId());
Frontend.getInstance().runQuery(QueryType.GetFenceAgentStatus, param, new AsyncQuery<QueryReturnValue>(returnValue -> {
String msg;
if (returnValue == null) {
msg = ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg();
} else {
FenceOperationResult result = returnValue.getReturnValue();
if (result.getStatus() == FenceOperationResult.Status.SUCCESS) {
msg = ConstantsManager.getInstance().getMessages().testSuccessfulWithPowerStatus(result.getPowerStatus() == PowerStatus.ON ? ConstantsManager.getInstance().getConstants().powerOn() : ConstantsManager.getInstance().getConstants().powerOff());
} else {
msg = ConstantsManager.getInstance().getMessages().testFailedWithErrorMsg(result.getMessage());
}
}
setMessage(msg);
getTestCommand().setIsExecutionAllowed(true);
}, true));
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class AdElementListModel method syncSearchGroups.
private void syncSearchGroups() {
AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(queryReturnValue -> {
if (handleQueryError(queryReturnValue)) {
return;
}
HashSet<String> excludeUsers = new HashSet<>();
if (getExcludeItems() != null) {
for (DbUser item : getExcludeItems()) {
excludeUsers.add(item.getExternalId());
}
}
setgroups(new ArrayList<>());
addGroupsToModel(queryReturnValue, excludeUsers);
onAdGroupsLoaded();
});
asyncQuery.setHandleFailure(true);
findGroups(// $NON-NLS-1$ //$NON-NLS-2$
"name=" + (StringHelper.isNullOrEmpty(getSearchString()) ? "*" : getSearchString()), asyncQuery);
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class SanStorageModelBase method updateInternal.
protected void updateInternal() {
if (!(getContainer().isNewStorage() || getContainer().isStorageActive())) {
return;
}
VDS host = getContainer().getHost().getSelectedItem();
if (host == null) {
proposeDiscover();
return;
}
final Collection<EntityModel<?>> prevSelected = Linq.findSelectedItems((Collection<EntityModel<?>>) getSelectedItem());
clearItems();
initializeItems(null, null);
final SanStorageModelBase model = this;
AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(response -> {
if (response.getSucceeded()) {
setValuesForMaintenance(model);
model.applyData((ArrayList<LUNs>) response.getReturnValue(), false, prevSelected, isInMaintenance, metadata);
model.initLunSelection();
// $NON-NLS-1$
model.setGetLUNsFailure("");
model.stopProgress();
} else {
model.setGetLUNsFailure(ConstantsManager.getInstance().getConstants().couldNotRetrieveLUNsLunsFailure());
}
}, true);
Frontend.getInstance().runQuery(QueryType.GetDeviceList, new GetDeviceListQueryParameters(host.getId(), getType(), false, null, false), asyncQuery);
getContainer().startProgress();
}
Aggregations