use of org.jclouds.domain.Credentials in project whirr by apache.
the class ClusterTest method setUp.
@Before
public void setUp() {
Credentials credentials = new Credentials("dummy", "dummy");
Set<Cluster.Instance> instances = Sets.newHashSet();
for (int i = 0; i < NUMBER_OF_INSTANCES; i++) {
String ip = "127.0.0." + (i + 1);
instances.add(new Cluster.Instance(credentials, Sets.newHashSet("role-" + i), ip, ip, "id-" + i, null));
}
this.cluster = new Cluster(instances);
}
use of org.jclouds.domain.Credentials in project whirr by apache.
the class BlobClusterStateStoreTest method createTestCluster.
private Cluster createTestCluster(String[] ids, String[] roles) {
checkArgument(ids.length == roles.length, "each ID should have a role");
Credentials credentials = new Credentials("dummy", "dummy");
Set<Cluster.Instance> instances = Sets.newLinkedHashSet();
for (int i = 0; i < ids.length; i++) {
String ip = "127.0.0." + (i + 1);
instances.add(new Cluster.Instance(credentials, Sets.newHashSet(roles[i]), ip, ip, ids[i], null));
}
return new Cluster(instances);
}
use of org.jclouds.domain.Credentials in project whirr by apache.
the class HadoopConfigurationBuilderTest method newCluster.
private Cluster newCluster(int numberOfWorkers) {
DnsResolver fakeDnsResolver = new FakeDnsResolver();
NodeMetadata node = mock(NodeMetadata.class);
List<Processor> processors = ImmutableList.of(new Processor(4, 1.0));
Hardware hardware = new HardwareImpl(null, null, "id", null, null, ImmutableMap.<String, String>of(), ImmutableSet.<String>of(), processors, 1024, ImmutableList.<Volume>of(), null, "xen");
when(node.getHardware()).thenReturn(hardware);
Builder<Instance> instances = ImmutableSet.<Instance>builder();
Instance master = new Instance(new Credentials("", ""), ImmutableSet.of(HadoopNameNodeClusterActionHandler.ROLE, HadoopJobTrackerClusterActionHandler.ROLE), "10.0.0.1", "10.0.0.1", "1", node, fakeDnsResolver);
instances.add(master);
for (int i = 0; i < numberOfWorkers; i++) {
int id = i + 2;
instances.add(new Instance(new Credentials("", ""), ImmutableSet.of(HadoopDataNodeClusterActionHandler.ROLE, HadoopTaskTrackerClusterActionHandler.ROLE), "10.0.0." + id, "10.0.0." + id, id + "", node, fakeDnsResolver));
}
return new Cluster(instances.build());
}
use of org.jclouds.domain.Credentials in project dhis2-core by dhis2.
the class JCloudsAppStorageService method init.
@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);
}
}
use of org.jclouds.domain.Credentials in project dhis2-core by dhis2.
the class JCloudsAppStorageService method configureForProvider.
private Pair<Credentials, Properties> configureForProvider(String provider, String identity, String secret) {
Properties overrides = new Properties();
Credentials credentials = new Credentials("Unused", "Unused");
if (provider.equals(JCLOUDS_PROVIDER_KEY_FILESYSTEM) && locationManager.externalDirectorySet()) {
overrides.setProperty(FilesystemConstants.PROPERTY_BASEDIR, locationManager.getExternalDirectoryPath());
} else if (provider.equals(JCLOUDS_PROVIDER_KEY_AWS_S3)) {
credentials = new Credentials(identity, secret);
overrides.setProperty(S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
if (credentials.identity.isEmpty() || credentials.credential.isEmpty()) {
log.warn("AWS S3 store configured without credentials, authentication not possible.");
}
}
return Pair.of(credentials, overrides);
}
Aggregations