Search in sources :

Example 6 with User

use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.

the class VmMapper method mapConsoleSession.

/**
 * This method maps the session of the 'console user', if exists. This is the ovirt user who opened a session
 * through the user-console; the one who is said to be 'logged in' (or 'have the ticket') to this VM. Currently
 * engine makes available only the name and IP of this user. In the future it may make available also the connection
 * protocol used in the session (spice/vnc).
 */
private static Sessions mapConsoleSession(org.ovirt.engine.core.common.businessentities.VM vm, Sessions sessions) {
    // currently in format user@domain, so needs to be
    String consoleUserName = vm.getConsoleCurentUserName();
    // parsed.
    if (consoleUserName != null && !consoleUserName.isEmpty()) {
        String userName = parseUserName(consoleUserName);
        String domainName = parseDomainName(consoleUserName);
        User consoleUser = new User();
        consoleUser.setUserName(userName);
        consoleUser.setDomain(new Domain());
        consoleUser.getDomain().setName(domainName);
        Session consoleSession = new Session();
        consoleSession.setUser(consoleUser);
        if (vm.getClientIp() != null && !vm.getClientIp().isEmpty()) {
            Ip ip = new Ip();
            ip.setAddress(vm.getClientIp());
            consoleSession.setIp(ip);
        }
        consoleSession.setConsoleUser(true);
        // TODO: in the future, map the connection protocol as well
        sessions.getSessions().add(consoleSession);
    }
    return sessions;
}
Also used : User(org.ovirt.engine.api.model.User) Ip(org.ovirt.engine.api.model.Ip) Domain(org.ovirt.engine.api.model.Domain) Session(org.ovirt.engine.api.model.Session)

Example 7 with User

use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.

the class BackendRoleResource method addParents.

@Override
protected Role addParents(Role role) {
    if (userId != null) {
        role.setUser(new User());
        role.getUser().setId(userId.toString());
    }
    return role;
}
Also used : User(org.ovirt.engine.api.model.User)

Example 8 with User

use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.

the class BackendUserAssignedPermissionsResourceTest method testAddIncompletePermission.

@Test
public void testAddIncompletePermission() throws Exception {
    Permission model = new Permission();
    model.setUser(new User());
    model.getUser().setId(GUIDS[1].toString());
    model.setRole(new Role());
    model.getRole().setId(GUIDS[3].toString());
    setUriInfo(setUpBasicUriExpectations());
    try {
        collection.add(model);
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Permission", "add", "dataCenter|cluster|host|storageDomain|vm|vmPool|template.id");
    }
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) WebApplicationException(javax.ws.rs.WebApplicationException) Permission(org.ovirt.engine.api.model.Permission) Test(org.junit.Test)

Example 9 with User

use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.

the class BackendUsersResourceTest method testAddUser2.

@Test
public void testAddUser2() throws Exception {
    setUpEntityQueryExpectations(QueryType.GetDomainList, QueryParametersBase.class, new String[] {}, new Object[] {}, setUpDomains());
    setUpAddUserExpectations("ADUSER@" + DOMAIN + ":: username=" + NAMES[0]);
    User model = new User();
    Domain domain = new Domain();
    domain.setName(DOMAIN);
    domain.setId(DirectoryEntryIdUtils.encode(domain.getName()));
    model.setDomain(domain);
    model.setUserName(NAMES[0]);
    Response response = collection.add(model);
    verifyAddUser(response);
}
Also used : Response(javax.ws.rs.core.Response) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DirectoryUser(org.ovirt.engine.core.aaa.DirectoryUser) User(org.ovirt.engine.api.model.User) Domain(org.ovirt.engine.api.model.Domain) Test(org.junit.Test) AbstractBackendCollectionResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)

Example 10 with User

use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.

the class BackendUserTagResource method addParents.

@Override
protected Tag addParents(Tag tag) {
    User user = new User();
    user.setId(userId.toString());
    tag.setUser(user);
    return tag;
}
Also used : User(org.ovirt.engine.api.model.User)

Aggregations

User (org.ovirt.engine.api.model.User)31 Test (org.junit.Test)12 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)9 Role (org.ovirt.engine.api.model.Role)7 Permission (org.ovirt.engine.api.model.Permission)6 DirectoryUser (org.ovirt.engine.core.aaa.DirectoryUser)6 Roles (org.ovirt.engine.api.model.Roles)5 Domain (org.ovirt.engine.api.model.Domain)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 Response (javax.ws.rs.core.Response)3 Group (org.ovirt.engine.api.model.Group)3 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)3 Groups (org.ovirt.engine.api.model.Groups)2 Session (org.ovirt.engine.api.model.Session)2 Ssh (org.ovirt.engine.api.model.Ssh)2 Users (org.ovirt.engine.api.model.Users)2 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)2 ArrayList (java.util.ArrayList)1 AuthorizedKey (org.ovirt.engine.api.model.AuthorizedKey)1 BaseResource (org.ovirt.engine.api.model.BaseResource)1