def WaitUntilSSHable(self, user, args, instance): """Blocks until SSHing to the given host succeeds.""" external_ip_address = GetExternalIPAddress(instance) ssh_args_for_polling = [self.ssh_executable] ssh_args_for_polling.extend(self.GetDefaultFlags()) ssh_args_for_polling.extend(self.GetHostKeyArgs(args, instance)) ssh_args_for_polling.append(UserHost(user, external_ip_address)) ssh_args_for_polling.append('true') ssh_args_for_polling = self.LocalizeCommand(ssh_args_for_polling) start_sec = time_utils.CurrentTimeSec() while True: logging.debug('polling instance for SSHability') retval = subprocess.call(ssh_args_for_polling) if retval == 0: break if (time_utils.CurrentTimeSec() - start_sec > _SSH_KEY_PROPAGATION_TIMEOUT_SEC): raise exceptions.ToolException( 'Could not SSH to the instance. It is possible that ' 'your SSH key has not propagated to the instance yet. ' 'Try running this command again. If you still cannot connect, ' 'verify that the firewall and instance are set to accept ' 'ssh traffic.') time_utils.Sleep(5)
def Execute(args): """Wraps an invocation of the docker client with the specified CLI arguments. Args: args: The list of command-line arguments to docker. Returns: The exit code from Docker. """ return subprocess.call( ['docker'] + args, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)