mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #17321 from privateip/ios
fixes authorize method in ios shared module
This commit is contained in:
commit
539d13a2cc
1 changed files with 8 additions and 7 deletions
|
@ -18,13 +18,14 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import urlparse
|
||||||
|
|
||||||
from ansible.module_utils.basic import json
|
from ansible.module_utils.basic import json
|
||||||
from ansible.module_utils.network import NetworkModule, NetworkError, ModuleStub
|
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.network import add_argument, register_transport, to_list
|
||||||
from ansible.module_utils.shell import CliBase
|
from ansible.module_utils.shell import CliBase
|
||||||
from ansible.module_utils.netcli import Command
|
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('use_ssl', dict(default=True, type='bool'))
|
||||||
add_argument('validate_certs', 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):
|
def authorize(self, params, **kwargs):
|
||||||
passwd = params['auth_pass']
|
passwd = params['auth_pass']
|
||||||
self.run_commands(
|
cmd = Command('enable', prompt=self.NET_PASSWD_RE, response=passwd)
|
||||||
Command('enable', prompt=self.NET_PASSWD_RE, response=passwd)
|
self.execute([cmd])
|
||||||
)
|
|
||||||
|
|
||||||
### implementation of netcli.Cli ###
|
### implementation of netcli.Cli ###
|
||||||
|
|
||||||
def run_commands(self, commands, **kwargs):
|
def run_commands(self, commands):
|
||||||
return self.execute(to_list(commands))
|
return self.execute(to_list(commands))
|
||||||
|
|
||||||
### implementation of netcfg.Config ###
|
### implementation of netcfg.Config ###
|
||||||
|
|
||||||
def configure(self, commands, **kwargs):
|
def configure(self, commands):
|
||||||
cmds = ['configure terminal']
|
cmds = ['configure terminal']
|
||||||
cmds.extend(to_list(commands))
|
cmds.extend(to_list(commands))
|
||||||
if cmds[-1] != 'end':
|
if cmds[-1] != 'end':
|
||||||
|
@ -183,7 +183,8 @@ class Restconf(object):
|
||||||
|
|
||||||
def run_commands(self, commands):
|
def run_commands(self, commands):
|
||||||
responses = list()
|
responses = list()
|
||||||
for cmd in to_list(commands):
|
commands = [str(c) for c in commands]
|
||||||
|
for cmd in commands:
|
||||||
if str(cmd).startswith('show '):
|
if str(cmd).startswith('show '):
|
||||||
cmd = str(cmd)[4:]
|
cmd = str(cmd)[4:]
|
||||||
responses.append(self.execute(str(cmd)))
|
responses.append(self.execute(str(cmd)))
|
||||||
|
|
Loading…
Reference in a new issue