Search in sources :

Example 46 with DockerException

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

the class DockerConnection method listNetworks.

@Override
public List<IDockerNetwork> listNetworks() throws DockerException, InterruptedException {
    try {
        List<Network> networkList = client.listNetworks();
        ArrayList<IDockerNetwork> networks = new ArrayList<>();
        for (Network n : networkList) {
            networks.add(new DockerNetwork(n));
        }
        return networks;
    } catch (com.spotify.docker.client.exceptions.DockerException e) {
        throw new DockerException(e.getMessage(), e.getCause());
    }
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) IDockerNetwork(org.eclipse.linuxtools.docker.core.IDockerNetwork) Network(com.spotify.docker.client.messages.Network) IDockerNetwork(org.eclipse.linuxtools.docker.core.IDockerNetwork) ArrayList(java.util.ArrayList) IDockerNetwork(org.eclipse.linuxtools.docker.core.IDockerNetwork)

Example 47 with DockerException

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

the class DockerConnection method unpauseContainer.

@Override
public void unpauseContainer(final String id, final OutputStream stream) throws DockerException, InterruptedException {
    try {
        // unpause container
        client.unpauseContainer(id);
        if (stream != null) {
            synchronized (loggingThreads) {
                LogThread t = loggingThreads.get(id);
                if (t == null || !t.isAlive()) {
                    t = new LogThread(id, getClientCopy(), true);
                    loggingThreads.put(id, t);
                    t.setOutputStream(stream);
                    t.start();
                } else {
                    // we aren't going to use the stream given...close it
                    try {
                        stream.close();
                    } catch (IOException e) {
                    // do nothing...we tried to close the stream
                    }
                }
            }
        }
        // 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) IOException(java.io.IOException) ContainerNotFoundException(com.spotify.docker.client.exceptions.ContainerNotFoundException) DockerContainerNotFoundException(org.eclipse.linuxtools.docker.core.DockerContainerNotFoundException)

Example 48 with DockerException

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

the class DockerConnection method copyToContainer.

@Override
public void copyToContainer(final String directory, final String id, final String path) throws DockerException, InterruptedException, IOException {
    try {
        DockerClient copy = getClientCopy();
        java.nio.file.Path dirPath = FileSystems.getDefault().getPath(directory);
        copy.copyToContainer(dirPath, id, path);
        copy.close();
    /* dispose of client copy now that we are done */
    } 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)

Example 49 with DockerException

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

the class DockerConnection method buildImage.

@Override
public String buildImage(final IPath path, final IDockerProgressHandler handler) 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, d, // $NON-NLS-1$ //$NON-NLS-2$
        BuildParam.create("forcerm", "true"));
        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 50 with DockerException

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

the class BuildDockerImageShortcut method launch.

@Override
protected void launch(IResource resource, String mode) {
    // the predicate to apply on the launch configuration to find the
    // matching candidates
    final Predicate<ILaunchConfiguration> predicate = config -> {
        try {
            final String sourcePath = config.getAttribute(IBuildDockerImageLaunchConfigurationConstants.SOURCE_PATH_LOCATION, // $NON-NLS-1$
            "");
            final boolean workspaceRelative = config.getAttribute(IBuildDockerImageLaunchConfigurationConstants.SOURCE_PATH_WORKSPACE_RELATIVE_LOCATION, false);
            final IPath dockerfilePath = getPath(sourcePath, workspaceRelative);
            return dockerfilePath.equals(resource.getLocation().removeLastSegments(1));
        } catch (CoreException e) {
            Activator.log(e);
            return false;
        }
    };
    final ILaunchConfiguration config = findLaunchConfiguration(IBuildDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID, resource, predicate);
    if (config != null) {
        DebugUITools.launch(config, mode);
    } else {
        Activator.log(new DockerException(LaunchMessages.getString(// $NON-NLS-1$
        "BuildDockerImageShortcut.launchconfig.error")));
    }
}
Also used : PlatformUI(org.eclipse.ui.PlatformUI) Predicate(java.util.function.Predicate) DockerConnectionManager(org.eclipse.linuxtools.docker.core.DockerConnectionManager) Activator(org.eclipse.linuxtools.docker.ui.Activator) NewDockerConnection(org.eclipse.linuxtools.internal.docker.ui.wizards.NewDockerConnection) CoreException(org.eclipse.core.runtime.CoreException) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) Display(org.eclipse.swt.widgets.Display) ImageBuildDialog(org.eclipse.linuxtools.internal.docker.ui.wizards.ImageBuildDialog) DebugUITools(org.eclipse.debug.ui.DebugUITools) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchShortcut(org.eclipse.debug.ui.ILaunchShortcut) IPath(org.eclipse.core.runtime.IPath) IResource(org.eclipse.core.resources.IResource) DockerException(org.eclipse.linuxtools.docker.core.DockerException) CommandUtils(org.eclipse.linuxtools.internal.docker.ui.commands.CommandUtils) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) DockerException(org.eclipse.linuxtools.docker.core.DockerException) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

DockerException (org.eclipse.linuxtools.docker.core.DockerException)78 IDockerConnection (org.eclipse.linuxtools.docker.core.IDockerConnection)26 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