String sshUserName = configurationProperties.getProperty(Constants.SSH_USER_NAME);
String sshPrivateKey = configurationProperties.getProperty(Constants.SSH_PRIVATE_KEY);
String sshPrivateKeyPass = configurationProperties.getProperty(Constants.SSH_PRIVATE_KEY_PASS);
String sshPassword = configurationProperties.getProperty(Constants.SSH_PASSWORD);
String sshPublicKey = configurationProperties.getProperty(Constants.SSH_PUBLIC_KEY);
SSHSecurityContext sshSecurityContext = new SSHSecurityContext();
if (((SSHHostType) registeredHost.getType()).getHpcResource()) {
AuthenticationInfo authenticationInfo = null;
// we give higher preference to the password over keypair ssh authentication
if (sshPassword != null) {
authenticationInfo = new DefaultPasswordAuthenticationInfo(sshPassword);
} else {
authenticationInfo = new DefaultPublicKeyFileAuthentication(sshPublicKey, sshPrivateKey, sshPrivateKeyPass);
}
ServerInfo serverInfo = new ServerInfo(sshUserName, registeredHost.getType().getHostAddress());
Cluster pbsCluster = null;
try {
String installedParentPath = ((HpcApplicationDeploymentType)
jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType()).getInstalledParentPath();
pbsCluster = new PBSCluster(serverInfo, authenticationInfo,
(CommonUtils.getPBSJobManager(installedParentPath)));
} catch (SSHApiException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
sshSecurityContext.setPbsCluster(pbsCluster);
sshSecurityContext.setUsername(sshUserName);
} else {
sshSecurityContext = new SSHSecurityContext();
sshSecurityContext.setUsername(sshUserName);
sshSecurityContext.setPrivateKeyLoc(sshPrivateKey);
sshSecurityContext.setKeyPass(sshPrivateKeyPass);
}
jobExecutionContext.addSecurityContext(SSHSecurityContext.SSH_SECURITY_CONTEXT, sshSecurityContext);
}