Search in sources :

Example 11 with RMException

use of org.ow2.proactive.resourcemanager.exception.RMException in project scheduling by ow2-proactive.

the class RMRest method rmConnect.

/**
 * Log into the resource manager using an form containing 2 fields
 * @return the sessionid of the user if succeed
 * @throws RMException
 * @throws LoginException
 * @throws KeyException
 * @throws NodeException
 * @throws ActiveObjectCreationException
 */
@Override
@POST
@Path("login")
@Produces("application/json")
public String rmConnect(@FormParam("username") String username, @FormParam("password") String password) throws KeyException, LoginException, RMException, ActiveObjectCreationException, NodeException {
    Session session = sessionStore.create(username);
    session.connectToRM(new CredData(CredData.parseLogin(username), CredData.parseDomain(username), password));
    return session.getSessionId();
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) Session(org.ow2.proactive_grid_cloud_portal.common.Session) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 12 with RMException

use of org.ow2.proactive.resourcemanager.exception.RMException in project scheduling by ow2-proactive.

the class RMRest method loginWithCredential.

/*
     * (non-Javadoc)
     * 
     * @see org.ow2.proactive_grid_cloud_portal.SchedulerRestInterface#loginWithCredential(org.ow2.
     * proactive_grid_cloud_portal.LoginForm)
     */
@Override
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("login")
@Produces("application/json")
public String loginWithCredential(@MultipartForm LoginForm multipart) throws ActiveObjectCreationException, NodeException, KeyException, IOException, LoginException, RMException {
    Session session;
    if (multipart.getCredential() != null) {
        session = sessionStore.createUnnamedSession();
        Credentials credentials = Credentials.getCredentials(multipart.getCredential());
        session.connectToRM(credentials);
    } else {
        session = sessionStore.create(multipart.getUsername());
        CredData credData = new CredData(CredData.parseLogin(multipart.getUsername()), CredData.parseDomain(multipart.getUsername()), multipart.getPassword(), multipart.getSshKey());
        session.connectToRM(credData);
    }
    return session.getSessionId();
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) Credentials(org.ow2.proactive.authentication.crypto.Credentials) Session(org.ow2.proactive_grid_cloud_portal.common.Session) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 13 with RMException

use of org.ow2.proactive.resourcemanager.exception.RMException in project scheduling by ow2-proactive.

the class RMProxiesManager method createRMProxiesManager.

/**
 * Create a RMProxiesManager using RM's URI (example : "rmi://localhost:1099/" ).
 *
 * @param rmURI The URI of a started Resource Manager
 * @return an instance of RMProxiesManager joined to the Resource Manager at the given URI
 */
public static RMProxiesManager createRMProxiesManager(final URI rmURI) throws RMException, RMProxyCreationException, URISyntaxException {
    Credentials schedulerProxyCredentials;
    try {
        schedulerProxyCredentials = Credentials.getCredentials(PASchedulerProperties.getAbsolutePath(PASchedulerProperties.RESOURCE_MANAGER_CREDS.getValueAsString()));
    } catch (Exception e) {
        throw new RMProxyCreationException(e);
    }
    boolean singleConnection = PASchedulerProperties.RESOURCE_MANAGER_SINGLE_CONNECTION.getValueAsBoolean();
    if (singleConnection) {
        return new SingleConnectionRMProxiesManager(rmURI, schedulerProxyCredentials);
    } else {
        return new PerUserConnectionRMProxiesManager(rmURI, schedulerProxyCredentials);
    }
}
Also used : Credentials(org.ow2.proactive.authentication.crypto.Credentials) URISyntaxException(java.net.URISyntaxException) RMException(org.ow2.proactive.resourcemanager.exception.RMException)

Example 14 with RMException

use of org.ow2.proactive.resourcemanager.exception.RMException in project scheduling by ow2-proactive.

the class NodeSourceTest method testSetNodeAvailableKnownNode.

@Test
public void testSetNodeAvailableKnownNode() throws RMException {
    Node node = createNode(PROACTIVE_PROGRAMMING_NODE_URL);
    RMNode rmNode = new RMNodeImpl(node, nodeSource, client, mock(Permission.class));
    nodeSource.internalAddNode(node);
    nodeSource.detectedPingedDownNode(node.getNodeInformation().getName(), node.getNodeInformation().getURL());
    assertThat(nodeSource.getDownNodes()).hasSize(1);
    boolean result = nodeSource.setNodeAvailable(rmNode);
    assertThat(result).isTrue();
    assertThat(nodeSource.getDownNodes()).hasSize(0);
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) Permission(java.security.Permission) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Example 15 with RMException

use of org.ow2.proactive.resourcemanager.exception.RMException in project scheduling by ow2-proactive.

the class NodeSourceTest method testSetNodeAvailableUnknownNode.

@Test
public void testSetNodeAvailableUnknownNode() throws RMException {
    Node node = createNode(PROACTIVE_PROGRAMMING_NODE_URL);
    RMNode rmNode = new RMNodeImpl(node, nodeSource, client, mock(Permission.class));
    nodeSource.internalAddNode(node);
    assertThat(nodeSource.getDownNodes()).hasSize(0);
    boolean result = nodeSource.setNodeAvailable(rmNode);
    assertThat(result).isFalse();
    assertThat(nodeSource.getDownNodes()).hasSize(0);
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) Permission(java.security.Permission) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Aggregations

RMException (org.ow2.proactive.resourcemanager.exception.RMException)19 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)9 IOException (java.io.IOException)8 Node (org.objectweb.proactive.core.node.Node)8 KeyException (java.security.KeyException)6 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)6 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)5 CredData (org.ow2.proactive.authentication.crypto.CredData)4 UnknownHostException (java.net.UnknownHostException)3 Test (org.junit.Test)3 Credentials (org.ow2.proactive.authentication.crypto.Credentials)3 AbstractRMNode (org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode)3 CommandLineBuilder (org.ow2.proactive.resourcemanager.utils.CommandLineBuilder)3 Permission (java.security.Permission)2 ArrayList (java.util.ArrayList)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)2 RMProxyUserInterface (org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)2