Search in sources :

Example 16 with Command

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Command in project docker-maven-plugin by fabric8io.

the class RunService method execInContainer.

/**
 * Create and start a Exec container with the given image configuration.
 * @param containerId container id to run exec command against
 * @param command command to execute
 * @param imageConfiguration configuration of the container's image
 * @return the exec container id
 *
 * @throws DockerAccessException if access to the docker backend fails
 */
public String execInContainer(String containerId, String command, ImageConfiguration imageConfiguration) throws DockerAccessException, ExecException {
    Arguments arguments = new Arguments();
    arguments.setExec(Arrays.asList(EnvUtil.splitOnSpaceWithEscape(command)));
    String execContainerId = docker.createExecContainer(containerId, arguments);
    docker.startExecContainer(execContainerId, logConfig.createSpec(containerId, imageConfiguration));
    ExecDetails execContainer = docker.getExecContainer(execContainerId);
    Integer exitCode = execContainer.getExitCode();
    if (exitCode != null && exitCode != 0) {
        ContainerDetails container = docker.getContainer(containerId);
        throw new ExecException(execContainer, container);
    }
    return execContainerId;
}
Also used : ExecDetails(io.fabric8.maven.docker.model.ExecDetails) ExecException(io.fabric8.maven.docker.access.ExecException) Arguments(io.fabric8.maven.docker.config.Arguments) ContainerDetails(io.fabric8.maven.docker.model.ContainerDetails)

Example 17 with Command

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Command in project docker-maven-plugin by fabric8io.

the class DockerAccessWinIT method testCreateContainer.

private void testCreateContainer() throws DockerAccessException {
    PortMapping portMapping = new PortMapping(Arrays.asList(new String[] { PORT + ":" + PORT }), new Properties());
    ContainerHostConfig hostConfig = new ContainerHostConfig().portBindings(portMapping);
    ContainerCreateConfig createConfig = new ContainerCreateConfig(IMAGE).command(new Arguments("ping google.com")).hostConfig(hostConfig);
    containerId = dockerClient.createContainer(createConfig, CONTAINER_NAME);
    assertNotNull(containerId);
    String name = dockerClient.getContainer(containerId).getName();
    assertEquals(CONTAINER_NAME, name);
}
Also used : Arguments(io.fabric8.maven.docker.config.Arguments) ContainerCreateConfig(io.fabric8.maven.docker.access.ContainerCreateConfig) PortMapping(io.fabric8.maven.docker.access.PortMapping) Properties(java.util.Properties) ContainerHostConfig(io.fabric8.maven.docker.access.ContainerHostConfig)

Example 18 with Command

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Command in project docker-maven-plugin by fabric8io.

the class DockerAccessIT method testCreateContainer.

private void testCreateContainer() throws DockerAccessException {
    PortMapping portMapping = new PortMapping(Arrays.asList(new String[] { PORT + ":" + PORT }), new Properties());
    ContainerHostConfig hostConfig = new ContainerHostConfig().portBindings(portMapping);
    ContainerCreateConfig createConfig = new ContainerCreateConfig(IMAGE).command(new Arguments("ping google.com")).hostConfig(hostConfig);
    containerId = dockerClient.createContainer(createConfig, CONTAINER_NAME);
    assertNotNull(containerId);
    String name = dockerClient.getContainer(containerId).getName();
    assertEquals(CONTAINER_NAME, name);
}
Also used : Arguments(io.fabric8.maven.docker.config.Arguments) ContainerCreateConfig(io.fabric8.maven.docker.access.ContainerCreateConfig) PortMapping(io.fabric8.maven.docker.access.PortMapping) Properties(java.util.Properties) ContainerHostConfig(io.fabric8.maven.docker.access.ContainerHostConfig)

Example 19 with Command

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Command in project fabric8 by jboss-fuse.

the class FabricGitSummaryAction method performContainerAction.

@Override
protected void performContainerAction(String queuePath, String containerName) throws Exception {
    JMXRequest containerRequest = new JMXRequest().withObjectName("io.fabric8:type=Fabric").withMethod("gitVersions");
    requests.put(containerName, containerRequest);
    String command = map(containerRequest);
    curator.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(queuePath, PublicStringSerializer.serialize(command));
}
Also used : JMXRequest(io.fabric8.api.commands.JMXRequest)

Example 20 with Command

use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.Command in project fabric8 by jboss-fuse.

the class FabricGitSummaryAction method beforeEachContainer.

@Override
protected void beforeEachContainer(Collection<String> names) throws Exception {
    // first, we need summary from fabric-git-server (to have something to compare local git repositories to)
    master = fabricService.getGitMaster();
    if (master == null) {
        System.out.println("Can't find container which is current git master");
        return;
    }
    System.out.println("Git master is: " + master);
    // ask master about the status first
    String queuePath = ZkPath.COMMANDS_REQUESTS_QUEUE.getPath(master);
    masterRequest = new JMXRequest().withObjectName("io.fabric8:type=GitServer").withMethod("gitVersions");
    String command = map(masterRequest);
    curator.create().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(queuePath, PublicStringSerializer.serialize(command));
}
Also used : JMXRequest(io.fabric8.api.commands.JMXRequest)

Aggregations

IOException (java.io.IOException)9 File (java.io.File)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Container (io.fabric8.api.Container)5 JMXRequest (io.fabric8.api.commands.JMXRequest)4 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 FabricService (io.fabric8.api.FabricService)3 ContainerCreateConfig (io.fabric8.maven.docker.access.ContainerCreateConfig)3 Arguments (io.fabric8.maven.docker.config.Arguments)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Properties (java.util.Properties)3 TemplatedResource (com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource)2 ArtifactService (com.netflix.spinnaker.halyard.deploy.services.v1.ArtifactService)2 GenerateService (com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService)2 SpinnakerRuntimeSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)2 Container (io.fabric8.kubernetes.api.model.Container)2