Search in sources :

Example 1 with SLF4JLoggingModule

use of org.jclouds.logging.slf4j.config.SLF4JLoggingModule in project druid by druid-io.

the class CloudFilesStorageDruidModule method getCloudFilesApi.

@Provides
@LazySingleton
public CloudFilesApi getCloudFilesApi(final CloudFilesAccountConfig config) {
    log.info("Building Cloud Files Api...");
    Iterable<com.google.inject.Module> modules = null;
    if (config.getUseServiceNet()) {
        log.info("Configuring Cloud Files Api to use the internal service network...");
        modules = ImmutableSet.<com.google.inject.Module>of(new SLF4JLoggingModule(), new InternalUrlModule());
    } else {
        log.info("Configuring Cloud Files Api to use the public network...");
        modules = ImmutableSet.<com.google.inject.Module>of(new SLF4JLoggingModule());
    }
    ProviderRegistry.registerProvider(CloudFilesUSProviderMetadata.builder().build());
    ProviderRegistry.registerProvider(CloudFilesUKProviderMetadata.builder().build());
    ContextBuilder cb = ContextBuilder.newBuilder(config.getProvider()).credentials(config.getUserName(), config.getApiKey()).modules(modules);
    CloudFilesApi cfa = cb.buildApi(CloudFilesApi.class);
    log.info("Cloud Files Api built.");
    return cfa;
}
Also used : InternalUrlModule(org.jclouds.openstack.v2_0.config.InternalUrlModule) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) ContextBuilder(org.jclouds.ContextBuilder) CloudFilesApi(org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi) Module(com.fasterxml.jackson.databind.Module) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) InternalUrlModule(org.jclouds.openstack.v2_0.config.InternalUrlModule) DruidModule(io.druid.initialization.DruidModule) LazySingleton(io.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Example 2 with SLF4JLoggingModule

use of org.jclouds.logging.slf4j.config.SLF4JLoggingModule in project SimianArmy by Netflix.

the class AWSClient method getJcloudsComputeService.

/** {@inheritDoc} */
@Override
public synchronized ComputeService getJcloudsComputeService() {
    if (jcloudsComputeService == null) {
        String username = awsCredentialsProvider.getCredentials().getAWSAccessKeyId();
        String password = awsCredentialsProvider.getCredentials().getAWSSecretKey();
        ComputeServiceContext jcloudsContext = ContextBuilder.newBuilder("aws-ec2").credentials(username, password).modules(ImmutableSet.<Module>of(new SLF4JLoggingModule(), new JschSshClientModule())).buildView(ComputeServiceContext.class);
        this.jcloudsComputeService = jcloudsContext.getComputeService();
    }
    return jcloudsComputeService;
}
Also used : SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) JschSshClientModule(org.jclouds.ssh.jsch.config.JschSshClientModule) ComputeServiceContext(org.jclouds.compute.ComputeServiceContext) Module(com.google.inject.Module) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) JschSshClientModule(org.jclouds.ssh.jsch.config.JschSshClientModule)

Example 3 with SLF4JLoggingModule

use of org.jclouds.logging.slf4j.config.SLF4JLoggingModule in project legacy-jclouds-examples by jclouds.

the class MainApp method initChefService.

private static ChefService initChefService(String client, String validator) {
    try {
        Properties chefConfig = new Properties();
        chefConfig.put(ChefProperties.CHEF_VALIDATOR_NAME, validator);
        chefConfig.put(ChefProperties.CHEF_VALIDATOR_CREDENTIAL, credentialForClient(validator));
        ContextBuilder builder = //
        ContextBuilder.newBuilder(new ChefApiMetadata()).credentials(client, //
        credentialForClient(client)).modules(//
        ImmutableSet.<Module>of(new SLF4JLoggingModule())).overrides(//
        chefConfig);
        System.out.printf(">> initializing %s%n", builder.getApiMetadata());
        ChefContext context = builder.build();
        return context.getChefService();
    } catch (Exception e) {
        System.err.println("error reading private key " + e.getMessage());
        System.exit(1);
        return null;
    }
}
Also used : ChefContext(org.jclouds.chef.ChefContext) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) ContextBuilder(org.jclouds.ContextBuilder) Properties(java.util.Properties) ChefProperties(org.jclouds.chef.config.ChefProperties) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) Module(com.google.inject.Module) SshjSshClientModule(org.jclouds.sshj.config.SshjSshClientModule) EnterpriseConfigurationModule(org.jclouds.enterprise.config.EnterpriseConfigurationModule) RunNodesException(org.jclouds.compute.RunNodesException) RunScriptOnNodesException(org.jclouds.compute.RunScriptOnNodesException) ChefApiMetadata(org.jclouds.chef.ChefApiMetadata)

