@Test(groups = "Integration") public void testIsSshableWhenTrue() throws Exception { assertTrue(host.isSshable()); }
public boolean isSshable() { String cmd = "date"; try { try { Socket s = new Socket(); s.connect(new InetSocketAddress(getAddress(), getPort()), SSHABLE_CONNECT_TIMEOUT); s.close(); } catch (IOException e) { if (LOG.isDebugEnabled()) LOG.debug(""+this+" not [yet] reachable (socket "+getAddress()+":"+getPort()+"): "+e); return false; } int result = execCommands(MutableMap.<String,Object>of(), "isSshable", ImmutableList.of(cmd)); if (result == 0) { return true; } else { if (LOG.isDebugEnabled()) LOG.debug("Not reachable: {}, executing `{}`, exit code {}", new Object[] {this, cmd, result}); return false; } } catch (SshException e) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } catch (IllegalStateException e) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } catch (RuntimeException e) { if (Exceptions.getFirstThrowableOfType(e, IOException.class) != null) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } else { throw e; } } }
SshMachineLocation extends AbstractLocation implements MachineLocation, PortSupplier, WithMutexes, Closeable { public boolean isSshable() { String cmd = "date"; try { try { Socket s = new Socket(); s.connect(new InetSocketAddress(getAddress(), getPort()), SSHABLE_CONNECT_TIMEOUT); s.close(); } catch (IOException e) { if (LOG.isDebugEnabled()) LOG.debug(""+this+" not [yet] reachable (socket "+getAddress()+":"+getPort()+"): "+e); return false; } int result = execCommands(MutableMap.<String,Object>of(), "isSshable", ImmutableList.of(cmd)); if (result == 0) { return true; } else { if (LOG.isDebugEnabled()) LOG.debug("Not reachable: {}, executing `{}`, exit code {}", new Object[] {this, cmd, result}); return false; } } catch (SshException e) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } catch (IllegalStateException e) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } catch (RuntimeException e) { if (Exceptions.getFirstThrowableOfType(e, IOException.class) != null) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } else { throw e; } } } }
SshMachineLocation extends AbstractLocation implements MachineLocation, PortSupplier, WithMutexes, Closeable { public boolean isSshable() { String cmd = "date"; try { try { Socket s = new Socket(); s.connect(new InetSocketAddress(getAddress(), getPort()), SSHABLE_CONNECT_TIMEOUT); s.close(); } catch (IOException e) { if (LOG.isDebugEnabled()) LOG.debug(""+this+" not [yet] reachable (socket "+getAddress()+":"+getPort()+"): "+e); return false; } int result = execCommands(MutableMap.<String,Object>of(), "isSshable", ImmutableList.of(cmd)); if (result == 0) { return true; } else { if (LOG.isDebugEnabled()) LOG.debug("Not reachable: {}, executing `{}`, exit code {}", new Object[] {this, cmd, result}); return false; } } catch (SshException e) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } catch (IllegalStateException e) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } catch (RuntimeException e) { if (Exceptions.getFirstThrowableOfType(e, IOException.class) != null) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } else { throw e; } } } SshMachineLocation();  SshMachineLocation(Map properties); }
SshMachineLocation extends AbstractLocation implements MachineLocation, PortSupplier, WithMutexes, Closeable { public boolean isSshable() { String cmd = "date"; try { try { Socket s = new Socket(); s.connect(new InetSocketAddress(getAddress(), getPort()), SSHABLE_CONNECT_TIMEOUT); s.close(); } catch (IOException e) { if (LOG.isDebugEnabled()) LOG.debug(""+this+" not [yet] reachable (socket "+getAddress()+":"+getPort()+"): "+e); return false; } int result = execCommands(MutableMap.<String,Object>of(), "isSshable", ImmutableList.of(cmd)); if (result == 0) { return true; } else { if (LOG.isDebugEnabled()) LOG.debug("Not reachable: {}, executing `{}`, exit code {}", new Object[] {this, cmd, result}); return false; } } catch (SshException e) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } catch (IllegalStateException e) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } catch (RuntimeException e) { if (Exceptions.getFirstThrowableOfType(e, IOException.class) != null) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } else { throw e; } } } SshMachineLocation();  SshMachineLocation(Map properties); @Override void init(); @Override SshMachineLocation configure(Map<?,?> properties); @Override void close(); @Override InetAddress getAddress(); @Override String getHostname(); @Override Set<String> getPublicAddresses(); @Override Set<String> getPrivateAddresses(); HostAndPort getSshHostAndPort(); String getUser(); int getPort(); int execCommands(String summaryForLogging, List<String> commands); int execCommands(Map<String,?> props, String summaryForLogging, List<String> commands); int execCommands(String summaryForLogging, List<String> commands, Map<String,?> env); int execCommands(Map<String,?> props, String summaryForLogging, List<String> commands, Map<String,?> env); int execScript(String summaryForLogging, List<String> commands); int execScript(Map<String,?> props, String summaryForLogging, List<String> commands); int execScript(String summaryForLogging, List<String> commands, Map<String,?> env); int execScript(Map<String,?> props, String summaryForLogging, List<String> commands, Map<String,?> env); int copyTo(File src, File destination); int copyTo(Map<String,?> props, File src, File destination); int copyTo(File src, String destination); int copyTo(Map<String,?> props, File src, String destination); int copyTo(Reader src, String destination); int copyTo(Map<String,?> props, Reader src, String destination); int copyTo(InputStream src, String destination); int copyTo(InputStream src, long filesize, String destination); int copyTo(final Map<String,?> props, final InputStream src, final long filesize, final String destination); int copyTo(final Map<String,?> props, final InputStream src, final String destination); int copyFrom(String remote, String local); int copyFrom(final Map<String,?> props, final String remote, final String local); int installTo(String url, String destPath); int installTo(Map<String,?> props, String url, String destPath); int installTo(ResourceUtils loader, String url, String destPath); int installTo(ResourceUtils utils, Map<String,?> props, String url, String destPath); @Override String toString(); @Override String toVerboseString(); @Override boolean obtainSpecificPort(int portNumber); @Override int obtainPort(PortRange range); @Override void releasePort(int portNumber); boolean isSshable(); @Override OsDetails getOsDetails(); @Override MachineDetails getMachineDetails(); @Override void acquireMutex(String mutexId, String description); @Override boolean tryAcquireMutex(String mutexId, String description); @Override void releaseMutex(String mutexId); @Override boolean hasMutex(String mutexId); KeyPair findKeyPair(); String findPassword(); }
SshMachineLocation extends AbstractLocation implements MachineLocation, PortSupplier, WithMutexes, Closeable { public boolean isSshable() { String cmd = "date"; try { try { Socket s = new Socket(); s.connect(new InetSocketAddress(getAddress(), getPort()), SSHABLE_CONNECT_TIMEOUT); s.close(); } catch (IOException e) { if (LOG.isDebugEnabled()) LOG.debug(""+this+" not [yet] reachable (socket "+getAddress()+":"+getPort()+"): "+e); return false; } int result = execCommands(MutableMap.<String,Object>of(), "isSshable", ImmutableList.of(cmd)); if (result == 0) { return true; } else { if (LOG.isDebugEnabled()) LOG.debug("Not reachable: {}, executing `{}`, exit code {}", new Object[] {this, cmd, result}); return false; } } catch (SshException e) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } catch (IllegalStateException e) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } catch (RuntimeException e) { if (Exceptions.getFirstThrowableOfType(e, IOException.class) != null) { if (LOG.isDebugEnabled()) LOG.debug("Exception checking if "+this+" is reachable; assuming not", e); return false; } else { throw e; } } } SshMachineLocation();  SshMachineLocation(Map properties); @Override void init(); @Override SshMachineLocation configure(Map<?,?> properties); @Override void close(); @Override InetAddress getAddress(); @Override String getHostname(); @Override Set<String> getPublicAddresses(); @Override Set<String> getPrivateAddresses(); HostAndPort getSshHostAndPort(); String getUser(); int getPort(); int execCommands(String summaryForLogging, List<String> commands); int execCommands(Map<String,?> props, String summaryForLogging, List<String> commands); int execCommands(String summaryForLogging, List<String> commands, Map<String,?> env); int execCommands(Map<String,?> props, String summaryForLogging, List<String> commands, Map<String,?> env); int execScript(String summaryForLogging, List<String> commands); int execScript(Map<String,?> props, String summaryForLogging, List<String> commands); int execScript(String summaryForLogging, List<String> commands, Map<String,?> env); int execScript(Map<String,?> props, String summaryForLogging, List<String> commands, Map<String,?> env); int copyTo(File src, File destination); int copyTo(Map<String,?> props, File src, File destination); int copyTo(File src, String destination); int copyTo(Map<String,?> props, File src, String destination); int copyTo(Reader src, String destination); int copyTo(Map<String,?> props, Reader src, String destination); int copyTo(InputStream src, String destination); int copyTo(InputStream src, long filesize, String destination); int copyTo(final Map<String,?> props, final InputStream src, final long filesize, final String destination); int copyTo(final Map<String,?> props, final InputStream src, final String destination); int copyFrom(String remote, String local); int copyFrom(final Map<String,?> props, final String remote, final String local); int installTo(String url, String destPath); int installTo(Map<String,?> props, String url, String destPath); int installTo(ResourceUtils loader, String url, String destPath); int installTo(ResourceUtils utils, Map<String,?> props, String url, String destPath); @Override String toString(); @Override String toVerboseString(); @Override boolean obtainSpecificPort(int portNumber); @Override int obtainPort(PortRange range); @Override void releasePort(int portNumber); boolean isSshable(); @Override OsDetails getOsDetails(); @Override MachineDetails getMachineDetails(); @Override void acquireMutex(String mutexId, String description); @Override boolean tryAcquireMutex(String mutexId, String description); @Override void releaseMutex(String mutexId); @Override boolean hasMutex(String mutexId); KeyPair findKeyPair(); String findPassword(); static final ConfigKey<String> SSH_TOOL_CLASS; static final String SSH_TOOL_CLASS_PROPERTIES_PREFIX; static final ConfigKey<Duration> SSH_CACHE_EXPIRY_DURATION; static final ConfigKey<MachineDetails> MACHINE_DETAILS; static final ConfigKey<Boolean> DETECT_MACHINE_DETAILS; static final ConfigKey<Iterable<String>> PRIVATE_ADDRESSES; static final ConfigKey<Map<Integer, String>> TCP_PORT_MAPPINGS; static final ConfigKey<String> SSH_HOST; static final ConfigKey<Integer> SSH_PORT; static final ConfigKey<String> SSH_EXECUTABLE; static final ConfigKey<String> SCP_EXECUTABLE; static final ConfigKey<String> PASSWORD; static final ConfigKey<String> PRIVATE_KEY_FILE; static final ConfigKey<String> PRIVATE_KEY_DATA; static final ConfigKey<String> PRIVATE_KEY_PASSPHRASE; static final ConfigKey<String> SCRIPT_DIR; static final ConfigKey<Map<String,Object>> SSH_ENV_MAP; static final ConfigKey<Boolean> ALLOCATE_PTY; static final ConfigKey<OutputStream> STDOUT; static final ConfigKey<OutputStream> STDERR; static final ConfigKey<Boolean> NO_STDOUT_LOGGING; static final ConfigKey<Boolean> NO_STDERR_LOGGING; static final ConfigKey<String> LOG_PREFIX; static final ConfigKey<String> LOCAL_TEMP_DIR; static final ConfigKey<Boolean> CLOSE_CONNECTION; static final ConfigKey<String> UNIQUE_ID; static final Set<ConfigKey<?>> REUSABLE_SSH_PROPS; static final Set<HasConfigKey<?>> ALL_SSH_CONFIG_KEYS; static final Set<String> ALL_SSH_CONFIG_KEY_NAMES; @Beta
    static final Set<ConfigKey<?>> SSH_CONFIG_GIVEN_TO_PROPS; }