jclouds-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ignasi Barrera <notificati...@github.com>
Subject [jclouds-labs] JCLOUDS-1014: Make the login port lookup function configurable (#209)
Date Fri, 09 Oct 2015 22:28:15 GMT

Some Docker images can have the SSH server running in a port different than 22, and that configuration
might not be populated in the container's networking configuration section. This pull request
introduces a pluggable mechanism to let users provide their own port lookup functions for
each image, allowing a more precise parsing of the container info.

The following example shows how to configure the user defined functions:

// Define custom functions that given a container, return the login port
Function<Container, Integer> AlpinePortLookup = new Function<Container, Integer>()
   @Override public Integer apply(Container input) {
      return 2222;  // Look for the port in the container object

// Create a Guice module that configures the "image -> lookup-function" mappings
Module customLookupModule = new AbstractModule() {
   @Override protected void configure() {
      MapBinder<String, Function<Container, Integer>> lookup = loginPortLookupBinder(binder());

// Provide the lookup module in the module list when creating the context
ComputeServiceContext context = ContextBuilder.newBuilder("docker")
   .credentials("identity", "credential")
   .modules(ImmutableSet.<Module> of(customLookupModule, new SshjSshClientModule()))

/cc @kwart 
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * JCLOUDS-1014: Make the login port lookup function configurable

-- File Changes --

    M docker/pom.xml (4)
    M docker/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java
    A docker/src/main/java/org/jclouds/docker/compute/config/LoginPort.java (36)
    A docker/src/main/java/org/jclouds/docker/compute/config/LoginPortLookupModule.java (44)
    M docker/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java
    A docker/src/test/java/org/jclouds/docker/compute/functions/ContainerLoginPortLookupTest.java
    M docker/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java

-- Patch Links --


Reply to this email directly or view it on GitHub:

View raw message