use of org.jclouds.domain.Credentials in project SimianArmy by Netflix.
the class AWSClient method getJcloudsComputeService.
/**
* {@inheritDoc}
*/
@Override
public ComputeService getJcloudsComputeService() {
if (jcloudsComputeService == null) {
synchronized (this) {
if (jcloudsComputeService == null) {
AWSCredentials awsCredentials = awsCredentialsProvider.getCredentials();
String username = awsCredentials.getAWSAccessKeyId();
String password = awsCredentials.getAWSSecretKey();
Credentials credentials;
if (awsCredentials instanceof AWSSessionCredentials) {
AWSSessionCredentials awsSessionCredentials = (AWSSessionCredentials) awsCredentials;
credentials = SessionCredentials.builder().accessKeyId(username).secretAccessKey(password).sessionToken(awsSessionCredentials.getSessionToken()).build();
} else {
credentials = new Credentials(username, password);
}
ComputeServiceContext jcloudsContext = ContextBuilder.newBuilder("aws-ec2").credentialsSupplier(Suppliers.ofInstance(credentials)).modules(ImmutableSet.<Module>of(new SLF4JLoggingModule(), new JschSshClientModule())).buildView(ComputeServiceContext.class);
this.jcloudsComputeService = jcloudsContext.getComputeService();
}
}
}
return jcloudsComputeService;
}
use of org.jclouds.domain.Credentials in project whirr by apache.
the class CreateSitePpAndApplyRolesTest method testWithAttribs.
@Test
public void testWithAttribs() throws IOException {
Configuration conf = new PropertiesConfiguration();
conf.setProperty("puppet.nginx.module", "git://github.com/puppetlabs/puppetlabs-nginx.git");
conf.setProperty("nginx.server.hostname", "foohost");
CreateSitePpAndApplyRoles nginx = new CreateSitePpAndApplyRoles(ImmutableSet.of("nginx::server"), ImmutableSet.of(new Cluster.Instance(new Credentials("dummy", "dummy"), Sets.newHashSet("puppet:nginx::server"), "127.0.0.1", "127.0.0.1", "id-1", null)), conf);
assertEquals(CharStreams.toString(Resources.newReaderSupplier(Resources.getResource("nginx-with-attribs.txt"), Charsets.UTF_8)), nginx.render(OsFamily.UNIX));
}
use of org.jclouds.domain.Credentials in project whirr by apache.
the class FirewallManagerTest method setUpClass.
@Before
public void setUpClass() throws Exception {
clusterSpec = getTestClusterSpec();
context = ComputeCache.INSTANCE.apply(clusterSpec);
/* create a dummy instance for testing */
instances = Sets.newHashSet(new Cluster.Instance(new Credentials("dummy", "dummy"), Sets.newHashSet("dummy-role"), "50.0.0.1", "10.0.0.1", region + "/i-dummy", null));
manager = new FirewallManager(context, clusterSpec, new Cluster(instances));
}
use of org.jclouds.domain.Credentials in project whirr by apache.
the class TemplateUtilsTest method testProcessTemplate.
@Test
public void testProcessTemplate() throws Exception {
Credentials credentials = new Credentials("dummy", "dummy");
Cluster.Instance instance = new Cluster.Instance(credentials, Sets.newHashSet("foo"), "127.0.0.1", "127.0.0.1", "id-0", null);
ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(new PropertiesConfiguration("whirr-core-test.properties"));
Cluster cluster = new Cluster(Sets.newHashSet(instance));
VelocityEngine ve = TemplateUtils.newVelocityEngine();
String result = TemplateUtils.processTemplate(ve, "template-test.txt.vm", clusterSpec, cluster);
Assert.assertEquals("instance ip: 127.0.0.1", result);
}
use of org.jclouds.domain.Credentials in project dhis2-core by dhis2.
the class JCloudsFileResourceContentStore method init.
// -------------------------------------------------------------------------
// Life cycle management
// -------------------------------------------------------------------------
@PostConstruct
public void init() {
// ---------------------------------------------------------------------
// Bootstrap config
// ---------------------------------------------------------------------
config = new BlobStoreProperties(configurationProvider.getProperty(ConfigurationKey.FILESTORE_PROVIDER), configurationProvider.getProperty(ConfigurationKey.FILESTORE_LOCATION), configurationProvider.getProperty(ConfigurationKey.FILESTORE_CONTAINER));
Pair<Credentials, Properties> providerConfig = configureForProvider(config.provider, configurationProvider.getProperty(ConfigurationKey.FILESTORE_IDENTITY), configurationProvider.getProperty(ConfigurationKey.FILESTORE_SECRET));
// ---------------------------------------------------------------------
// Set up JClouds context
// ---------------------------------------------------------------------
blobStoreContext = ContextBuilder.newBuilder(config.provider).credentials(providerConfig.getLeft().identity, providerConfig.getLeft().credential).overrides(providerConfig.getRight()).build(BlobStoreContext.class);
blobStore = blobStoreContext.getBlobStore();
Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id(config.provider).description(config.provider).build();
try {
blobStore.createContainerInLocation(createRegionLocation(config, provider), config.container);
log.info(String.format("File store configured with provider: '%s', container: '%s' and location: '%s'.", config.provider, config.container, config.location));
} catch (HttpResponseException ex) {
log.error(String.format("Could not configure file store with provider '%s' and container '%s'.\n" + "File storage will not be available.", config.provider, config.container), ex);
} catch (AuthorizationException ex) {
log.error(String.format("Could not authenticate with file store provider '%s' and container '%s'. " + "File storage will not be available.", config.provider, config.location), ex);
}
}
Aggregations