Fix junos integration zuul CI failures (#57309)
This commit is contained in:
parent
51229eb99c
commit
a867ced4de
9 changed files with 318 additions and 234 deletions
|
@ -223,9 +223,9 @@ class NetconfBase(AnsiblePlugin):
|
|||
"""
|
||||
if rpc_command is None:
|
||||
raise ValueError('rpc_command value must be provided')
|
||||
req = fromstring(rpc_command)
|
||||
resp = self.m.dispatch(req, source=source, filter=filter)
|
||||
return resp.data_xml if resp.data_ele else resp.xml
|
||||
|
||||
resp = self.m.dispatch(fromstring(rpc_command), source=source, filter=filter)
|
||||
return resp.data_xml if hasattr(resp, 'data_xml') else resp.xml
|
||||
|
||||
@ensure_connected
|
||||
def lock(self, target="candidate"):
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "result.msg == 'Subset must be one of [config, default, hardware, interfaces, ofacts], got test'"
|
||||
- "'Subset must be one of' in result.msg"
|
||||
|
||||
- name: Collect config facts from device in set format
|
||||
junos_facts:
|
||||
|
|
|
@ -1,32 +1,49 @@
|
|||
---
|
||||
- debug: msg="START junos_lldp netconf/basic.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup - Disable lldp and remove it's configuration
|
||||
- name: get supported protocols
|
||||
junos_command:
|
||||
commands: show lldp
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: lldp supported
|
||||
set_fact:
|
||||
lldp_supported: True
|
||||
when: not result.failed
|
||||
|
||||
- name: lldp not supported
|
||||
set_fact:
|
||||
lldp_supported: False
|
||||
when: result.failed
|
||||
|
||||
- block:
|
||||
- name: setup - Disable lldp and remove it's configuration
|
||||
junos_lldp:
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: Enable lldp
|
||||
- name: Enable lldp
|
||||
junos_lldp:
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: Enable lldp (idempotent)
|
||||
- name: Enable lldp (idempotent)
|
||||
junos_lldp:
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: configure lldp parameters and enable lldp
|
||||
- name: configure lldp parameters and enable lldp
|
||||
junos_lldp:
|
||||
interval: 10
|
||||
hold_multiplier: 5
|
||||
|
@ -35,14 +52,14 @@
|
|||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("\+ *advertisement-interval 10")
|
||||
- result.diff.prepared is search("\+ *transmit-delay 2")
|
||||
- result.diff.prepared is search("\+ *hold-multiplier 5")
|
||||
|
||||
- name: configure lldp parameters and enable lldp(idempotent)
|
||||
- name: configure lldp parameters and enable lldp(idempotent)
|
||||
junos_lldp:
|
||||
interval: 10
|
||||
hold_multiplier: 5
|
||||
|
@ -51,11 +68,11 @@
|
|||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: configure lldp parameters and disable lldp
|
||||
- name: configure lldp parameters and disable lldp
|
||||
junos_lldp:
|
||||
interval: 10
|
||||
hold_multiplier: 5
|
||||
|
@ -64,7 +81,7 @@
|
|||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("\+ *disable")
|
||||
|
@ -72,7 +89,7 @@
|
|||
- "'transmit-delay 2;' not in result.diff.prepared"
|
||||
- "'hold-multiplier 5;' not in result.diff.prepared"
|
||||
|
||||
- name: configure lldp parameters and enable lldp
|
||||
- name: configure lldp parameters and enable lldp
|
||||
junos_lldp:
|
||||
interval: 10
|
||||
hold_multiplier: 5
|
||||
|
@ -81,7 +98,7 @@
|
|||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("\- *disable")
|
||||
|
@ -89,7 +106,7 @@
|
|||
- "'transmit-delay 2;' not in result.diff.prepared"
|
||||
- "'hold-multiplier 5;' not in result.diff.prepared"
|
||||
|
||||
- name: Remove lldp configuration and diable lldp
|
||||
- name: Remove lldp configuration and diable lldp
|
||||
junos_lldp:
|
||||
interval: 10
|
||||
hold_multiplier: 5
|
||||
|
@ -98,7 +115,7 @@
|
|||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("\+ *disable")
|
||||
|
@ -106,14 +123,16 @@
|
|||
- result.diff.prepared is search("\- *transmit-delay 2")
|
||||
- result.diff.prepared is search("\- *hold-multiplier 5")
|
||||
|
||||
- name: Remove lldp (idempotent)
|
||||
- name: Remove lldp (idempotent)
|
||||
junos_lldp:
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
when: lldp_supported
|
||||
|
||||
- debug: msg="END junos_lldp netconf/basic.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -3,25 +3,42 @@
|
|||
|
||||
# Add minimal testcase to check args are passed correctly to
|
||||
# implementation module and module run is successful.
|
||||
- name: get supported protocols
|
||||
junos_command:
|
||||
commands: show lldp
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: setup - Disable lldp - setup
|
||||
- name: lldp supported
|
||||
set_fact:
|
||||
lldp_supported: True
|
||||
when: not result.failed
|
||||
|
||||
- name: lldp not supported
|
||||
set_fact:
|
||||
lldp_supported: False
|
||||
when: result.failed
|
||||
|
||||
- block:
|
||||
- name: setup - Disable lldp - setup
|
||||
net_lldp:
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: Enable lldp using platform agnostic module
|
||||
- name: Enable lldp using platform agnostic module
|
||||
net_lldp:
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
|
||||
- name: setup - Disable lldp - teardown
|
||||
- name: setup - Disable lldp - teardown
|
||||
net_lldp:
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
when: lldp_supported
|
||||
|
||||
- debug: msg="START junos netconf/net_lldp.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -1,36 +1,53 @@
|
|||
---
|
||||
- debug: msg="START junos_lldp_interface netconf/basic.yaml on connection={{ ansible_connection }}"
|
||||
|
||||
- name: setup - Remove lldp interface configuration
|
||||
- name: get supported protocols
|
||||
junos_command:
|
||||
commands: show lldp
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: lldp supported
|
||||
set_fact:
|
||||
lldp_supported: True
|
||||
when: not result.failed
|
||||
|
||||
- name: lldp not supported
|
||||
set_fact:
|
||||
lldp_supported: False
|
||||
when: result.failed
|
||||
|
||||
- block:
|
||||
- name: setup - Remove lldp interface configuration
|
||||
junos_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: lldp interface configuration
|
||||
- name: lldp interface configuration
|
||||
junos_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("\+ *interface ge-0/0/5")
|
||||
|
||||
- name: lldp interface configuration (idempotent)
|
||||
- name: lldp interface configuration (idempotent)
|
||||
junos_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: Deactivate lldp interface configuration
|
||||
- name: Deactivate lldp interface configuration
|
||||
junos_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: present
|
||||
|
@ -38,12 +55,12 @@
|
|||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("! *inactive[:] interface ge-0/0/5")
|
||||
|
||||
- name: Activate lldp interface configuration
|
||||
- name: Activate lldp interface configuration
|
||||
junos_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: present
|
||||
|
@ -51,56 +68,57 @@
|
|||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("! *active[:] interface ge-0/0/5")
|
||||
|
||||
- name: Disable lldp on particular interface
|
||||
- name: Disable lldp on particular interface
|
||||
junos_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: disabled
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("\+ *disable")
|
||||
|
||||
- name: Enable lldp on particular interface
|
||||
- name: Enable lldp on particular interface
|
||||
junos_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: enabled
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("\- *disable")
|
||||
|
||||
- name: Delete lldp on particular interface
|
||||
- name: Delete lldp on particular interface
|
||||
junos_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("\- *interface ge-0/0/5")
|
||||
|
||||
- name: Delete lldp on particular interface (idempotent)
|
||||
- name: Delete lldp on particular interface (idempotent)
|
||||
junos_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
when: lldp_supported
|
||||
|
||||
- debug: msg="END junos_lldp_interface netconf/basic.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -4,28 +4,46 @@
|
|||
# Add minimal testcase to check args are passed correctly to
|
||||
# implementation module and module run is successful.
|
||||
|
||||
- name: setup - Remove lldp interface configuration
|
||||
- name: get supported protocols
|
||||
junos_command:
|
||||
commands: show lldp
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: lldp supported
|
||||
set_fact:
|
||||
lldp_supported: True
|
||||
when: not result.failed
|
||||
|
||||
- name: lldp not supported
|
||||
set_fact:
|
||||
lldp_supported: False
|
||||
when: result.failed
|
||||
|
||||
- block:
|
||||
- name: setup - Remove lldp interface configuration
|
||||
net_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
|
||||
- name: lldp interface configuration using platform agnostic module
|
||||
- name: lldp interface configuration using platform agnostic module
|
||||
net_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: present
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result.diff.prepared is search("\+ *interface ge-0/0/5")
|
||||
|
||||
- name: teardown - Remove lldp interface configuration
|
||||
- name: teardown - Remove lldp interface configuration
|
||||
net_lldp_interface:
|
||||
name: ge-0/0/5
|
||||
state: absent
|
||||
provider: "{{ netconf }}"
|
||||
when: lldp_supported
|
||||
|
||||
- debug: msg="END junos netconf/net_lldp_interface.yaml on connection={{ ansible_connection }}"
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "'<name>\nem0\n</name>' in result['xml']"
|
||||
- "'<interface-information' in result['xml']"
|
||||
- "result.output is defined"
|
||||
|
||||
- name: Execute RPC with args on device
|
||||
junos_rpc:
|
||||
rpc: get-interface-information
|
||||
args:
|
||||
interface-name: em0
|
||||
interface-name: lo0
|
||||
media: True
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
@ -25,8 +25,9 @@
|
|||
- assert:
|
||||
that:
|
||||
- "result.changed == false"
|
||||
- "'<name>\nem0\n</name>' in result['xml']"
|
||||
- "'<name>\nlo0\n</name>' not in result['xml']"
|
||||
- "'<name>\nlo0\n</name>' in result['xml']"
|
||||
- "'<name>\nem0\n</name>' not in result['xml']"
|
||||
- "'<name>\fxp0\n</name>' not in result['xml']"
|
||||
|
||||
- name: Execute RPC on device and get output in text format
|
||||
junos_rpc:
|
||||
|
@ -40,14 +41,14 @@
|
|||
- "result.changed == false"
|
||||
- "result.output is defined"
|
||||
- "result.output_lines is defined"
|
||||
- "'Physical interface: em0' in result['output']"
|
||||
- "'Physical interface' in result['output']"
|
||||
|
||||
- name: Execute RPC on device and get output in json format
|
||||
junos_rpc:
|
||||
rpc: get-interface-information
|
||||
output: json
|
||||
args:
|
||||
interface-name: em0
|
||||
interface-name: lo0
|
||||
media: True
|
||||
provider: "{{ netconf }}"
|
||||
register: result
|
||||
|
@ -56,7 +57,7 @@
|
|||
that:
|
||||
- "result.changed == false"
|
||||
- "result.output is defined"
|
||||
- "result['output']['interface-information'][0]['physical-interface'][0]['name'][0]['data'] == \"em0\""
|
||||
- "result['output']['interface-information'][0]['physical-interface'][0]['name'][0]['data'] == \"lo0\""
|
||||
|
||||
- name: Execute invalid RPC
|
||||
junos_rpc:
|
||||
|
|
|
@ -27,11 +27,22 @@
|
|||
that:
|
||||
- "result.changed == false"
|
||||
|
||||
- name: configure syslog file replace
|
||||
- name: replace default operation fail
|
||||
netconf_config:
|
||||
content: "{{ syslog_config_replace }}"
|
||||
default_operation: 'replace'
|
||||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- "'Missing mandatory statement' in result.msg"
|
||||
|
||||
- name: replace syslog config with operation key in content
|
||||
netconf_config:
|
||||
content: "{{ syslog_config_replace }}"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
|
|
|
@ -24,7 +24,7 @@ syslog_config_replace: |
|
|||
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
|
||||
<configuration>
|
||||
<system>
|
||||
<syslog>
|
||||
<syslog operation="replace">
|
||||
<file>
|
||||
<name>test_netconf_config</name>
|
||||
<contents>
|
||||
|
|
Loading…
Reference in a new issue