diff options
author | GomathiselviS <gomathiselvi@gmail.com> | 2020-08-10 11:13:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-10 15:13:45 +0000 |
commit | a69b936ac650fee178a5c07c74db6aeea739267a (patch) | |
tree | b23d6462eb2ef7e6cfd72c430354beda5a836770 /plugins/modules/vyos_interface.py | |
parent | f88b875dd9377951b973cdfe871f7dd4a19b09f1 (diff) | |
download | vyos.vyos-a69b936ac650fee178a5c07c74db6aeea739267a.tar.gz vyos.vyos-a69b936ac650fee178a5c07c74db6aeea739267a.zip |
vyos_interface : refactor testcases (#71)
vyos_interface : refactor testcases
Reviewed-by: https://github.com/apps/ansible-zuul
Diffstat (limited to 'plugins/modules/vyos_interface.py')
-rw-r--r-- | plugins/modules/vyos_interface.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/plugins/modules/vyos_interface.py b/plugins/modules/vyos_interface.py index 839e559..21b0dc2 100644 --- a/plugins/modules/vyos_interface.py +++ b/plugins/modules/vyos_interface.py @@ -277,7 +277,6 @@ def search_obj_in_list(name, lst): def map_obj_to_commands(updates): commands = list() want, have = updates - params = ("speed", "description", "duplex", "mtu") for w in want: name = w["name"] @@ -402,6 +401,18 @@ def map_params_to_obj(module): return obj +def get_interfaces_data(module, name): + command = "show interfaces ethernet %s" % name + rc, out, err = exec_command(module, command) + return [rc, out, err] + + +def get_lldp_neighbor(module): + command = "show lldp neighbors detail" + rc, out, err = exec_command(module, command) + return [rc, out, err] + + def check_declarative_intent_params(module, want, result): failed_conditions = [] have_neighbors = None @@ -416,7 +427,7 @@ def check_declarative_intent_params(module, want, result): sleep(w["delay"]) command = "show interfaces ethernet %s" % w["name"] - rc, out, err = exec_command(module, command) + rc, out, err = get_interfaces_data(w["name"], module) if rc != 0: module.fail_json( msg=to_text(err, errors="surrogate_then_replace"), @@ -438,9 +449,7 @@ def check_declarative_intent_params(module, want, result): have_host = [] have_port = [] if have_neighbors is None: - rc, have_neighbors, err = exec_command( - module, "show lldp neighbors detail" - ) + rc, have_neighbors, err = get_lldp_neighbor(module) if rc != 0: module.fail_json( msg=to_text(err, errors="surrogate_then_replace"), |