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());
}
}
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());
}
}
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());
}
}
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;
}
}
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")));
}
}
Aggregations