mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
removes filter attribute from asa
This removes the filter attribute from the asa shared module and moves the function to the asa_acl module where it was used.
This commit is contained in:
parent
4e325274d6
commit
c9d74e9a6e
1 changed files with 12 additions and 15 deletions
|
@ -30,36 +30,31 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from ansible.module_utils.network import NetworkError, NetworkModule
|
from ansible.module_utils.network import NetworkError, NetworkModule
|
||||||
from ansible.module_utils.network import add_argument, register_transport, to_list
|
from ansible.module_utils.network import add_argument, register_transport
|
||||||
|
from ansible.module_utils.network import 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
|
||||||
|
|
||||||
add_argument('show_command', dict(default='show running-config', choices=['show running-config', 'more system:running-config']))
|
add_argument('show_command', dict(default='show running-config',
|
||||||
|
choices=['show running-config', 'more system:running-config']))
|
||||||
add_argument('context', dict(required=False))
|
add_argument('context', dict(required=False))
|
||||||
|
|
||||||
|
|
||||||
class Cli(CliBase):
|
class Cli(CliBase):
|
||||||
|
|
||||||
CLI_PROMPTS_RE = [
|
CLI_PROMPTS_RE = [
|
||||||
re.compile(r"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"),
|
re.compile(r"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"),
|
||||||
re.compile(r"\[\w+\@[\w\-\.]+(?: [^\]])\] ?[>#\$] ?$")
|
re.compile(r"\[\w+\@[\w\-\.]+(?: [^\]])\] ?[>#\$] ?$")
|
||||||
]
|
]
|
||||||
|
|
||||||
CLI_ERRORS_RE = [
|
CLI_ERRORS_RE = [
|
||||||
re.compile(r"% ?Error"),
|
re.compile(r"error:", re.I),
|
||||||
re.compile(r"% ?Bad secret"),
|
|
||||||
re.compile(r"invalid input", re.I),
|
|
||||||
re.compile(r"is not valid", re.I),
|
|
||||||
re.compile(r"(?:incomplete|ambiguous) command", re.I),
|
|
||||||
re.compile(r"connection timed out", re.I),
|
|
||||||
re.compile(r"[^\r\n]+ not found", re.I),
|
|
||||||
re.compile(r"'[^']' +returned error code: ?\d+"),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
NET_PASSWD_RE = re.compile(r"[\r\n]?password: $", re.I)
|
NET_PASSWD_RE = re.compile(r"[\r\n]?password: $", re.I)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Cli, self).__init__(*args, **kwargs)
|
super(Cli, self).__init__(*args, **kwargs)
|
||||||
self.filter = None
|
|
||||||
|
|
||||||
def connect(self, params, **kwargs):
|
def connect(self, params, **kwargs):
|
||||||
super(Cli, self).connect(params, kickstart=False, **kwargs)
|
super(Cli, self).connect(params, kickstart=False, **kwargs)
|
||||||
|
@ -72,7 +67,7 @@ class Cli(CliBase):
|
||||||
cmd = Command('enable', prompt=self.NET_PASSWD_RE, response=passwd)
|
cmd = Command('enable', prompt=self.NET_PASSWD_RE, response=passwd)
|
||||||
self.execute([cmd, 'no terminal pager'])
|
self.execute([cmd, 'no terminal pager'])
|
||||||
|
|
||||||
def change_context(self, params, **kwargs):
|
def change_context(self, params):
|
||||||
context = params['context']
|
context = params['context']
|
||||||
if context == 'system':
|
if context == 'system':
|
||||||
command = 'changeto system'
|
command = 'changeto system'
|
||||||
|
@ -86,18 +81,20 @@ class Cli(CliBase):
|
||||||
def configure(self, commands):
|
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] == 'exit':
|
||||||
|
cmds[-1] = 'end'
|
||||||
|
elif cmds[-1] != 'end':
|
||||||
cmds.append('end')
|
cmds.append('end')
|
||||||
responses = self.execute(cmds)
|
responses = self.execute(cmds)
|
||||||
return responses[1:]
|
return responses[1:]
|
||||||
|
|
||||||
def get_config(self, include_defaults=False, **kwargs):
|
def get_config(self, include_defaults=False):
|
||||||
cmd = 'show running-config'
|
cmd = 'show running-config'
|
||||||
if include_defaults:
|
if include_defaults:
|
||||||
cmd += ' all'
|
cmd += ' all'
|
||||||
return self.run_commands(cmd)[0]
|
return self.run_commands(cmd)[0]
|
||||||
|
|
||||||
def load_config(self, commands, **kwargs):
|
def load_config(self, commands):
|
||||||
return self.configure(commands)
|
return self.configure(commands)
|
||||||
|
|
||||||
def save_config(self):
|
def save_config(self):
|
||||||
|
|
Loading…
Reference in a new issue