From c6acf44a7cc6626cc1c0a1b2cd97cb6385e46005 Mon Sep 17 00:00:00 2001 From: Senthil Kumar Ganesan Date: Tue, 13 Sep 2016 10:42:12 -0700 Subject: [PATCH] Added support for dnos9_config module --- CHANGELOG.md | 9 +++---- lib/ansible/module_utils/dnos9.py | 15 +++++++++--- lib/ansible/plugins/action/dnos9_config.py | 28 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 lib/ansible/plugins/action/dnos9_config.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 72988cf28a6..378174ca047 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,11 @@ Ansible Changes By Release - cloudstack * cs_router * cs_snapshot_policy +- dnos6 + * dnos6_command +- dnos9 + * dnos9_command + * dnos9_config - dnos10 * dnos10_command * dnos10_config @@ -73,10 +78,6 @@ Ansible Changes By Release - exoscale: * exo_dns_domain * exo_dns_record -- dnos6 - * dnos6_command -- dnos9 - * dnos9_command - f5: * bigip_device_dns * bigip_device_ntp diff --git a/lib/ansible/module_utils/dnos9.py b/lib/ansible/module_utils/dnos9.py index 71a290e440e..0efa77f86e6 100755 --- a/lib/ansible/module_utils/dnos9.py +++ b/lib/ansible/module_utils/dnos9.py @@ -63,18 +63,23 @@ class Cli(CliBase): NET_PASSWD_RE = re.compile(r"[\r\n]?password:\s?$", re.I) + WARNING_PROMPTS_RE = [ + re.compile(r"[\r\n]?\[confirm yes/no\]:\s?$"), + re.compile(r"[\r\n]?\[y/n\]:\s?$"), + re.compile(r"[\r\n]?\[yes/no\]:\s?$") + ] + CLI_PROMPTS_RE = [ re.compile(r"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"), re.compile(r"\[\w+\@[\w\-\.]+(?: [^\]])\] ?[>#\$] ?$") ] CLI_ERRORS_RE = [ - re.compile(r"% ?Error"), + re.compile(r"% ?Error: (?:(?!\bdoes not exist\b)(?!\balready exists\b)(?!\bHost not found\b).)*$"), re.compile(r"% ?Bad secret"), re.compile(r"invalid input", re.I), re.compile(r"(?:incomplete|ambiguous) command", re.I), re.compile(r"connection timed out", re.I), - re.compile(r"[^\r\n]+ not found", re.I), re.compile(r"'[^']' +returned error code: ?\d+"), ] @@ -92,7 +97,11 @@ class Cli(CliBase): def configure(self, commands, **kwargs): cmds = ['configure terminal'] - cmds.extend(to_list(commands)) + cmdlist = list() + for c in to_list(commands): + cmd = Command(c, prompt=self.WARNING_PROMPTS_RE, response='yes') + cmdlist.append(cmd) + cmds.extend(cmdlist) cmds.append('end') responses = self.execute(cmds) diff --git a/lib/ansible/plugins/action/dnos9_config.py b/lib/ansible/plugins/action/dnos9_config.py new file mode 100644 index 00000000000..ffcb0f057f8 --- /dev/null +++ b/lib/ansible/plugins/action/dnos9_config.py @@ -0,0 +1,28 @@ +# +# Copyright 2015 Peter Sprygada +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . +# +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +from ansible.plugins.action import ActionBase +from ansible.plugins.action.net_config import ActionModule as NetActionModule + +class ActionModule(NetActionModule, ActionBase): + pass + +