From 823f2e3fca29ff4581e1c032fb770e6623242945 Mon Sep 17 00:00:00 2001 From: yanzhangi <51999930+yanzhangi@users.noreply.github.com> Date: Mon, 28 Oct 2019 21:21:11 +0800 Subject: [PATCH] update ce_acl_interface to fix bugs (#64018) --- .../network/cloudengine/ce_acl_interface.py | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/network/cloudengine/ce_acl_interface.py b/lib/ansible/modules/network/cloudengine/ce_acl_interface.py index 321cedb3090..a71d30d5f12 100644 --- a/lib/ansible/modules/network/cloudengine/ce_acl_interface.py +++ b/lib/ansible/modules/network/cloudengine/ce_acl_interface.py @@ -122,7 +122,7 @@ updates: from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.network.cloudengine.ce import get_config, load_config, exec_command +from ansible.module_utils.network.cloudengine.ce import get_config, exec_command, cli_err_msg from ansible.module_utils.network.cloudengine.ce import ce_argument_spec @@ -231,11 +231,31 @@ class AclInterface(object): end.append(item.strip()) self.end_state["acl interface"] = end + def load_config(self, config): + """Sends configuration commands to the remote device""" + + rc, out, err = exec_command(self.module, 'mmi-mode enable') + if rc != 0: + self.module.fail_json(msg='unable to set mmi-mode enable', output=err) + rc, out, err = exec_command(self.module, 'system-view immediately') + if rc != 0: + self.module.fail_json(msg='unable to enter system-view', output=err) + + for cmd in config: + rc, out, err = exec_command(self.module, cmd) + if rc != 0: + if "unrecognized command found" in err.lower(): + self.module.fail_json(msg="Error:The parameter is incorrect or the interface does not support this parameter.") + else: + self.module.fail_json(msg=cli_err_msg(cmd.strip(), err)) + + exec_command(self.module, 'return') + def cli_load_config(self, commands): """ Cli method to load config """ if not self.module.check_mode: - load_config(self.module, commands) + self.load_config(commands) def work(self): """ Work function """