From 50c445c3561175718aefd6e7ab7afb6d98799f8d Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Sun, 2 Oct 2016 15:03:03 -0400 Subject: [PATCH] switches the kickstart arg from True to False for eos (#17858) The kickstart kwarg should be set to False for eos based devices and was set to True. This change cleans up problems loading json output from cli commands All eos_command test cases are now passing successfully fixes #17441 --- lib/ansible/module_utils/eos.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/lib/ansible/module_utils/eos.py b/lib/ansible/module_utils/eos.py index e17ea18e346..2569a321e38 100644 --- a/lib/ansible/module_utils/eos.py +++ b/lib/ansible/module_utils/eos.py @@ -268,26 +268,19 @@ class Cli(EosConfigMixin, CliBase): NET_PASSWD_RE = re.compile(r"[\r\n]?password: $", re.I) def connect(self, params, **kwargs): - super(Cli, self).connect(params, kickstart=True, **kwargs) + super(Cli, self).connect(params, kickstart=False, **kwargs) self.shell.send('terminal length 0') def authorize(self, params, **kwargs): passwd = params['auth_pass'] - self.execute(Command('enable', prompt=self.NET_PASSWD_RE, response=passwd)) + if passwd: + self.execute(Command('enable', prompt=self.NET_PASSWD_RE, response=passwd)) + else: + self.execute('enable') ### Command methods ### def run_commands(self, commands): - """execute the ordered set of commands on the remote host - - This method will take a list of Command objects, convert them - to a list of dict objects and execute them on the shell - connection. - - :param commands: list of Command objects - - :returns: set of ordered responses - """ cmds = list(prepare_commands(commands)) responses = self.execute(cmds) for index, cmd in enumerate(commands): @@ -297,7 +290,8 @@ class Cli(EosConfigMixin, CliBase): except ValueError: raise NetworkError( msg='unable to load response from device', - response=responses[index] + response=responses[index], + responses=responses ) return responses @@ -312,12 +306,6 @@ def prepare_config(commands): def prepare_commands(commands): - """ transforms a list of Command objects to dict - - :param commands: list of Command objects - - :returns: list of dict objects - """ jsonify = lambda x: '%s | json' % x for item in to_list(commands): if item.output == 'json':