From 35f625ee3b9a01b9e8fc7ffaea18457d77efa08a Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Wed, 8 Aug 2018 15:15:08 -0400 Subject: [PATCH] Network *_config action plugin updates (#43838) * Compatibility fixes for ${network_os}_config action plugins --- lib/ansible/plugins/action/aireos_config.py | 4 ++-- lib/ansible/plugins/action/aruba_config.py | 4 ++-- lib/ansible/plugins/action/asa_config.py | 2 +- lib/ansible/plugins/action/ce_config.py | 5 ++--- lib/ansible/plugins/action/cnos_config.py | 3 +-- lib/ansible/plugins/action/dellos10_config.py | 4 ++-- lib/ansible/plugins/action/dellos6_config.py | 4 ++-- lib/ansible/plugins/action/dellos9_config.py | 4 ++-- lib/ansible/plugins/action/iosxr_config.py | 2 +- lib/ansible/plugins/action/ironware_config.py | 4 ++-- lib/ansible/plugins/action/junos_config.py | 5 ++--- lib/ansible/plugins/action/net_config.py | 5 ++--- lib/ansible/plugins/action/nxos_config.py | 3 +-- lib/ansible/plugins/action/onyx_config.py | 2 +- lib/ansible/plugins/action/sros_config.py | 10 +++++----- 15 files changed, 28 insertions(+), 33 deletions(-) diff --git a/lib/ansible/plugins/action/aireos_config.py b/lib/ansible/plugins/action/aireos_config.py index 99abd86bdf4..b94be5447af 100644 --- a/lib/ansible/plugins/action/aireos_config.py +++ b/lib/ansible/plugins/action/aireos_config.py @@ -40,7 +40,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect @@ -55,7 +55,7 @@ class ActionModule(_ActionModule): # strip out any keys that have two leading and two trailing # underscore characters - for key in result.keys(): + for key in list(result): if PRIVATE_KEYS_RE.match(key): del result[key] diff --git a/lib/ansible/plugins/action/aruba_config.py b/lib/ansible/plugins/action/aruba_config.py index bff406b150b..7c9e1a77ae4 100644 --- a/lib/ansible/plugins/action/aruba_config.py +++ b/lib/ansible/plugins/action/aruba_config.py @@ -40,7 +40,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect @@ -55,7 +55,7 @@ class ActionModule(_ActionModule): # strip out any keys that have two leading and two trailing # underscore characters - for key in result.keys(): + for key in list(result): if PRIVATE_KEYS_RE.match(key): del result[key] diff --git a/lib/ansible/plugins/action/asa_config.py b/lib/ansible/plugins/action/asa_config.py index 8513d84616d..f878ba34d4e 100644 --- a/lib/ansible/plugins/action/asa_config.py +++ b/lib/ansible/plugins/action/asa_config.py @@ -40,7 +40,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect diff --git a/lib/ansible/plugins/action/ce_config.py b/lib/ansible/plugins/action/ce_config.py index a798d1f9c39..e422292e49a 100644 --- a/lib/ansible/plugins/action/ce_config.py +++ b/lib/ansible/plugins/action/ce_config.py @@ -29,7 +29,6 @@ from ansible.module_utils._text import to_text from ansible.module_utils.six.moves.urllib.parse import urlsplit from ansible.utils.vars import merge_hash - PRIVATE_KEYS_RE = re.compile('__.+__') @@ -41,7 +40,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect @@ -56,7 +55,7 @@ class ActionModule(_ActionModule): # strip out any keys that have two leading and two trailing # underscore characters - for key in result.keys(): + for key in list(result): if PRIVATE_KEYS_RE.match(key): del result[key] diff --git a/lib/ansible/plugins/action/cnos_config.py b/lib/ansible/plugins/action/cnos_config.py index 2201b5702aa..31699b3db09 100644 --- a/lib/ansible/plugins/action/cnos_config.py +++ b/lib/ansible/plugins/action/cnos_config.py @@ -25,7 +25,6 @@ from ansible.module_utils._text import to_text from ansible.module_utils.six.moves.urllib.parse import urlsplit from ansible.utils.vars import merge_hash - PRIVATE_KEYS_RE = re.compile('__.+__') @@ -52,7 +51,7 @@ class ActionModule(_ActionModule): # strip out any keys that have two leading and two trailing # underscore characters - for key in list(result.keys()): + for key in list(result): if PRIVATE_KEYS_RE.match(key): del result[key] diff --git a/lib/ansible/plugins/action/dellos10_config.py b/lib/ansible/plugins/action/dellos10_config.py index ab8b60cdbd4..b08f6d995d9 100644 --- a/lib/ansible/plugins/action/dellos10_config.py +++ b/lib/ansible/plugins/action/dellos10_config.py @@ -42,7 +42,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect @@ -57,7 +57,7 @@ class ActionModule(_ActionModule): # strip out any keys that have two leading and two trailing # underscore characters - for key in result.keys(): + for key in list(result): if PRIVATE_KEYS_RE.match(key): del result[key] diff --git a/lib/ansible/plugins/action/dellos6_config.py b/lib/ansible/plugins/action/dellos6_config.py index b02ee7232d6..7e7854c4296 100644 --- a/lib/ansible/plugins/action/dellos6_config.py +++ b/lib/ansible/plugins/action/dellos6_config.py @@ -39,7 +39,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect @@ -54,7 +54,7 @@ class ActionModule(_ActionModule): # strip out any keys that have two leading and two trailing # underscore characters - for key in result.keys(): + for key in list(result): if PRIVATE_KEYS_RE.match(key): del result[key] diff --git a/lib/ansible/plugins/action/dellos9_config.py b/lib/ansible/plugins/action/dellos9_config.py index 88d4dd42b46..85902e16e9b 100644 --- a/lib/ansible/plugins/action/dellos9_config.py +++ b/lib/ansible/plugins/action/dellos9_config.py @@ -42,7 +42,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect @@ -57,7 +57,7 @@ class ActionModule(_ActionModule): # strip out any keys that have two leading and two trailing # underscore characters - for key in result.keys(): + for key in list(result): if PRIVATE_KEYS_RE.match(key): del result[key] diff --git a/lib/ansible/plugins/action/iosxr_config.py b/lib/ansible/plugins/action/iosxr_config.py index cdc2eccced4..d862e7fa338 100644 --- a/lib/ansible/plugins/action/iosxr_config.py +++ b/lib/ansible/plugins/action/iosxr_config.py @@ -25,7 +25,7 @@ import time import glob from ansible.plugins.action.iosxr import ActionModule as _ActionModule -from ansible.module_utils._text import to_text, to_bytes +from ansible.module_utils._text import to_text from ansible.module_utils.six.moves.urllib.parse import urlsplit from ansible.utils.vars import merge_hash diff --git a/lib/ansible/plugins/action/ironware_config.py b/lib/ansible/plugins/action/ironware_config.py index 06609f1b6a1..c4cd817043b 100644 --- a/lib/ansible/plugins/action/ironware_config.py +++ b/lib/ansible/plugins/action/ironware_config.py @@ -40,7 +40,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect @@ -55,7 +55,7 @@ class ActionModule(_ActionModule): # strip out any keys that have two leading and two trailing # underscore characters - for key in result.keys(): + for key in list(result): if PRIVATE_KEYS_RE.match(key): del result[key] diff --git a/lib/ansible/plugins/action/junos_config.py b/lib/ansible/plugins/action/junos_config.py index ea0687ec34e..d382714d1d8 100644 --- a/lib/ansible/plugins/action/junos_config.py +++ b/lib/ansible/plugins/action/junos_config.py @@ -25,9 +25,8 @@ import time import glob from ansible.plugins.action.junos import ActionModule as _ActionModule -from ansible.module_utils._text import to_text +from ansible.module_utils._text import to_text, to_bytes from ansible.module_utils.six.moves.urllib.parse import urlsplit -from ansible.module_utils._text import to_bytes from ansible.utils.vars import merge_hash PRIVATE_KEYS_RE = re.compile('__.+__') @@ -41,7 +40,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect diff --git a/lib/ansible/plugins/action/net_config.py b/lib/ansible/plugins/action/net_config.py index 85214626079..1fcfd55324a 100644 --- a/lib/ansible/plugins/action/net_config.py +++ b/lib/ansible/plugins/action/net_config.py @@ -29,7 +29,6 @@ from ansible.module_utils._text import to_text from ansible.module_utils.six.moves.urllib.parse import urlsplit from ansible.utils.vars import merge_hash - PRIVATE_KEYS_RE = re.compile('__.+__') @@ -41,7 +40,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect @@ -56,7 +55,7 @@ class ActionModule(_ActionModule): # strip out any keys that have two leading and two trailing # underscore characters - for key in result.keys(): + for key in list(result): if PRIVATE_KEYS_RE.match(key): del result[key] diff --git a/lib/ansible/plugins/action/nxos_config.py b/lib/ansible/plugins/action/nxos_config.py index 2d61a224e6c..a62b2a85b7f 100644 --- a/lib/ansible/plugins/action/nxos_config.py +++ b/lib/ansible/plugins/action/nxos_config.py @@ -29,7 +29,6 @@ from ansible.module_utils._text import to_text from ansible.module_utils.six.moves.urllib.parse import urlsplit from ansible.utils.vars import merge_hash - PRIVATE_KEYS_RE = re.compile('__.+__') @@ -41,7 +40,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=str(exc)) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect diff --git a/lib/ansible/plugins/action/onyx_config.py b/lib/ansible/plugins/action/onyx_config.py index a290d5cdfd8..e8c9b3564e0 100644 --- a/lib/ansible/plugins/action/onyx_config.py +++ b/lib/ansible/plugins/action/onyx_config.py @@ -39,7 +39,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect diff --git a/lib/ansible/plugins/action/sros_config.py b/lib/ansible/plugins/action/sros_config.py index aeb6468c9e3..07ae645564d 100644 --- a/lib/ansible/plugins/action/sros_config.py +++ b/lib/ansible/plugins/action/sros_config.py @@ -19,14 +19,14 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -import glob import os import re import time +import glob -from ansible.module_utils.six.moves.urllib.parse import urlsplit -from ansible.module_utils._text import to_text from ansible.plugins.action.sros import ActionModule as _ActionModule +from ansible.module_utils._text import to_text +from ansible.module_utils.six.moves.urllib.parse import urlsplit from ansible.utils.vars import merge_hash PRIVATE_KEYS_RE = re.compile('__.+__') @@ -40,7 +40,7 @@ class ActionModule(_ActionModule): try: self._handle_template() except ValueError as exc: - return dict(failed=True, msg=exc.message) + return dict(failed=True, msg=to_text(exc)) result = super(ActionModule, self).run(tmp, task_vars) del tmp # tmp no longer has any effect @@ -55,7 +55,7 @@ class ActionModule(_ActionModule): # strip out any keys that have two leading and two trailing # underscore characters - for key in result.keys(): + for key in list(result): if PRIVATE_KEYS_RE.match(key): del result[key]