mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Fix anomalous backslashes and enable pylint test.
This commit is contained in:
@@ -208,7 +208,7 @@ def validate_local_http_port(value, module):
|
||||
|
||||
def validate_vrf(value, module):
|
||||
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')
|
||||
if value not in configured_vrfs:
|
||||
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:
|
||||
return vrf in _CONFIGURED_VRFS
|
||||
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')
|
||||
return vrf in _CONFIGURED_VRFS
|
||||
|
||||
@@ -223,18 +223,18 @@ def map_obj_to_commands(want, have, module):
|
||||
return commands
|
||||
|
||||
def parse_hostname(config):
|
||||
match = re.search('^hostname (\S+)', config, re.M)
|
||||
match = re.search(r'^hostname (\S+)', config, re.M)
|
||||
if match:
|
||||
return match.group(1)
|
||||
|
||||
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:
|
||||
return match.group(1)
|
||||
|
||||
def parse_lookup_source(config):
|
||||
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):
|
||||
if len(vrf) == 0:
|
||||
vrf= None
|
||||
@@ -243,7 +243,7 @@ def parse_lookup_source(config):
|
||||
|
||||
def parse_name_servers(config):
|
||||
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})
|
||||
return objects
|
||||
|
||||
@@ -252,7 +252,7 @@ def map_config_to_obj(module):
|
||||
return {
|
||||
'hostname': parse_hostname(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),
|
||||
'name_servers': parse_name_servers(config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user