use of org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters in project ovirt-engine by oVirt.
the class AsyncDataProvider method getStorageDomainsWithAttachedStoragePoolGuid.
public void getStorageDomainsWithAttachedStoragePoolGuid(AsyncQuery<List<StorageDomainStatic>> aQuery, StoragePool storagePool, List<StorageDomain> storageDomains) {
aQuery.converterCallback = new ListConverter<>();
StorageDomainsAndStoragePoolIdQueryParameters parameters = new StorageDomainsAndStoragePoolIdQueryParameters(storageDomains, storagePool.getId());
Frontend.getInstance().runQuery(QueryType.GetStorageDomainsWithAttachedStoragePoolGuid, parameters, aQuery);
}
use of org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters in project ovirt-engine by oVirt.
the class AbstractGetStorageDomainsWithAttachedStoragePoolGuidQueryTestCase method testEmptyStorageDomainListQuery.
@Test
public void testEmptyStorageDomainListQuery() {
StoragePool storagePool = new StoragePool();
storagePool.setStatus(StoragePoolStatus.Up);
mockStoragePoolDao(storagePool);
// Create parameters
List<StorageDomain> storageDomainList = new ArrayList<>();
StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
// Run 'HSMGetStorageDomainInfo' command
VDSReturnValue returnValue = new VDSReturnValue();
returnValue.setSucceeded(true);
Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), Guid.newGuid());
returnValue.setReturnValue(storageDomainToPoolId);
when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
// Execute command
getQuery().executeQueryCommand();
// Assert the query's results
List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
use of org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters in project ovirt-engine by oVirt.
the class AbstractGetStorageDomainsWithAttachedStoragePoolGuidQueryTestCase method testAttachedStorageDomainWithStorageDomainsParameterQuery.
@Test
public void testAttachedStorageDomainWithStorageDomainsParameterQuery() {
StoragePool storagePool = new StoragePool();
storagePool.setStatus(StoragePoolStatus.Up);
mockStoragePoolDao(storagePool);
// Create parameters
List<StorageDomain> storageDomainList = new ArrayList<>();
storageDomainList.add(storageDomain);
StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
// Run 'HSMGetStorageDomainInfo' command
VDSReturnValue returnValue = new VDSReturnValue();
returnValue.setSucceeded(true);
Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), Guid.newGuid());
returnValue.setReturnValue(storageDomainToPoolId);
when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
// Execute command
getQuery().executeQueryCommand();
// Assert the query's results
List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
returnedStorageDomainList.add(storageDomain.getStorageStaticData());
assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
use of org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters in project ovirt-engine by oVirt.
the class GetStorageDomainsWithAttachedStoragePoolGuidQueryTest method testStoragePoolIsUninitializedButCheckBooleanIsFalse.
@Test
public void testStoragePoolIsUninitializedButCheckBooleanIsFalse() {
StoragePool storagePool = new StoragePool();
storagePool.setStatus(StoragePoolStatus.Uninitialized);
mockStoragePoolDao(storagePool);
// Create parameters
List<StorageDomain> storageDomainList = new ArrayList<>();
storageDomainList.add(storageDomain);
StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
when(paramsMock.isCheckStoragePoolStatus()).thenReturn(Boolean.FALSE);
// Run 'HSMGetStorageDomainInfo' command
VDSReturnValue returnValue = new VDSReturnValue();
returnValue.setSucceeded(true);
Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), Guid.newGuid());
returnValue.setReturnValue(storageDomainToPoolId);
when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
// Execute command
getQuery().executeQueryCommand();
// Assert the query's results
List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
returnedStorageDomainList.add(storageDomain.getStorageStaticData());
assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
use of org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters in project ovirt-engine by oVirt.
the class BackendStorageDomainResource method isAttached.
@Override
public Response isAttached(Action action) {
validateParameters(action, "host.id|name");
Guid hostId = getHostId(action);
org.ovirt.engine.core.common.businessentities.StorageDomain storageDomainToAttach = getEntity(org.ovirt.engine.core.common.businessentities.StorageDomain.class, QueryType.GetStorageDomainById, new IdQueryParameters(guid), guid.toString());
StorageDomainsAndStoragePoolIdQueryParameters parameters = new StorageDomainsAndStoragePoolIdQueryParameters(storageDomainToAttach, null, hostId);
parameters.setCheckStoragePoolStatus(false);
List<StorageDomainStatic> attachedStorageDomains = getEntity(List.class, QueryType.GetStorageDomainsWithAttachedStoragePoolGuid, parameters, guid.toString(), true);
// This is an atypical action, as it doesn't invoke a backend action, but a query. As a result we need to
// create and populate the returned action object so that it looks like a real action result.
Action result = new Action();
result.setIsAttached(!attachedStorageDomains.isEmpty());
result.setStatus(CreationStatus.COMPLETE.value());
return Response.ok().entity(result).build();
}
Aggregations