Skip to content

Commit 63cc76e

Browse files
author
rsmekala
committed
Sync Up to resolve merge conflicts
2 parents 0e535b8 + 664aa73 commit 63cc76e

File tree

6 files changed

+105
-14
lines changed

6 files changed

+105
-14
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ RUN tar -czf Juniper.junos ansible-junos-stdlib &&\
2424
apk update && apk add ca-certificates &&\
2525
apk add openssh-client &&\
2626
apk add build-base gcc g++ make python-dev &&\
27+
apk update && apk add py-pip &&\
2728
pip install --upgrade pip setuptools &&\
2829
pip install jxmlease &&\
2930
pip install ansible==$ver_ansible &&\

ISSUE_TEMPLATE.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!---
2+
Verify first that your issue/request is not already reported on GitHub. -->
3+
4+
Issue Type
5+
------
6+
<!--- Pick one below and delete the rest -->
7+
- Bug Report
8+
- Feature Idea
9+
- Documentation Report
10+
11+
Module Name
12+
------
13+
<!--- Insert, BELOW THIS COMMENT, the name of the module, plugin, task or feature
14+
-->
15+
16+
Juniper.Junos role and Python libraries version
17+
<!--- Paste, BELOW THIS COMMENT, verbatim output from "ansible --version" and "pip freeze" between quotes below
18+
Also provide the version of Juniper.junos role-->
19+
```
20+
21+
```
22+
23+
OS / Environment
24+
------
25+
<!--- Mention, the JUNOS version and firmware model you are trying to control-->
26+
27+
Summary
28+
------
29+
<!--- Explain the problem briefly -->
30+
31+
Steps to reproduce
32+
------
33+
<!--- For bugs, show exactly how to reproduce the problem, using a minimal test-case.
34+
For new features, show how the feature would be used. -->
35+
36+
<!--- Paste example playbooks or commands between quotes below -->
37+
```yaml
38+
39+
```
40+
41+
<!--- You can also paste gist.github.com links for larger files -->
42+
43+
Expected results
44+
<!--- What did you expect to happen when running the steps above? -->
45+
```
46+
47+
```
48+
Actual results
49+
------
50+
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
51+
52+
<!--- Paste verbatim command output between quotes below -->
53+
```
54+
55+
```

callback_plugins/jsnapy.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,20 @@ def __init__(self):
3131

3232
def v2_runner_on_ok(self, result):
3333
"""
34-
Collect test results for all tests executed if module is junos_jsnapy
34+
Collect test results for all tests executed if action is snapcheck or check
3535
"""
3636

3737
## Extract module name
38-
module_name = ''
3938
module_args = {}
4039
if 'invocation' in result._result:
41-
if 'module_name' in result._result['invocation']:
42-
module_name = result._result['invocation']['module_name']
40+
if 'module_args' in result._result['invocation']:
4341
module_args = result._result['invocation']['module_args']
4442

4543
## Check if dic return has all valid information
46-
if module_name == '' or module_args == {}:
47-
return None
48-
elif 'action' not in module_args:
44+
if 'action' not in module_args:
4945
return None
5046

51-
if module_name == 'junos_jsnapy' and \
52-
( module_args['action'] == 'snapcheck' or module_args['action'] == 'check' ):
47+
if module_args['action'] == 'snapcheck' or module_args['action'] == 'check':
5348

5449
## Check if dict entry already exist for this host
5550
host = result._host.name

library/juniper_junos_facts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ def get_facts_dict(junos_module):
208208
del facts['2RE']
209209
# The value of the 'version_info' key is a custom junos.version_info
210210
# object. Convert this value to a dict.
211-
if 'version_info' in facts:
211+
if 'version_info' in facts and facts['version_info'] is not None:
212212
facts['version_info'] = dict(facts['version_info'])
213213
# The values of the ['junos_info'][re_name]['object'] keys are
214214
# custom junos.version_info objects. Convert all of these to dicts.
215-
if 'junos_info' in facts:
215+
if 'junos_info' in facts and facts['junos_info'] is not None:
216216
for key in facts['junos_info']:
217217
facts['junos_info'][key]['object'] = dict(
218218
facts['junos_info'][key]['object'])

library/juniper_junos_jsnapy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
from ansible.module_utils.basic import AnsibleModule
212212
from ansible.module_utils import juniper_junos_common
213213

214+
214215
def main():
215216
JSNAPY_ACTION_CHOICES = ['check', 'snapcheck', 'snap_pre', 'snap_post']
216217

