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();
}
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();
}
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);
}
}
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);
}
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);
}
Aggregations