Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-07 Thread Andrea Turli
great @nacx! Thanks again for your valuable reviews --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-48165987

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-07 Thread Ignasi Barrera
Closed #57. --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#event-138666393

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-07 Thread Ignasi Barrera
Rebased and [merged](https://git-wip-us.apache.org/repos/asf?p=jclouds-labs.git;a=commit;h=9b124ee9f12e0392b6d2f083308297bfcca8ea79). Huge thanks @andreaturli! --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-48159799

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-02 Thread Andrew Kennedy
> + > + if (templateOptions.getCommands().isPresent()) { > + containerConfigBuilder.cmd(templateOptions.getCommands().get()); > + } > + > + if (templateOptions.getMemory().isPresent()) { > + containerConfigBuilder.memory(templateOptions.getMemory().get()); > + }

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-02 Thread CloudBees pull request builder plugin
[jclouds-labs-pull-requests #205](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/205/) SUCCESS This pull request looks good --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-47840689

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-02 Thread BuildHive
[jclouds » jclouds-labs #1258](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/1258/) SUCCESS This pull request looks good [(what's this?)](https://www.cloudbees.com/what-is-buildhive) --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pul

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-02 Thread Andrea Turli
> + return this; > + } > + > + public TemplateOptions commands(Iterable commands) { > + for (String command : checkNotNull(commands, "commands")) > + checkNotNull(command, "all commands must be non-empty"); > + this.commands = Optional.> > of(ImmutableList.copyOf(command

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-02 Thread Andrew Kennedy
> + > + if (templateOptions.getCommands().isPresent()) { > + containerConfigBuilder.cmd(templateOptions.getCommands().get()); > + } > + > + if (templateOptions.getMemory().isPresent()) { > + containerConfigBuilder.memory(templateOptions.getMemory().get()); > + }

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-02 Thread Andrew Kennedy
> + return this; > + } > + > + public TemplateOptions commands(Iterable commands) { > + for (String command : checkNotNull(commands, "commands")) > + checkNotNull(command, "all commands must be non-empty"); > + this.commands = Optional.> > of(ImmutableList.copyOf(command

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-01 Thread BuildHive
[jclouds » jclouds-labs #1244](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/1244/) SUCCESS This pull request looks good [(what's this?)](https://www.cloudbees.com/what-is-buildhive) --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pul

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-01 Thread CloudBees pull request builder plugin
[jclouds-labs-pull-requests #204](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/204/) SUCCESS This pull request looks good --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-47683209

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-01 Thread BuildHive
[jclouds » jclouds-labs #1243](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/1243/) SUCCESS This pull request looks good [(what's this?)](https://www.cloudbees.com/what-is-buildhive) --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pul

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-01 Thread CloudBees pull request builder plugin
[jclouds-labs-pull-requests #203](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/203/) SUCCESS This pull request looks good --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-47680678

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-01 Thread BuildHive
[jclouds » jclouds-labs #1242](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/1242/) UNSTABLE Looks like there's a problem with this pull request [(what's this?)](https://www.cloudbees.com/what-is-buildhive) --- Reply to this email directly or view it on GitHub: https://github.com/

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-01 Thread CloudBees pull request builder plugin
[jclouds-labs-pull-requests #202](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/202/) UNSTABLE Looks like there's a problem with this pull request --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-47677495

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-07-01 Thread Andrea Turli
Here you can find the result of `mvn clean install -Plive` https://gist.github.com/andreaturli/595ce6e44a987ed5be06 unfortunately there are still issue with the DockerComputeServiceLiveTest but I think it is good to be accepted on jclouds-labs at least and fix liveTests there, if you agree ---

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread CloudBees pull request builder plugin
[jclouds-labs-pull-requests #184](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/184/) SUCCESS This pull request looks good --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-47081238

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread BuildHive
[jclouds » jclouds-labs #1208](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/1208/) SUCCESS This pull request looks good [(what's this?)](https://www.cloudbees.com/what-is-buildhive) --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pul

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread Ignasi Barrera
Thanks @andreaturli! All the points in the checklist have been addressed, and I think it is almost ready to be merged. Could you address the last comments? (Don't forget about [this one](https://github.com/jclouds/jclouds-labs/pull/57/files#r14173875) and [this one](https://github.com/jclouds/j

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread Ignasi Barrera
> +import org.jclouds.sshj.config.SshjSshClientModule; > +import org.testng.annotations.AfterMethod; > +import org.testng.annotations.BeforeMethod; > +import org.testng.annotations.Test; > + > +import javax.annotation.Resource; > +import javax.inject.Named; > +import java.io.IOException; > +import

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread Ignasi Barrera
> + > +import com.google.common.io.CharStreams; > + > +@Test(groups = "unit", testName = "BindInputStreamToRequestTest") > +public class BindInputStreamToRequestTest { > + > + @Test > + public void testBindInputStreamToRequest() throws IOException { > + BindInputStreamToRequest binder = ne

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread Ignasi Barrera
> +throw Throwables.propagate(e); > + } > + command.setException(exception); > + } > + } > + > + public String parseMessage(HttpResponse response) { > + if (response.getPayload() == null) > + return null; > + try { > + return Strings2.t

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread Ignasi Barrera
> + .hardware(new HardwareBuilder() > + .id("") > + .ram(container.getContainerConfig().getMemory()) > + .processor(new > Processor(container.getContainerConfig().getCpuShares(), > container.getContainerConfig().getCpuSha

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread Ignasi Barrera
> + > + @Resource > + @Named(ComputeServiceConstants.COMPUTE_LOGGER) > + private Logger logger = Logger.NULL; > + private final DockerApi api; > + private final ListeningExecutorService userExecutor; > + private final Predicate> imageAvailablePredicate; > + private final ImageToImage

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread Ignasi Barrera
> +import org.jclouds.rest.Binder; > + > +import com.google.common.base.Throwables; > +import com.google.common.io.Files; > + > +/** > + * @author Andrea Turli > + */ > +@Singleton > +public class BindInputStreamToRequest implements Binder { > + > + @Resource > + @Named(ComputeServiceConstants.

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread Ignasi Barrera
> + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > +package org.jclouds.docker;

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-25 Thread Ignasi Barrera
> +##Components > + > +- jclouds \- acts as a java client to access to docker features > +- DOCKER_HOST \- hosts Docker API, NB: jclouds-docker assumes that the > latest Docker is installed > +- Image \- it is a docker image that can be started. > +- Node \- is a docker container > + > +## Assumpt

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-12 Thread BuildHive
[jclouds » jclouds-labs #1158](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/1158/) SUCCESS This pull request looks good [(what's this?)](https://www.cloudbees.com/what-is-buildhive) --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pul

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-12 Thread CloudBees pull request builder plugin
[jclouds-labs-pull-requests #176](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/176/) SUCCESS This pull request looks good --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-45945836

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-10 Thread BuildHive
[jclouds » jclouds-labs #1150](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/1150/) SUCCESS This pull request looks good [(what's this?)](https://www.cloudbees.com/what-is-buildhive) --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pul

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-10 Thread CloudBees pull request builder plugin
[jclouds-labs-pull-requests #175](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/175/) SUCCESS This pull request looks good --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-45648690

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-09 Thread CloudBees pull request builder plugin
[jclouds-labs-pull-requests #174](https://jclouds.ci.cloudbees.com/job/jclouds-labs-pull-requests/174/) SUCCESS This pull request looks good --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-45491046

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-09 Thread BuildHive
[jclouds » jclouds-labs #1139](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs/1139/) SUCCESS This pull request looks good [(what's this?)](https://www.cloudbees.com/what-is-buildhive) --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pul

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-06 Thread Andrea Turli
> + destroyNode(container.getId()); > + throw new IllegalStateException(String.format("Container %s has not > started correctly", container.getId())); > + } > + return new NodeAndInitialCredentials(container, > container.getId(), > + > LoginCredentials.buil

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-04 Thread Imesh Guaratne
@andreaturli I found several problems while trying to run a docker container (apache2) and sent PR to your forked branch: https://github.com/andreaturli/jclouds-labs/pull/2 WDYT? --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-04 Thread Imesh Guaratne
Thanks all for the quick responses! @andrewgaul Yes Stopwatch constructor has been made private in com.google.guava 17.0. That's the reason why I think we see this problem. @andreaturli I think I found the problem. I was able to build jclouds-labs master branch without any problem therefore I

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-03 Thread Andrea Turli
@imesh Thanks for your feedback. That's odd because I can see ``` $ mvn dependency:tree|grep guava [INFO] | \- com.google.guava:guava:jar:17.0:compile ``` and I can build jclouds docker master Are you using jclouds-docker from another application as @andrewgaul was guessing? --- Reply to this

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-03 Thread Andrew Gaul
@imesh jclouds master branch uses Guava 17.0 which makes ```Stopwatch``` constructors private access. The jclouds dependency supersedes your application dependency on an older version of Guava. You should update your application dependency to 17.0 and address the Guava API changes and depreca

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-03 Thread Andrew Kennedy
@imesh @andreaturli It looks like an explicit dependency on Guava might be required? ```XML com.google.guava guava 17.0 ``` --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-45006489

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-06-03 Thread Imesh Guaratne
@andreaturli I just tried to build this pr but I get the following error: Any thoughts? jclouds-labs/virtualbox/src/main/java/org/jclouds/virtualbox/functions/CreateAndInstallVm.java:[109,29] cannot find symbol symbol : constructor Stopwatch() location: class com.google.common.base.Stopwatch -

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-31 Thread Andrew Kennedy
@andreaturli would be nice to be able to set `Memory` and `CpuShares` in` Config` from the template options. --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-44749515

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-30 Thread Andrew Gaul
> + checkArgument(baseDir.isDirectory(), "%s is not a directory", baseDir); > + File[] files = baseDir.listFiles(); > + File tarFile = new File(archivePath); > + > + String token = getLast(Splitter.on("/").split(archivePath.substring(0, > archivePath.lastIndexOf("/"; > + >

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-30 Thread Andrea Turli
> + } > + > + @Override > + public Iterable listLocations() { > + return ImmutableSet.of(); > + } > + > + @Override > + public Container getNode(String id) { > + return api.getRemoteApi().inspectContainer(id); > + } > + > + @Override > + public void destroyNode(String id

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-25 Thread Andrew Phillips
Thanks for the detailed review, @nacx! --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-44155452

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Andrea Turli
> +*/ > + @Named("images:list") > + @GET > + @Path("/images/json") > + @Fallback(Fallbacks.EmptySetOnNotFoundOr404.class) > + Set listImages(ListImageOptions options); > + > + /** > +* Inspect an image > +* > +* @param imageId The id of the image to inspect. > +* @re

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + > + @Inject > + public DockerComputeServiceAdapter(DockerApi api) { > + this.api = checkNotNull(api, "api"); > + } > + > + @Override > + public NodeAndInitialCredentials > createNodeWithGroupEncodedIntoName(String group, String name, > +

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Andrea Turli
> + } > + > + @Override > + public Iterable listLocations() { > + return ImmutableSet.of(); > + } > + > + @Override > + public Container getNode(String id) { > + return api.getRemoteApi().inspectContainer(id); > + } > + > + @Override > + public void destroyNode(String id

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + } > + > + @Override > + public Iterable listLocations() { > + return ImmutableSet.of(); > + } > + > + @Override > + public Container getNode(String id) { > + return api.getRemoteApi().inspectContainer(id); > + } > + > + @Override > + public void destroyNode(String id

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + > + @Inject > + public DockerComputeServiceAdapter(DockerApi api) { > + this.api = checkNotNull(api, "api"); > + } > + > + @Override > + public NodeAndInitialCredentials > createNodeWithGroupEncodedIntoName(String group, String name, > +

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Andrea Turli
> + @SuppressWarnings("unchecked") > + @Override > + public R bindToRequest(R request, Object input) { > + checkArgument(checkNotNull(input, "input") instanceof File, "this > binder is only valid for File!"); > + checkNotNull(request, "request"); > + > + File dockerFile = (Fi

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Andrea Turli
> + > + @Inject > + public DockerComputeServiceAdapter(DockerApi api) { > + this.api = checkNotNull(api, "api"); > + } > + > + @Override > + public NodeAndInitialCredentials > createNodeWithGroupEncodedIntoName(String group, String name, > +

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + .id("") > + .ram(container.getConfig().getMemory()) > + .processor(new > Processor(container.getConfig().getCpuShares(), > container.getConfig().getCpuShares())) > + .build()); > + // TODO Set up location

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Andrea Turli
> + > builder.operatingSystem(OperatingSystem.builder().description("linux").family(OsFamily.LINUX).build()); > + return builder.build(); > + } > + > + private String cleanUpName(String name) { > + return name.startsWith("/") ? name.substring(1) : name; > + } > + > + private

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Andrea Turli
> + .id("") > + .ram(container.getConfig().getMemory()) > + .processor(new > Processor(container.getConfig().getCpuShares(), > container.getConfig().getCpuShares())) > + .build()); > + // TODO Set up location

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + @SuppressWarnings("unchecked") > + @Override > + public R bindToRequest(R request, Object input) { > + checkArgument(checkNotNull(input, "input") instanceof File, "this > binder is only valid for File!"); > + checkNotNull(request, "request"); > + > + File dockerFile = (Fi

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Andrea Turli
> + checkArgument(baseDir.isDirectory(), "%s is not a directory", baseDir); > + File[] files = baseDir.listFiles(); > + File tarFile = new File(archivePath); > + > + String token = getLast(Splitter.on("/").split(archivePath.substring(0, > archivePath.lastIndexOf("/"; > + >

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Andrew Gaul
Please run through Checkstyle. --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57#issuecomment-43858507

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Andrew Gaul
> + } > + assertRequestHasCommonFields(server.takeRequest(), "POST", > "/build"); > + } finally { > + dockerFile.deleteOnExit(); > + api.close(); > + server.shutdown(); > + } > + } > + > + private File createDockerFile(String content) { > +

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
Thanks for the contribution @andreaturli! I look forward to have this merged! Next steps should be: **General** - [ ] Address all review comments. - [ ] Make all constructors for the domain objects that have a builder `protected`, to enforce the use of the builder. - [ ] Run `mvn checkstyle:check

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + try { > + remoteApi.deleteImage("1"); > + assertRequestHasCommonFields(server.takeRequest(), "DELETE", > "/images/1"); > + } finally { > + api.close(); > + server.shutdown(); > + } > + } > + > + public void testDeleteNotExistingImage() throws

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + try { > + remoteApi.stopContainer("1"); > + assertRequestHasCommonFields(server.takeRequest(), "POST", > "/containers/1/stop"); > + } finally { > + api.close(); > + server.shutdown(); > + } > + } > + > + public void testStopNonExistingContaine

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + assertRequestHasParameters(server.takeRequest(), "POST", > "/images/create", ImmutableMultimap.of("fromImage", > + "base")); > + } finally { > + api.close(); > + server.shutdown(); > + } > + } > + > + public void testCreateImageFailure() th

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + server.shutdown(); > + } > + } > + > + public void testStartNonExistingContainer() throws Exception { > + MockWebServer server = mockWebServer(); > + server.enqueue(new MockResponse().setResponseCode(204)); > + DockerApi api = api(server.getUrl("/")); > + Re

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + remoteApi.removeContainer(containerId); > + assertRequestHasCommonFields(server.takeRequest(), "DELETE", > "/containers/"+containerId); > + } finally { > + api.close(); > + server.shutdown(); > + } > + } > + > + public void testRemoveNonExistingCon

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Andrew Gaul
> + > + DockerApi api = api(server.getUrl("/")); > + RemoteApi remoteApi = api.getRemoteApi(); > + > + String content = new String(payloadFromResource("/Dockerfile")); > + File dockerFile = createDockerFile(content); > + try { > + try { > +remoteApi.buil

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + MockWebServer server = mockWebServer(); > + server.enqueue(new > MockResponse().setBody(payloadFromResource("/container-creation.json"))); > + > + DockerApi api = api(server.getUrl("/")); > + RemoteApi remoteApi = api.getRemoteApi(); > + Config config = Config.builder(

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + dockerFile.deleteOnExit(); > + api.close(); > + server.shutdown(); > + } > + } > + > + private File createDockerFile(String content) { > + File newTempDir = Files.createTempDir(); > + File dockerFile = new File(newTempDir + "/dockerFile"); > + try

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + String content = new String(payloadFromResource("/Dockerfile")); > + File dockerFile = createDockerFile(content); > + try { > + try { > +remoteApi.build(dockerFile, BuildOptions.NONE); > +fail("Build container should fail on 404"); > + } ca

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + public void testListContainers() throws Exception { > + MockWebServer server = mockWebServer(); > + server.enqueue(new > MockResponse().setBody(payloadFromResource("/containers.json"))); > + > + DockerApi api = api(server.getUrl("/")); > + RemoteApi remoteApi = api.getRem

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + MockWebServer server = mockWebServer(); > + server.enqueue(new > MockResponse().setBody(payloadFromResource("/containers.json"))); > + > + DockerApi api = api(server.getUrl("/")); > + RemoteApi remoteApi = api.getRemoteApi(); > + > + try { > + Set containers =

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + assertNull(api().inspectImage(image.getId())); > + } > + > + @Test(dependsOnMethods = "testDeleteImage") > + public void testBuildImage() throws IOException, InterruptedException, > URISyntaxException { > + BuildOptions options = > BuildOptions.Builder.tag("testBuildImage").ve

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + public void testVersion() { > + Assert.assertEquals(api().getVersion().getVersion(), "0.9.0"); > + } > + > + @Test(dependsOnMethods = "testVersion") > + public void testCreateImage() throws IOException, InterruptedException { > + CreateImageOptions options = > CreateImageOpti

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + public void testVersion() { > + Assert.assertEquals(api().getVersion().getVersion(), "0.9.0"); > + } > + > + @Test(dependsOnMethods = "testVersion") > + public void testCreateImage() throws IOException, InterruptedException { > + CreateImageOptions options = > CreateImageOpti

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> +import org.testng.annotations.Test; > + > +import javax.annotation.Resource; > +import javax.inject.Named; > +import java.io.IOException; > +import java.util.Map; > +import java.util.Set; > + > +import static org.testng.Assert.assertEquals; > +import static org.testng.Assert.assertTrue; > + > +/

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + return result; > + } > + > + protected Payload createPayload() throws IOException { > + String folderPath = System.getProperty("user.dir") + > "/docker/src/test/resources"; > + File parentDir = new File(folderPath + "/archive"); > + parentDir.mkdirs(); > + URL url

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + public NodeMetadata apply(Container container) { > + String name = cleanUpName(container.getName()); > + String group = nodeNamingConvention.extractGroup(name); > + NodeMetadataBuilder builder = new NodeMetadataBuilder(); > + builder.ids(container.getId()) > +

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > +package org.jclouds.docker.options; > + > +import org.jclouds.http.options.BaseHttpRequestOptions;

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + private final String gateway; > + @SerializedName("Bridge") > + private final String bridge; > + @SerializedName("PortMapping") > + private final String portMapping; > + @SerializedName("Ports") > + private final Map>> ports; > + > + @ConstructorProperties({ "IpAddress", "IpPref

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + @SerializedName("Binds") > + private final List binds; > + @SerializedName("Privileged") > + private final boolean privileged; > + @SerializedName("PortBindings") > + private final Map>> portBindings; > + @SerializedName("Links") > + private final List links; > + @SerializedNa

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> +import java.util.Set; > + > +import static com.google.common.base.Preconditions.checkNotNull; > + > +/** > + * @author Andrea Turli > + */ > +public class ExposedPorts { > + > + private final String portAndProtocol; > + private final Set hostPorts; > + > + @ConstructorProperties({ "PortAnd

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + > +import com.google.common.base.Objects; > +import com.google.common.collect.ImmutableSet; > + > +import java.beans.ConstructorProperties; > +import java.util.Set; > + > +import static com.google.common.base.Preconditions.checkNotNull; > + > +/** > + * @author Andrea Turli > + */ > +public cla

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> +String image, NetworkSettings networkSettings, String > resolvConfPath, > +String driver, String execDriver, Map > volumes, Map volumesRW, > +String command, String status, HostConfig hostConfig, > List ports) { > + this.id = c

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + this.created = checkNotNull(created, "created"); > + this.path = checkNotNull(path, "path"); > + this.args = checkNotNull(args, "args"); > + this.config = checkNotNull(config, "config"); > + this.state = checkNotNull(state, "state"); > + this.image = checkNotNull(i

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> +String driver, String execDriver, Map > volumes, Map volumesRW, > +String command, String status, HostConfig hostConfig, > List ports) { > + this.id = checkNotNull(id, "id"); > + this.name = checkNotNull(name, "name"); > + this.created = c

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + this.user = user; > + this.memory = checkNotNull(memory, "memory"); > + this.memorySwap = checkNotNull(memorySwap, "memorySwap"); > + this.cpuShares = checkNotNull(cpuShares, "cpuShares"); > + this.attachStdin = checkNotNull(attachStdin, "attachStdin"); > + this.at

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + } > + > + @Override > + public Iterable listLocations() { > + return ImmutableSet.of(); > + } > + > + @Override > + public Container getNode(String id) { > + return api.getRemoteApi().inspectContainer(id); > + } > + > + @Override > + public void destroyNode(String id

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + //return api.getRemoteApi().listImages(); > + Set images = Sets.newHashSet(); > + for (Image image : api.getRemoteApi().listImages()) { > + // less efficient than just listNodes but returns richer json that > needs repoTags coming from listImages > + Image inspec

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + }, null); > + } > + > + @Override > + public Iterable listNodes() { > + Set containers = Sets.newHashSet(); > + for (Container container : api.getRemoteApi().listContainers()) { > + // less efficient than just listNodes but returns richer json > + > contain

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + } > + > + @Override > + public Iterable listHardwareProfiles() { > + Set hardware = Sets.newLinkedHashSet(); > + // todo they are only placeholders at the moment > + hardware.add(new > HardwareBuilder().ids("micro").hypervisor("lxc").name("micro").ram(512).build()); > +

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + destroyNode(container.getId()); > + throw new IllegalStateException(String.format("Container %s has not > started correctly", container.getId())); > + } > + return new NodeAndInitialCredentials(container, > container.getId(), > + > LoginCredentials.buil

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + > + @Inject > + public DockerComputeServiceAdapter(DockerApi api) { > + this.api = checkNotNull(api, "api"); > + } > + > + @Override > + public NodeAndInitialCredentials > createNodeWithGroupEncodedIntoName(String group, String name, > +

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> + > +import com.google.common.base.Objects; > +import com.google.common.base.Optional; > +import com.google.common.collect.ImmutableMap; > + > +/** > + * Contains options supported in the {@code ComputeService#runNode} > operation on the > + * "docker" provider. Usage The recommended way to inst

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-22 Thread Ignasi Barrera
> +import org.jclouds.compute.options.TemplateOptions; > +import org.jclouds.domain.LoginCredentials; > +import org.jclouds.scriptbuilder.domain.Statement; > + > +import com.google.common.base.Objects; > +import com.google.common.base.Optional; > +import com.google.common.collect.ImmutableMap; > +

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-21 Thread Ignasi Barrera
> +/** > + * @author Andrea Turli > + */ > +public class ImageToImage implements > Function { > + > + private static final String CENTOS = "centos"; > + private static final String UBUNTU = "ubuntu"; > + > + @Resource > + @Named(ComputeServiceConstants.COMPUTE_LOGGER) > + protected Logge

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-21 Thread Ignasi Barrera
> + } > + > + private Iterable getPrivateIpAddresses(Container container) { > + if (container.getNetworkSettings() == null) return ImmutableList.of(); > + return ImmutableList.of(container.getNetworkSettings().getIpAddress()); > + } > + > + private List getPublicIpAddresses() { >

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-21 Thread Ignasi Barrera
> + > builder.operatingSystem(OperatingSystem.builder().description("linux").family(OsFamily.LINUX).build()); > + return builder.build(); > + } > + > + private String cleanUpName(String name) { > + return name.startsWith("/") ? name.substring(1) : name; > + } > + > + private

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-21 Thread Ignasi Barrera
> @@ -0,0 +1,275 @@ > +/* The entire `features` package must be moved outside the `compute` one. --- Reply to this email directly or view it on GitHub: https://github.com/jclouds/jclouds-labs/pull/57/files#r12936907

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-21 Thread Andrew Gaul
> + checkArgument(baseDir.isDirectory(), "%s is not a directory", baseDir); > + File[] files = baseDir.listFiles(); > + File tarFile = new File(archivePath); > + > + String token = getLast(Splitter.on("/").split(archivePath.substring(0, > archivePath.lastIndexOf("/"; > + >

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-21 Thread Ignasi Barrera
> + .id("") > + .ram(container.getConfig().getMemory()) > + .processor(new > Processor(container.getConfig().getCpuShares(), > container.getConfig().getCpuShares())) > + .build()); > + // TODO Set up location

Re: [jclouds-labs] [JCLOUDS-500] Initial commit for docker (#57)

2014-05-21 Thread Ignasi Barrera
> + TarArchiveEntry tarEntry = new TarArchiveEntry(file); > + tarEntry.setName("/" + > getLast(Splitter.on(token).split(file.toString(; > + tos.putArchiveEntry(tarEntry); > + if (!file.isDirectory()) { > +FileInputStream fin = new FileInputStream(fil

  1   2   >