Search in sources :

Example 1 with JschSshClientModule

use of org.jclouds.ssh.jsch.config.JschSshClientModule in project whirr by apache.

the class ComputeServiceContextBuilder method build.

public static ComputeServiceContext build(ClusterSpec spec) throws IOException {
    Set<AbstractModule> wiring = ImmutableSet.of(new JschSshClientModule(), new Log4JLoggingModule());
    ComputeServiceContext context = new ComputeServiceContextFactory().createContext(spec.getProvider(), spec.getIdentity(), spec.getCredential(), wiring);
    return context;
}
Also used : Log4JLoggingModule(org.jclouds.logging.log4j.config.Log4JLoggingModule) JschSshClientModule(org.jclouds.ssh.jsch.config.JschSshClientModule) ComputeServiceContext(org.jclouds.compute.ComputeServiceContext) ComputeServiceContextFactory(org.jclouds.compute.ComputeServiceContextFactory) AbstractModule(com.google.inject.AbstractModule)

Example 2 with JschSshClientModule

use of org.jclouds.ssh.jsch.config.JschSshClientModule 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;
}
Also used : SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) AWSSessionCredentials(com.amazonaws.auth.AWSSessionCredentials) JschSshClientModule(org.jclouds.ssh.jsch.config.JschSshClientModule) ComputeServiceContext(org.jclouds.compute.ComputeServiceContext) Module(com.google.inject.Module) SLF4JLoggingModule(org.jclouds.logging.slf4j.config.SLF4JLoggingModule) JschSshClientModule(org.jclouds.ssh.jsch.config.JschSshClientModule) AWSCredentials(com.amazonaws.auth.AWSCredentials) AWSCredentials(com.amazonaws.auth.AWSCredentials) AWSSessionCredentials(com.amazonaws.auth.AWSSessionCredentials) Credentials(org.jclouds.domain.Credentials) SessionCredentials(org.jclouds.aws.domain.SessionCredentials) LoginCredentials(org.jclouds.domain.LoginCredentials)

Aggregations

ComputeServiceContext (org.jclouds.compute.ComputeServiceContext)2 JschSshClientModule (org.jclouds.ssh.jsch.config.JschSshClientModule)2 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 AWSSessionCredentials (com.amazonaws.auth.AWSSessionCredentials)1 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 SessionCredentials (org.jclouds.aws.domain.SessionCredentials)1 ComputeServiceContextFactory (org.jclouds.compute.ComputeServiceContextFactory)1 Credentials (org.jclouds.domain.Credentials)1 LoginCredentials (org.jclouds.domain.LoginCredentials)1 Log4JLoggingModule (org.jclouds.logging.log4j.config.Log4JLoggingModule)1 SLF4JLoggingModule (org.jclouds.logging.slf4j.config.SLF4JLoggingModule)1