From 466c3e63ce20b97a74e98f006b62c0a88c569f6d Mon Sep 17 00:00:00 2001 From: yanzhangi <51999930+yanzhangi@users.noreply.github.com> Date: Wed, 18 Sep 2019 09:45:06 +0800 Subject: [PATCH] Update ce_stp to fix bugs (#61774) --- .../modules/network/cloudengine/ce_stp.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/network/cloudengine/ce_stp.py b/lib/ansible/modules/network/cloudengine/ce_stp.py index 99738f3338d..046af50d55f 100644 --- a/lib/ansible/modules/network/cloudengine/ce_stp.py +++ b/lib/ansible/modules/network/cloudengine/ce_stp.py @@ -167,14 +167,23 @@ updates: import re from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.network.cloudengine.ce import load_config, ce_argument_spec -from ansible.module_utils.network.cloudengine.ce import get_config as get_cli_config +from ansible.module_utils.network.cloudengine.ce import exec_command, load_config, ce_argument_spec def get_config(module, flags): - cfg = get_cli_config(module, flags) - config = cfg.strip() if cfg else "" + """Retrieves the current config from the device or cache""" + + flags = [] if flags is None else flags + + cmd = 'display current-configuration ' + cmd += ' '.join(flags) + cmd = cmd.strip() + + rc, out, err = exec_command(module, cmd) + if rc != 0: + module.fail_json(msg=err) + config = str(out).strip() if config.startswith("display"): configs = config.split("\n") if len(configs) > 1: