1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

adding support for loopback interface (#36141)

* adding support for loopback interface

currently the loopback interface lo is not supported with vyos_l3_interface, this commit fixes that.  Right now there is a limit of loopback interfaces to just lo, if you want more interfaces you need to use a dummy interface https://wiki.vyos.net/wiki/Dummy_interfaces

* fixing spacing as per pep8 test

fixing issues for sanity test

lib/ansible/modules/network/vyos/vyos_l3_interface.py:120:15: E111 indentation is not a multiple of four
lib/ansible/modules/network/vyos/vyos_l3_interface.py:122:15: E111 indentation is not a multiple of four
lib/ansible/modules/network/vyos/vyos_l3_interface.py:126:19: E111 indentation is not a multiple of four
lib/ansible/modules/network/vyos/vyos_l3_interface.py:128:19: E111 indentation is not a multiple of four
lib/ansible/modules/network/vyos/vyos_l3_interface.py:131:19: E111 indentation is not a multiple of four
lib/ansible/modules/network/vyos/vyos_l3_interface.py:133:19: E111 indentation is not a multiple of four
lib/ansible/modules/network/vyos/vyos_l3_interface.py:137:15: E111 indentation is not a multiple of four
lib/ansible/modules/network/vyos/vyos_l3_interface.py:140:15: E111 indentation is not a multiple of four
lib/ansible/modules/network/vyos/vyos_l3_interface.py:145:15: E111 indentation is not a multiple of four
lib/ansible/modules/network/vyos/vyos_l3_interface.py:148:15: E111 indentation is not a multiple of four

* ugh, missed on spacing issue

* getting rid of continuation lines, the CI system does not like it
This commit is contained in:
Sean Cavanaugh 2018-02-14 02:31:48 -05:00 committed by Ganesh Nalawade
parent dc902a5022
commit a52a7d2065

View file

@ -117,27 +117,40 @@ def map_obj_to_commands(updates, module):
obj_in_have = search_obj_in_list(name, have)
if state == 'absent' and obj_in_have:
if not ipv4 and not ipv6 and (obj_in_have['ipv4'] or obj_in_have['ipv6']):
commands.append('delete interfaces ethernet ' + name + ' address')
if name == "lo":
commands.append('delete interfaces loopback lo address')
else:
commands.append('delete interfaces ethernet ' + name + ' address')
else:
if ipv4 and obj_in_have['ipv4']:
commands.append('delete interfaces ethernet ' + name + ' address ' + ipv4)
if name == "lo":
commands.append('delete interfaces loopback lo address ' + ipv4)
else:
commands.append('delete interfaces ethernet ' + name + ' address ' + ipv4)
if ipv6 and obj_in_have['ipv6']:
commands.append('delete interfaces ethernet ' + name + ' address ' + ipv6)
if name == "lo":
commands.append('delete interfaces loopback lo address ' + ipv6)
else:
commands.append('delete interfaces ethernet ' + name + ' address ' + ipv6)
elif (state == 'present' and obj_in_have):
if ipv4 and ipv4 != obj_in_have['ipv4']:
commands.append('set interfaces ethernet ' + name + ' address ' +
ipv4)
if name == "lo":
commands.append('set interfaces loopback lo address ' + ipv4)
else:
commands.append('set interfaces ethernet ' + name + ' address ' + ipv4)
if ipv6 and ipv6 != obj_in_have['ipv6']:
commands.append('set interfaces ethernet ' + name + ' address ' +
ipv6)
if name == "lo":
commands.append('set interfaces loopback lo address ' + ipv6)
else:
commands.append('set interfaces ethernet ' + name + ' address ' + ipv6)
return commands
def map_config_to_obj(module):
obj = []
output = run_commands(module, ['show interfaces ethernet'])
output = run_commands(module, ['show interfaces'])
lines = output[0].splitlines()
if len(lines) > 3: