Backport ios test fixes to 2.5 (#40662)
* 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 (cherry picked from commiteb818df1ec
) * Search all assigned ipv6 addresses instead of just the first (#40533) * Search all assigned ipv6 addresses instead of just the first * Add test for idempotency with multiple ipv6 addresses assigned (cherry picked from commite8d02a3a0f
) * Fix ios test pt. 2 (#40628) * Add missing idempotence assert * Remove dhcp with other addresses on ipv6 (cherry picked from commitf88412b7cd
)
This commit is contained in:
parent
3f2831c6e2
commit
d6a07186fd
3 changed files with 20 additions and 8 deletions
|
@ -107,11 +107,10 @@ from copy import deepcopy
|
|||
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.network.ios.ios import get_config, load_config
|
||||
from ansible.module_utils.network.ios.ios import ios_argument_spec
|
||||
from ansible.module_utils.network.common.config import NetworkConfig
|
||||
from ansible.module_utils.network.common.utils import conditional, remove_default_spec
|
||||
from ansible.module_utils.network.common.utils import remove_default_spec
|
||||
from ansible.module_utils.network.common.utils import is_netmask, is_masklen, to_netmask, to_masklen
|
||||
|
||||
|
||||
|
@ -148,9 +147,18 @@ def validate_param_values(module, obj, param=None):
|
|||
def parse_config_argument(configobj, name, arg=None):
|
||||
cfg = configobj['interface %s' % name]
|
||||
cfg = '\n'.join(cfg.children)
|
||||
match = re.search(r'%s (.+)$' % arg, cfg, re.M)
|
||||
if match:
|
||||
return match.group(1).strip()
|
||||
|
||||
values = []
|
||||
matches = re.finditer(r'%s (.+)$' % arg, cfg, re.M)
|
||||
for match in matches:
|
||||
match_str = match.group(1).strip()
|
||||
if arg == 'ipv6 address':
|
||||
values.append(match_str)
|
||||
else:
|
||||
values = match_str
|
||||
break
|
||||
|
||||
return values or None
|
||||
|
||||
|
||||
def search_obj_in_list(name, lst):
|
||||
|
@ -188,6 +196,8 @@ def map_obj_to_commands(updates, module):
|
|||
commands.append('no ipv6 address {}'.format(ipv6))
|
||||
else:
|
||||
commands.append('no ipv6 address')
|
||||
if 'dhcp' in obj_in_have['ipv6']:
|
||||
commands.append('no ipv6 address dhcp')
|
||||
|
||||
elif state == 'present':
|
||||
if ipv4:
|
||||
|
@ -198,7 +208,7 @@ def map_obj_to_commands(updates, module):
|
|||
commands.append('ip address {}'.format(ipv4))
|
||||
|
||||
if ipv6:
|
||||
if obj_in_have is None or obj_in_have.get('ipv6') is None or ipv6.lower() != obj_in_have['ipv6'].lower():
|
||||
if obj_in_have is None or obj_in_have.get('ipv6') is None or ipv6.lower() not in [addr.lower() for addr in obj_in_have['ipv6']]:
|
||||
commands.append('ipv6 address {}'.format(ipv6))
|
||||
|
||||
if commands[-1] == interface:
|
||||
|
|
|
@ -185,7 +185,7 @@ class CliconfBase(with_metaclass(ABCMeta, object)):
|
|||
ssh = self._connection.paramiko_conn._connect_uncached()
|
||||
if proto == 'scp':
|
||||
if not HAS_SCP:
|
||||
self._connection.internal_error("Required library scp is not installed. Please install it using `pip install scp`")
|
||||
raise AnsibleError("Required library scp is not installed. Please install it using `pip install scp`")
|
||||
with SCPClient(ssh.get_transport()) as scp:
|
||||
scp.put(source, destination)
|
||||
elif proto == 'sftp':
|
||||
|
@ -197,7 +197,7 @@ class CliconfBase(with_metaclass(ABCMeta, object)):
|
|||
ssh = self._connection.paramiko_conn._connect_uncached()
|
||||
if proto == 'scp':
|
||||
if not HAS_SCP:
|
||||
self._connection.internal_error("Required library scp is not installed. Please install it using `pip install scp`")
|
||||
raise AnsibleError("Required library scp is not installed. Please install it using `pip install scp`")
|
||||
with SCPClient(ssh.get_transport()) as scp:
|
||||
scp.get(source, destination)
|
||||
elif proto == 'sftp':
|
||||
|
|
|
@ -168,6 +168,8 @@
|
|||
provider: "{{ cli }}"
|
||||
register: result
|
||||
|
||||
- assert: *unchanged
|
||||
|
||||
- name: Delete second interface ipv4 and ipv6 address (setup)
|
||||
ios_l3_interface:
|
||||
name: "{{ test_interface2 }}"
|
||||
|
|
Loading…
Reference in a new issue