summaryrefslogtreecommitdiff
path: root/lib/ansible/module_utils/junos.py
diff options
context:
space:
mode:
authorDag Wieers <dag@wieers.com>2017-06-02 13:14:11 +0200
committerJohn R Barker <john@johnrbarker.com>2017-06-02 12:14:11 +0100
commit5553b208281d723ead1e61be5c37227ec2b2736e (patch)
tree2f81e684e9f4451a3b1b58b95e1d00125b34e439 /lib/ansible/module_utils/junos.py
parent2f33c1a1a1d0c74d31445984fd85d877f0d8ab59 (diff)
downloadansible-5553b208281d723ead1e61be5c37227ec2b2736e.tar.gz
Collated PEP8 fixes (#25293)
- Make PEP8 compliant
Diffstat (limited to 'lib/ansible/module_utils/junos.py')
-rw-r--r--lib/ansible/module_utils/junos.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/ansible/module_utils/junos.py b/lib/ansible/module_utils/junos.py
index 31bfe8a5d1..b45acfb640 100644
--- a/lib/ansible/module_utils/junos.py
+++ b/lib/ansible/module_utils/junos.py
@@ -47,12 +47,13 @@ ARGS_DEFAULT_VALUE = {
'timeout': 10
}
+
def check_args(module, warnings):
provider = module.params['provider'] or {}
for key in junos_argument_spec:
if key not in ('provider',) and module.params[key]:
warnings.append('argument %s has been deprecated and will be '
- 'removed in a future version' % key)
+ 'removed in a future version' % key)
# set argument's default value if not provided in input
# This is done to avoid unwanted argument deprecation warning
@@ -66,6 +67,7 @@ def check_args(module, warnings):
if provider.get(param):
module.no_log_values.update(return_values(provider[param]))
+
def _validate_rollback_id(module, value):
try:
if not 0 <= int(value) <= 49:
@@ -73,6 +75,7 @@ def _validate_rollback_id(module, value):
except ValueError:
module.fail_json(msg='rollback must be between 0 and 49')
+
def load_configuration(module, candidate=None, action='merge', rollback=None, format='xml'):
if all((candidate is None, rollback is None)):
@@ -117,6 +120,7 @@ def load_configuration(module, candidate=None, action='merge', rollback=None, fo
cfg.append(candidate)
return send_request(module, obj)
+
def get_configuration(module, compare=False, format='xml', rollback='0'):
if format not in CONFIG_FORMATS:
module.fail_json(msg='invalid config format specified')
@@ -127,6 +131,7 @@ def get_configuration(module, compare=False, format='xml', rollback='0'):
xattrs['rollback'] = str(rollback)
return send_request(module, Element('get-configuration', xattrs))
+
def commit_configuration(module, confirm=False, check=False, comment=None, confirm_timeout=None):
obj = Element('commit-configuration')
if confirm:
@@ -141,6 +146,7 @@ def commit_configuration(module, confirm=False, check=False, comment=None, confi
subele.text = str(confirm_timeout)
return send_request(module, obj)
+
def command(module, command, format='text', rpc_only=False):
xattrs = {'format': format}
if rpc_only:
@@ -148,8 +154,14 @@ def command(module, command, format='text', rpc_only=False):
xattrs['format'] = 'text'
return send_request(module, Element('command', xattrs, text=command))
-lock_configuration = lambda x: send_request(x, Element('lock-configuration'))
-unlock_configuration = lambda x: send_request(x, Element('unlock-configuration'))
+
+def lock_configuration(x):
+ return send_request(x, Element('lock-configuration'))
+
+
+def unlock_configuration(x):
+ return send_request(x, Element('unlock-configuration'))
+
@contextmanager
def locked_config(module):
@@ -159,6 +171,7 @@ def locked_config(module):
finally:
unlock_configuration(module)
+
def get_diff(module):
reply = get_configuration(module, compare=True, format='text')
@@ -166,6 +179,7 @@ def get_diff(module):
if output is not None:
return to_text(output.text, encoding='latin1').strip()
+
def load_config(module, candidate, warnings, action='merge', commit=False, format='xml',
comment=None, confirm=False, confirm_timeout=None):
@@ -192,5 +206,6 @@ def load_config(module, candidate, warnings, action='merge', commit=False, forma
return diff
+
def get_param(module, key):
return module.params[key] or module.params['provider'].get(key)