Refactor common network shared and platform utils code into package (#33452)

* Refactor common network shared and platform specific code into package (part-1)

As per proposal #76 refactor common network shared and platform specific
code into sub-package.
https://github.com/ansible/proposals/issues/76

*  ansible.module_utils.network.common - command shared functions
*  ansible.module_utils.network.{{ platform }} - where platform is platform specific shared functions

*  Fix review comments

* Fix review comments
This commit is contained in:
Ganesh Nalawade
2017-12-03 21:42:30 +05:30
committed by GitHub
parent 18aca48075
commit 11c9ad23d5
483 changed files with 871 additions and 887 deletions

View File

@@ -0,0 +1,19 @@
_DEVICE_CONFIGS = {}
def get_config(module, flags=None):
flags = [] if flags is None else flags
cmd = 'show running-config '
cmd += ' '.join(flags)
cmd = cmd.strip()
try:
return _DEVICE_CONFIGS[cmd]
except KeyError:
rc, out, err = module.exec_command(cmd)
if rc != 0:
module.fail_json(msg='unable to retrieve current config', stderr=err)
cfg = str(out).strip()
_DEVICE_CONFIGS[cmd] = cfg
return cfg