Rearranging some become stuff in relation to action/connection plugins

Moving the make_sudo_cmd() calls back up to the action level so that connection
plugins don't have to know about it at all, and moving some of the become data
(prompt and success_key) into the ConnectionInformation object so they don't
need to be passed around needlessly.
This commit is contained in:
James Cammarata 2015-06-24 12:12:54 -04:00
parent 7a9b5b6fe8
commit 1c185b68be
6 changed files with 25 additions and 20 deletions

View file

@ -118,7 +118,7 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
@ensure_connect
@abstractmethod
def exec_command(self, cmd, tmp_path, in_data=None, sudoable=True):
def exec_command(self, cmd, tmp_path, in_data=None, executable=None, sudoable=True):
"""Run a command on the remote host"""
pass
@ -140,15 +140,15 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
pass
def check_become_success(self, output):
return self.success_key in output
return self._connection_info.success_key in output
def check_password_prompt(self, output):
if self.prompt is None:
if self._connection_info.prompt is None:
return False
elif isinstance(self.prompt, basestring):
return output.endswith(self.prompt)
elif isinstance(self._connection_info.prompt, basestring):
return output.endswith(self._connection_info.prompt)
else:
return self.prompt(output)
return self._connection_info.prompt(output)
def check_incorrect_password(self, output):
incorrect_password = gettext.dgettext(self._connection_info.become_method, C.BECOME_ERROR_STRINGS[self._connection_info.become_method])