Search in sources :

Example 1 with DbUser

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;
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 2 with DbUser

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;
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) HashSet(java.util.HashSet)

Example 3 with DbUser

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;
}
Also used : KeyValuePairCompat(org.ovirt.engine.core.compat.KeyValuePairCompat) HashMap(java.util.HashMap) Label(org.ovirt.engine.core.common.businessentities.Label) Guid(org.ovirt.engine.core.compat.Guid) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) VM(org.ovirt.engine.core.common.businessentities.VM) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) HashSet(java.util.HashSet)

Example 4 with DbUser

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.
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) User(org.ovirt.engine.api.model.User) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 5 with DbUser

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;
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Aggregations

DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)109 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)18 Guid (org.ovirt.engine.core.compat.Guid)18 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)13 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)10 HashSet (java.util.HashSet)9 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)9 HashMap (java.util.HashMap)8 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)8 Collection (java.util.Collection)7 Before (org.junit.Before)7 Permission (org.ovirt.engine.core.common.businessentities.Permission)7 List (java.util.List)5 Map (java.util.Map)5 AttachEntityToTagParameters (org.ovirt.engine.core.common.action.AttachEntityToTagParameters)5 PermissionsOperationsParameters (org.ovirt.engine.core.common.action.PermissionsOperationsParameters)5 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5 TagListModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)5