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