Java源码示例:com.github.dockerjava.api.model.Info

示例1
@Test
public void leaveSwarmAsMaster() throws DockerException {
    DockerClient dockerClient = startSwarm();

    Info info = dockerClient.infoCmd().exec();
    LOG.info("Inspected docker: {}", info.toString());

    assertThat(info.getSwarm().getLocalNodeState(), is(LocalNodeState.ACTIVE));

    dockerClient.leaveSwarmCmd()
            .withForceEnabled(true)
            .exec();
    LOG.info("Left swarm");

    info = dockerClient.infoCmd().exec();
    LOG.info("Inspected docker: {}", info.toString());

    assertThat(info.getSwarm().getLocalNodeState(), is(LocalNodeState.INACTIVE));

}
 
示例2
public DockerTraceabilityReport(@Nonnull Event event, @Nonnull Info hostInfo, 
        @CheckForNull InspectContainerResponse container, 
        @CheckForNull String imageId, @CheckForNull String imageName, 
        @CheckForNull InspectImageResponse image,
        @Nonnull List<String> parents, @CheckForNull String environment) {
    this.event = event;
    this.hostInfo = hostInfo;
    this.container = container;
    this.imageId = imageId;
    this.image = image;
    this.parents = new ArrayList<String>(parents);
    this.imageName = imageName;
    this.environment = environment;
    
}
 
示例3
@Test
public void infoTest() throws DockerException {
    DockerClient dockerClient = dockerRule.getClient();
    // Make sure that there is at least one container for the assertion
    // TODO extract this into a shared method
    if (dockerClient.listContainersCmd().withShowAll(true).exec().size() == 0) {
        CreateContainerResponse container = dockerClient.createContainerCmd(DEFAULT_IMAGE)
                .withName("docker-java-itest-info")
                .withCmd("touch", "/test")
                .exec();

        LOG.info("Created container: {}", container);
        assertThat(container.getId(), not(isEmptyOrNullString()));

        dockerClient.startContainerCmd(container.getId()).exec();
    }

    Info dockerInfo = dockerClient.infoCmd().exec();
    LOG.info(dockerInfo.toString());

    assertThat(dockerInfo.getContainers(), notNullValue());
    assertThat(dockerInfo.getContainers(), greaterThan(0));

    assertThat(dockerInfo.getImages(), notNullValue());
    assertThat(dockerInfo.getImages(), greaterThan(0));
    assertThat(dockerInfo.getDebug(), notNullValue());

    if (isNotSwarm(dockerClient)) {
        assertThat(dockerInfo.getNFd(), greaterThan(0));
        assertThat(dockerInfo.getNGoroutines(), greaterThan(0));
        assertThat(dockerInfo.getNCPU(), greaterThan(0));
    }
}
 
示例4
@Test
public void getDockerInfo() {
    Info dockerInfo = dockerClientOperation.getDockerInfo(IP);
    System.err.println(dockerInfo);
}
 
示例5
@Test
public void dockerInfo() throws Exception {
    Info info = dockerClient.infoCmd().exec();
    Assert.assertNotNull(info);
}
 
示例6
@Override
public void infoCommand() {
    Info info = dockerClient.infoCmd().exec();
    System.out.print(info);
}
 
示例7
/**
 * Stub constructor for deserialization purposes.
 */
public DockerTraceabilityReport() {
    event = new Event();
    hostInfo = new Info();
    parents = new LinkedList<String>();
}
 
示例8
public @Nonnull Info getHostInfo() {
    return hostInfo;
}
 
示例9
@Test
public void testPullImage() throws Exception {
    Info info = dockerRule.getClient().infoCmd().exec();
    LOG.info("Client info: {}", info.toString());

    int imgCount = info.getImages();
    LOG.info("imgCount1: {}", imgCount);

    // This should be an image that is not used by other repositories
    // already
    // pulled down, preferably small in size. If tag is not used pull will
    // download all images in that repository but tmpImgs will only
    // deleted 'latest' image but not images with other tags
    String testImage = "hackmann/empty";

    LOG.info("Removing image: {}", testImage);

    try {
        dockerRule.getClient().removeImageCmd(testImage).withForce(true).exec();
    } catch (NotFoundException e) {
        // just ignore if not exist
    }

    info = dockerRule.getClient().infoCmd().exec();
    LOG.info("Client info: {}", info.toString());

    imgCount = info.getImages();
    LOG.info("imgCount2: {}", imgCount);

    LOG.info("Pulling image: {}", testImage);

    dockerRule.getClient().pullImageCmd(testImage)
            .start()
            .awaitCompletion(30, TimeUnit.SECONDS);

    info = dockerRule.getClient().infoCmd().exec();
    LOG.info("Client info after pull, {}", info.toString());

    assertThat(imgCount, lessThanOrEqualTo(info.getImages()));

    InspectImageResponse inspectImageResponse = dockerRule.getClient().inspectImageCmd(testImage).exec();
    LOG.info("Image Inspect: {}", inspectImageResponse.toString());
    assertThat(inspectImageResponse, notNullValue());
}
 
示例10
@Override
public Info exec(InfoCmd command) {
    return webResource.path("info").request().get(new TypeReference<Info>() {
    });
}
 
示例11
public Info getInfo(){
    Info info = dockerClient.infoCmd().exec();
    return info;
}