sub-interface support for nxos module (#37392)

* nxos sub-interface support

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* update l3_interface test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Add integration test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
pull/39283/head
Trishna Guha 6 years ago committed by GitHub
parent 9940b5db9c
commit 6db3f522c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -302,7 +302,7 @@ def normalize_interface(name):
def _get_number(name):
digits = ''
for char in name:
if char.isdigit() or char == '/':
if char.isdigit() or char in '/.':
digits += char
return digits

@ -122,7 +122,6 @@ def map_obj_to_commands(updates, module):
if command:
command.append('exit')
command.insert(0, 'interface {0}'.format(name))
command.insert(1, 'no switchport')
commands.extend(command)
elif state == 'present' and obj_in_have:
@ -135,10 +134,8 @@ def map_obj_to_commands(updates, module):
if command:
command.append('exit')
command.insert(0, 'interface {0}'.format(name))
command.insert(1, 'no switchport')
elif not ipv4 and not ipv6:
command.append('interface {0}'.format(name))
command.append('no switchport')
commands.extend(command)
return commands

@ -0,0 +1,77 @@
---
- debug: msg="START connection={{ ansible_connection }} nxos_interface sub-interface test"
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"
- set_fact: testint="{{ nxos_int1 }}"
- name: Setup - delete sub-interface
nxos_interface: &rm
name: "{{ testint }}.20"
state: absent
ignore_errors: yes
- name: Setup - Ensure the interface is layer3
nxos_interface:
name: "{{ testint }}"
mode: layer3
- name: Create sub-interface
nxos_interface: &sub_int
name: "{{ testint }}.20"
description: "sub-interface Configured by Ansible"
admin_state: up
mtu: 800
provider: "{{ connection }}"
register: result
- assert:
that:
- "result.changed == true"
- name: Create sub-interface (Idempotence)
nxos_interface: *sub_int
register: result
- assert:
that:
- "result.changed == false"
- name: Make admin_state down
nxos_interface: &state_down
name: "{{ testint }}.20"
description: "sub-interface Configured by Ansible"
admin_state: down
mtu: 800
provider: "{{ connection }}"
register: result
- assert:
that:
- "result.changed == true"
- name: Create sub-interface (Idempotence)
nxos_interface: *state_down
register: result
- assert:
that:
- "result.changed == false"
- name: Remove sub-interface
nxos_interface: *rm
register: result
- assert:
that:
- "result.changed == true"
- name: Remove sub-interface (Idempotence)
nxos_interface: *rm
register: result
- assert:
that:
- "result.changed == false"
- debug: msg="END connection={{ ansible_connection }} nxos_interface sub-interface test"

@ -30,6 +30,14 @@
provider: "{{ cli }}"
ignore_errors: yes
- name: Setup - Ensure interfaces are layer3
nxos_interface:
aggregate:
- name: "{{ testint2 }}"
- name: "{{ testint3 }}"
mode: layer3
provider: "{{ cli }}"
- name: Configure ipv4 address to interface
nxos_l3_interface: &conf
name: "{{ testint2 }}"

@ -20,6 +20,14 @@
state: absent
ignore_errors: yes
- name: Setup - Ensure interfaces are layer3
nxos_interface:
aggregate:
- name: "{{ testint2 }}"
- name: "{{ testint3 }}"
mode: layer3
provider: "{{ nxapi }}"
- name: Configure ipv4 address to interface
nxos_l3_interface: &conf
name: "{{ testint2 }}"

Loading…
Cancel
Save