Search in sources :

Example 16 with ComputeServiceContext

use of org.jclouds.compute.ComputeServiceContext in project legacy-jclouds-examples by jclouds.

the class CreateServer 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];
    // These properties control how often jclouds polls for a status udpate
    Properties overrides = new Properties();
    overrides.setProperty(ComputeServiceProperties.POLL_INITIAL_PERIOD, Constants.POLL_PERIOD_TWENTY_SECONDS);
    overrides.setProperty(ComputeServiceProperties.POLL_MAX_PERIOD, Constants.POLL_PERIOD_TWENTY_SECONDS);
    ComputeServiceContext context = ContextBuilder.newBuilder(provider).credentials(username, apiKey).overrides(overrides).buildView(ComputeServiceContext.class);
    compute = context.getComputeService();
}
Also used : ComputeServiceContext(org.jclouds.compute.ComputeServiceContext) Properties(java.util.Properties) ComputeServiceProperties(org.jclouds.compute.config.ComputeServiceProperties)

Example 17 with ComputeServiceContext

use of org.jclouds.compute.ComputeServiceContext in project legacy-jclouds-examples by jclouds.

the class DeleteServer 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];
    // These properties control how often jclouds polls for a status udpate
    Properties overrides = new Properties();
    overrides.setProperty(ComputeServiceProperties.POLL_INITIAL_PERIOD, Constants.POLL_PERIOD_TWENTY_SECONDS);
    overrides.setProperty(ComputeServiceProperties.POLL_MAX_PERIOD, Constants.POLL_PERIOD_TWENTY_SECONDS);
    ComputeServiceContext context = ContextBuilder.newBuilder(provider).credentials(username, apiKey).overrides(overrides).buildView(ComputeServiceContext.class);
    compute = context.getComputeService();
}
Also used : ComputeServiceContext(org.jclouds.compute.ComputeServiceContext) Properties(java.util.Properties) ComputeServiceProperties(org.jclouds.compute.config.ComputeServiceProperties)

Example 18 with ComputeServiceContext

use of org.jclouds.compute.ComputeServiceContext in project legacy-jclouds-examples by jclouds.

the class ServerMetadata 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];
    ComputeServiceContext context = ContextBuilder.newBuilder(provider).credentials(username, apiKey).buildView(ComputeServiceContext.class);
    compute = context.getComputeService();
    nova = context.unwrap();
    serverApi = nova.getApi().getServerApiForZone(Constants.ZONE);
}
Also used : ComputeServiceContext(org.jclouds.compute.ComputeServiceContext)

Aggregations

ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)18 Properties (java.util.Properties)8 Module (com.google.inject.Module)7 SshjSshClientModule (org.jclouds.sshj.config.SshjSshClientModule)5 RunNodesException (org.jclouds.compute.RunNodesException)4 ComputeServiceProperties (org.jclouds.compute.config.ComputeServiceProperties)4 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)4 TemplateBuilder (org.jclouds.compute.domain.TemplateBuilder)4 IOException (java.io.IOException)3 InstanceTemplate (org.apache.whirr.service.ClusterSpec.InstanceTemplate)3 ComputeService (org.jclouds.compute.ComputeService)3 Template (org.jclouds.compute.domain.Template)3 SLF4JLoggingModule (org.jclouds.logging.slf4j.config.SLF4JLoggingModule)3 RunScriptOnNodesException (org.jclouds.compute.RunScriptOnNodesException)2 JschSshClientModule (org.jclouds.ssh.jsch.config.JschSshClientModule)2 AbstractModule (com.google.inject.AbstractModule)1 File (java.io.File)1 InetAddress (java.net.InetAddress)1 DecimalFormat (java.text.DecimalFormat)1 MemStore (org.apache.gora.memory.store.MemStore)1