Search in sources :

Example 16 with DockerException

use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.

the class DockerConnection method pushImage.

@Override
public void pushImage(final String name, final IDockerProgressHandler handler) throws DockerException, InterruptedException {
    try {
        DockerProgressHandler d = new DockerProgressHandler(handler);
        client.push(name, d);
    } catch (com.spotify.docker.client.exceptions.DockerRequestException e) {
        throw new DockerException(e.message());
    } catch (com.spotify.docker.client.exceptions.DockerException e) {
        DockerException f = new DockerException(e);
        throw f;
    }
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) IDockerProgressHandler(org.eclipse.linuxtools.docker.core.IDockerProgressHandler)

Example 17 with DockerException

use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.

the class DockerConnection method copyContainer.

public InputStream copyContainer(final Closeable token, final String id, final String path) throws DockerException, InterruptedException {
    InputStream stream;
    DockerClient clientCopy = (DockerClient) token;
    try {
        stream = clientCopy.archiveContainer(id, path);
    } catch (com.spotify.docker.client.exceptions.DockerException e) {
        throw new DockerException(e.getMessage(), e.getCause());
    }
    return stream;
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) DockerClient(com.spotify.docker.client.DockerClient) InputStream(java.io.InputStream)

Example 18 with DockerException

use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.

the class DockerConnection method pauseContainer.

@Override
public void pauseContainer(final String id) throws DockerException, InterruptedException {
    try {
        // pause container
        client.pauseContainer(id);
        // update container list
        listContainers();
    } catch (ContainerNotFoundException e) {
        throw new DockerContainerNotFoundException(e);
    } catch (com.spotify.docker.client.exceptions.DockerRequestException e) {
        throw new DockerException(e.message());
    } catch (com.spotify.docker.client.exceptions.DockerException e) {
        throw new DockerException(e.getMessage(), e.getCause());
    }
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) DockerContainerNotFoundException(org.eclipse.linuxtools.docker.core.DockerContainerNotFoundException) ContainerNotFoundException(com.spotify.docker.client.exceptions.ContainerNotFoundException) DockerContainerNotFoundException(org.eclipse.linuxtools.docker.core.DockerContainerNotFoundException)

Example 19 with DockerException

use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.

the class DockerConnection method buildImage.

/**
 * Builds an {@link IDockerImage}
 *
 * @param path
 *            path to the build context
 * @param name
 *            optional name and tag of the image to build
 * @param handler
 *            progress handler
 * @param buildOptions
 *            build options
 * @return the id of the {@link IDockerImage} that was build
 * @throws DockerException
 *             if building image failed
 * @throws InterruptedException
 *             if the thread was interrupted
 */
// TODO: add this method in the public interface
public String buildImage(final IPath path, final String name, final IDockerProgressHandler handler, final Map<String, Object> buildOptions) throws DockerException, InterruptedException {
    try {
        final DockerProgressHandler d = new DockerProgressHandler(handler);
        final java.nio.file.Path p = FileSystems.getDefault().getPath(path.makeAbsolute().toOSString());
        String res = getClientCopy().build(p, name, d, getBuildParameters(buildOptions));
        return res;
    } catch (com.spotify.docker.client.exceptions.DockerRequestException e) {
        throw new DockerException(e.message());
    } catch (com.spotify.docker.client.exceptions.DockerException | IOException e) {
        DockerException f = new DockerException(e);
        throw f;
    }
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) IDockerProgressHandler(org.eclipse.linuxtools.docker.core.IDockerProgressHandler) IOException(java.io.IOException)

Example 20 with DockerException

use of org.eclipse.linuxtools.docker.core.DockerException in project linuxtools by eclipse.

the class DockerConnection method attachLog.

public void attachLog(final Closeable token, final String id, final OutputStream out, final OutputStream err) throws DockerException, InterruptedException, IOException {
    try {
        LogStream stream = ((DockerClient) token).logs(id, LogsParam.follow(), LogsParam.stdout(), LogsParam.stderr());
        stream.attach(out, err);
        stream.close();
    } catch (com.spotify.docker.client.exceptions.DockerException e) {
        throw new DockerException(e.getMessage(), e.getCause());
    }
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) DockerClient(com.spotify.docker.client.DockerClient) LogStream(com.spotify.docker.client.LogStream)

Aggregations

DockerException (org.eclipse.linuxtools.docker.core.DockerException)80 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)27 DockerConnection (org.eclipse.linuxtools.internal.docker.core.DockerConnection)19 Job (org.eclipse.core.runtime.jobs.Job)17 IOException (java.io.IOException)16 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)16 DockerContainerNotFoundException (org.eclipse.linuxtools.docker.core.DockerContainerNotFoundException)16 ContainerNotFoundException (com.spotify.docker.client.exceptions.ContainerNotFoundException)15 ArrayList (java.util.ArrayList)14 DockerClient (com.spotify.docker.client.DockerClient)13 IDockerContainerInfo (org.eclipse.linuxtools.docker.core.IDockerContainerInfo)10 IDockerImage (org.eclipse.linuxtools.docker.core.IDockerImage)9 DockerCertificateException (com.spotify.docker.client.exceptions.DockerCertificateException)8 DockerTimeoutException (com.spotify.docker.client.exceptions.DockerTimeoutException)7 ProcessingException (javax.ws.rs.ProcessingException)7 IPath (org.eclipse.core.runtime.IPath)7 RunConsole (org.eclipse.linuxtools.internal.docker.ui.consoles.RunConsole)7 LogStream (com.spotify.docker.client.LogStream)6 File (java.io.File)6 HashMap (java.util.HashMap)6