Search in sources :

Example 6 with SLF4JLoggingModule

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

the class Logging method init.

private void init(String[] args) {
    // The provider configures jclouds To use the Rackspace Cloud (US)
    // To use the Rackspace Cloud (UK) set the provider to "rackspace-cloudservers-uk"
    String provider = "rackspace-cloudservers-us";
    String username = args[0];
    String apiKey = args[1];
    // This module is responsible for enabling logging
    Iterable<Module> modules = ImmutableSet.<Module>of(new SLF4JLoggingModule());
    ComputeServiceContext context = ContextBuilder.newBuilder(provider).credentials(username, apiKey).modules(// don't forget to add the modules to your context!
    modules).buildView(ComputeServiceContext.class);
    compute = context.getComputeService();
    nova = context.unwrap();
    // Calling getConfiguredZones() talks to the cloud which gets logged
    zones = nova.getApi().getConfiguredZones();
    System.out.println("Zones: " + zones);
}
Also used : SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) ComputeServiceContext(org.jclouds.compute.ComputeServiceContext) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) Module(com.google.inject.Module)

Example 7 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) 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)

Example 8 with SLF4JLoggingModule

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

the class MainApp method initController.

private static MinecraftController initController(String provider, String identity, String credential, String group) {
    Properties properties = new Properties();
    properties.setProperty("minecraft.port", "25565");
    properties.setProperty("minecraft.group", group);
    properties.setProperty("minecraft.ms", "1024");
    properties.setProperty("minecraft.mx", "1024");
    properties.setProperty("minecraft.url", "https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.jar");
    if ("aws-ec2".equals(provider)) {
        // since minecraft download is in s3 on us-east, lowest latency is from
        // there
        properties.setProperty(PROPERTY_REGIONS, "us-east-1");
        properties.setProperty("jclouds.ec2.ami-query", "owner-id=137112412989;state=available;image-type=machine");
        properties.setProperty("jclouds.ec2.cc-ami-query", "");
    }
    // example of injecting a ssh implementation
    Iterable<Module> modules = ImmutableSet.<Module>of(new SshjSshClientModule(), new SLF4JLoggingModule(), new EnterpriseConfigurationModule(), // This is extended stuff you might inject!!
    new ConfigureMinecraftDaemon());
    ContextBuilder builder = ContextBuilder.newBuilder(provider).credentials(identity, credential).modules(modules).overrides(properties);
    System.out.printf(">> initializing %s%n", builder.getApiMetadata());
    ComputeServiceContext context = builder.buildView(ComputeServiceContext.class);
    context.utils().eventBus().register(ScriptLogger.INSTANCE);
    return context.utils().injector().getInstance(MinecraftController.class);
}
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)

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