use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class BackendVmKatelloErrataResource method list.
@Override
public KatelloErrata list() {
ErrataData errataData = null;
try {
QueryReturnValue returnValue = runQuery(QueryType.GetErrataForVm, new GetErrataCountsParameters(asGuid(vmId)));
if (!returnValue.getSucceeded()) {
backendFailure(returnValue.getExceptionString());
}
errataData = returnValue.getReturnValue();
} catch (Exception e) {
handleError(e, false);
}
if (errataData == null) {
return new KatelloErrata();
}
return mapCollection(errataData.getErrata());
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class BackendOpenStackNetworksResource method getBackendCollection.
private Map<Network, Set<Guid>> getBackendCollection() {
try {
IdQueryParameters parameters = new IdQueryParameters(asGuid(providerId));
QueryReturnValue result = runQuery(QueryType.GetAllExternalNetworksOnProvider, parameters);
if (!result.getSucceeded()) {
backendFailure(result.getExceptionString());
}
return result.getReturnValue();
} catch (Exception exception) {
return handleError(exception, false);
}
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class StorageDomainHelper method addAttachedDataCenterReferences.
/**
* Adds to the given Storage Domain the references to the Data Centers it is attached to.
*
* @param resource the resource that will be used to run the required queries
* @param model the model of the Storage Domain where the references will be added
*/
public static void addAttachedDataCenterReferences(BackendResource resource, StorageDomain model) {
// Note that this implementation is far from efficient, as we are retrieving all the content of the Storage
// Domains and immediately discarding everything but the identifiers of the Data Centers. It would be better to
// have a query that returns only the identifiers.
Guid id = Guid.createGuidFromString(model.getId());
QueryReturnValue result = resource.runQuery(QueryType.GetStorageDomainListById, new IdQueryParameters(id));
if (result != null && result.getSucceeded()) {
List<org.ovirt.engine.core.common.businessentities.StorageDomain> storageDomains = result.getReturnValue();
if (CollectionUtils.isNotEmpty(storageDomains)) {
DataCenters dataCenters = new DataCenters();
for (org.ovirt.engine.core.common.businessentities.StorageDomain storageDomain : storageDomains) {
DataCenter dataCenter = new DataCenter();
dataCenter.setId(storageDomain.getStoragePoolId().toString());
dataCenters.getDataCenters().add(dataCenter);
}
model.setDataCenters(dataCenters);
}
}
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class BackendHostResourceTest method testIscsiDiscover.
@Test
public void testIscsiDiscover() throws Exception {
IscsiDetails iscsiDetails = new IscsiDetails();
iscsiDetails.setAddress(ISCSI_SERVER_ADDRESS);
iscsiDetails.setPort(ISCSI_PORT_INT);
iscsiDetails.setUsername(ISCSI_USER_NAME);
iscsiDetails.setPassword(ISCSI_USER_PASS);
Action action = new Action();
action.setIscsi(iscsiDetails);
QueryReturnValue queryResult = new QueryReturnValue();
queryResult.setSucceeded(true);
when(backend.runQuery(eq(QueryType.DiscoverSendTargets), eqParams(DiscoverSendTargetsQueryParameters.class, addSession("VdsId", "Connection.Connection", "Connection.Port", "Connection.UserName", "Connection.Password"), addSession(GUIDS[0], ISCSI_SERVER_ADDRESS, ISCSI_PORT_STRING, ISCSI_USER_NAME, ISCSI_USER_PASS)))).thenReturn(queryResult);
enqueueInteraction(() -> verify(backend, atLeastOnce()).runQuery(eq(QueryType.DiscoverSendTargets), eqParams(DiscoverSendTargetsQueryParameters.class, addSession("VdsId", "Connection.Connection", "Connection.Port", "Connection.UserName", "Connection.Password"), addSession(GUIDS[0], ISCSI_SERVER_ADDRESS, ISCSI_PORT_STRING, ISCSI_USER_NAME, ISCSI_USER_PASS))));
resource.iscsiDiscover(action);
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class BackendMacPoolsResourceTest method setUpMacPoolsQueryExpectations.
private void setUpMacPoolsQueryExpectations(Object failure) {
QueryReturnValue queryResult = new QueryReturnValue();
queryResult.setSucceeded(failure == null);
List<org.ovirt.engine.core.common.businessentities.MacPool> entities = new ArrayList<>();
if (failure == null) {
for (int i = 0; i < NAMES.length; i++) {
entities.add(getEntity(i));
}
queryResult.setReturnValue(entities);
} else {
if (failure instanceof String) {
queryResult.setExceptionString((String) failure);
setUpL10nExpectations((String) failure);
} else if (failure instanceof Exception) {
when(backend.runQuery(eq(listQueryType), any())).thenThrow((Exception) failure);
return;
}
}
when(backend.runQuery(eq(listQueryType), any())).thenReturn(queryResult);
}
Aggregations