mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
changed interface config blocks parsing logic (#50340)
This commit is contained in:
parent
8f5cd049d6
commit
844e194aa4
1 changed files with 9 additions and 5 deletions
|
@ -297,14 +297,18 @@ class CliConfiguration(ConfigBase):
|
||||||
|
|
||||||
def map_config_to_obj(self):
|
def map_config_to_obj(self):
|
||||||
data = get_config(self._module, config_filter='interface')
|
data = get_config(self._module, config_filter='interface')
|
||||||
interfaces = data.strip().rstrip('!').split('!')
|
data_lines = data.splitlines()
|
||||||
|
start_indexes = [i for i, e in enumerate(data_lines) if e.startswith('interface')]
|
||||||
|
end_indexes = [i for i, e in enumerate(data_lines) if e == '!']
|
||||||
|
|
||||||
if not interfaces:
|
intf_configs = list()
|
||||||
|
for start_index, end_index in zip(start_indexes, end_indexes):
|
||||||
|
intf_configs.append([i.strip() for i in data_lines[start_index:end_index]])
|
||||||
|
|
||||||
|
if not intf_configs:
|
||||||
return list()
|
return list()
|
||||||
|
|
||||||
for interface in interfaces:
|
for intf_config in intf_configs:
|
||||||
intf_config = interface.strip().splitlines()
|
|
||||||
|
|
||||||
name = intf_config[0].strip().split()[1]
|
name = intf_config[0].strip().split()[1]
|
||||||
|
|
||||||
active = 'act'
|
active = 'act'
|
||||||
|
|
Loading…
Reference in a new issue