/** * {@inheritDoc} */ @Override public synchronized Info fetchDockerDaemonInfo() throws IOException { if (this.dockerDaemonInfo == null) { this.dockerDaemonInfo = this.dockerClient.infoCmd().exec(); } return this.dockerDaemonInfo; }
Info dockerInfo = client.infoCmd().exec(); Version version = client.versionCmd().exec(); activeApiVersion = version.getApiVersion();
public Info getInfo(){ Info info = dockerClient.infoCmd().exec(); return info; }
private Map<String, String> resolveSystemDefaultSetup(Map<String, String> config) { if (!config.containsKey(CubeDockerConfiguration.DOCKER_URI)) { final String defaultUri = operatingSystem.getDefaultFamily().getServerUri(); URI uri = URI.create(defaultUri); if (Files.exists(FileSystems.getDefault().getPath(uri.getPath()))){ DockerClient client = defaultDocker.getDefaultDockerClient(defaultUri); InfoCmd cmd = client.infoCmd(); try { Info info = cmd.exec(); config.put(CubeDockerConfiguration.DOCKER_URI, defaultUri); log.info(String.format("Connected to docker (%s) using default settings version: %s kernel: %s", info.getName(), info.getServerVersion(), info.getKernelVersion())); } catch (ProcessingException e){ log.info(String.format("Could not connect to default socket %s. Go on with ", operatingSystem.getDefaultFamily().getServerUri())); } } } return config; }
private Map<String, String> resolveSystemDefaultSetup(Map<String, String> config) { if (!config.containsKey(CubeDockerConfiguration.DOCKER_URI)) { final String defaultUri = operatingSystem.getDefaultFamily().getServerUri(); URI uri = URI.create(defaultUri); if (Files.exists(FileSystems.getDefault().getPath(uri.getPath()))){ DockerClient client = defaultDocker.getDefaultDockerClient(defaultUri); InfoCmd cmd = client.infoCmd(); try { Info info = cmd.exec(); config.put(CubeDockerConfiguration.DOCKER_URI, defaultUri); log.info(String.format("Connected to docker (%s) using default settings version: %s kernel: %s", info.getName(), info.getServerVersion(), info.getKernelVersion())); } catch (ProcessingException e){ log.info(String.format("Could not connect to default socket %s. Go on with ", operatingSystem.getDefaultFamily().getServerUri())); } } } return config; }
public DefaultDocker mockDefaultDocker() { when(defaultDocker.getDefaultDockerClient(anyString())).thenReturn(dockerClient); when(dockerClient.infoCmd()).thenReturn(infoCmd); when(infoCmd.exec()).thenReturn(info); return defaultDocker; }
@Test public void shouldNotSetTlsVerifyForTcpSchemeOnLinux() { CubeDockerConfigurationResolver resolver = new CubeDockerConfigurationResolver(new Top(), new DockerMachine(null), new Boot2Docker(null), mockDefaultDocker(), operatingSystemInterface); when(infoCmd.exec()).thenThrow(new ProcessingException("test exception")); String sockUri = "unix:///a/path-that/does/not/exist"; when(defaultOperatingSystemFamilyInterface.getServerUri()).thenReturn(sockUri); when(operatingSystemInterface.getDefaultFamily()).thenReturn(defaultOperatingSystemFamilyInterface); when(operatingSystemInterface.getFamily()).thenReturn(OperatingSystem.LINUX_OS.getFamily()); Map<String, String> config = new HashMap<>(); config.put(CubeDockerConfiguration.DOCKER_URI, "tcp://localhost:2376"); Map<String, String> resolvedConfig = resolver.resolve(config); assertThat(Boolean.valueOf(resolvedConfig.get(CubeDockerConfiguration.TLS_VERIFY)), is(false)); assertThat(resolvedConfig.get(CubeDockerConfiguration.CERT_PATH), is(nullValue())); } }
@Test public void shouldNotSetTlsVerifyForTcpSchemeOnOSX() { CubeDockerConfigurationResolver resolver = new CubeDockerConfigurationResolver(new Top(), new DockerMachine(null), new Boot2Docker(null), mockDefaultDocker(), operatingSystemInterface); when(infoCmd.exec()).thenThrow(new ProcessingException("test exception")); String sockUri = "unix:///a/path-that/does/not/exist"; when(defaultOperatingSystemFamilyInterface.getServerUri()).thenReturn(sockUri); when(operatingSystemInterface.getDefaultFamily()).thenReturn(defaultOperatingSystemFamilyInterface); when(operatingSystemInterface.getFamily()).thenReturn(OperatingSystem.MAC_OSX.getFamily()); Map<String, String> config = new HashMap<>(); config.put(CubeDockerConfiguration.DOCKER_URI, "tcp://localhost:2376"); Map<String, String> resolvedConfig = resolver.resolve(config); assertThat(Boolean.valueOf(resolvedConfig.get(CubeDockerConfiguration.TLS_VERIFY)), is(false)); assertThat(resolvedConfig.get(CubeDockerConfiguration.CERT_PATH), is(nullValue())); }
@BeforeClass public static void setupDockerScanner() { DockerScanner ds = new Projector.Builder().build().createBuilder(DockerScannerBuilder.class).withLocalDockerDaemon().build(); boolean b = ds.getNeoRxClient().checkConnection(); if (b==false) { logger.warn("neo4j is not available...integration tests will be skipped"); Assume.assumeTrue("neo4j available", b); } else { logger.info("neo4j is available for integration tests"); } try { Info info = ds.getDockerClient().infoCmd().exec(); logger.info("local docker daemon is available for integration tests"); dockerScanner = ds; } catch (Exception e) { logger.warn("neo4j is not available for integration tests",e); Assume.assumeTrue(false); return; } } }
break; case INFO: result = executeInfoRequest(client, message).exec(); break; case PING: