/** * Initialize JClouds */ public static ComputeServiceContext initComputeServiceContext(Configuration conf, Credential cred) { Properties properties = new Properties(); // Max time a script can take to execute properties.setProperty(ComputeServiceProperties.TIMEOUT_SCRIPT_COMPLETE, String.valueOf(TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES))); properties.setProperty(ComputeServiceProperties.TIMEOUT_PORT_OPEN, String.valueOf(TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES))); properties.setProperty(ComputeServiceProperties.TIMEOUT_NODE_RUNNING, String.valueOf(TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES))); properties.setProperty(Constants.PROPERTY_CONNECTION_TIMEOUT, String.valueOf(TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES))); properties.setProperty(Constants.PROPERTY_REQUEST_TIMEOUT, String.valueOf(TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES))); properties.setProperty(Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST, "5"); properties.setProperty(Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, "20"); properties.setProperty(Constants.PROPERTY_MAX_CONNECTION_REUSE, "10"); properties.setProperty(Constants.PROPERTY_MAX_RETRIES, "999999"); // inject ssh implementation Iterable<Module> modules = ImmutableSet.<Module> of(new SshjSshClientModule(), new SLF4JLoggingModule(), new EnterpriseConfigurationModule()); return ContextBuilder.newBuilder("aws-ec2").credentials(cred.get_ec2_identity(), cred.get_ec2_credential()).modules(modules).overrides(properties).buildView(ComputeServiceContext.class); }
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(); }
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(); }
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; }
private static ComputeService initComputeService(final String provider, final String identity, final String credential) { // example of specific properties, in this case optimizing image list to // only amazon supplied Properties properties = new Properties(); 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(); }
new SshjSshClientModule(), new SLF4JLoggingModule(), new EnterpriseConfigurationModule(),
@Override public BlobStoreContext load(Key arg0) { LOG.debug("creating new BlobStoreContext {}", arg0); ContextBuilder builder = ContextBuilder.newBuilder(arg0.provider) .credentials(arg0.identity, arg0.credential) .overrides(arg0.overrides) .modules(ImmutableSet.<Module>of(new SLF4JLoggingModule(), new EnterpriseConfigurationModule())); if (arg0.endpoint != null) builder.endpoint(arg0.endpoint); BlobStoreContext context = new IgnoreCloseBlobStoreContext( builder.buildView(BlobStoreContext.class)); LOG.info("created new BlobStoreContext {}", context); return context; }
@Override public BlobStoreContext load(Key arg0) { LOG.debug("creating new BlobStoreContext {}", arg0); ContextBuilder builder = ContextBuilder.newBuilder(arg0.provider) .credentials(arg0.identity, arg0.credential) .overrides(arg0.overrides) .modules(ImmutableSet.<Module>of(new SLF4JLoggingModule(), new EnterpriseConfigurationModule())); if (arg0.endpoint != null) builder.endpoint(arg0.endpoint); BlobStoreContext context = new IgnoreCloseBlobStoreContext( builder.buildView(BlobStoreContext.class)); LOG.info("created new BlobStoreContext {}", context); return context; }
public OpenStackStorageProvider(String username, String apiAccessKey, String authUrl) { if (null == authUrl) { authUrl = getAuthUrl(); } try { String trimmedAuthUrl = // JClouds expects authURL with no version authUrl.substring(0, authUrl.lastIndexOf("/")); ListeningExecutorService useExecutor = createThreadPool(); ListeningExecutorService ioExecutor = createThreadPool(); Iterable<Module> modules = ImmutableSet.<Module>of( new EnterpriseConfigurationModule(useExecutor, ioExecutor)); Properties properties = new Properties(); properties.setProperty(Constants.PROPERTY_STRIP_EXPECT_HEADER, "true"); swiftClient = ContextBuilder.newBuilder(new SwiftApiMetadata()) .endpoint(trimmedAuthUrl) .credentials(username, apiAccessKey) .modules(modules) .overrides(properties) .buildApi(SwiftClient.class); } catch (Exception e) { String err = "Could not connect to " + getProviderName() + " due to error: " + e.getMessage(); throw new StorageException(err, e, RETRY); } }
new EnterpriseConfigurationModule(), new SshjSshClientModule(), new CacheNodeStoreModule(ImmutableMap.<String,Node>copyOf(spec.getByonNodes()))); } else { modules = ImmutableSet.<Module>of(new SLF4JLoggingModule(), new EnterpriseConfigurationModule(), new SshjSshClientModule());
new EnterpriseConfigurationModule(), new SshjSshClientModule(), new CacheNodeStoreModule(ImmutableMap.<String,Node>copyOf(spec.getByonNodes()))); } else { modules = ImmutableSet.<Module>of(new SLF4JLoggingModule(), new EnterpriseConfigurationModule(), new SshjSshClientModule());