module_utils/juniper_junos_common.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ class ModuleDocFragment(object):
289289
type: path
290290
aliases:
291291
- ssh_keyfile
292+
ssh_config:
293+
description:
294+
- The path to the SSH client configuration file. If this option is not
295+
specified, then the PyEZ Device instance by default queries file
296+
~/.ssh/config.
297+
required: false
298+
type: path
292299
timeout:
293300
description:
294301
- The maximum number of seconds to wait for RPC responses from the
@@ -332,7 +339,7 @@ class ModuleDocFragment(object):
332339
- The log file must be writeable. If the file already exists, it is
333340
appended. It is the users responsibility to delete/rotate log files.
334341
- The level of information logged in this file is controlled by
335-
Ansible's verbosity and debug options
342+
Ansible's verbosity, debug options and level option in task
336343
- 1) By default, messages at level C(WARNING) or higher are logged.
337344
- 2) If the C(-v) or C(--verbose) command-line options to the
338345
C(ansible-playbook) command are specified, messages at level
@@ -341,6 +348,8 @@ class ModuleDocFragment(object):
341348
C(ansible-playbook) command is specified, or the C(ANSIBLE_DEBUG)
342349
environment variable is set, then messages at level C(DEBUG) or
343350
higher are logged.
351+
- 4) If C(level) is mentioned then messages at level C(level) or more are
352+
logged.
344353
- The I(logfile) and I(logdir) options are mutually exclusive. The
345354
I(logdir) option is recommended for all new playbooks.
346355
required: false
@@ -355,7 +364,7 @@ class ModuleDocFragment(object):
355364
- The log file must be writeable. If the file already exists, it is
356365
appended. It is the users responsibility to delete/rotate log files.
357366
- The level of information logged in this file is controlled by
358-
Ansible's verbosity and debug options
367+
Ansible's verbosity, debug options and level option in task
359368
- 1) By default, messages at level C(WARNING) or higher are logged.
360369
- 2) If the C(-v) or C(--verbose) command-line options to the
361370
C(ansible-playbook) command are specified, messages at level
@@ -364,6 +373,8 @@ class ModuleDocFragment(object):
364373
C(ansible-playbook) command is specified, or the C(ANSIBLE_DEBUG)
365374
environment variable is set, then messages at level C(DEBUG) or
366375
higher are logged.
376+
- 4) If C(level) is mentioned then messages at level C(level) or more are
377+
logged.
367378
- When tasks are executed against more than one target host,
368379
one process is forked for each target host. (Up to the maximum
369380
specified by the forks configuration. See
@@ -381,6 +392,27 @@ class ModuleDocFragment(object):
381392
type: path
382393
aliases:
383394
- log_file
395+
level:
396+
description:
397+
- The level of information to be logged can be modified using this option
398+
- 1) By default, messages at level C(WARNING) or higher are logged.
399+
- 2) If the C(-v) or C(--verbose) command-line options to the
400+
C(ansible-playbook) command are specified, messages at level
401+
C(INFO) or higher are logged.
402+
- 3) If the C(-vv) (or more verbose) command-line option to the
403+
C(ansible-playbook) command is specified, or the C(ANSIBLE_DEBUG)
404+
environment variable is set, then messages at level C(DEBUG) or
405+
higher are logged.
406+
- 4) If C(level) is mentioned then messages at level C(level) or more are
407+
logged.
408+
required: false
409+
default: WARNING
410+
type: str
411+
choices:
412+
- INFO
413+
- DEBUG
414+
415+
384416
'''
385417

386418
# _SUB_CONNECT_DOCUMENTATION is just _CONNECT_DOCUMENTATION with each
@@ -443,6 +475,9 @@ class ModuleDocFragment(object):
443475
# Default behavior coded in
444476
# JuniperJunosActionModule.run()
445477
default=None),
478+
'ssh_config': dict(type='path',
479+
required=False,
480+
default=None),
446481
'mode': dict(choices=[None, 'telnet', 'serial'],
447482
default=None),
448483
'console': dict(type='str',
@@ -497,7 +532,8 @@ class ModuleDocFragment(object):
497532
# Specify the logging spec.
498533
logging_spec = {
499534
'logfile': dict(type='path', required=False, default=None),
500-
'logdir': dict(type='path', required=False, default=None)
535+
'logdir': dict(type='path', required=False, default=None),
536+
'level': dict(choices=[None, 'INFO', 'DEBUG'], required=False, default=None)
501537
}
502538

503539
# The logdir and logfile options are mutually exclusive.
@@ -874,6 +910,9 @@ def process(self, msg, kwargs):
874910
level = logging.INFO
875911
elif self._verbosity > 1:
876912
level = logging.DEBUG
913+
# Set level as mentioned in task
914+
elif self.params.get('level') is not None:
915+
level = self.params.get('level')
877916
# Get the logger object to be used for our logging.
878917
logger = logging.getLogger('jnpr.ansible_module.' + self.module_name)
879918
# Attach the NullHandler to avoid any errors if no logging is needed.

0 commit comments

Comments
 (0)