Package org.jclouds.docker.domain

Examples of org.jclouds.docker.domain.Container$Builder


         containerConfigBuilder.volumes(volumes);
      }
      Config containerConfig = containerConfigBuilder.build();

      logger.debug(">> creating new container with containerConfig(%s)", containerConfig);
      Container container = api.getRemoteApi().createContainer(name, containerConfig);
      logger.trace("<< container(%s)", container.getId());

      HostConfig.Builder hostConfigBuilder = HostConfig.builder()
              .publishAllPorts(true)
              .privileged(true);

      if (templateOptions.getDns().isPresent()) {
         hostConfigBuilder.dns(templateOptions.getDns().get());
      }
      // set up for volume bindings
      if (templateOptions.getVolumes().isPresent()) {
         for (Map.Entry<String, String> entry : templateOptions.getVolumes().get().entrySet()) {
            hostConfigBuilder.binds(ImmutableList.of(entry.getKey() + ":" + entry.getValue()));
         }
      }
      HostConfig hostConfig = hostConfigBuilder.build();

      api.getRemoteApi().startContainer(container.getId(), hostConfig);
      container = api.getRemoteApi().inspectContainer(container.getId());
      if (container.getState().getExitCode() != 0) {
         destroyNode(container.getId());
         throw new IllegalStateException(String.format("Container %s has not started correctly", container.getId()));
      }
      return new NodeAndInitialCredentials<Container>(container, container.getId(),
              LoginCredentials.builder().user(loginUser).password(loginUserPassword).build());
   }
View Full Code Here


              .create();
   }

   @Test
   public void testContainerWithVolumesNull() {
      Container container = gson.fromJson(
              "{ \"Volumes\": null }", Container.class);
      assertNotNull(container);
      assertEquals(container.getVolumes(), null);
   }
View Full Code Here

      server.enqueue(new MockResponse().setBody(payloadFromResource("/container.json")));
      DockerApi api = api(server.getUrl("/"));
      RemoteApi remoteApi = api.getRemoteApi();
      String containerId = "b03d4cd15b76f8876110615cdeed15eadf77c9beb408d62f1687dcc69192cd6d";
      try {
         Container container = remoteApi.inspectContainer(containerId);
         assertRequestHasCommonFields(server.takeRequest(), "/containers/" + containerId + "/json");
         assertNotNull(container);
         assertNotNull(container.getId(), containerId);
         assertNotNull(container.getContainerConfig());
         assertNotNull(container.getHostConfig());
         assertEquals(container.getName(), "/tender_lumiere");
         assertEquals(container.getState().isRunning(), true);
      } finally {
         api.close();
         server.shutdown();
      }
   }
View Full Code Here

      server.enqueue(new MockResponse().setResponseCode(404));
      DockerApi api = api(server.getUrl("/"));
      RemoteApi remoteApi = api.getRemoteApi();
      String containerId = "notExisting";
      try {
         Container container = remoteApi.inspectContainer(containerId);
         assertRequestHasCommonFields(server.takeRequest(), "/containers/" + containerId + "/json");
      } finally {
         api.close();
         server.shutdown();
      }
View Full Code Here

              .attachStdout(true)
              .tty(false)
              .imageId("base")
              .build();
      try {
         Container container = remoteApi.createContainer("test", containerConfig);
         assertRequestHasCommonFields(server.takeRequest(), "POST", "/containers/create?name=test");
         assertNotNull(container);
         assertEquals(container.getId(), "c6c74153ae4b1d1633d68890a68d89c40aa5e284a1ea016cbc6ef0e634ee37b2");
      } finally {
         api.close();
         server.shutdown();
      }
   }
View Full Code Here

         replay(function);
         return function;
   }

   public void testVirtualMachineToNodeMetadata() {
      Container mockContainer = mockContainer();

      NodeMetadata node = function.apply(mockContainer);

      verify(mockContainer);
View Full Code Here

      assertEquals(node.getPrivateAddresses().size(), 1);
      assertEquals(node.getPublicAddresses().size(), 1);
   }

   private Container mockContainer() {
      Container mockContainer = EasyMock.createMock(Container.class);

      expect(mockContainer.getId()).andReturn(container.getId());
      expect(mockContainer.getName()).andReturn(container.getName());
      expect(mockContainer.getContainerConfig()).andReturn(container.getContainerConfig()).anyTimes();
      expect(mockContainer.getNetworkSettings()).andReturn(container.getNetworkSettings()).anyTimes();
      expect(mockContainer.getState()).andReturn(container.getState());
      expect(mockContainer.getImage()).andReturn(container.getImage()).anyTimes();
      replay(mockContainer);

      return mockContainer;
   }
View Full Code Here

         containerConfigBuilder.volumes(volumes);
      }
      Config containerConfig = containerConfigBuilder.build();

      logger.debug(">> creating new container with containerConfig(%s)", containerConfig);
      Container container = api.getRemoteApi().createContainer(name, containerConfig);
      logger.trace("<< container(%s)", container.getId());

      HostConfig.Builder hostConfigBuilder = HostConfig.builder()
              .publishAllPorts(true)
              .privileged(true);

      if (templateOptions.getDns().isPresent()) {
         hostConfigBuilder.dns(templateOptions.getDns().get());
      }
      // set up for volume bindings
      if (templateOptions.getVolumes().isPresent()) {
         for (Map.Entry<String, String> entry : templateOptions.getVolumes().get().entrySet()) {
            hostConfigBuilder.binds(ImmutableList.of(entry.getKey() + ":" + entry.getValue()));
         }
      }
      HostConfig hostConfig = hostConfigBuilder.build();

      api.getRemoteApi().startContainer(container.getId(), hostConfig);
      container = api.getRemoteApi().inspectContainer(container.getId());
      if (container.getState().getExitCode() != 0) {
         destroyNode(container.getId());
         throw new IllegalStateException(String.format("Container %s has not started correctly", container.getId()));
      }
      return new NodeAndInitialCredentials<Container>(container, container.getId(),
              LoginCredentials.builder().user(loginUser).password(loginUserPassword).build());
   }
View Full Code Here

TOP

Related Classes of org.jclouds.docker.domain.Container$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.