/** * @param container * @throws DockerJSONException */ public void createContainer(DockerContainer container) throws DockerJSONException { try { logger.info("The client attempts to create a container..."); DockerResponse dockerResponse = driver.create(container); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } }
/** * @param container * @return * @throws DockerJSONException */ public DockerContainer findContainer(DockerContainer container) throws DockerJSONException { logger.info("The client attempts to find a container..."); try { DockerResponse dockerResponse = driver.find(container); handleDockerAPIError(dockerResponse); container = objectMapper.readValue(dockerResponse.getBody(), DockerContainer.class); } catch (FatalDockerJSONException | IOException e) { throw new DockerJSONException(e.getMessage(), e); } return container; }
/** * @return * @throws DockerJSONException */ public List<DockerContainer> findAllContainers() throws DockerJSONException { List<DockerContainer> containers = null; try { logger.info("The client attempts to list all containers..."); DockerResponse dockerResponse = driver.findAll(); handleDockerAPIError(dockerResponse); containers = objectMapper.readValue(dockerResponse.getBody(), new TypeReference<List<DockerContainer>>() { }); } catch (FatalDockerJSONException | IOException e) { throw new DockerJSONException(e.getMessage(), e); } return containers; }
public void connectToNetwork(String id, String containerId) throws DockerJSONException, ServiceException { try { logger.info("The client attempts to add container to a network..."); Network network = findNetwork(id); DockerResponse dockerResponse = driver.connectToNetwork(network, containerId); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } catch (IOException e) { throw new ServiceException(e.getMessage(), e); } }
public Network findNetwork(String id) throws DockerJSONException, IOException { try { logger.info("The client attempts to find a network..."); Network network = new Network(); network.setId(id); DockerResponse dockerResponse = driver.findNetwork(network); handleDockerAPIError(dockerResponse); return objectMapper.readValue(dockerResponse.getBody(), Network.class); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } }
public Image findAnImage(Image image) throws DockerJSONException { DockerResponse dockerResponse = null; try { logger.info("The client attempts to find an image..."); dockerResponse = driver.findAnImage(image); handleDockerAPIError(dockerResponse); image = objectMapper.readValue(dockerResponse.getBody(), Image.class); } catch (FatalDockerJSONException | IOException e) { throw new DockerJSONException(e.getMessage(), e); } return image; }
public DockerResponse findVolume(String name) throws DockerJSONException { DockerResponse dockerResponse = null; try { logger.info("The client attempts to find a volume..."); Volume volume = new Volume(); volume.setName(name); dockerResponse = driver.findVolume(volume); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } return dockerResponse; }
public DockerResponse createVolume(String name, String label) throws DockerJSONException { DockerResponse dockerResponse = null; try { logger.info("The client attempts to create a volume..."); Volume volume = new Volume(); volume.setName(name); Map<String, String> labels = new HashMap<String, String>() { private static final long serialVersionUID = 1L; { put("cloudunit.type", label); } }; volume.setLabels(labels); dockerResponse = driver.createVolume(volume); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } return dockerResponse; }
/** * @param container * @param tag * @return * @throws DockerJSONException */ public DockerResponse commitImage(DockerContainer container, String tag, String repository) throws DockerJSONException { DockerResponse dockerResponse = null; try { logger.info("The client attempts to commit an image..."); dockerResponse = driver.commit(container, tag, repository); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } return dockerResponse; }
public DockerResponse createNetwork(String name, String label) throws DockerJSONException { DockerResponse dockerResponse = null; try { logger.info("The client attempts to create a network..."); Network network = new Network(); network.setName(name); Map<String, String> labels = new HashMap<String, String>() { private static final long serialVersionUID = 1L; { put("cloudunit.type", label); } }; network.setLabels(labels); dockerResponse = driver.createNetwork(network); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException | IOException e) { throw new DockerJSONException(e.getMessage(), e); } return dockerResponse; }
public void connectToNetwork(String id, String containerId) throws DockerJSONException, ServiceException { try { logger.info("The client attempts to add container to a network..."); Network network = findNetwork(id); DockerResponse dockerResponse = driver.connectToNetwork(network, containerId); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } catch (IOException e) { throw new ServiceException(e.getMessage(), e); } }
public Network findNetwork(String id) throws DockerJSONException, IOException { try { logger.info("The client attempts to find a network..."); Network network = new Network(); network.setId(id); DockerResponse dockerResponse = driver.findNetwork(network); handleDockerAPIError(dockerResponse); return objectMapper.readValue(dockerResponse.getBody(), Network.class); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } }
public Image findAnImage(Image image) throws DockerJSONException { DockerResponse dockerResponse = null; try { logger.info("The client attempts to find an image..."); dockerResponse = driver.findAnImage(image); handleDockerAPIError(dockerResponse); image = objectMapper.readValue(dockerResponse.getBody(), Image.class); } catch (FatalDockerJSONException | IOException e) { throw new DockerJSONException(e.getMessage(), e); } return image; }
public DockerResponse findVolume(String name) throws DockerJSONException { DockerResponse dockerResponse = null; try { logger.info("The client attempts to find a volume..."); Volume volume = new Volume(); volume.setName(name); dockerResponse = driver.findVolume(volume); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } return dockerResponse; }
public DockerResponse createVolume(String name, String label) throws DockerJSONException { DockerResponse dockerResponse = null; try { logger.info("The client attempts to create a volume..."); Volume volume = new Volume(); volume.setName(name); Map<String, String> labels = new HashMap<String, String>() { private static final long serialVersionUID = 1L; { put("cloudunit.type", label); } }; volume.setLabels(labels); dockerResponse = driver.createVolume(volume); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } return dockerResponse; }
/** * @param container * @param tag * @return * @throws DockerJSONException */ public DockerResponse commitImage(DockerContainer container, String tag, String repository) throws DockerJSONException { DockerResponse dockerResponse = null; try { logger.info("The client attempts to commit an image..."); dockerResponse = driver.commit(container, tag, repository); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } return dockerResponse; }
public DockerResponse createNetwork(String name, String label) throws DockerJSONException { DockerResponse dockerResponse = null; try { logger.info("The client attempts to create a network..."); Network network = new Network(); network.setName(name); Map<String, String> labels = new HashMap<String, String>() { private static final long serialVersionUID = 1L; { put("cloudunit.type", label); } }; network.setLabels(labels); dockerResponse = driver.createNetwork(network); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException | IOException e) { throw new DockerJSONException(e.getMessage(), e); } return dockerResponse; }
/** * @param container * @throws DockerJSONException */ public void createContainer(DockerContainer container) throws DockerJSONException { try { logger.info("The client attempts to create a container..."); DockerResponse dockerResponse = driver.create(container); handleDockerAPIError(dockerResponse); } catch (FatalDockerJSONException e) { throw new DockerJSONException(e.getMessage(), e); } }
/** * @param container * @param host * @return * @throws DockerJSONException */ public DockerContainer findContainer(DockerContainer container, String host) throws DockerJSONException { logger.info("The client attempts to find a container..."); try { DockerResponse dockerResponse = driver.find(container); handleDockerAPIError(dockerResponse); container = objectMapper.readValue(dockerResponse.getBody(), DockerContainer.class); } catch (FatalDockerJSONException | IOException e) { throw new DockerJSONException(e.getMessage(), e); } return container; }
/** * @return * @throws DockerJSONException */ public List<DockerContainer> findAllContainers() throws DockerJSONException { List<DockerContainer> containers = null; try { logger.info("The client attempts to list all containers..."); DockerResponse dockerResponse = driver.findAll(); handleDockerAPIError(dockerResponse); containers = objectMapper.readValue(dockerResponse.getBody(), new TypeReference<List<DockerContainer>>() { }); } catch (FatalDockerJSONException | IOException e) { throw new DockerJSONException(e.getMessage(), e); } return containers; }