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:
Nathaniel Case 2018-03-05 09:28:37 -05:00 committed by GitHub
parent 0feea66988
commit 7016b3b9ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 121 additions and 87 deletions

View file

@ -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