Search in sources :

Example 11 with Credentials

use of org.jclouds.domain.Credentials in project fabric8 by jboss-fuse.

the class ZookeeperCredentialStore method onConnected.

private void onConnected() {
    // Whenever a connection to Zookeeper is made copy everything to Zookeeper.
    for (Map.Entry<String, Credentials> entry : cache.asMap().entrySet()) {
        String s = entry.getKey();
        Credentials credentials = entry.getValue();
        getStore().put(s, credentials);
    }
}
Also used : Map(java.util.Map) LoginCredentials(org.jclouds.domain.LoginCredentials) Credentials(org.jclouds.domain.Credentials)

Example 12 with Credentials

use of org.jclouds.domain.Credentials in project whirr by apache.

the class ListClusterCommandTest 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.newHashSet();
    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) Matchers.containsString(org.hamcrest.Matchers.containsString) Credentials(org.jclouds.domain.Credentials)

Example 13 with Credentials

use of org.jclouds.domain.Credentials in project whirr by apache.

the class ClusterController method toInstance.

private Cluster.Instance toInstance(NodeMetadata metadata, Cluster cluster, ClusterSpec spec) {
    Credentials credentials = new Credentials(spec.getClusterUser(), spec.getPrivateKey());
    Set<String> roles = Sets.newHashSet();
    try {
        if (cluster != null) {
            roles = cluster.getInstanceMatching(withIds(metadata.getId())).getRoles();
        }
    } catch (NoSuchElementException e) {
    }
    return new Cluster.Instance(credentials, roles, Iterables.getFirst(metadata.getPublicAddresses().size() > 0 ? metadata.getPublicAddresses() : metadata.getPrivateAddresses(), null), Iterables.getFirst(metadata.getPrivateAddresses(), null), metadata.getId(), metadata);
}
Also used : LoginCredentials(org.jclouds.domain.LoginCredentials) Builder.overrideLoginCredentials(org.jclouds.compute.options.RunScriptOptions.Builder.overrideLoginCredentials) Credentials(org.jclouds.domain.Credentials) NoSuchElementException(java.util.NoSuchElementException)

Example 14 with Credentials

use of org.jclouds.domain.Credentials in project whirr by apache.

the class RunScriptCommandTest 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.newHashSet();
    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) Matchers.containsString(org.hamcrest.Matchers.containsString) Credentials(org.jclouds.domain.Credentials)

Example 15 with Credentials

use of org.jclouds.domain.Credentials in project whirr by apache.

the class ClusterStateStore method unserialize.

/**
 * Rebuild the {@link Cluster} instance by using the string representation
 *
 * @param spec
 * @param content
 * @return
 * @throws UnknownHostException
 */
protected Cluster unserialize(ClusterSpec spec, String content) throws UnknownHostException {
    Credentials credentials = new Credentials(spec.getClusterUser(), spec.getPrivateKey());
    Set<Cluster.Instance> instances = Sets.newLinkedHashSet();
    for (String line : Splitter.on("\n").split(content)) {
        if (line.trim().equals(""))
            continue;
        /* ignore empty lines */
        Iterator<String> fields = Splitter.on("\t").split(line).iterator();
        String id = fields.next();
        Set<String> roles = Sets.newLinkedHashSet(Splitter.on(",").split(fields.next()));
        String publicIPAddress = fields.next();
        String privateIPAddress = fields.next();
        instances.add(new Cluster.Instance(credentials, roles, publicIPAddress, privateIPAddress, id, null));
    }
    return new Cluster(instances);
}
Also used : Cluster(org.apache.whirr.Cluster) 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