Search in sources :

Example 16 with Credentials

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);
}
Also used : Credentials(org.jclouds.domain.Credentials) Before(org.junit.Before)

Example 17 with Credentials

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);
}
Also used : Cluster(org.apache.whirr.Cluster) Credentials(org.jclouds.domain.Credentials)

Example 18 with Credentials

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());
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) FakeDnsResolver(org.apache.whirr.net.FakeDnsResolver) DnsResolver(org.apache.whirr.net.DnsResolver) Processor(org.jclouds.compute.domain.Processor) Instance(org.apache.whirr.Cluster.Instance) HardwareImpl(org.jclouds.compute.domain.internal.HardwareImpl) Cluster(org.apache.whirr.Cluster) FakeDnsResolver(org.apache.whirr.net.FakeDnsResolver) Hardware(org.jclouds.compute.domain.Hardware) Credentials(org.jclouds.domain.Credentials)

Example 19 with Credentials

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);
    }
}
Also used : LocationBuilder(org.jclouds.domain.LocationBuilder) AuthorizationException(org.jclouds.rest.AuthorizationException) HttpResponseException(org.jclouds.http.HttpResponseException) BlobStoreContext(org.jclouds.blobstore.BlobStoreContext) Properties(java.util.Properties) Credentials(org.jclouds.domain.Credentials) Location(org.jclouds.domain.Location) PostConstruct(javax.annotation.PostConstruct)

Example 20 with Credentials

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);
}
Also used : Properties(java.util.Properties) Credentials(org.jclouds.domain.Credentials)

Aggregations

Credentials (org.jclouds.domain.Credentials)20 Cluster (org.apache.whirr.Cluster)7 Location (org.jclouds.domain.Location)3 LoginCredentials (org.jclouds.domain.LoginCredentials)3 AWSSessionCredentials (com.amazonaws.auth.AWSSessionCredentials)2 NoSuchElementException (java.util.NoSuchElementException)2 Properties (java.util.Properties)2 PostConstruct (javax.annotation.PostConstruct)2 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 SessionCredentials (org.jclouds.aws.domain.SessionCredentials)2 LocationBuilder (org.jclouds.domain.LocationBuilder)2 HttpResponseException (org.jclouds.http.HttpResponseException)2 AuthorizationException (org.jclouds.rest.AuthorizationException)2 Before (org.junit.Before)2 Test (org.junit.Test)2 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AmazonS3ClientBuilder (com.amazonaws.services.s3.AmazonS3ClientBuilder)1 Module (com.google.inject.Module)1 File (java.io.File)1