1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fixes authorize method in ios shared module

The authorize method was calling run_commands() instead of execute().  This
fixes that problem so that authorize() calls are made direclty on the shell
object now
This commit is contained in:
Peter Sprygada 2016-08-31 07:24:07 -04:00
parent 1c33b5a9f0
commit 7fc46e8233

View file

@ -18,13 +18,14 @@
#
import re
import urlparse
from ansible.module_utils.basic import json
from ansible.module_utils.network import NetworkModule, NetworkError, ModuleStub
from ansible.module_utils.network import add_argument, register_transport, to_list
from ansible.module_utils.shell import CliBase
from ansible.module_utils.netcli import Command
from ansible.module_utils.urls import fetch_url, url_argument_spec, urlparse
from ansible.module_utils.urls import fetch_url, url_argument_spec
add_argument('use_ssl', dict(default=True, type='bool'))
add_argument('validate_certs', dict(default=True, type='bool'))
@ -56,18 +57,17 @@ class Cli(CliBase):
def authorize(self, params, **kwargs):
passwd = params['auth_pass']
self.run_commands(
Command('enable', prompt=self.NET_PASSWD_RE, response=passwd)
)
cmd = Command('enable', prompt=self.NET_PASSWD_RE, response=passwd)
self.execute([cmd])
### implementation of netcli.Cli ###
def run_commands(self, commands, **kwargs):
def run_commands(self, commands):
return self.execute(to_list(commands))
### implementation of netcfg.Config ###
def configure(self, commands, **kwargs):
def configure(self, commands):
cmds = ['configure terminal']
cmds.extend(to_list(commands))
if cmds[-1] != 'end':
@ -183,7 +183,8 @@ class Restconf(object):
def run_commands(self, commands):
responses = list()
for cmd in to_list(commands):
commands = [str(c) for c in commands]
for cmd in commands:
if str(cmd).startswith('show '):
cmd = str(cmd)[4:]
responses.append(self.execute(str(cmd)))