Example 4 with SLF4JLoggingModule

use of org.jclouds.logging.slf4j.config.SLF4JLoggingModule in project legacy-jclouds-examples by jclouds.

the class MainApp method initComputeService.

private static ComputeService initComputeService(String provider, String identity, String credential) {
    // example of specific properties, in this case optimizing image list to
    // only amazon supplied
    Properties properties = new Properties();
    properties.setProperty(PROPERTY_EC2_AMI_QUERY, "owner-id=137112412989;state=available;image-type=machine");
    properties.setProperty(PROPERTY_EC2_CC_AMI_QUERY, "");
    long scriptTimeout = TimeUnit.MILLISECONDS.convert(20, TimeUnit.MINUTES);
    properties.setProperty(TIMEOUT_SCRIPT_COMPLETE, scriptTimeout + "");
    // example of injecting a ssh implementation
    Iterable<Module> modules = ImmutableSet.<Module>of(new SshjSshClientModule(), new SLF4JLoggingModule(), new EnterpriseConfigurationModule());
    ContextBuilder builder = ContextBuilder.newBuilder(provider).credentials(identity, credential).modules(modules).overrides(properties);
    System.out.printf(">> initializing %s%n", builder.getApiMetadata());
    return builder.buildView(ComputeServiceContext.class).getComputeService();
}
Also used : EnterpriseConfigurationModule(org.jclouds.enterprise.config.EnterpriseConfigurationModule) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) SshjSshClientModule(org.jclouds.sshj.config.SshjSshClientModule) ContextBuilder(org.jclouds.ContextBuilder) ComputeServiceContext(org.jclouds.compute.ComputeServiceContext) Properties(java.util.Properties) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) Module(com.google.inject.Module) SshjSshClientModule(org.jclouds.sshj.config.SshjSshClientModule) EnterpriseConfigurationModule(org.jclouds.enterprise.config.EnterpriseConfigurationModule)

Example 5 with SLF4JLoggingModule

use of org.jclouds.logging.slf4j.config.SLF4JLoggingModule 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

SLF4JLoggingModule (org.jclouds.logging.slf4j.config.SLF4JLoggingModule)8 Module (com.google.inject.Module)7 ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)6 Properties (java.util.Properties)5 ContextBuilder (org.jclouds.ContextBuilder)5 EnterpriseConfigurationModule (org.jclouds.enterprise.config.EnterpriseConfigurationModule)4 SshjSshClientModule (org.jclouds.sshj.config.SshjSshClientModule)4 ChefProperties (org.jclouds.chef.config.ChefProperties)2 Module (com.fasterxml.jackson.databind.Module)1 Function (com.google.common.base.Function)1 Provides (com.google.inject.Provides)1 LazySingleton (io.druid.guice.LazySingleton)1 DruidModule (io.druid.initialization.DruidModule)1 Nullable (javax.annotation.Nullable)1 ChefApiMetadata (org.jclouds.chef.ChefApiMetadata)1 ChefContext (org.jclouds.chef.ChefContext)1 RunNodesException (org.jclouds.compute.RunNodesException)1 RunScriptOnNodesException (org.jclouds.compute.RunScriptOnNodesException)1 Location (org.jclouds.domain.Location)1 BouncyCastleCryptoModule (org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule)1