예제 #1
0
 def _try_ping_host(self, verbose):
     if self._empty_state():
         raise remotelib.Down("not started")
     self._terraform_refresh()
     try:
         host = self._output("host")
     except LookupError:
         raise remotelib.Down("not running")
     else:
         if not host:
             raise remotelib.Down("stopped")
         ssh_util.ssh_ping(host, self.user, verbose)
         sys.stdout.write("%s (%s) is available\n" % (self.name, host))
예제 #2
0
def ssh_ping(host,
             user=None,
             verbose=False,
             connect_timeout=DEFAULT_CONNECT_TIMEOUT):
    host = _full_host(host, user)
    cmd = ["ssh"] + _ssh_opts(None, verbose, connect_timeout) + [host, "true"]
    result = subprocess.call(cmd)
    if result != 0:
        raise remotelib.Down("cannot reach host %s" % host)
예제 #3
0
 def status(self, verbose=False):
     self._verify_aws_creds()
     self._verify_terraform()
     if os.path.exists(self.working_dir):
         self._refresh_config()
     if not self._has_state():
         raise remotelib.Down("not started")
     if verbose:
         self._terraform_show()
     else:
         self._try_ping_host(verbose)
예제 #4
0
def ssh_ping(host,
             user=None,
             private_key=None,
             verbose=False,
             connect_timeout=DEFAULT_CONNECT_TIMEOUT,
             port=None):
    host = _full_host(host, user)
    opts = _ssh_opts(private_key, verbose, connect_timeout, port)
    cmd = ["ssh"] + opts + [host, "true"]
    log.debug("ssh cmd: %r", cmd)
    result = subprocess.call(cmd)
    if result != 0:
        raise remotelib.Down("cannot reach host %s" % host)