diff --git a/lib/ansible/modules/network/nxos/nxos_command.py b/lib/ansible/modules/network/nxos/nxos_command.py
index 812d2112b0..a11026a0a6 100644
--- a/lib/ansible/modules/network/nxos/nxos_command.py
+++ b/lib/ansible/modules/network/nxos/nxos_command.py
@@ -1,20 +1,10 @@
#!/usr/bin/python
-#
-# 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 .
-#
+# Copyright: Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
@@ -155,13 +145,13 @@ failed_conditions:
"""
import time
-from ansible.module_utils.nxos import run_commands
-from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.six import string_types
from ansible.module_utils.netcli import Conditional, FailedConditionalError
from ansible.module_utils.network_common import ComplexList
-from ansible.module_utils.nxos import nxos_argument_spec, check_args
+from ansible.module_utils.nxos import check_args, nxos_argument_spec, run_commands
+from ansible.module_utils.six import string_types
+from ansible.module_utils._text import to_native
+
def to_lines(stdout):
lines = list()
@@ -171,6 +161,7 @@ def to_lines(stdout):
lines.append(item)
return lines
+
def parse_commands(module, warnings):
transform = ComplexList(dict(
command=dict(key=True),
@@ -199,6 +190,7 @@ def to_cli(obj):
cmd += ' | json'
return cmd
+
def main():
"""entry point for module execution
"""
@@ -218,7 +210,6 @@ def main():
module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=True)
-
result = {'changed': False}
warnings = list()
@@ -230,9 +221,8 @@ def main():
try:
conditionals = [Conditional(c) for c in wait_for]
- except AttributeError:
- exc = get_exception()
- module.fail_json(msg=str(exc))
+ except AttributeError as exc:
+ module.fail_json(msg=to_native(exc))
retries = module.params['retries']
interval = module.params['interval']
@@ -248,9 +238,8 @@ def main():
conditionals = list()
break
conditionals.remove(item)
- except FailedConditionalError:
- exc = get_exception()
- module.fail_json(msg=str(exc))
+ except FailedConditionalError as exc:
+ module.fail_json(msg=to_native(exc))
if not conditionals:
break
diff --git a/lib/ansible/modules/network/nxos/nxos_ntp.py b/lib/ansible/modules/network/nxos/nxos_ntp.py
index e939925e3e..4b000a5ca5 100644
--- a/lib/ansible/modules/network/nxos/nxos_ntp.py
+++ b/lib/ansible/modules/network/nxos/nxos_ntp.py
@@ -1,20 +1,10 @@
#!/usr/bin/python
-#
-# 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 .
-#
+# Copyright: Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
@@ -127,12 +117,11 @@ changed:
sample: true
'''
-from ansible.module_utils.nxos import get_config, load_config, run_commands
-from ansible.module_utils.nxos import nxos_argument_spec, check_args
-from ansible.module_utils.basic import AnsibleModule
-
import re
+from ansible.module_utils.basic import AnsibleModule
+from ansible.module_utils.nxos import check_args, load_config, nxos_argument_spec, run_commands
+
def execute_show_command(command, module, command_type='cli_show'):
if 'show run' not in command:
@@ -319,10 +308,10 @@ def main():
argument_spec.update(nxos_argument_spec)
module = AnsibleModule(argument_spec=argument_spec,
- mutually_exclusive=[
- ['server','peer'],
- ['source_addr','source_int']],
- supports_check_mode=True)
+ mutually_exclusive=[
+ ['server', 'peer'],
+ ['source_addr', 'source_int']],
+ supports_check_mode=True)
warnings = list()
check_args(module, warnings)
@@ -424,6 +413,5 @@ def main():
module.exit_json(**results)
-from ansible.module_utils.basic import *
if __name__ == '__main__':
main()