use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class AutoLoginData method getDbUser.
public DbUser getDbUser() {
DbUser user = new DbUser();
user.setId(Guid.createGuidFromStringDefaultEmpty(getId()));
user.setDomain(getDomain());
user.setLoginName(getUserName());
user.setAdmin(isAdmin());
return user;
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class DrMappingHelper method mapDbUsers.
public Set<DbUser> mapDbUsers(Set<DbUser> dbUsers, Map<String, String> userDomainsMap) {
if (dbUsers == null) {
return Collections.emptySet();
}
Set<DbUser> dbUsersToAdd = new HashSet<>();
dbUsers.forEach(dbUser -> {
String destDomain = userDomainsMap.get(dbUser.getLoginName());
log.info("Attempting to map user '{}@{}' to '{}@{}'", dbUser.getLoginName(), dbUser.getDomain(), dbUser.getLoginName(), destDomain);
if (destDomain == null) {
log.warn("Mapping for domain not found, falling back to OVF user '{}@{}'", dbUser.getLoginName(), dbUser.getDomain());
dbUsersToAdd.add(dbUser);
} else {
DbUser destUser = dbUserDao.getByUsernameAndDomain(dbUser.getLoginName(), destDomain);
dbUsersToAdd.add(Optional.ofNullable(destUser).orElse(dbUser));
}
});
return dbUsersToAdd;
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class ProcessOvfUpdateForStoragePoolCommand method populateVmsMetadataForOvfUpdate.
/**
* Create and returns map contains valid vms metadata
*/
protected Map<Guid, KeyValuePairCompat<String, List<Guid>>> populateVmsMetadataForOvfUpdate(List<Guid> idsToProcess) {
Map<Guid, KeyValuePairCompat<String, List<Guid>>> vmsAndTemplateMetadata = new HashMap<>();
List<VM> vms = vmDao.getVmsByIds(idsToProcess);
for (VM vm : vms) {
if (VMStatus.ImageLocked != vm.getStatus()) {
updateVmDisksFromDb(vm);
if (!verifyImagesStatus(vm.getDiskList())) {
continue;
}
ArrayList<DiskImage> vmImages = ovfUpdateProcessHelper.getVmImagesFromDb(vm);
if (!verifyImagesStatus(vmImages)) {
continue;
}
vm.setSnapshots(snapshotDao.getAllWithConfiguration(vm.getId()));
if (!verifySnapshotsStatus(vm.getSnapshots())) {
continue;
}
ovfUpdateProcessHelper.loadVmData(vm);
Long currentDbGeneration = vmStaticDao.getDbGeneration(vm.getId());
if (currentDbGeneration == null) {
log.warn("currentDbGeneration of VM (name: '{}', id: '{}') is null, probably because the VM was deleted during the run of OvfDataUpdater.", vm.getName(), vm.getId());
continue;
}
if (vm.getStaticData().getDbGeneration() == currentDbGeneration) {
List<LunDisk> lunDisks = DisksFilter.filterLunDisks(vm.getDiskMap().values());
for (LunDisk lun : lunDisks) {
lun.getLun().setLunConnections(new ArrayList<>(storageServerConnectionDao.getAllForLun(lun.getLun().getId())));
}
List<AffinityGroup> affinityGroups = affinityGroupDao.getAllAffinityGroupsByVmId(vm.getId());
List<Label> affinityLabels = labelDao.getAllByEntityIds(Collections.singletonList(vm.getId()));
Set<DbUser> dbUsers = new HashSet<>(dbUserDao.getAllForVm(vm.getId()));
FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(vm);
fullEntityOvfData.setDiskImages(vmImages);
fullEntityOvfData.setLunDisks(lunDisks);
fullEntityOvfData.setAffinityGroups(affinityGroups);
fullEntityOvfData.setAffinityLabels(affinityLabels);
fullEntityOvfData.setDbUsers(dbUsers);
ovfHelper.populateUserToRoles(fullEntityOvfData, vm.getId());
proccessedOvfConfigurationsInfo.add(ovfUpdateProcessHelper.buildMetadataDictionaryForVm(vm, vmsAndTemplateMetadata, fullEntityOvfData));
proccessedIdsInfo.add(vm.getId());
proccessedOvfGenerationsInfo.add(vm.getStaticData().getDbGeneration());
proccessDisksDomains(vm.getDiskList());
}
}
}
return vmsAndTemplateMetadata;
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser 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.businessentities.aaa.DbUser 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