Ios fixes 2.5 (#40543)

* Ios test fixes (#40503)

* Return messages generated from edit_config to module

* This does not seem to work that way

* Change test IP addresses to not conflict with device config

* Add test for idempotency with multiple ipv6 addresses assigned
pull/40548/head
Nathaniel Case 7 years ago committed by GitHub
parent e877469533
commit 7df6df9017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -165,4 +165,4 @@ def run_commands(module, commands, check_rc=True):
def load_config(module, commands):
connection = get_connection(module)
out = connection.edit_config(commands)
return connection.edit_config(commands)

@ -296,9 +296,6 @@ def main():
result = {'changed': False}
if warnings:
result['warnings'] = warnings
want = map_params_to_obj(module)
have = map_config_to_obj(module)
@ -307,10 +304,14 @@ def main():
if commands:
if not module.check_mode:
load_config(module, commands)
resp = load_config(module, commands)
warnings.extend((out for out in resp if out))
result['changed'] = True
if warnings:
result['warnings'] = warnings
module.exit_json(**result)

@ -72,6 +72,7 @@ class Cliconf(CliconfBase):
@enable_mode
def edit_config(self, command):
results = []
for cmd in chain(['configure terminal'], to_list(command), ['end']):
if isinstance(cmd, dict):
command = cmd['command']
@ -84,7 +85,8 @@ class Cliconf(CliconfBase):
answer = None
newline = True
self.send_command(command, prompt, answer, False, newline)
results.append(self.send_command(command, prompt, answer, False, newline))
return results[1:-1]
def get(self, command, prompt=None, answer=None, sendonly=False):
return self.send_command(command, prompt=prompt, answer=answer, sendonly=sendonly)

@ -22,7 +22,7 @@
- name: Configure interface ipv4 address
ios_l3_interface:
name: "{{ test_interface }}"
ipv4: 192.168.0.1/24
ipv4: 192.168.20.1/24
state: present
provider: "{{ cli }}"
register: result
@ -31,24 +31,24 @@
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"ip address 192.168.0.1 255.255.255.0" in result.commands'
- '"ip address 192.168.20.1 255.255.255.0" in result.commands'
- name: Configure interface ipv4 address (idempotent)
ios_l3_interface:
name: "{{ test_interface }}"
ipv4: 192.168.0.1/24
ipv4: 192.168.20.1/24
state: present
provider: "{{ cli }}"
register: result
- assert:
- assert: &unchanged
that:
- 'result.changed == false'
- name: Assign same ipv4 address to other interface (fail)
ios_l3_interface:
name: "{{ test_interface2 }}"
ipv4: 192.168.0.1/24
ipv4: 192.168.20.1/24
state: present
provider: "{{ cli }}"
ignore_errors: yes
@ -74,7 +74,7 @@
- '"ip address dhcp" in result.commands'
- name: Configure interface ipv6 address
ios_l3_interface:
ios_l3_interface: &ipv6-1
name: "{{ test_interface }}"
ipv6: fd5d:12c9:2201:1::1/64
state: present
@ -88,16 +88,36 @@
- '"ipv6 address fd5d:12c9:2201:1::1/64" in result.commands'
- name: Configure interface ipv6 address (idempotent)
ios_l3_interface:
ios_l3_interface: *ipv6-1
register: result
- assert: *unchanged
- name: Configure second ipv6 address on interface
ios_l3_interface: &ipv6-2
name: "{{ test_interface }}"
ipv6: fd5d:12c9:2201:1::1/64
ipv6: fd5d:12c9:2291:1::1/64
state: present
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == false'
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"ipv6 address fd5d:12c9:2291:1::1/64" in result.commands'
- name: Ensure first ipv6 address still associated with interface
ios_l3_interface: *ipv6-1
register: result
- assert: *unchanged
- name: Ensure second ipv6 address still associated with interface
ios_l3_interface: *ipv6-2
register: result
- assert: *unchanged
- name: Assign same ipv6 address to other interface (fail)
ios_l3_interface:
@ -181,9 +201,7 @@
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == false'
- assert: *unchanged
- name: Change ipv4 and ipv6 address using aggregate
ios_l3_interface:
@ -232,8 +250,6 @@
provider: "{{ cli }}"
register: result
- assert:
that:
- 'result.changed == false'
- assert: *unchanged
- debug: msg="END ios_l3_interface cli/basic.yaml on connection={{ ansible_connection }}"

Loading…
Cancel
Save