Add mlnxos_config module (#33356)

* Add new module mlnxos_config

Signed-off-by: Samer Deeb <samerd@mellanox.com>

* Add unit-test for mlnxos_config module

Signed-off-by: Samer Deeb <samerd@mellanox.com>
This commit is contained in:
Samer Deeb 2017-12-01 09:03:02 -08:00 committed by John R Barker
commit 717b6e7c1a
8 changed files with 624 additions and 7 deletions

View file

@ -20,7 +20,7 @@
from ansible.module_utils._text import to_text
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.connection import Connection
from ansible.module_utils.connection import Connection, ConnectionError
from ansible.module_utils.network_common import to_list, EntityCollection
_DEVICE_CONFIGS = {}
@ -85,3 +85,18 @@ def run_commands(module, commands, check_rc=True):
responses.append(to_text(out, errors='surrogate_then_replace'))
return responses
def get_config(module, source='running'):
conn = get_connection(module)
out = conn.get_config(source)
cfg = to_text(out, errors='surrogate_then_replace').strip()
return cfg
def load_config(module, config):
try:
conn = get_connection(module)
conn.edit_config(config)
except ConnectionError as exc:
module.fail_json(msg=to_text(exc))