use of org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule in project legacy-jclouds-examples by jclouds.
the class MainApp method run.
private void run() throws Exception {
Properties overrides = new Properties();
overrides.put(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, "owner-id=" + arguments.getAmiOwner() + ";state=available;image-type=machine");
ImmutableSet<Module> modules = ImmutableSet.<Module>of(// OverThere uses SLF4J so we will as well
new SLF4JLoggingModule(), // needed to decrypt the password from EC2
new BouncyCastleCryptoModule());
context = ContextBuilder.newBuilder("aws-ec2").credentials(arguments.getIdentity(), arguments.getCredential()).overrides(overrides).modules(modules).build(ComputeServiceContext.class);
try {
computeService = context.getComputeService();
Set<String> regions = Sets.newHashSet(Iterables.transform(Iterables.filter(computeService.listAssignableLocations(), LocationPredicates.isRegion()), new Function<Location, String>() {
@Override
public String apply(@Nullable Location location) {
return (location != null) ? location.getId() : null;
}
}));
if (!regions.contains(arguments.getRegion())) {
System.err.println("Region \"" + arguments.getRegion() + "\" is not known. Known regions are:");
for (String r : regions) {
System.err.println(" " + r);
}
System.exit(1);
}
WindowsInstanceStarter app = new WindowsInstanceStarter(arguments, context);
app.run();
} finally {
context.close();
}
}
Aggregations