Search in sources :

Example 1 with BouncyCastleCryptoModule

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();
    }
}
Also used : Function(com.google.common.base.Function) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) BouncyCastleCryptoModule(org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule) ComputeServiceContext(org.jclouds.compute.ComputeServiceContext) Properties(java.util.Properties) Module(com.google.inject.Module) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) BouncyCastleCryptoModule(org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule) Nullable(javax.annotation.Nullable) Location(org.jclouds.domain.Location)

Aggregations

Function (com.google.common.base.Function)1 Module (com.google.inject.Module)1 Properties (java.util.Properties)1 Nullable (javax.annotation.Nullable)1 ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)1 Location (org.jclouds.domain.Location)1 BouncyCastleCryptoModule (org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule)1 SLF4JLoggingModule (org.jclouds.logging.slf4j.config.SLF4JLoggingModule)1