diff options
author | Dhivyap <dhivya.p@dell.com> | 2019-10-22 14:06:34 +0530 |
---|---|---|
committer | Ganesh Nalawade <ganesh634@gmail.com> | 2019-10-22 14:06:34 +0530 |
commit | 2e65c1ebb7ab66d028efb30c20d1662150466de1 (patch) | |
tree | 1588daf6175ebd19ede35bf016e94f1be12804cd /lib/ansible/plugins/cliconf/dellos6.py | |
parent | 4745d4571163d6f25664afb60f47bd8ea0f3e4c4 (diff) | |
download | ansible-2e65c1ebb7ab66d028efb30c20d1662150466de1.tar.gz |
Bug fixes- Dellos modules (#63272)
Diffstat (limited to 'lib/ansible/plugins/cliconf/dellos6.py')
-rw-r--r-- | lib/ansible/plugins/cliconf/dellos6.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/ansible/plugins/cliconf/dellos6.py b/lib/ansible/plugins/cliconf/dellos6.py index da0d8dcc5f..bae7caeb78 100644 --- a/lib/ansible/plugins/cliconf/dellos6.py +++ b/lib/ansible/plugins/cliconf/dellos6.py @@ -36,7 +36,9 @@ import json from itertools import chain +from ansible.errors import AnsibleConnectionFailure from ansible.module_utils._text import to_bytes, to_text +from ansible.module_utils.common._collections_compat import Mapping from ansible.module_utils.network.common.utils import to_list from ansible.plugins.cliconf import CliconfBase, enable_mode @@ -58,7 +60,7 @@ class Cliconf(CliconfBase): if match: device_info['network_os_model'] = match.group(1) - reply = self.get('show running-config | grep hostname') + reply = self.get('show running-config | include hostname') data = to_text(reply, errors='surrogate_or_strict').strip() match = re.search(r'^hostname (.+)', data, re.M) if match: @@ -87,3 +89,27 @@ class Cliconf(CliconfBase): def get_capabilities(self): result = super(Cliconf, self).get_capabilities() return json.dumps(result) + + def run_commands(self, commands=None, check_rc=True): + if commands is None: + raise ValueError("'commands' value is required") + + responses = list() + for cmd in to_list(commands): + if not isinstance(cmd, Mapping): + cmd = {'command': cmd} + + output = cmd.pop('output', None) + if output: + raise ValueError("'output' value %s is not supported for run_commands" % output) + + try: + out = self.send_command(**cmd) + except AnsibleConnectionFailure as e: + if check_rc: + raise + out = getattr(e, 'err', to_text(e)) + + responses.append(out) + + return responses |