From 4a24d5d7831a414b224460db730c5eb7c2cdf69a Mon Sep 17 00:00:00 2001 From: Przemyslaw Kaminski Date: Fri, 15 May 2015 09:58:21 +0200 Subject: [PATCH] Fix SSH interactive mode Fabric is broken, use os.execvp like it was before. Change-Id: I59759618d3cbba907c931ddcf88cbb21045e4b4d --- fuel_dev_tools/shell.py | 1 + fuel_dev_tools/ssh.py | 31 +++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/fuel_dev_tools/shell.py b/fuel_dev_tools/shell.py index a9a37bf..9e48219 100644 --- a/fuel_dev_tools/shell.py +++ b/fuel_dev_tools/shell.py @@ -39,6 +39,7 @@ from fuel_dev_tools import ssh COMMANDS = { 'info': info.Info, + 'send-identity': ssh.SendIdentity, 'ssh': ssh.SSH, 'astute-id': astute.Id, diff --git a/fuel_dev_tools/ssh.py b/fuel_dev_tools/ssh.py index 9ee222f..4c1f601 100644 --- a/fuel_dev_tools/ssh.py +++ b/fuel_dev_tools/ssh.py @@ -12,10 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. +import os import six import subprocess import fabric +from fabric import context_managers from fabric import api as fabric_api from fuel_dev_tools import command @@ -99,14 +101,35 @@ class SSHMixin(object): def ssh_command_interactive(self, *args): self.print_debug("COMMAND: %r" % list(args)) - command = None + # NOTE: fabric's open_shell is broken: it's TERM or something like + # that that breaks arrow keys for browsing history in Bash, etc. + + #command = None + + #if args: + #command = ' '.join(args) + + #self.print_debug('interactive %s' % command) + + #fabric_api.open_shell(command=command) + + commands = [ + 'ssh', '-t', + '{}@{}'.format(self.app_args.user, self.app_args.ip), + '-p', self.app_args.port, + '-i', self.app_args.identity_file, + ] if args: - command = ' '.join(args) + commands.append('-C') + commands.extend(list(args)) - self.print_debug('interactive %s' % command) + os.execvp('ssh', commands) - fabric_api.open_shell(command=command) + +class SendIdentity(SSHMixin, command.BaseCommand): + def take_action(self, parsed_args): + self.send_identity() class SSH(SSHMixin, command.BaseCommand):