mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-07 08:54:01 -07:00
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:
parent
addb882138
commit
717b6e7c1a
8 changed files with 624 additions and 7 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue