mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix anomalous backslashes and enable pylint test.
This commit is contained in:
parent
9735a70059
commit
c6bb6c72cc
30 changed files with 76 additions and 77 deletions
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
'supported_by': 'community'}
|
'supported_by': 'community'}
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: cl_bond
|
module: cl_bond
|
||||||
version_added: "2.1"
|
version_added: "2.1"
|
||||||
|
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
'supported_by': 'community'}
|
'supported_by': 'community'}
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: cl_bridge
|
module: cl_bridge
|
||||||
version_added: "2.1"
|
version_added: "2.1"
|
||||||
|
|
|
@ -181,7 +181,7 @@ def check_fw_print_env(module, slot_num):
|
||||||
cmd = "/usr/bin/grub-editenv list"
|
cmd = "/usr/bin/grub-editenv list"
|
||||||
grub_output = run_cl_cmd(module, cmd)
|
grub_output = run_cl_cmd(module, cmd)
|
||||||
for _line in grub_output:
|
for _line in grub_output:
|
||||||
_regex_str = re.compile('cl.ver' + slot_num + '=([\w.]+)-')
|
_regex_str = re.compile('cl.ver' + slot_num + r'=([\w.]+)-')
|
||||||
m0 = re.match(_regex_str, _line)
|
m0 = re.match(_regex_str, _line)
|
||||||
if m0:
|
if m0:
|
||||||
return m0.group(1)
|
return m0.group(1)
|
||||||
|
@ -197,7 +197,7 @@ def get_primary_slot_num(module):
|
||||||
cmd = "/usr/bin/grub-editenv list"
|
cmd = "/usr/bin/grub-editenv list"
|
||||||
grub_output = run_cl_cmd(module, cmd)
|
grub_output = run_cl_cmd(module, cmd)
|
||||||
for _line in grub_output:
|
for _line in grub_output:
|
||||||
_regex_str = re.compile('cl.active=(\d)')
|
_regex_str = re.compile(r'cl.active=(\d)')
|
||||||
m0 = re.match(_regex_str, _line)
|
m0 = re.match(_regex_str, _line)
|
||||||
if m0:
|
if m0:
|
||||||
return m0.group(1)
|
return m0.group(1)
|
||||||
|
@ -210,7 +210,7 @@ def get_active_slot(module):
|
||||||
module.fail_json(msg='Failed to open /proc/cmdline. ' +
|
module.fail_json(msg='Failed to open /proc/cmdline. ' +
|
||||||
'Unable to determine active slot')
|
'Unable to determine active slot')
|
||||||
|
|
||||||
_match = re.search('active=(\d+)', cmdline)
|
_match = re.search(r'active=(\d+)', cmdline)
|
||||||
if _match:
|
if _match:
|
||||||
return _match.group(1)
|
return _match.group(1)
|
||||||
return None
|
return None
|
||||||
|
@ -247,9 +247,9 @@ def determine_sw_version(module):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
_filename = module.params.get('src').split('/')[-1]
|
_filename = module.params.get('src').split('/')[-1]
|
||||||
_match = re.search('\d+\W\d+\W\w+', _filename)
|
_match = re.search(r'\d+\W\d+\W\w+', _filename)
|
||||||
if _match:
|
if _match:
|
||||||
module.sw_version = re.sub('\W', '.', _match.group())
|
module.sw_version = re.sub(r'\W', '.', _match.group())
|
||||||
return
|
return
|
||||||
_msg = 'Unable to determine version from file %s' % (_filename)
|
_msg = 'Unable to determine version from file %s' % (_filename)
|
||||||
module.exit_json(changed=False, msg=_msg)
|
module.exit_json(changed=False, msg=_msg)
|
||||||
|
|
|
@ -13,7 +13,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||||
'supported_by': 'community'}
|
'supported_by': 'community'}
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = '''
|
DOCUMENTATION = r'''
|
||||||
---
|
---
|
||||||
module: cl_interface
|
module: cl_interface
|
||||||
version_added: "2.1"
|
version_added: "2.1"
|
||||||
|
|
|
@ -185,7 +185,7 @@ class Hardware(FactsBase):
|
||||||
def populate(self):
|
def populate(self):
|
||||||
super(Hardware, self).populate()
|
super(Hardware, self).populate()
|
||||||
data = self.responses[0]
|
data = self.responses[0]
|
||||||
match = re.findall('\s(\d+)\s', data)
|
match = re.findall(r'\s(\d+)\s', data)
|
||||||
if match:
|
if match:
|
||||||
self.facts['memtotal_mb'] = int(match[0]) // 1024
|
self.facts['memtotal_mb'] = int(match[0]) // 1024
|
||||||
self.facts['memfree_mb'] = int(match[1]) // 1024
|
self.facts['memfree_mb'] = int(match[1]) // 1024
|
||||||
|
@ -231,12 +231,12 @@ class Interfaces(FactsBase):
|
||||||
for en in vlan_info_next.splitlines():
|
for en in vlan_info_next.splitlines():
|
||||||
if en == '':
|
if en == '':
|
||||||
continue
|
continue
|
||||||
match = re.search('^(\S+)\s+(\S+)\s+(\S+)', en)
|
match = re.search(r'^(\S+)\s+(\S+)\s+(\S+)', en)
|
||||||
intf = match.group(1)
|
intf = match.group(1)
|
||||||
if intf not in facts:
|
if intf not in facts:
|
||||||
facts[intf] = list()
|
facts[intf] = list()
|
||||||
fact = dict()
|
fact = dict()
|
||||||
matc = re.search('^([\w+\s\d]*)\s+(\S+)\s+(\S+)', en)
|
matc = re.search(r'^([\w+\s\d]*)\s+(\S+)\s+(\S+)', en)
|
||||||
fact['address'] = matc.group(2)
|
fact['address'] = matc.group(2)
|
||||||
fact['masklen'] = matc.group(3)
|
fact['masklen'] = matc.group(3)
|
||||||
facts[intf].append(fact)
|
facts[intf].append(fact)
|
||||||
|
@ -299,7 +299,7 @@ class Interfaces(FactsBase):
|
||||||
desc_val, desc_info = desc_next.split('Port')
|
desc_val, desc_info = desc_next.split('Port')
|
||||||
for en in desc_val.splitlines():
|
for en in desc_val.splitlines():
|
||||||
if key in en:
|
if key in en:
|
||||||
match = re.search('^(\S+)\s+(\S+)', en)
|
match = re.search(r'^(\S+)\s+(\S+)', en)
|
||||||
if match.group(2) in ['Full', 'N/A']:
|
if match.group(2) in ['Full', 'N/A']:
|
||||||
return "Null"
|
return "Null"
|
||||||
else:
|
else:
|
||||||
|
@ -331,7 +331,7 @@ class Interfaces(FactsBase):
|
||||||
for en in mediatype_next.splitlines():
|
for en in mediatype_next.splitlines():
|
||||||
if key in en:
|
if key in en:
|
||||||
flag = 0
|
flag = 0
|
||||||
match = re.search('^(\S+)\s+(\S+)\s+(\S+)', en)
|
match = re.search(r'^(\S+)\s+(\S+)\s+(\S+)', en)
|
||||||
if match:
|
if match:
|
||||||
strval = match.group(3)
|
strval = match.group(3)
|
||||||
return strval
|
return strval
|
||||||
|
@ -344,7 +344,7 @@ class Interfaces(FactsBase):
|
||||||
for en in type_val_next.splitlines():
|
for en in type_val_next.splitlines():
|
||||||
if key in en:
|
if key in en:
|
||||||
flag = 0
|
flag = 0
|
||||||
match = re.search('^(\S+)\s+(\S+)\s+(\S+)', en)
|
match = re.search(r'^(\S+)\s+(\S+)\s+(\S+)', en)
|
||||||
if match:
|
if match:
|
||||||
strval = match.group(2)
|
strval = match.group(2)
|
||||||
return strval
|
return strval
|
||||||
|
|
|
@ -215,7 +215,7 @@ class Hardware(FactsBase):
|
||||||
self.facts['filesystems'] = self.parse_filesystems(data)
|
self.facts['filesystems'] = self.parse_filesystems(data)
|
||||||
|
|
||||||
data = self.responses[1]
|
data = self.responses[1]
|
||||||
match = re.findall('\s(\d+)\s', data)
|
match = re.findall(r'\s(\d+)\s', data)
|
||||||
if match:
|
if match:
|
||||||
self.facts['memtotal_mb'] = int(match[0]) // 1024
|
self.facts['memtotal_mb'] = int(match[0]) // 1024
|
||||||
self.facts['memfree_mb'] = int(match[2]) // 1024
|
self.facts['memfree_mb'] = int(match[2]) // 1024
|
||||||
|
|
|
@ -208,7 +208,7 @@ def validate_local_http_port(value, module):
|
||||||
|
|
||||||
def validate_vrf(value, module):
|
def validate_vrf(value, module):
|
||||||
out = run_commands(module, ['show vrf'])
|
out = run_commands(module, ['show vrf'])
|
||||||
configured_vrfs = re.findall('^\s+(\w+)(?=\s)', out[0], re.M)
|
configured_vrfs = re.findall(r'^\s+(\w+)(?=\s)', out[0], re.M)
|
||||||
configured_vrfs.append('default')
|
configured_vrfs.append('default')
|
||||||
if value not in configured_vrfs:
|
if value not in configured_vrfs:
|
||||||
module.fail_json(msg='vrf `%s` is not configured on the system' % value)
|
module.fail_json(msg='vrf `%s` is not configured on the system' % value)
|
||||||
|
|
|
@ -140,7 +140,7 @@ def has_vrf(module, vrf):
|
||||||
if _CONFIGURED_VRFS is not None:
|
if _CONFIGURED_VRFS is not None:
|
||||||
return vrf in _CONFIGURED_VRFS
|
return vrf in _CONFIGURED_VRFS
|
||||||
config = get_config(module)
|
config = get_config(module)
|
||||||
_CONFIGURED_VRFS = re.findall('vrf definition (\S+)', config)
|
_CONFIGURED_VRFS = re.findall(r'vrf definition (\S+)', config)
|
||||||
_CONFIGURED_VRFS.append('default')
|
_CONFIGURED_VRFS.append('default')
|
||||||
return vrf in _CONFIGURED_VRFS
|
return vrf in _CONFIGURED_VRFS
|
||||||
|
|
||||||
|
@ -223,18 +223,18 @@ def map_obj_to_commands(want, have, module):
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
def parse_hostname(config):
|
def parse_hostname(config):
|
||||||
match = re.search('^hostname (\S+)', config, re.M)
|
match = re.search(r'^hostname (\S+)', config, re.M)
|
||||||
if match:
|
if match:
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
|
|
||||||
def parse_domain_name(config):
|
def parse_domain_name(config):
|
||||||
match = re.search('^ip domain-name (\S+)', config, re.M)
|
match = re.search(r'^ip domain-name (\S+)', config, re.M)
|
||||||
if match:
|
if match:
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
|
|
||||||
def parse_lookup_source(config):
|
def parse_lookup_source(config):
|
||||||
objects = list()
|
objects = list()
|
||||||
regex = 'ip domain lookup (?:vrf (\S+) )*source-interface (\S+)'
|
regex = r'ip domain lookup (?:vrf (\S+) )*source-interface (\S+)'
|
||||||
for vrf, intf in re.findall(regex, config, re.M):
|
for vrf, intf in re.findall(regex, config, re.M):
|
||||||
if len(vrf) == 0:
|
if len(vrf) == 0:
|
||||||
vrf= None
|
vrf= None
|
||||||
|
@ -243,7 +243,7 @@ def parse_lookup_source(config):
|
||||||
|
|
||||||
def parse_name_servers(config):
|
def parse_name_servers(config):
|
||||||
objects = list()
|
objects = list()
|
||||||
for vrf, addr in re.findall('ip name-server vrf (\S+) (\S+)', config, re.M):
|
for vrf, addr in re.findall(r'ip name-server vrf (\S+) (\S+)', config, re.M):
|
||||||
objects.append({'server': addr, 'vrf': vrf})
|
objects.append({'server': addr, 'vrf': vrf})
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ def map_config_to_obj(module):
|
||||||
return {
|
return {
|
||||||
'hostname': parse_hostname(config),
|
'hostname': parse_hostname(config),
|
||||||
'domain_name': parse_domain_name(config),
|
'domain_name': parse_domain_name(config),
|
||||||
'domain_list': re.findall('^ip domain-list (\S+)', config, re.M),
|
'domain_list': re.findall(r'^ip domain-list (\S+)', config, re.M),
|
||||||
'lookup_source': parse_lookup_source(config),
|
'lookup_source': parse_lookup_source(config),
|
||||||
'name_servers': parse_name_servers(config)
|
'name_servers': parse_name_servers(config)
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,7 +451,7 @@ class ApiParameters(Parameters):
|
||||||
|
|
||||||
@address.setter
|
@address.setter
|
||||||
def address(self, value):
|
def address(self, value):
|
||||||
pattern = '^(?P<ip>[0-9A-Fa-f:.]+)%?(?P<rd>\d+)?\/(?P<nm>\d+)$'
|
pattern = r'^(?P<ip>[0-9A-Fa-f:.]+)%?(?P<rd>\d+)?\/(?P<nm>\d+)$'
|
||||||
matches = re.match(pattern, value)
|
matches = re.match(pattern, value)
|
||||||
if not matches:
|
if not matches:
|
||||||
raise F5ModuleError(
|
raise F5ModuleError(
|
||||||
|
|
|
@ -123,7 +123,7 @@ def map_config_to_obj(module):
|
||||||
'show running-config | begin banner %s'
|
'show running-config | begin banner %s'
|
||||||
% module.params['banner'])
|
% module.params['banner'])
|
||||||
if out:
|
if out:
|
||||||
output = re.search('\^C(.*)\^C', out, re.S).group(1).strip()
|
output = re.search(r'\^C(.*)\^C', out, re.S).group(1).strip()
|
||||||
else:
|
else:
|
||||||
output = None
|
output = None
|
||||||
obj = {'banner': module.params['banner'], 'state': 'absent'}
|
obj = {'banner': module.params['banner'], 'state': 'absent'}
|
||||||
|
|
|
@ -188,8 +188,8 @@ def parse_ping(ping_stats):
|
||||||
Example: "Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/8 ms"
|
Example: "Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/8 ms"
|
||||||
Returns the percent of packet loss, recieved packets, transmitted packets, and RTT dict.
|
Returns the percent of packet loss, recieved packets, transmitted packets, and RTT dict.
|
||||||
"""
|
"""
|
||||||
rate_re = re.compile("^\w+\s+\w+\s+\w+\s+(?P<pct>\d+)\s+\w+\s+\((?P<rx>\d+)\/(?P<tx>\d+)\)")
|
rate_re = re.compile(r"^\w+\s+\w+\s+\w+\s+(?P<pct>\d+)\s+\w+\s+\((?P<rx>\d+)/(?P<tx>\d+)\)")
|
||||||
rtt_re = re.compile(".*,\s+\S+\s+\S+\s+=\s+(?P<min>\d+)\/(?P<avg>\d+)\/(?P<max>\d+)\s+\w+\s*$|.*\s*$")
|
rtt_re = re.compile(r".*,\s+\S+\s+\S+\s+=\s+(?P<min>\d+)/(?P<avg>\d+)/(?P<max>\d+)\s+\w+\s*$|.*\s*$")
|
||||||
|
|
||||||
rate = rate_re.match(ping_stats)
|
rate = rate_re.match(ping_stats)
|
||||||
rtt = rtt_re.match(ping_stats)
|
rtt = rtt_re.match(ping_stats)
|
||||||
|
|
|
@ -130,7 +130,7 @@ def has_vrf(module, vrf):
|
||||||
if _CONFIGURED_VRFS is not None:
|
if _CONFIGURED_VRFS is not None:
|
||||||
return vrf in _CONFIGURED_VRFS
|
return vrf in _CONFIGURED_VRFS
|
||||||
config = get_config(module)
|
config = get_config(module)
|
||||||
_CONFIGURED_VRFS = re.findall('vrf definition (\S+)', config)
|
_CONFIGURED_VRFS = re.findall(r'vrf definition (\S+)', config)
|
||||||
return vrf in _CONFIGURED_VRFS
|
return vrf in _CONFIGURED_VRFS
|
||||||
|
|
||||||
def requires_vrf(module, vrf):
|
def requires_vrf(module, vrf):
|
||||||
|
@ -244,11 +244,11 @@ def map_obj_to_commands(want, have, module):
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
def parse_hostname(config):
|
def parse_hostname(config):
|
||||||
match = re.search('^hostname (\S+)', config, re.M)
|
match = re.search(r'^hostname (\S+)', config, re.M)
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
|
|
||||||
def parse_domain_name(config):
|
def parse_domain_name(config):
|
||||||
match = re.findall('^ip domain name (?:vrf (\S+) )*(\S+)', config, re.M)
|
match = re.findall(r'^ip domain name (?:vrf (\S+) )*(\S+)', config, re.M)
|
||||||
matches = list()
|
matches = list()
|
||||||
for vrf, name in match:
|
for vrf, name in match:
|
||||||
if not vrf:
|
if not vrf:
|
||||||
|
@ -257,7 +257,7 @@ def parse_domain_name(config):
|
||||||
return matches
|
return matches
|
||||||
|
|
||||||
def parse_domain_search(config):
|
def parse_domain_search(config):
|
||||||
match = re.findall('^ip domain list (?:vrf (\S+) )*(\S+)', config, re.M)
|
match = re.findall(r'^ip domain list (?:vrf (\S+) )*(\S+)', config, re.M)
|
||||||
matches = list()
|
matches = list()
|
||||||
for vrf, name in match:
|
for vrf, name in match:
|
||||||
if not vrf:
|
if not vrf:
|
||||||
|
@ -266,7 +266,7 @@ def parse_domain_search(config):
|
||||||
return matches
|
return matches
|
||||||
|
|
||||||
def parse_name_servers(config):
|
def parse_name_servers(config):
|
||||||
match = re.findall('^ip name-server (?:vrf (\S+) )*(.*)', config, re.M)
|
match = re.findall(r'^ip name-server (?:vrf (\S+) )*(.*)', config, re.M)
|
||||||
matches = list()
|
matches = list()
|
||||||
for vrf, servers in match:
|
for vrf, servers in match:
|
||||||
if not vrf:
|
if not vrf:
|
||||||
|
@ -276,7 +276,7 @@ def parse_name_servers(config):
|
||||||
return matches
|
return matches
|
||||||
|
|
||||||
def parse_lookup_source(config):
|
def parse_lookup_source(config):
|
||||||
match = re.search('ip domain lookup source-interface (\S+)', config, re.M)
|
match = re.search(r'ip domain lookup source-interface (\S+)', config, re.M)
|
||||||
if match:
|
if match:
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
|
|
||||||
|
|
|
@ -168,16 +168,16 @@ def map_obj_to_commands(want, have, module):
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
def parse_hostname(config):
|
def parse_hostname(config):
|
||||||
match = re.search('^hostname (\S+)', config, re.M)
|
match = re.search(r'^hostname (\S+)', config, re.M)
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
|
|
||||||
def parse_domain_name(config):
|
def parse_domain_name(config):
|
||||||
match = re.search('^domain name (\S+)', config, re.M)
|
match = re.search(r'^domain name (\S+)', config, re.M)
|
||||||
if match:
|
if match:
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
|
|
||||||
def parse_lookup_source(config):
|
def parse_lookup_source(config):
|
||||||
match = re.search('^domain lookup source-interface (\S+)', config, re.M)
|
match = re.search(r'^domain lookup source-interface (\S+)', config, re.M)
|
||||||
if match:
|
if match:
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
|
|
||||||
|
@ -186,10 +186,10 @@ def map_config_to_obj(module):
|
||||||
return {
|
return {
|
||||||
'hostname': parse_hostname(config),
|
'hostname': parse_hostname(config),
|
||||||
'domain_name': parse_domain_name(config),
|
'domain_name': parse_domain_name(config),
|
||||||
'domain_search': re.findall('^domain list (\S+)', config, re.M),
|
'domain_search': re.findall(r'^domain list (\S+)', config, re.M),
|
||||||
'lookup_source': parse_lookup_source(config),
|
'lookup_source': parse_lookup_source(config),
|
||||||
'lookup_enabled': 'domain lookup disable' not in config,
|
'lookup_enabled': 'domain lookup disable' not in config,
|
||||||
'name_servers': re.findall('^domain name-server (\S+)', config, re.M)
|
'name_servers': re.findall(r'^domain name-server (\S+)', config, re.M)
|
||||||
}
|
}
|
||||||
|
|
||||||
def map_params_to_obj(module):
|
def map_params_to_obj(module):
|
||||||
|
|
|
@ -418,7 +418,7 @@ class MPLS(FactsBase):
|
||||||
path['up'] = True if match.group(1) == 'UP' else False
|
path['up'] = True if match.group(1) == 'UP' else False
|
||||||
path['name'] = None
|
path['name'] = None
|
||||||
if path['up']:
|
if path['up']:
|
||||||
match = re.search('bypass_lsp: (\S)', data, re.M)
|
match = re.search(r'bypass_lsp: (\S)', data, re.M)
|
||||||
path['name'] = match.group(1) if match else None
|
path['name'] = match.group(1) if match else None
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ def get_aaa_server_info(server_type, module):
|
||||||
server_command = 'show {0}-server'.format(server_type)
|
server_command = 'show {0}-server'.format(server_type)
|
||||||
request_command = 'show {0}-server directed-request'.format(server_type)
|
request_command = 'show {0}-server directed-request'.format(server_type)
|
||||||
global_key_command = 'show run | sec {0}'.format(server_type)
|
global_key_command = 'show run | sec {0}'.format(server_type)
|
||||||
aaa_regex = '.*{0}-server\skey\s\d\s+(?P<key>\S+).*'.format(server_type)
|
aaa_regex = r'.*{0}-server\skey\s\d\s+(?P<key>\S+).*'.format(server_type)
|
||||||
|
|
||||||
server_body = execute_show_command(
|
server_body = execute_show_command(
|
||||||
server_command, module, command_type='cli_show_ascii')[0]
|
server_command, module, command_type='cli_show_ascii')[0]
|
||||||
|
|
|
@ -211,8 +211,8 @@ def get_aaa_host_info(module, server_type, address):
|
||||||
|
|
||||||
if body[0]:
|
if body[0]:
|
||||||
try:
|
try:
|
||||||
pattern = ('(acct-port \d+)|(timeout \d+)|(auth-port \d+)|'
|
pattern = (r'(acct-port \d+)|(timeout \d+)|(auth-port \d+)|'
|
||||||
'(key 7 "\w+")|( port \d+)')
|
r'(key 7 "\w+")|( port \d+)')
|
||||||
raw_match = re.findall(pattern, body[0])
|
raw_match = re.findall(pattern, body[0])
|
||||||
aaa_host_info = _match_dict(raw_match, {'acct-port': 'acct_port',
|
aaa_host_info = _match_dict(raw_match, {'acct-port': 'acct_port',
|
||||||
'auth-port': 'auth_port',
|
'auth-port': 'auth_port',
|
||||||
|
|
|
@ -87,7 +87,7 @@ def check_args(module, warnings):
|
||||||
|
|
||||||
def get_available_features(feature, module):
|
def get_available_features(feature, module):
|
||||||
available_features = {}
|
available_features = {}
|
||||||
feature_regex = '(?P<feature>\S+)\s+\d+\s+(?P<state>.*)'
|
feature_regex = r'(?P<feature>\S+)\s+\d+\s+(?P<state>.*)'
|
||||||
command = {'command': 'show feature', 'output': 'text'}
|
command = {'command': 'show feature', 'output': 'text'}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -358,11 +358,11 @@ def get_igmp_interface(module, interface):
|
||||||
staticoif = []
|
staticoif = []
|
||||||
if body:
|
if body:
|
||||||
split_body = body.split('\n')
|
split_body = body.split('\n')
|
||||||
route_map_regex = ('.*ip igmp static-oif route-map\s+'
|
route_map_regex = (r'.*ip igmp static-oif route-map\s+'
|
||||||
'(?P<route_map>\S+).*')
|
r'(?P<route_map>\S+).*')
|
||||||
prefix_source_regex = ('.*ip igmp static-oif\s+(?P<prefix>'
|
prefix_source_regex = (r'.*ip igmp static-oif\s+(?P<prefix>'
|
||||||
'((\d+.){3}\d+))(\ssource\s'
|
r'((\d+.){3}\d+))(\ssource\s'
|
||||||
'(?P<source>\S+))?.*')
|
r'(?P<source>\S+))?.*')
|
||||||
|
|
||||||
for line in split_body:
|
for line in split_body:
|
||||||
temp = {}
|
temp = {}
|
||||||
|
|
|
@ -306,9 +306,9 @@ def parse_unstructured_data(body, interface_name, version, module):
|
||||||
else:
|
else:
|
||||||
for index in range(0, len(splitted_body) - 1):
|
for index in range(0, len(splitted_body) - 1):
|
||||||
if "IP address" in splitted_body[index]:
|
if "IP address" in splitted_body[index]:
|
||||||
regex = '.*IP\saddress:\s(?P<addr>\d{1,3}(?:\.\d{1,3}){3}),\sIP\ssubnet:' + \
|
regex = r'.*IP\saddress:\s(?P<addr>\d{1,3}(?:\.\d{1,3}){3}),\sIP\ssubnet:' + \
|
||||||
'\s\d{1,3}(?:\.\d{1,3}){3}\/(?P<mask>\d+)(?:\s(?P<secondary>secondary)\s)?' + \
|
r'\s\d{1,3}(?:\.\d{1,3}){3}\/(?P<mask>\d+)(?:\s(?P<secondary>secondary)\s)?' + \
|
||||||
'(.+?tag:\s(?P<tag>\d+).*)?'
|
r'(.+?tag:\s(?P<tag>\d+).*)?'
|
||||||
match = re.match(regex, splitted_body[index])
|
match = re.match(regex, splitted_body[index])
|
||||||
if match:
|
if match:
|
||||||
match_dict = match.groupdict()
|
match_dict = match.groupdict()
|
||||||
|
@ -325,7 +325,7 @@ def parse_unstructured_data(body, interface_name, version, module):
|
||||||
interface['prefixes'].append(prefix)
|
interface['prefixes'].append(prefix)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
vrf_regex = '.+?VRF\s+(?P<vrf>\S+?)\s'
|
vrf_regex = r'.+?VRF\s+(?P<vrf>\S+?)\s'
|
||||||
match_vrf = re.match(vrf_regex, body, re.DOTALL)
|
match_vrf = re.match(vrf_regex, body, re.DOTALL)
|
||||||
vrf = match_vrf.groupdict()['vrf']
|
vrf = match_vrf.groupdict()['vrf']
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -344,7 +344,7 @@ def parse_interface_data(body):
|
||||||
|
|
||||||
for index in range(0, len(splitted_body) - 1):
|
for index in range(0, len(splitted_body) - 1):
|
||||||
if "Encapsulation 802.1Q" in splitted_body[index]:
|
if "Encapsulation 802.1Q" in splitted_body[index]:
|
||||||
regex = '(.+?ID\s(?P<dot1q>\d+).*)?'
|
regex = r'(.+?ID\s(?P<dot1q>\d+).*)?'
|
||||||
match = re.match(regex, splitted_body[index])
|
match = re.match(regex, splitted_body[index])
|
||||||
if match:
|
if match:
|
||||||
match_dict = match.groupdict()
|
match_dict = match.groupdict()
|
||||||
|
|
|
@ -179,9 +179,9 @@ def get_ntp_peer(module):
|
||||||
ntp = response
|
ntp = response
|
||||||
if ntp:
|
if ntp:
|
||||||
ntp_regex = (
|
ntp_regex = (
|
||||||
".*ntp\s(server\s(?P<address>\S+)|peer\s(?P<peer_address>\S+))"
|
r".*ntp\s(server\s(?P<address>\S+)|peer\s(?P<peer_address>\S+))"
|
||||||
"\s*((?P<prefer>prefer)\s*)?(use-vrf\s(?P<vrf_name>\S+)\s*)?"
|
r"\s*((?P<prefer>prefer)\s*)?(use-vrf\s(?P<vrf_name>\S+)\s*)?"
|
||||||
"(key\s(?P<key_id>\d+))?.*"
|
r"(key\s(?P<key_id>\d+))?.*"
|
||||||
)
|
)
|
||||||
|
|
||||||
split_ntp = ntp.splitlines()
|
split_ntp = ntp.splitlines()
|
||||||
|
|
|
@ -161,8 +161,8 @@ def get_ntp_trusted_key(module):
|
||||||
def get_ntp_auth_key(key_id, module):
|
def get_ntp_auth_key(key_id, module):
|
||||||
authentication_key = {}
|
authentication_key = {}
|
||||||
command = 'show run | inc ntp.authentication-key.{0}'.format(key_id)
|
command = 'show run | inc ntp.authentication-key.{0}'.format(key_id)
|
||||||
auth_regex = (".*ntp\sauthentication-key\s(?P<key_id>\d+)\s"
|
auth_regex = (r".*ntp\sauthentication-key\s(?P<key_id>\d+)\s"
|
||||||
"md5\s(?P<md5string>\S+).*")
|
r"md5\s(?P<md5string>\S+).*")
|
||||||
|
|
||||||
body = execute_show_command(command, module)[0]
|
body = execute_show_command(command, module)[0]
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ def get_current(module):
|
||||||
output = run_commands(module, ({'command': cmd[0], 'output': 'text'},
|
output = run_commands(module, ({'command': cmd[0], 'output': 'text'},
|
||||||
{'command': cmd[1], 'output': 'text'}))
|
{'command': cmd[1], 'output': 'text'}))
|
||||||
|
|
||||||
match = re.search("^ntp master(?: (\d+))", output[0], re.M)
|
match = re.search(r"^ntp master(?: (\d+))", output[0], re.M)
|
||||||
if match:
|
if match:
|
||||||
master = True
|
master = True
|
||||||
stratum = match.group(1)
|
stratum = match.group(1)
|
||||||
|
|
|
@ -72,7 +72,7 @@ PARAM_TO_COMMAND_KEYMAP = {
|
||||||
def get_value(config, module):
|
def get_value(config, module):
|
||||||
splitted_config = config.splitlines()
|
splitted_config = config.splitlines()
|
||||||
value_list = []
|
value_list = []
|
||||||
REGEX = '^router ospf\s(?P<ospf>\S+).*'
|
REGEX = r'^router ospf\s(?P<ospf>\S+).*'
|
||||||
for line in splitted_config:
|
for line in splitted_config:
|
||||||
value = ''
|
value = ''
|
||||||
if 'router ospf' in line:
|
if 'router ospf' in line:
|
||||||
|
|
|
@ -191,8 +191,8 @@ def get_existing(module):
|
||||||
body = execute_show_command(command, module)[0]
|
body = execute_show_command(command, module)[0]
|
||||||
if body:
|
if body:
|
||||||
split_body = body.splitlines()
|
split_body = body.splitlines()
|
||||||
snapshot_regex = ('(?P<name>\S+)\s+(?P<date>\w+\s+\w+\s+\d+\s+\d+'
|
snapshot_regex = (r'(?P<name>\S+)\s+(?P<date>\w+\s+\w+\s+\d+\s+\d+'
|
||||||
':\d+:\d+\s+\d+)\s+(?P<description>.*)')
|
r':\d+:\d+\s+\d+)\s+(?P<description>.*)')
|
||||||
for snapshot in split_body:
|
for snapshot in split_body:
|
||||||
temp = {}
|
temp = {}
|
||||||
try:
|
try:
|
||||||
|
@ -229,7 +229,7 @@ def action_add(module, existing_snapshots):
|
||||||
body = execute_show_command(command, module)[0]
|
body = execute_show_command(command, module)[0]
|
||||||
|
|
||||||
if body:
|
if body:
|
||||||
section_regex = '.*\[(?P<section>\S+)\].*'
|
section_regex = r'.*\[(?P<section>\S+)\].*'
|
||||||
split_body = body.split('\n\n')
|
split_body = body.split('\n\n')
|
||||||
for section in split_body:
|
for section in split_body:
|
||||||
temp = {}
|
temp = {}
|
||||||
|
|
|
@ -125,7 +125,7 @@ def has_vrf(module, vrf):
|
||||||
if _CONFIGURED_VRFS is not None:
|
if _CONFIGURED_VRFS is not None:
|
||||||
return vrf in _CONFIGURED_VRFS
|
return vrf in _CONFIGURED_VRFS
|
||||||
config = get_config(module)
|
config = get_config(module)
|
||||||
_CONFIGURED_VRFS = re.findall('vrf context (\S+)', config)
|
_CONFIGURED_VRFS = re.findall(r'vrf context (\S+)', config)
|
||||||
return vrf in _CONFIGURED_VRFS
|
return vrf in _CONFIGURED_VRFS
|
||||||
|
|
||||||
def map_obj_to_commands(want, have, module):
|
def map_obj_to_commands(want, have, module):
|
||||||
|
@ -207,13 +207,13 @@ def map_obj_to_commands(want, have, module):
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
def parse_hostname(config):
|
def parse_hostname(config):
|
||||||
match = re.search('^hostname (\S+)', config, re.M)
|
match = re.search(r'^hostname (\S+)', config, re.M)
|
||||||
if match:
|
if match:
|
||||||
return match.group(1)
|
return match.group(1)
|
||||||
|
|
||||||
def parse_domain_name(config, vrf_config):
|
def parse_domain_name(config, vrf_config):
|
||||||
objects = list()
|
objects = list()
|
||||||
regex = re.compile('ip domain-name (\S+)')
|
regex = re.compile(r'ip domain-name (\S+)')
|
||||||
|
|
||||||
match = regex.search(config, re.M)
|
match = regex.search(config, re.M)
|
||||||
if match:
|
if match:
|
||||||
|
@ -229,11 +229,11 @@ def parse_domain_name(config, vrf_config):
|
||||||
def parse_domain_search(config, vrf_config):
|
def parse_domain_search(config, vrf_config):
|
||||||
objects = list()
|
objects = list()
|
||||||
|
|
||||||
for item in re.findall('^ip domain-list (\S+)', config, re.M):
|
for item in re.findall(r'^ip domain-list (\S+)', config, re.M):
|
||||||
objects.append({'name': item, 'vrf': None})
|
objects.append({'name': item, 'vrf': None})
|
||||||
|
|
||||||
for vrf, cfg in iteritems(vrf_config):
|
for vrf, cfg in iteritems(vrf_config):
|
||||||
for item in re.findall('ip domain-list (\S+)', cfg, re.M):
|
for item in re.findall(r'ip domain-list (\S+)', cfg, re.M):
|
||||||
objects.append({'name': item, 'vrf': vrf})
|
objects.append({'name': item, 'vrf': vrf})
|
||||||
|
|
||||||
return objects
|
return objects
|
||||||
|
@ -257,7 +257,7 @@ def parse_name_servers(config, vrf_config, vrfs):
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
def parse_system_mtu(config):
|
def parse_system_mtu(config):
|
||||||
match = re.search('^system jumbomtu (\d+)', config, re.M)
|
match = re.search(r'^system jumbomtu (\d+)', config, re.M)
|
||||||
if match:
|
if match:
|
||||||
return int(match.group(1))
|
return int(match.group(1))
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ def map_config_to_obj(module):
|
||||||
|
|
||||||
vrf_config = {}
|
vrf_config = {}
|
||||||
|
|
||||||
vrfs = re.findall('^vrf context (\S+)$', config, re.M)
|
vrfs = re.findall(r'^vrf context (\S+)$', config, re.M)
|
||||||
for vrf in vrfs:
|
for vrf in vrfs:
|
||||||
config_data = configobj.get_block_config(path=['vrf context %s' % vrf])
|
config_data = configobj.get_block_config(path=['vrf context %s' % vrf])
|
||||||
vrf_config[vrf] = config_data
|
vrf_config[vrf] = config_data
|
||||||
|
|
|
@ -151,7 +151,7 @@ def get_interface_info(interface, module):
|
||||||
interface = interface.capitalize()
|
interface = interface.capitalize()
|
||||||
|
|
||||||
command = 'show run | section interface.{0}'.format(interface)
|
command = 'show run | section interface.{0}'.format(interface)
|
||||||
vrf_regex = ".*vrf\s+member\s+(?P<vrf>\S+).*"
|
vrf_regex = r".*vrf\s+member\s+(?P<vrf>\S+).*"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
body = execute_show_command(command, module)
|
body = execute_show_command(command, module)
|
||||||
|
|
|
@ -123,8 +123,8 @@ def get_vtp_config(module):
|
||||||
vtp_parsed = {}
|
vtp_parsed = {}
|
||||||
|
|
||||||
if body:
|
if body:
|
||||||
version_regex = '.*VTP version running\s+:\s+(?P<version>\d).*'
|
version_regex = r'.*VTP version running\s+:\s+(?P<version>\d).*'
|
||||||
domain_regex = '.*VTP Domain Name\s+:\s+(?P<domain>\S+).*'
|
domain_regex = r'.*VTP Domain Name\s+:\s+(?P<domain>\S+).*'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
match_version = re.match(version_regex, body, re.DOTALL)
|
match_version = re.match(version_regex, body, re.DOTALL)
|
||||||
|
|
|
@ -154,8 +154,8 @@ def get_vtp_config(module):
|
||||||
vtp_parsed = {}
|
vtp_parsed = {}
|
||||||
|
|
||||||
if body:
|
if body:
|
||||||
version_regex = '.*VTP version running\s+:\s+(?P<version>\d).*'
|
version_regex = r'.*VTP version running\s+:\s+(?P<version>\d).*'
|
||||||
domain_regex = '.*VTP Domain Name\s+:\s+(?P<domain>\S+).*'
|
domain_regex = r'.*VTP Domain Name\s+:\s+(?P<domain>\S+).*'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
match_version = re.match(version_regex, body, re.DOTALL)
|
match_version = re.match(version_regex, body, re.DOTALL)
|
||||||
|
|
|
@ -121,8 +121,8 @@ def get_vtp_config(module):
|
||||||
vtp_parsed = {}
|
vtp_parsed = {}
|
||||||
|
|
||||||
if body:
|
if body:
|
||||||
version_regex = '.*VTP version running\s+:\s+(?P<version>\d).*'
|
version_regex = r'.*VTP version running\s+:\s+(?P<version>\d).*'
|
||||||
domain_regex = '.*VTP Domain Name\s+:\s+(?P<domain>\S+).*'
|
domain_regex = r'.*VTP Domain Name\s+:\s+(?P<domain>\S+).*'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
match_version = re.match(version_regex, body, re.DOTALL)
|
match_version = re.match(version_regex, body, re.DOTALL)
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
disable=
|
disable=
|
||||||
abstract-method,
|
abstract-method,
|
||||||
access-member-before-definition,
|
access-member-before-definition,
|
||||||
anomalous-backslash-in-string,
|
|
||||||
arguments-differ,
|
arguments-differ,
|
||||||
assignment-from-no-return,
|
assignment-from-no-return,
|
||||||
attribute-defined-outside-init,
|
attribute-defined-outside-init,
|
||||||
|
|
Loading…
Reference in a new issue