diff options
author | yanzhangi <51999930+yanzhangi@users.noreply.github.com> | 2019-11-13 03:56:01 +0800 |
---|---|---|
committer | Matt Davis <nitzmahone@users.noreply.github.com> | 2019-11-12 11:56:01 -0800 |
commit | 20a8bf592e16556ac6c97144e3b3df6a1cde79cc (patch) | |
tree | 2dd21b82c3062d39b1cb4880c3c5aa60584a9fbb | |
parent | dfa74b5c52097263e8aba6b1c887564454fd0e7a (diff) | |
download | ansible-20a8bf592e16556ac6c97144e3b3df6a1cde79cc.tar.gz |
{Backport/2.8/64018]update ce_acl_interface to fix bugs (#64024)
* update ce_acl_interface to fix bugs
(cherry picked from commit 2849738e24bfbfbf142a32596536ac2a6b89aab5)
* Module modification information
-rw-r--r-- | changelogs/fragments/64018-ce_acl_interface-to-fix-bugs.yml | 2 | ||||
-rw-r--r-- | lib/ansible/modules/network/cloudengine/ce_acl_interface.py | 24 |
2 files changed, 24 insertions, 2 deletions
diff --git a/changelogs/fragments/64018-ce_acl_interface-to-fix-bugs.yml b/changelogs/fragments/64018-ce_acl_interface-to-fix-bugs.yml new file mode 100644 index 0000000000..951b94f5a3 --- /dev/null +++ b/changelogs/fragments/64018-ce_acl_interface-to-fix-bugs.yml @@ -0,0 +1,2 @@ +bugfixes: +- ce_acl_interface - update to fix some bugs - Modified the prompt statement when the switch device cannot be configured. (https://github.com/ansible/ansible/pull/64018) diff --git a/lib/ansible/modules/network/cloudengine/ce_acl_interface.py b/lib/ansible/modules/network/cloudengine/ce_acl_interface.py index 321cedb309..a71d30d5f1 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 """ |