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;
}
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;
}
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;
}
}
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();
}
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;
}
Aggregations