Refine search
.newBuilder(provider) .credentials(identity, credential) .modules(ImmutableList.<Module>of( new SLF4JLoggingModule(), new ExecutorServiceModule(executorService))) .overrides(properties);
@Bean @ConditionalOnProperty("openstack.endpoint") NovaApi novaApi(@Value("${openstack.endpoint}") String endpoint, @Value("${openstack.tenant}") String tenant, @Value("${openstack.username}") String username, @Value("${openstack.password}") String password) { String identity = String.format("%s:%s", tenant, username); // see https://issues.apache.org/jira/browse/JCLOUDS-816 Properties overrides = new Properties(); overrides.put(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true"); return ContextBuilder.newBuilder("openstack-nova") .endpoint(endpoint) .credentials(identity, password) .modules(Collections.singleton(new SLF4JLoggingModule())) .overrides(overrides) .buildApi(NovaApi.class); }
private BlobStoreContext createContext() { ContextBuilder builder = ContextBuilder.newBuilder(provider) .credentialsSupplier(credentials::get) .modules(ImmutableSet.<Module>of(new SLF4JLoggingModule())); if (!properties.isEmpty()) { builder.overrides(properties); } return builder.buildView(BlobStoreContext.class); }
@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; }
modules = ImmutableSet.<Module>of(new SLF4JLoggingModule(), new DryRunModule()); } else if ("byon".equals(spec.getProvider()) && !spec.getByonNodes().isEmpty()) { overrideApiMetadata = new BYONApiMetadata() .build(); modules = ImmutableSet.<Module>of(new SLF4JLoggingModule(), new EnterpriseConfigurationModule(), new SshjSshClientModule(), new CacheNodeStoreModule(ImmutableMap.<String,Node>copyOf(spec.getByonNodes()))); } else { modules = ImmutableSet.<Module>of(new SLF4JLoggingModule(), new EnterpriseConfigurationModule(), new SshjSshClientModule());
public static CloudstackNew40FeaturesClient newInstance(String endpoint, String apiKey, String secretKey, Optional<AccountAndDomain> accAndDomain) { Properties overrides = new Properties(); overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); ContextBuilder builder = ContextBuilder .newBuilder("cloudstack") .endpoint(endpoint) .apiVersion("3.0.5") .credentials(apiKey, secretKey) .modules(ImmutableSet.<Module>builder() .add(new SLF4JLoggingModule()) .build()) .overrides(overrides); CloudStackContext context = builder.buildView(CloudStackContext.class); return new CloudstackNew40FeaturesClient(endpoint, apiKey, secretKey, accAndDomain, context); }
@Override protected Iterable<Module> setupModules() { ImmutableSet.Builder<Module> modules = ImmutableSet.builder(); modules.add(new OkHttpCommandExecutorServiceModule()); modules.add(new SLF4JLoggingModule()); return modules.build(); }
@Override protected LoggingModule getLoggingModule() { return new SLF4JLoggingModule(); }
Iterable<Module> modules = ImmutableSet.<Module> of(new SLF4JLoggingModule(), new InternalUrlModule()); ContextBuilder builder = ContextBuilder.newBuilder(PROVIDER) .modules(modules) .credentials(username, apiKey); blobStore = builder.buildView(RegionScopedBlobStoreContext.class).getBlobStore(REGION); cloudFiles = blobStore.getContext().unwrapApi(CloudFilesApi.class);
public OpenStackClient(String user, String password, String tenant, String url, String region) { Iterable<Module> modules = ImmutableSet.<Module> of(new SLF4JLoggingModule()); Properties overrides = new Properties(); overrides.setProperty(KeystoneProperties.CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); overrides.setProperty(Constants.PROPERTY_API_VERSION, "2"); this.cinderApi = ContextBuilder.newBuilder("openstack-cinder").endpoint(url).credentials(tenant + ":" + user, password).modules(modules) .overrides(overrides).buildApi(CinderApi.class); if (!this.cinderApi.getConfiguredRegions().contains(region)) { throw new InvalidArgumentException("Region " + region + " do not exist, available regions are " + cinderApi.getConfiguredRegions()); } this.volumeApi = this.cinderApi.getVolumeApi(region); this.novaApi = ContextBuilder.newBuilder("openstack-nova").endpoint(url).credentials(tenant + ":" + user, password).modules(modules) .overrides(overrides).buildApi(NovaApi.class); if (!this.novaApi.getConfiguredRegions().contains(region)) { throw new InvalidArgumentException("Region " + region + " do not exist, available regions are " + novaApi.getConfiguredRegions()); } this.serverApi = this.novaApi.getServerApi(region); this.neutronApi = ContextBuilder.newBuilder("openstack-neutron").endpoint(url).credentials(tenant + ":" + user, password).modules(modules) .overrides(overrides).buildApi(NeutronApi.class); if (!this.neutronApi.getConfiguredRegions().contains(region)) { throw new InvalidArgumentException("Region " + region + " do not exist, available regions are " + neutronApi.getConfiguredRegions()); } this.floatingIPApi = this.neutronApi.getFloatingIPApi(region).get(); this.novaFloatingIPApi = this.novaApi.getFloatingIPApi(region).get(); this.networkApi = this.neutronApi.getNetworkApi(region); }
private <T> T withCompute(ComputeTask<T> task) throws HekateException { ContextBuilder builder = ContextBuilder.newBuilder(provider) .credentialsSupplier(credentials::get) .modules(ImmutableSet.<Module>of(new SLF4JLoggingModule())); if (!properties.isEmpty()) { builder.overrides(properties); } if (endpoint != null) { String trimmedEndpoint = endpoint.trim(); if (!trimmedEndpoint.isEmpty()) { builder.endpoint(trimmedEndpoint); } } try (ComputeServiceContext ctx = builder.buildView(ComputeServiceContext.class)) { return task.execute(ctx); } }
public AwsClient() { String accessKeyId = System.getenv("AWS_ACCESS_KEY_ID"); String secretKey = System.getenv("AWS_SECRET_KEY"); String region = System.getenv("AWS_REGION"); if (StringUtils.isBlank(accessKeyId) || StringUtils.isBlank(secretKey) || StringUtils.isBlank(region)) { throw new NotFoundException("Aws Client need 3 environment variables set : AWS_ACCESS_KEY_ID, AWS_SECRET_KEY, AWS_REGION"); } AWSEC2Api ec2Api = ContextBuilder.newBuilder("aws-ec2").credentials(accessKeyId, secretKey) .modules(ImmutableSet.<Module> of(new SLF4JLoggingModule(), new SshjSshClientModule())).buildApi(AWSEC2Api.class); blockStoreApi = ec2Api.getElasticBlockStoreApiForRegion(region).get(); instanceApi = ec2Api.getInstanceApiForRegion(region).get(); }
modules = ImmutableSet.<Module>of(new SLF4JLoggingModule(), new DryRunModule()); } else if ("byon".equals(spec.getProvider()) && !spec.getByonNodes().isEmpty()) { overrideApiMetadata = new BYONApiMetadata() .build(); modules = ImmutableSet.<Module>of(new SLF4JLoggingModule(), new EnterpriseConfigurationModule(), new SshjSshClientModule(), new CacheNodeStoreModule(ImmutableMap.<String,Node>copyOf(spec.getByonNodes()))); } else { modules = ImmutableSet.<Module>of(new SLF4JLoggingModule(), new EnterpriseConfigurationModule(), new SshjSshClientModule());
protected Set<Module> modules() { ImmutableSet.Builder<Module> modules = ImmutableSet.builder(); modules.add(new ExecutorServiceModule(newDirectExecutorService())); modules.add(new OkHttpCommandExecutorServiceModule()); modules.add(new SLF4JLoggingModule()); return modules.build(); }
@Override protected LoggingModule getLoggingModule() { return new SLF4JLoggingModule(); }
public static BlobStore storeFromProperties(Properties properties) { String provider = properties.getProperty(Constants.PROPERTY_PROVIDER); ContextBuilder builder = ContextBuilder .newBuilder(provider) .modules(ImmutableList.<Module>of(new SLF4JLoggingModule())) .overrides(properties); BlobStoreContext context = builder.build(BlobStoreContext.class); return context.getBlobStore(); }
private static List<AbstractModule> getModules() { return asList(new SLF4JLoggingModule(), new SshjSshClientModule()); } }
@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 protected LoggingModule getLoggingModule() { return new SLF4JLoggingModule(); }
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; }