use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class StorageDomainValidatorTest method validRunningVmsWithUnpluggedDisksForBackupDomain.
@Test
public void validRunningVmsWithUnpluggedDisksForBackupDomain() {
// VM1
VM vm1 = new VM();
vm1.setName("firstVM");
Map<Guid, Disk> attachedDisksForVm1 = new HashMap<>();
DiskImage diskVm1 = new DiskImage();
diskVm1.setStorageIds(new ArrayList<>(Collections.singletonList(domain.getId())));
diskVm1.setPlugged(false);
attachedDisksForVm1.put(Guid.newGuid(), diskVm1);
vm1.setDiskMap(attachedDisksForVm1);
List<VM> runningVMs = new ArrayList<>();
runningVMs.add(vm1);
when(vmDao.getAllActiveForStorageDomain(any())).thenReturn(runningVMs);
QueryReturnValue ret = new QueryReturnValue();
ret.setReturnValue(new ArrayList<VmBase>());
ret.setSucceeded(true);
doReturn(ret).when(validator).getEntitiesWithLeaseIdForStorageDomain(any());
assertThat(validator.isRunningVmsOrVmLeasesForBackupDomain(vmHandler), isValid());
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class StorageDomainValidatorTest method validVmLeasesForBackupDomain.
@Test
public void validVmLeasesForBackupDomain() {
when(vmDao.getAllActiveForStorageDomain(any())).thenReturn(Collections.EMPTY_LIST);
QueryReturnValue ret = new QueryReturnValue();
List<VmBase> vmLeases = new ArrayList<>();
VM vm1 = new VM();
vm1.setName("firstVM");
vm1.setStatus(VMStatus.Down);
vmLeases.add(vm1.getStaticData());
ret.setReturnValue(vmLeases);
ret.setSucceeded(true);
doReturn(ret).when(validator).getEntitiesWithLeaseIdForStorageDomain(any());
when(vmDao.get(vm1.getId())).thenReturn(vm1);
assertThat(validator.isRunningVmsOrVmLeasesForBackupDomain(vmHandler), isValid());
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class BackendApiResource method setAuthenticatedUser.
/**
* Set a link to the user of the current session
* (the 'authenticated user') in the API object.
* This link enables users a convenient way to see
* which is the logged-in user, using the system.
*/
private void setAuthenticatedUser(Api api) {
QueryReturnValue returnValue = runQuery(QueryType.GetUserBySessionId, new QueryParametersBase());
DbUser authenticatedUser = (DbUser) returnValue.getReturnValue();
User user = new User();
user.setId(authenticatedUser.getId().toString());
LinkHelper.addLinks(user);
api.setAuthenticatedUser(user);
api.setEffectiveUser(user);
// currently the authenticated and effective users are the same one,
// but if and when impersonation is introduced, they may be different.
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class AbstractBackendResource method getVdsmTasksStatus.
private CreationStatus getVdsmTasksStatus(ActionReturnValue result) {
CreationStatus asyncStatus = null;
QueryReturnValue monitorResult = runQuery(QueryType.GetTasksStatusesByTasksIDs, new GetTasksStatusesByTasksIDsParameters(result.getVdsmTaskIdList()));
if (monitorResult != null && monitorResult.getSucceeded() && monitorResult.getReturnValue() != null) {
Mapper<AsyncTaskStatus, CreationStatus> mapper = getMapper(AsyncTaskStatus.class, CreationStatus.class);
for (AsyncTaskStatus task : asCollection(AsyncTaskStatus.class, monitorResult.getReturnValue())) {
asyncStatus = mapper.map(task, asyncStatus);
}
}
return asyncStatus;
}
use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.
the class BackendAssignedPermissionsResource method getUserById.
public DbUser getUserById(Guid userId) {
IdQueryParameters queryParameters = new IdQueryParameters(userId);
QueryReturnValue userQueryResponse = runQuery(QueryType.GetAnyDbUserByUserId, queryParameters);
DbUser returnValue = null;
if (userQueryResponse != null && userQueryResponse.getSucceeded()) {
returnValue = userQueryResponse.getReturnValue();
}
return returnValue;
}
Aggregations