Search in sources :

Example 1 with ContextBuilder

use of org.jclouds.ContextBuilder 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 ContextBuilder

use of org.jclouds.ContextBuilder in project acceptance-test-harness by jenkinsci.

the class JcloudsMachineProvider method initComputeService.

private ContextBuilder initComputeService(String provider, String identity, String credential) {
    Iterable<Module> modules = ImmutableSet.<Module>of(new SshjSshClientModule(), new SLF4JLoggingModule(), new EnterpriseConfigurationModule());
    ContextBuilder contextBuilder = ContextBuilder.newBuilder(provider).credentials(identity, credential).modules(modules).overrides(getOptions());
    logger.info(String.format("Initializing %s", contextBuilder.getApiMetadata()));
    return contextBuilder;
}
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) Module(com.google.inject.Module) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) SshjSshClientModule(org.jclouds.sshj.config.SshjSshClientModule) EnterpriseConfigurationModule(org.jclouds.enterprise.config.EnterpriseConfigurationModule)

Example 3 with ContextBuilder

use of org.jclouds.ContextBuilder 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 ContextBuilder

use of org.jclouds.ContextBuilder 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 ContextBuilder

use of org.jclouds.ContextBuilder 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;
    if (config.getUseServiceNet()) {
        log.info("Configuring Cloud Files Api to use the internal service network...");
        modules = ImmutableSet.of(new SLF4JLoggingModule(), new InternalUrlModule());
    } else {
        log.info("Configuring Cloud Files Api to use the public network...");
        modules = ImmutableSet.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(org.apache.druid.initialization.DruidModule) LazySingleton(org.apache.druid.guice.LazySingleton) Provides(com.google.inject.Provides)

Aggregations

ContextBuilder (org.jclouds.ContextBuilder)8 SLF4JLoggingModule (org.jclouds.logging.slf4j.config.SLF4JLoggingModule)7 Module (com.google.inject.Module)5 Properties (java.util.Properties)5 EnterpriseConfigurationModule (org.jclouds.enterprise.config.EnterpriseConfigurationModule)5 SshjSshClientModule (org.jclouds.sshj.config.SshjSshClientModule)5 ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)4 Module (com.fasterxml.jackson.databind.Module)2 Provides (com.google.inject.Provides)2 ChefProperties (org.jclouds.chef.config.ChefProperties)2 InternalUrlModule (org.jclouds.openstack.v2_0.config.InternalUrlModule)2 CloudFilesApi (org.jclouds.rackspace.cloudfiles.v1.CloudFilesApi)2 Predicate (com.google.common.base.Predicate)1 LazySingleton (io.druid.guice.LazySingleton)1 DruidModule (io.druid.initialization.DruidModule)1 IOException (java.io.IOException)1 LazySingleton (org.apache.druid.guice.LazySingleton)1 DruidModule (org.apache.druid.initialization.DruidModule)1 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)1 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)1