@Test(dependsOnMethods = "testCopyFileFromContainer") public void testPauseContainer() { api().pause(container.id()); assertTrue(api().inspectContainer(container.id()).state().paused()); }
@Test(dependsOnMethods = "testStopContainer") public void testRestartContainer() { api().restart(container.id()); assertTrue(api().inspectContainer(container.id()).state().running()); }
@Test(dependsOnMethods = "testCreateContainer") public void testStartContainer() throws IOException, InterruptedException { api().startContainer(container.id()); assertTrue(api().inspectContainer(container.id()).state().running()); }
@Test(dependsOnMethods = "testPauseContainer") public void testUnpauseContainer() { api().unpause(container.id()); assertFalse(api().inspectContainer(container.id()).state().paused()); }
@Test(dependsOnMethods = "testUnpauseContainer") public void testStopContainer() { api().stopContainer(container.id()); assertFalse(api().inspectContainer(container.id()).state().running()); }
if (container.state().exitCode() != 0) { destroyNode(container.id()); throw new IllegalStateException(String.format("Container %s has not started correctly", container.id()));
@Override public NodeMetadata apply(Container container) { String name = cleanUpName(container.name()); String group = nodeNamingConvention.extractGroup(name); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(container.id()) .name(name) .group(group) .hostname(container.config().hostname()) // TODO Set up hardware .hardware(new HardwareBuilder() .id("") .ram(container.config().memory()) .processor(new Processor(container.config().cpuShares(), container.config().cpuShares())) .build()); builder.status(toPortableStatus.apply(container.state())); builder.loginPort(loginPortForContainer.apply(container).or(NO_LOGIN_PORT)); builder.publicAddresses(getPublicIpAddresses(container)); builder.privateAddresses(getPrivateIpAddresses(container)); builder.location(Iterables.getOnlyElement(locations.get())); String imageId = container.image(); builder.imageId(imageId); if (images.get().containsKey(imageId)) { Image image = images.get().get(imageId); builder.operatingSystem(image.getOperatingSystem()); } return builder.build(); }
@Override public NodeMetadata apply(Container container) { String name = cleanUpName(container.name()); String group = nodeNamingConvention.extractGroup(name); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(container.id()) .name(name) .group(group) .hostname(container.config().hostname()) // TODO Set up hardware .hardware(new HardwareBuilder() .id("") .ram(container.config().memory()) .processor(new Processor(container.config().cpuShares(), container.config().cpuShares())) .build()); builder.status(toPortableStatus.apply(container.state())); builder.loginPort(loginPortForContainer.apply(container).or(NO_LOGIN_PORT)); builder.publicAddresses(getPublicIpAddresses(container)); builder.privateAddresses(getPrivateIpAddresses(container)); builder.location(Iterables.getOnlyElement(locations.get())); String imageId = container.image(); builder.imageId(imageId); if (images.get().containsKey(imageId)) { Image image = images.get().get(imageId); builder.operatingSystem(image.getOperatingSystem()); } return builder.build(); }
@Override public NodeMetadata apply(Container container) { String name = cleanUpName(container.name()); String group = nodeNamingConvention.extractGroup(name); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(container.id()) .name(name) .group(group) .hostname(container.config().hostname()) // TODO Set up hardware .hardware(new HardwareBuilder() .id("") .ram(container.config().memory()) .processor(new Processor(container.config().cpuShares(), container.config().cpuShares())) .build()); builder.status(toPortableStatus.apply(container.state())); builder.loginPort(loginPortForContainer.apply(container).or(NO_LOGIN_PORT)); builder.publicAddresses(getPublicIpAddresses(container)); builder.privateAddresses(getPrivateIpAddresses(container)); builder.location(Iterables.getOnlyElement(locations.get())); String imageId = container.image(); builder.imageId(imageId); if (images.get().containsKey(imageId)) { Image image = images.get().get(imageId); builder.operatingSystem(image.getOperatingSystem()); } return builder.build(); }
@Override public NodeMetadata apply(Container container) { String name = cleanUpName(container.name()); String group = nodeNamingConvention.extractGroup(name); NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(container.id()) .name(name) .group(group) .hostname(container.config().hostname()) // TODO Set up hardware .hardware(new HardwareBuilder() .id("") .ram(container.config().memory()) .processor(new Processor(container.config().cpuShares(), container.config().cpuShares())) .build()); builder.status(toPortableStatus.apply(container.state())); builder.loginPort(loginPortForContainer.apply(container).or(NO_LOGIN_PORT)); builder.publicAddresses(getPublicIpAddresses(container)); builder.privateAddresses(getPrivateIpAddresses(container)); builder.location(Iterables.getOnlyElement(locations.get())); String imageId = container.image(); builder.imageId(imageId); if (images.get().containsKey(imageId)) { Image image = images.get().get(imageId); builder.operatingSystem(image.getOperatingSystem()); } return builder.build(); }
@BeforeClass protected void init() { if (api.getImageApi().inspectImage(ALPINE_IMAGE_TAG) == null) { CreateImageOptions options = CreateImageOptions.Builder.fromImage(ALPINE_IMAGE_TAG); InputStream createImageStream = api.getImageApi().createImage(options); consumeStream(createImageStream); } image = api.getImageApi().inspectImage(ALPINE_IMAGE_TAG); assertNotNull(image); Config containerConfig = Config.builder().image(image.id()) .cmd(ImmutableList.of("/bin/sh", "-c", "touch hello; while true; do echo hello world; sleep 1; done")) .build(); container = api.getContainerApi().createContainer("miscApiTest", containerConfig); assertNotNull(container); api.getContainerApi().startContainer(container.id()); assertTrue(api.getContainerApi().inspectContainer(container.id()).state().running()); }
public Builder fromContainer(Container in) { return this.id(in.id()).name(in.name()).created(in.created()).path(in.path()).args(in.args()) .config(in.config()).state(in.state()).image(in.image()).networkSettings(in.networkSettings()) .sysInitPath(in.sysInitPath()).resolvConfPath(in.resolvConfPath()).driver(in.driver()) .execDriver(in.execDriver()).volumes(in.volumes()).hostConfig(in.hostConfig()).volumesRW(in.volumesRW()) .command(in.command()).status(in.status()).ports(in.ports()).hostnamePath(in.hostnamePath()) .hostsPath(in.hostsPath()).mountLabel(in.mountLabel()).processLabel(in.processLabel()).node(in.node().orNull()); } }
public Builder fromContainer(Container in) { return this.id(in.id()).name(in.name()).created(in.created()).path(in.path()).args(in.args()) .config(in.config()).state(in.state()).image(in.image()).networkSettings(in.networkSettings()) .sysInitPath(in.sysInitPath()).resolvConfPath(in.resolvConfPath()).driver(in.driver()) .execDriver(in.execDriver()).volumes(in.volumes()).hostConfig(in.hostConfig()).volumesRW(in.volumesRW()) .command(in.command()).status(in.status()).ports(in.ports()).hostnamePath(in.hostnamePath()) .hostsPath(in.hostsPath()).mountLabel(in.mountLabel()).processLabel(in.processLabel()).node(in.node().orNull()); } }
public Builder fromContainer(Container in) { return this.id(in.id()).name(in.name()).created(in.created()).path(in.path()).args(in.args()) .config(in.config()).state(in.state()).image(in.image()).networkSettings(in.networkSettings()) .sysInitPath(in.sysInitPath()).resolvConfPath(in.resolvConfPath()).driver(in.driver()) .execDriver(in.execDriver()).volumes(in.volumes()).hostConfig(in.hostConfig()).volumesRW(in.volumesRW()) .command(in.command()).status(in.status()).ports(in.ports()).hostnamePath(in.hostnamePath()) .hostsPath(in.hostsPath()).mountLabel(in.mountLabel()).processLabel(in.processLabel()).node(in.node().orNull()); } }
public Builder fromContainer(Container in) { return this.id(in.id()).name(in.name()).created(in.created()).path(in.path()).args(in.args()) .config(in.config()).state(in.state()).image(in.image()).networkSettings(in.networkSettings()) .sysInitPath(in.sysInitPath()).resolvConfPath(in.resolvConfPath()).driver(in.driver()) .execDriver(in.execDriver()).volumes(in.volumes()).hostConfig(in.hostConfig()).volumesRW(in.volumesRW()) .command(in.command()).status(in.status()).ports(in.ports()).hostnamePath(in.hostnamePath()) .hostsPath(in.hostsPath()).mountLabel(in.mountLabel()).processLabel(in.processLabel()).node(in.node().orNull()); } }