mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
ios_static_route idempotence fix (#35912)
* Remove default admin_distance and fix the idempotence thereof Fixes #33290 * Fix tests and use yaml anchors to shorten tests * Add test for undefined admin_distance * Read config from `show run` if `show ip static route` fails * Restore flags to ios.get_config & use get_config where appropriate
This commit is contained in:
parent
0feea66988
commit
7016b3b9ca
5 changed files with 121 additions and 87 deletions
|
@ -108,15 +108,15 @@ def get_defaults_flag(module):
|
|||
|
||||
|
||||
def get_config(module, flags=None):
|
||||
global _DEVICE_CONFIGS
|
||||
flag_str = ' '.join(to_list(flags))
|
||||
|
||||
if _DEVICE_CONFIGS != {}:
|
||||
return _DEVICE_CONFIGS
|
||||
else:
|
||||
try:
|
||||
return _DEVICE_CONFIGS[flag_str]
|
||||
except KeyError:
|
||||
connection = get_connection(module)
|
||||
out = connection.get_config()
|
||||
out = connection.get_config(flags=flags)
|
||||
cfg = to_text(out, errors='surrogate_then_replace').strip()
|
||||
_DEVICE_CONFIGS = cfg
|
||||
_DEVICE_CONFIGS[flag_str] = cfg
|
||||
return cfg
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue