Skip to content

Instantly share code, notes, and snippets.

@etoews
Last active October 11, 2015 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etoews/3862499 to your computer and use it in GitHub Desktop.
Save etoews/3862499 to your computer and use it in GitHub Desktop.
jclouds workshop
private void printResults() throws IOException {
for (ComputeService computeService: nodes.keySet()) {
try {
NodeMetadata node = nodes.get(computeService);
String publicAddress = node.getPublicAddresses().iterator().next();
String provider = computeService.getContext().toString().contains("rackspace") ? "Rackspace" : "HP";
System.out.println("Provider: " + provider);
if (node.getCredentials().getOptionalPrivateKey().isPresent()) {
Files.write(node.getCredentials().getPrivateKey(), new File("jclouds.pem"), UTF_8);
System.out.println(" Login: ssh -i jclouds.pem " + node.getCredentials().getUser() + "@" + publicAddress);
}
else {
System.out.println(" Login: ssh " + node.getCredentials().getUser() + "@" + publicAddress);
System.out.println(" Password: " + node.getCredentials().getPassword());
}
System.out.println(" Go to http://" + publicAddress);
}
catch (Throwable e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment