Vyos interface desc fix28 (#57228)

* vyos interfacefix and  test cases

Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
(cherry picked from commit be1820d3af)

* backport 28

Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
pull/57255/merge
Rohit 7 years ago committed by Toshio Kuratomi
parent f0664476b7
commit 3ae459b3b4

@ -0,0 +1,2 @@
bugfixes:
- vyos_interface fix <https://github.com/ansible/ansible/pull/57169>

@ -204,6 +204,8 @@ def map_obj_to_commands(updates):
value = w.get(item) value = w.get(item)
if value and value != obj_in_have.get(item): if value and value != obj_in_have.get(item):
if item == 'description':
value = "\'" + str(value) + "\'"
commands.append(set_interface + ' ' + item + ' ' + str(value)) commands.append(set_interface + ' ' + item + ' ' + str(value))
if disable and not obj_in_have.get('disable', False): if disable and not obj_in_have.get('disable', False):
@ -215,6 +217,8 @@ def map_obj_to_commands(updates):
for item in params: for item in params:
value = w.get(item) value = w.get(item)
if value: if value:
if item == 'description':
value = "\'" + str(value) + "\'"
commands.append(set_interface + ' ' + item + ' ' + str(value)) commands.append(set_interface + ' ' + item + ' ' + str(value))
if disable: if disable:
@ -244,7 +248,7 @@ def map_config_to_obj(module):
if match: if match:
param = match.group(1) param = match.group(1)
if param == 'description': if param == 'description':
match = re.search(r'description (\S+)', line, re.M) match = re.search(r'description (.+)', line, re.M)
description = match.group(1).strip("'") description = match.group(1).strip("'")
interface['description'] = description interface['description'] = description
elif param == 'speed': elif param == 'speed':

@ -23,7 +23,7 @@
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"set interfaces ethernet eth1" in result.commands' - '"set interfaces ethernet eth1" in result.commands'
- '"set interfaces ethernet eth1 description test-interface" in result.commands' - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands'
- name: Configure interface params - name: Configure interface params
vyos_interface: vyos_interface:
@ -39,7 +39,7 @@
- assert: - assert:
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"set interfaces ethernet eth1 description test-interface-1" in result.commands' - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands'
- '"set interfaces ethernet eth1 speed 100" in result.commands' - '"set interfaces ethernet eth1 speed 100" in result.commands'
- '"set interfaces ethernet eth1 duplex half" in result.commands' - '"set interfaces ethernet eth1 duplex half" in result.commands'
- '"set interfaces ethernet eth1 mtu 256" in result.commands' - '"set interfaces ethernet eth1 mtu 256" in result.commands'
@ -75,7 +75,7 @@
- assert: - assert:
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"set interfaces ethernet eth1 description test-interface-2" in result.commands' - '"set interfaces ethernet eth1 description ''test-interface-2''" in result.commands'
- '"set interfaces ethernet eth1 speed 1000" in result.commands' - '"set interfaces ethernet eth1 speed 1000" in result.commands'
- '"set interfaces ethernet eth1 duplex full" in result.commands' - '"set interfaces ethernet eth1 duplex full" in result.commands'
- '"set interfaces ethernet eth1 mtu 512" in result.commands' - '"set interfaces ethernet eth1 mtu 512" in result.commands'
@ -141,11 +141,11 @@
- assert: - assert:
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"set interfaces ethernet eth1 description test-interface-1" in result.commands' - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands'
- '"set interfaces ethernet eth1 speed 100" in result.commands' - '"set interfaces ethernet eth1 speed 100" in result.commands'
- '"set interfaces ethernet eth1 duplex half" in result.commands' - '"set interfaces ethernet eth1 duplex half" in result.commands'
- '"set interfaces ethernet eth1 mtu 512" in result.commands' - '"set interfaces ethernet eth1 mtu 512" in result.commands'
- '"set interfaces ethernet eth2 description test-interface-2" in result.commands' - '"set interfaces ethernet eth2 description ''test-interface-2''" in result.commands'
- '"set interfaces ethernet eth2 speed 1000" in result.commands' - '"set interfaces ethernet eth2 speed 1000" in result.commands'
- '"set interfaces ethernet eth2 duplex full" in result.commands' - '"set interfaces ethernet eth2 duplex full" in result.commands'
- '"set interfaces ethernet eth2 mtu 256" in result.commands' - '"set interfaces ethernet eth2 mtu 256" in result.commands'

@ -26,7 +26,7 @@
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"set interfaces ethernet eth1" in result.commands' - '"set interfaces ethernet eth1" in result.commands'
- '"set interfaces ethernet eth1 description test-interface" in result.commands' - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands'
- name: Configure interface params using platform agnostic module - name: Configure interface params using platform agnostic module
net_interface: net_interface:
@ -42,7 +42,7 @@
- assert: - assert:
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"set interfaces ethernet eth1 description test-interface-1" in result.commands' - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands'
- '"set interfaces ethernet eth1 speed 100" in result.commands' - '"set interfaces ethernet eth1 speed 100" in result.commands'
- '"set interfaces ethernet eth1 duplex half" in result.commands' - '"set interfaces ethernet eth1 duplex half" in result.commands'
- '"set interfaces ethernet eth1 mtu 256" in result.commands' - '"set interfaces ethernet eth1 mtu 256" in result.commands'

Loading…
Cancel
Save