summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/network-integration.cfg4
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg12
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml27
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml26
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml16
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml47
-rw-r--r--tests/integration/targets/vyos_interfaces/vars/main.yaml37
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/_parsed_config.cfg8
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml23
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml26
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml33
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml38
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/vars/main.yaml10
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg6
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml23
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml25
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml16
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml37
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml30
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/deleted.yaml62
-rw-r--r--tests/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml68
-rw-r--r--tests/integration/targets/vyos_static_routes/vars/main.yaml26
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_static_route.py8
-rw-r--r--tests/unit/modules/network/vyos/test_vyos_static_routes.py12
24 files changed, 445 insertions, 175 deletions
diff --git a/tests/integration/network-integration.cfg b/tests/integration/network-integration.cfg
new file mode 100644
index 0000000..d12c1ef
--- /dev/null
+++ b/tests/integration/network-integration.cfg
@@ -0,0 +1,4 @@
+[persistent_connection]
+command_timeout = 100
+connect_timeout = 100
+connect_retry_timeout = 100
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg
new file mode 100644
index 0000000..e5c3fc7
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg
@@ -0,0 +1,12 @@
+set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1'
+set interfaces ethernet eth1 duplex 'auto'
+set interfaces ethernet eth1 hw-id '08:00:27:da:67:43'
+set interfaces ethernet eth1 mtu '1500'
+set interfaces ethernet eth1 speed 'auto'
+set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100'
+set interfaces ethernet eth1 vif 100 mtu '400'
+set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101'
+set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)'
+set interfaces ethernet eth2 'disable'
+set interfaces ethernet eth2 hw-id '08:00:27:d8:70:b0'
+set interfaces ethernet eth2 mtu '600'
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
index e1e154d..652f158 100644
--- a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
@@ -1,7 +1,7 @@
---
- debug:
- msg: START vyos_interfaces empty_config integration tests on connection={{ ansible_connection
- }}
+ msg: START vyos_interfaces empty_config integration tests on connection={{
+ ansible_connection }}
- name: Merged with empty config should give appropriate error message
register: result
@@ -35,3 +35,26 @@
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Parsed with empty running_config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_interfaces:
+ running_config:
+ state: parsed
+
+- assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state
+ parsed'
+
+- name: Rendered with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_interfaces:
+ config:
+ state: rendered
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 0000000..ac9892c
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,26 @@
+---
+- debug:
+ msg: START vyos_interfaces gathered integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Gather the provided configuration with the exisiting running configuration
+ register: result
+ vyos.vyos.vyos_interfaces:
+ config:
+ state: gathered
+
+ - name: Assert that gathered dicts was correctly generated
+ assert:
+ that:
+ - "{{ populate | symmetric_difference(result['gathered']) |length == 0\
+ \ }}"
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 0000000..a44fc2f
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,16 @@
+---
+- debug:
+ msg: START vyos_interfaces parsed integration tests on connection={{ ansible_connection
+ }}
+
+- name: Parse externally provided interfaces config to agnostic model
+ register: result
+ vyos.vyos.vyos_interfaces:
+ running_config: "{{ lookup('file', '_parsed_config.cfg') }}"
+ state: parsed
+
+- name: Assert that config was correctly parsed
+ assert:
+ that:
+ - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\
+ \ 0 }}"
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 0000000..5030d71
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,47 @@
+---
+- debug:
+ msg: START vyos_interfaces rendered integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Structure provided configuration into device specific commands
+ register: result
+ vyos.vyos.vyos_interfaces:
+ config:
+ - name: eth0
+ enabled: true
+ duplex: auto
+ speed: auto
+ - name: eth1
+ description: Configured by Ansible - Interface 1
+ mtu: 1500
+ speed: auto
+ duplex: auto
+ enabled: true
+ vifs:
+ - vlan_id: 100
+ description: Eth1 - VIF 100
+ mtu: 400
+ enabled: true
+ - vlan_id: 101
+ description: Eth1 - VIF 101
+ enabled: true
+ - name: eth2
+ description: Configured by Ansible - Interface 2 (ADMIN DOWN)
+ mtu: 600
+ enabled: false
+ state: rendered
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\
+ \ |length == 0 }}"
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_interfaces/vars/main.yaml b/tests/integration/targets/vyos_interfaces/vars/main.yaml
index b730080..84a8bf0 100644
--- a/tests/integration/targets/vyos_interfaces/vars/main.yaml
+++ b/tests/integration/targets/vyos_interfaces/vars/main.yaml
@@ -104,6 +104,26 @@ replaced:
enabled: true
duplex: auto
speed: auto
+parsed:
+ after:
+ - name: eth1
+ description: Configured by Ansible - Interface 1
+ mtu: 1500
+ speed: auto
+ duplex: auto
+ enabled: true
+ vifs:
+ - vlan_id: 100
+ description: Eth1 - VIF 100
+ mtu: 400
+ enabled: true
+ - vlan_id: 101
+ description: Eth1 - VIF 101
+ enabled: true
+ - name: eth2
+ description: Configured by Ansible - Interface 2 (ADMIN DOWN)
+ mtu: 600
+ enabled: false
overridden:
commands:
- delete interfaces ethernet eth1 description
@@ -133,6 +153,23 @@ overridden:
vifs:
- vlan_id: 200
enabled: true
+rendered:
+ commands:
+ - set interfaces ethernet eth0 duplex 'auto'
+ - set interfaces ethernet eth0 speed 'auto'
+ - delete interfaces ethernet eth0 disable
+ - set interfaces ethernet eth1 duplex 'auto'
+ - delete interfaces ethernet eth1 disable
+ - set interfaces ethernet eth1 speed 'auto'
+ - set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1'
+ - set interfaces ethernet eth1 mtu '1500'
+ - set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100'
+ - set interfaces ethernet eth1 vif 100 mtu '400'
+ - set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101'
+ - set interfaces ethernet eth2 disable
+ - set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)'
+ - set interfaces ethernet eth2 mtu '600'
+
deleted:
commands:
- delete interfaces ethernet eth1 description
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_parsed_config.cfg
new file mode 100644
index 0000000..ea3bfce
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/_parsed_config.cfg
@@ -0,0 +1,8 @@
+set interfaces bonding bond0 hash-policy 'layer2'
+set interfaces bonding bond0 mode 'active-backup'
+set interfaces bonding bond0 primary 'eth1'
+set interfaces bonding bond1 hash-policy 'layer2+3'
+set interfaces bonding bond1 mode 'active-backup'
+set interfaces bonding bond1 primary 'eth2'
+set interfaces ethernet eth1 bond-group 'bond0'
+set interfaces ethernet eth2 bond-group 'bond1' \ No newline at end of file
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml
index 3894fb5..6e89eae 100644
--- a/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml
@@ -35,3 +35,26 @@
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Parsed with empty running_config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_lag_interfaces:
+ running_config:
+ state: parsed
+
+- assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state
+ parsed'
+
+- name: Rendered with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_lag_interfaces:
+ config:
+ state: rendered
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 0000000..aca168d
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,26 @@
+---
+- debug:
+ msg: START vyos_lag_interfaces gathered integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Gather the provided configuration with the exisiting running configuration
+ register: result
+ vyos.vyos.vyos_lag_interfaces: &id001
+ config:
+ state: gathered
+
+ - name: Assert that gathered dicts was correctly generated
+ assert:
+ that:
+ - "{{ populate | symmetric_difference(result['gathered']) |length == 0\
+ \ }}"
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 0000000..ed7bc61
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,33 @@
+---
+- debug:
+ msg: START vyos_lag_interfaces parsed integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Gather lag_interfaces facts
+ register: lag_interfaces_facts
+ vyos.vyos.vyos_facts:
+ gather_subset:
+ - default
+ gather_network_resources:
+ - lag_interfaces
+
+ - name: Provide the running configuration for parsing (config to be parsed)
+ register: result
+ vyos.vyos.vyos_lag_interfaces:
+ running_config: "{{ lookup('file', '_parsed_config.cfg') }}"
+ state: parsed
+
+ - name: Assert that correct parsing done
+ assert:
+ that: "{{ ansible_facts['network_resources']['lag_interfaces'] | symmetric_difference(result['parsed'])\
+ \ |length == 0 }}"
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 0000000..e6d7928
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,38 @@
+---
+- debug:
+ msg: START vyos_lag_interfaces rendered integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Structure provided configuration into device specific commands
+ register: result
+ vyos.vyos.vyos_lag_interfaces:
+ config:
+ - name: bond0
+ hash_policy: layer2
+ members:
+ - member: eth1
+ mode: active-backup
+ primary: eth1
+ - name: bond1
+ hash_policy: layer2+3
+ members:
+ - member: eth2
+ mode: active-backup
+ primary: eth2
+ state: rendered
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\
+ \ |length == 0 }}"
+
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml b/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml
index 5783693..9784fb9 100644
--- a/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml
+++ b/tests/integration/targets/vyos_lag_interfaces/vars/main.yaml
@@ -83,6 +83,16 @@ deleted:
after:
- name: bond0
- name: bond1
+rendered:
+ commands:
+ - set interfaces bonding bond0 hash-policy 'layer2'
+ - set interfaces ethernet eth1 bond-group 'bond0'
+ - set interfaces bonding bond0 mode 'active-backup'
+ - set interfaces bonding bond0 primary 'eth1'
+ - set interfaces bonding bond1 hash-policy 'layer2+3'
+ - set interfaces ethernet eth2 bond-group 'bond1'
+ - set interfaces bonding bond1 mode 'active-backup'
+ - set interfaces bonding bond1 primary 'eth2'
round_trip:
after:
- name: bond0
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg
new file mode 100644
index 0000000..40c96c4
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/_parsed_config.cfg
@@ -0,0 +1,6 @@
+set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH'
+set service lldp interface eth1 location civic-based country-code 'US'
+set service lldp interface eth2 location coordinate-based altitude '2200'
+set service lldp interface eth2 location coordinate-based datum 'WGS84'
+set service lldp interface eth2 location coordinate-based latitude '33.524449N'
+set service lldp interface eth2 location coordinate-based longitude '222.267255W' \ No newline at end of file
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml
index a5ff0a8..4ef40c9 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml
@@ -35,3 +35,26 @@
- assert:
that:
- result.msg == 'value of config parameter must not be empty for state overridden'
+
+- name: Parsed with empty running_config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_lldp_interfaces:
+ running_config:
+ state: parsed
+
+- assert:
+ that:
+ - result.msg == 'value of running_config parameter must not be empty for state
+ parsed'
+
+- name: Rendered with empty config should give appropriate error message
+ register: result
+ ignore_errors: true
+ vyos.vyos.vyos_lldp_interfaces:
+ config:
+ state: rendered
+
+- assert:
+ that:
+ - result.msg == 'value of config parameter must not be empty for state rendered'
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml
new file mode 100644
index 0000000..180b62f
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/gathered.yaml
@@ -0,0 +1,25 @@
+---
+- debug:
+ msg: START vyos_lldp_interfaces gathered integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- include_tasks: _populate.yaml
+
+- block:
+
+ - name: Gather the provided configuration with the exisiting running configuration
+ register: result
+ vyos.vyos.vyos_lldp_interfaces:
+ config:
+ state: gathered
+
+ - name: Assert that gathered dicts was correctly generated
+ assert:
+ that:
+ - "{{ populate | symmetric_difference(result['gathered']) |length == 0\
+ \ }}"
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml
new file mode 100644
index 0000000..0ca52be
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/parsed.yaml
@@ -0,0 +1,16 @@
+---
+- debug:
+ msg: START vyos_lldp_nterfaces parsed integration tests on connection={{ ansible_connection
+ }}
+
+- name: Parse externally provided interfaces config to agnostic model
+ register: result
+ vyos.vyos.vyos_lldp_interfaces:
+ running_config: "{{ lookup('file', '_parsed_config.cfg') }}"
+ state: parsed
+
+- name: Assert that config was correctly parsed
+ assert:
+ that:
+ - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\
+ \ 0 }}"
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml
new file mode 100644
index 0000000..342e64b
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/rendered.yaml
@@ -0,0 +1,37 @@
+---
+- debug:
+ msg: START vyos_lldp_interfaces rendered integration tests on connection={{ ansible_connection
+ }}
+
+- include_tasks: _remove_config.yaml
+
+- block:
+
+ - name: Structure provided configuration into device specific commands
+ register: result
+ vyos.vyos.vyos_lldp_interfaces:
+ config:
+ - name: eth1
+ location:
+ civic_based:
+ country_code: US
+ ca_info:
+ - ca_type: 0
+ ca_value: ENGLISH
+ - name: eth2
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
+ state: rendered
+
+ - name: Assert that correct set of commands were generated
+ assert:
+ that:
+ - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\
+ \ |length == 0 }}"
+ always:
+
+ - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml b/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml
index 3cb684e..092f653 100644
--- a/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml
+++ b/tests/integration/targets/vyos_lldp_interfaces/vars/main.yaml
@@ -9,10 +9,6 @@ merged:
- set service lldp interface eth2 location coordinate-based altitude '2200'
- set service lldp interface eth2 location coordinate-based datum 'WGS84'
- set service lldp interface eth2 location coordinate-based longitude '222.267255W'
- - set service lldp interface eth2 location coordinate-based latitude '33.524449N'
- - set service lldp interface eth2 location coordinate-based altitude '2200'
- - set service lldp interface eth2 location coordinate-based datum 'WGS84'
- - set service lldp interface eth2 location coordinate-based longitude '222.267255W'
- set service lldp interface eth2
after:
- name: eth1
@@ -44,6 +40,16 @@ populate:
datum: WGS84
longitude: 222.267255W
latitude: 33.524449N
+rendered:
+ commands:
+ - set service lldp interface eth1 location civic-based country-code 'US'
+ - set service lldp interface eth1 location civic-based ca-type 0 ca-value 'ENGLISH'
+ - set service lldp interface eth1
+ - set service lldp interface eth2 location coordinate-based latitude '33.524449N'
+ - set service lldp interface eth2 location coordinate-based altitude '2200'
+ - set service lldp interface eth2 location coordinate-based datum 'WGS84'
+ - set service lldp interface eth2 location coordinate-based longitude '222.267255W'
+ - set service lldp interface eth2
replaced:
commands:
- delete service lldp interface eth2 location
@@ -91,6 +97,22 @@ overridden:
- name: eth2
location:
elin: 0000000911
+parsed:
+ after:
+ - name: eth1
+ location:
+ civic_based:
+ country_code: US
+ ca_info:
+ - ca_type: 0
+ ca_value: ENGLISH
+ - name: eth2
+ location:
+ coordinate_based:
+ altitude: 2200
+ datum: WGS84
+ longitude: 222.267255W
+ latitude: 33.524449N
deleted:
commands:
- delete service lldp interface eth1
diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/deleted.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/deleted.yaml
deleted file mode 100644
index 7f098f5..0000000
--- a/tests/integration/targets/vyos_static_routes/tests/cli/deleted.yaml
+++ /dev/null
@@ -1,62 +0,0 @@
----
-- debug:
- msg: Start vyos_static_routes deleted integration tests ansible_connection={{
- ansible_connection }}
-
-- include_tasks: _populate.yaml
-
-- block:
-
- - name: Delete static route based on destiation.
- register: result
- vyos.vyos.vyos_static_routes: &id001
- config:
-
- - address_families:
-
- - afi: ipv4
- routes:
-
- - dest: 192.0.2.32/28
-
- - afi: ipv6
- routes:
-
- - dest: 2001:db8:1000::/36
- state: deleted
-
- - name: Assert that the before dicts were correctly generated
- assert:
- that:
- - "{{ populate | symmetric_difference(result['before']) |length == 0 }}"
-
- - name: Assert that the correct set of commands were generated
- assert:
- that:
- - "{{ deleted_dest['commands'] | symmetric_difference(result['commands'])\
- \ |length == 0 }}"
-
- - name: Assert that the after dicts were correctly generated
- assert:
- that:
- - "{{ deleted_dest['after'] | symmetric_difference(result['after']) |length\
- \ == 0 }}"
-
- - name: Delete attributes of given interfaces (IDEMPOTENT)
- register: result
- vyos.vyos.vyos_static_routes: *id001
-
- - name: Assert that the previous task was idempotent
- assert:
- that:
- - result.changed == false
- - result.commands|length == 0
-
- - name: Assert that the before dicts were correctly generated
- assert:
- that:
- - "{{ deleted_dest['after'] | symmetric_difference(result['before']) |length\
- \ == 0 }}"
- always:
-
- - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml b/tests/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml
deleted file mode 100644
index f6075d2..0000000
--- a/tests/integration/targets/vyos_static_routes/tests/cli/deleted_nh.yaml
+++ /dev/null
@@ -1,68 +0,0 @@
----
-- debug:
- msg: Start vyos_static_routes deleted integration tests ansible_connection={{
- ansible_connection }}
-
-- include_tasks: _populate.yaml
-
-- block:
-
- - name: Delete static route based on next_hop.
- register: result
- vyos.vyos.vyos_static_routes: &id001
- config:
-
- - address_families:
-
- - afi: ipv4
- routes:
-
- - dest: 192.0.2.32/28
- next_hops:
-
- - forward_router_address: 192.0.2.9
-
- - afi: ipv6
- routes:
-
- - dest: 2001:db8:1000::/36
- next_hops:
-
- - forward_router_address: 2001:db8:2000:2::1
- state: deleted
-
- - name: Assert that the before dicts were correctly generated
- assert:
- that:
- - "{{ populate | symmetric_difference(result['before']) |length == 0 }}"
-
- - name: Assert that the correct set of commands were generated
- assert:
- that:
- - "{{ deleted_nh['commands'] | symmetric_difference(result['commands'])\
- \ |length == 0 }}"
-
- - name: Assert that the after dicts were correctly generated
- assert:
- that:
- - "{{ deleted_nh['after'] | symmetric_difference(result['after']) |length\
- \ == 0 }}"
-
- - name: Delete attributes of given interfaces (IDEMPOTENT)
- register: result
- vyos.vyos.vyos_static_routes: *id001
-
- - name: Assert that the previous task was idempotent
- assert:
- that:
- - result.changed == false
- - result.commands|length == 0
-
- - name: Assert that the before dicts were correctly generated
- assert:
- that:
- - "{{ deleted_nh['after'] | symmetric_difference(result['before']) |length\
- \ == 0 }}"
- always:
-
- - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_static_routes/vars/main.yaml b/tests/integration/targets/vyos_static_routes/vars/main.yaml
index 93b875f..6ce4cea 100644
--- a/tests/integration/targets/vyos_static_routes/vars/main.yaml
+++ b/tests/integration/targets/vyos_static_routes/vars/main.yaml
@@ -94,31 +94,7 @@ rendered:
- set protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::2'
- set protocols static route6 2001:db8:1000::/36 blackhole distance '2'
- set protocols static route6 2001:db8:1000::/36
-deleted_dest:
- commands:
- - delete protocols static route 192.0.2.32/28
- - delete protocols static route6 2001:db8:1000::/36
- after: []
-deleted_nh:
- commands:
- - delete protocols static route 192.0.2.32/28 next-hop '192.0.2.9'
- - delete protocols static route6 2001:db8:1000::/36 next-hop '2001:db8:2000:2::1'
- after:
- - address_families:
- - afi: ipv4
- routes:
- - dest: 192.0.2.32/28
- blackhole_config:
- type: blackhole
- next_hops:
- - forward_router_address: 192.0.2.10
- - afi: ipv6
- routes:
- - dest: 2001:db8:1000::/36
- blackhole_config:
- distance: 2
- next_hops:
- - forward_router_address: 2001:db8:2000:2::2
+
deleted_afi_all:
commands:
- delete protocols static route
diff --git a/tests/unit/modules/network/vyos/test_vyos_static_route.py b/tests/unit/modules/network/vyos/test_vyos_static_route.py
index 762508c..8eef5fb 100644
--- a/tests/unit/modules/network/vyos/test_vyos_static_route.py
+++ b/tests/unit/modules/network/vyos/test_vyos_static_route.py
@@ -21,7 +21,7 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible_collections.vyos.vyos.tests.unit.compat.mock import patch
-from ansible.modules.network.vyos import _vyos_static_route
+from ansible.modules.network.vyos import vyos_static_route
from ansible_collections.vyos.vyos.tests.unit.modules.utils import (
set_module_args,
)
@@ -30,18 +30,18 @@ from .vyos_module import TestVyosModule
class TestVyosStaticRouteModule(TestVyosModule):
- module = _vyos_static_route
+ module = vyos_static_route
def setUp(self):
super(TestVyosStaticRouteModule, self).setUp()
self.mock_get_config = patch(
- "ansible.modules.network.vyos._vyos_static_route.get_config"
+ "ansible.modules.network.vyos.vyos_static_route.get_config"
)
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch(
- "ansible.modules.network.vyos._vyos_static_route.load_config"
+ "ansible.modules.network.vyos.vyos_static_route.load_config"
)
self.load_config = self.mock_load_config.start()
diff --git a/tests/unit/modules/network/vyos/test_vyos_static_routes.py b/tests/unit/modules/network/vyos/test_vyos_static_routes.py
index 3646d61..85c0842 100644
--- a/tests/unit/modules/network/vyos/test_vyos_static_routes.py
+++ b/tests/unit/modules/network/vyos/test_vyos_static_routes.py
@@ -277,17 +277,9 @@ class TestVyosStaticRoutesModule(TestVyosModule):
def test_vyos_static_routes_deleted(self):
set_module_args(
dict(
- config=[
- dict(
- address_families=[
- dict(
- afi="ipv4", routes=[dict(dest="192.0.2.32/28")]
- )
- ]
- )
- ],
+ config=[dict(address_families=[dict(afi="ipv4")])],
state="deleted",
)
)
- commands = ["delete protocols static route 192.0.2.32/28"]
+ commands = ["delete protocols static route"]
self.execute_module(changed=True, commands=commands)