summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Nalawade <ganesh634@gmail.com>2017-04-05 23:39:16 +0530
committerGitHub <noreply@github.com>2017-04-05 23:39:16 +0530
commit3ba95b8ef73d45de9fcc472b13cb96bd24e34fdb (patch)
tree3a9c6c8ebbafdf5c05aaa3081699a44588439c05
parent55583c71ff0dd22a6b60aa089805f1d222ef42f4 (diff)
downloadansible-3ba95b8ef73d45de9fcc472b13cb96bd24e34fdb.tar.gz
Fix junos pylint issues (#23292)
* Fix junos rollback id validate issue (#23283) (cherry picked from commit 0b8ca98c48522b46f8f001348de6f603e15735da) * Fix various junos errors (#23278) (cherry picked from commit e8538213fa8fb884c67443a4b017718b2f9a5c41)
-rw-r--r--lib/ansible/module_utils/junos.py9
-rw-r--r--lib/ansible/modules/network/junos/junos_command.py4
-rw-r--r--lib/ansible/modules/network/junos/junos_config.py2
-rw-r--r--lib/ansible/modules/network/junos/junos_facts.py4
-rw-r--r--lib/ansible/modules/network/junos/junos_user.py4
5 files changed, 11 insertions, 12 deletions
diff --git a/lib/ansible/module_utils/junos.py b/lib/ansible/module_utils/junos.py
index 211e099eb6..e0827c437c 100644
--- a/lib/ansible/module_utils/junos.py
+++ b/lib/ansible/module_utils/junos.py
@@ -18,12 +18,11 @@
#
from contextlib import contextmanager
-from xml.etree.ElementTree import Element, SubElement, tostring
+from xml.etree.ElementTree import Element, SubElement
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.netconf import send_request, children
from ansible.module_utils.netconf import discard_changes, validate
-from ansible.module_utils.network_common import to_list
from ansible.module_utils.six import string_types
ACTIONS = frozenset(['merge', 'override', 'replace', 'update', 'set'])
@@ -49,7 +48,7 @@ def check_args(module, warnings):
warnings.append('argument %s has been deprecated and will be '
'removed in a future version' % key)
-def _validate_rollback_id(value):
+def _validate_rollback_id(module, value):
try:
if not 0 <= int(value) <= 49:
raise ValueError
@@ -75,7 +74,7 @@ def load_configuration(module, candidate=None, action='merge', rollback=None, fo
module.fail_json(msg='format must be text when action is set')
if rollback is not None:
- _validate_rollback_id(rollback)
+ _validate_rollback_id(module, rollback)
xattrs = {'rollback': str(rollback)}
else:
xattrs = {'action': action, 'format': format}
@@ -103,7 +102,7 @@ def get_configuration(module, compare=False, format='xml', rollback='0'):
module.fail_json(msg='invalid config format specified')
xattrs = {'format': format}
if compare:
- _validate_rollback_id(rollback)
+ _validate_rollback_id(module, rollback)
xattrs['compare'] = 'rollback'
xattrs['rollback'] = str(rollback)
return send_request(module, Element('get-configuration', xattrs))
diff --git a/lib/ansible/modules/network/junos/junos_command.py b/lib/ansible/modules/network/junos/junos_command.py
index 1b4c1caa9d..cab0bfe166 100644
--- a/lib/ansible/modules/network/junos/junos_command.py
+++ b/lib/ansible/modules/network/junos/junos_command.py
@@ -246,7 +246,7 @@ def parse_rpcs(module):
return items
-def parse_commands(module):
+def parse_commands(module, warnings):
items = list()
for command in (module.params['commands'] or list()):
@@ -301,7 +301,7 @@ def main():
check_args(module, warnings)
items = list()
- items.extend(parse_commands(module))
+ items.extend(parse_commands(module, warnings))
items.extend(parse_rpcs(module))
wait_for = module.params['wait_for'] or list()
diff --git a/lib/ansible/modules/network/junos/junos_config.py b/lib/ansible/modules/network/junos/junos_config.py
index b69b1e570e..ac738d6c4e 100644
--- a/lib/ansible/modules/network/junos/junos_config.py
+++ b/lib/ansible/modules/network/junos/junos_config.py
@@ -194,7 +194,7 @@ def check_args(module, warnings):
if module.params['replace'] is not None:
module.fail_json(msg='argument replace is deprecated, use update')
-zeroize = lambda x: send_request(x, Element('request-system-zeroize'))
+zeroize = lambda x: send_request(x, ElementTree.Element('request-system-zeroize'))
rollback = lambda x: get_diff(x)
def guess_format(config):
diff --git a/lib/ansible/modules/network/junos/junos_facts.py b/lib/ansible/modules/network/junos/junos_facts.py
index db9357b509..1f47e35ae6 100644
--- a/lib/ansible/modules/network/junos/junos_facts.py
+++ b/lib/ansible/modules/network/junos/junos_facts.py
@@ -65,7 +65,7 @@ ansible_facts:
"""
import re
-from xml.etree.ElementTree import Element, SubElement
+from xml.etree.ElementTree import Element, SubElement, tostring
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
@@ -89,7 +89,7 @@ class FactsBase(object):
reply = command(self.module, command)
output = reply.find('.//output')
if not output:
- module.fail_json(msg='failed to retrieve facts for command %s' % command)
+ self.module.fail_json(msg='failed to retrieve facts for command %s' % command)
return str(output.text).strip()
def rpc(self, rpc):
diff --git a/lib/ansible/modules/network/junos/junos_user.py b/lib/ansible/modules/network/junos/junos_user.py
index 470276c4a2..652553fc82 100644
--- a/lib/ansible/modules/network/junos/junos_user.py
+++ b/lib/ansible/modules/network/junos/junos_user.py
@@ -119,7 +119,7 @@ from functools import partial
from ncclient.xml_ import new_ele, sub_ele, to_xml
from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.junos import load
+from ansible.module_utils.junos import load_config
from ansible.module_utils.six import iteritems
ROLES = ['operator', 'read-only', 'super-user', 'unauthorized']
@@ -242,7 +242,7 @@ def main():
if module.params['purge']:
kwargs['action'] = 'replace'
- diff = load(module, ele, **kwargs)
+ diff = load_config(module, ele, **kwargs)
if diff:
result.update({