"No handlers could be found for logger" ncclient.transport.session while using juniper.junos_rpc module

243 views
Skip to first unread message

mamado...@gmail.com

unread,
Apr 4, 2018, 12:47:36 PM4/4/18
to Junos Python EZ
Hi there,

I would like to get system information about my juniper equipment  while using ansible (2.4.2) and juniper.junos role.
I can assume this:

I can't connect to internet that's why I downloaded manually the role (https://github.com/Juniper/ansible-junos-stdlib) without git nor ansible-galaxy ,  and I pasted the folders in /etc/ansible/roles/Juniper.junos/
In the Juniper.Junos repository, I ussed source env-setup

I have installed the required packages.

ansible 2.4.2

pyserial

netaddr

scp>=0.7.0

jxmlease >= 1.0.1

paramiko>=1.15.2

jinja2>=2.7.1

PyYAML>=3.10

python-six

I set the role path in /etc/ansible/ansible.cfg :
roles_path = /etc/ansible/roles/Juniper.junos/library/juniper_junos_rpc.py



Below my playbook.yaml :
---
- name: Get system info
  hosts: Juniper
  roles:
    - Juniper.junos
  connection: local
  gather_facts: no
  tasks:
  - name: checking Netconf connectivity
    wait_for: host=10.142.21.138 port=22 timeout=10
  - name: get interface information
    juniper_junos_rpc:
      host: 10.142.21.138
      username: myuser
      password: mypass
      port: 22
      rpcs: get-interface-information
     # register: response
      kwargs:
        interface-em0: Internal
        media: True
      dest: savedfile.conf
  - name: Print configuration
    debug: mgs= "{{ junos.rpc_reply }}"
    delegate_to: localhost

Below the output of my playbook


Using module file /usr/lib/python2.7/site-packages/ansible-2.4.3.0-py2.7.egg/ansible/modules/utilities/logic/wait_for.py
<10.142.21.138> ESTABLISH LOCAL CONNECTION FOR USER: root
<10.142.21.138> EXEC /bin/sh -c 'echo ~ && sleep 0'
<10.142.21.138> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690 `" && echo ansible-tmp-1522859464.57-245909329780690="` echo /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690 `" ) && sleep 0'
<10.142.21.138> PUT /tmp/tmpuXKQoy TO /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690/wait_for.py
<10.142.21.138> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690/ /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690/wait_for.py && sleep 0'
<10.142.21.138> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690/wait_for.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690/" > /dev/null 2>&1 && sleep 0'
ok: [pulse-secure] => {
    "changed": false,
    "elapsed": 0,
    "invocation": {
        "module_args": {
            "active_connection_states": [
                "ESTABLISHED",
                "FIN_WAIT1",
                "FIN_WAIT2",
                "SYN_RECV",
                "SYN_SENT",
                "TIME_WAIT"
            ],
            "connect_timeout": 5,
            "delay": 0,
            "exclude_hosts": null,
            "host": "10.142.21.138",
            "msg": null,
            "path": null,
            "port": 22,
            "search_regex": null,
            "sleep": 1,
            "state": "started",
            "timeout": 10
        }
    },
    "path": null,
    "port": 22,
    "search_regex": null,
    "state": "started"
}

TASK [get interface information] ******************************************************************************************************************
task path: /images/juniper/startup-conf.yaml:11


Using module file /etc/ansible/roles/Juniper.junos/library/juniper_junos_rpc.py
<10.142.21.138> ESTABLISH LOCAL CONNECTION FOR USER: root
<10.142.21.138> EXEC /bin/sh -c 'echo ~ && sleep 0'
<10.142.21.138> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637 `" && echo ansible-tmp-1522858141.92-41570732472637="` echo /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637 `" ) && sleep 0'
<10.142.21.138> PUT /tmp/tmptwLsK0 TO /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637/juniper_junos_rpc.py
<10.142.21.138> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637/ /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637/juniper_junos_rpc.py && sleep 0'
<10.142.21.138> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637/juniper_junos_rpc.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637/" > /dev/null 2>&1 && sleep 0'
fatal: [pulse-secure]: FAILED! => {
    "changed": false,
    "module_stderr": "No handlers could be found for logger \"ncclient.transport.session\"\nTraceback (most recent call last):\n  File \"/tmp/ansible_GbggM7/ansible_module_juniper_junos_rpc.py\", line 662, in <module>\n    main()\n  File \"/tmp/ansible_GbggM7/ansible_module_juniper_junos_rpc.py\", line 648, in main\n    junos_module.exit_json(**results[0])\n  File \"/etc/ansible/roles/Juniper.junos/module_utils/juniper_junos_common.py\", line 755, in exit_json\n    self.close()\n  File \"/etc/ansible/roles/Juniper.junos/module_utils/juniper_junos_common.py\", line 1287, in close\n    dev.close()\n  File \"/usr/lib/python2.7/site-packages/junos_eznc-2.1.7-py2.7.egg/jnpr/junos/device.py\", line 1314, in close\n    self._conn.close_session()\n  File \"build/bdist.linux-x86_64/egg/ncclient/manager.py\", line 162, in wrapper\n  File \"build/bdist.linux-x86_64/egg/ncclient/manager.py\", line 232, in execute\n  File \"build/bdist.linux-x86_64/egg/ncclient/operations/session.py\", line 28, in request\n  File \"build/bdist.linux-x86_64/egg/ncclient/operations/rpc.py\", line 343, in _request\nncclient.operations.errors.TimeoutExpiredError: ncclient timed out while waiting for an rpc reply.\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE",
    "rc": 0
}
        to retry, use: --limit @/images/juniper/startup-conf.retry
 to retry, use: --limit @/images/juniper/startup-conf.retry

PLAY RECAP *************************************************************************************************************************************************
pulse-secure               : ok=1    changed=0    unreachable=0    failed=1




I had a look at  /usr/lib/python2.7/site-packages/junos_eznc-2.1.7-py2.7.egg/jnpr/junos/device.py and changed the port 830 to 22 as I was able to join the juniper pulse with the command  ssh myuser@10.142.21.138 -p 830 -s netconf

I can't use pip install cryptography as my VM can't access to internet but I have cryptography1.3.1 installed

Can you guide to fix this bug.


Thanks in advance


Nitin Kr (India)

unread,
Apr 6, 2018, 10:16:36 AM4/6/18
to mamado...@gmail.com, Junos Python EZ

Hi,

 

I need few details to debug:

 

Share me the output for

ssh myu...@10.142.21.138 -p 830 -s netconf

 

when you say juniper pulse, can you share more details about the device (output of cli command “show version”)

 

Can you enable netconf trace on the device and share the log file generated after playbook run (/var/log/netconf-ops.log)

http://www.juniper.net/techpubs/en_US/junos12.3/topics/topic-map/netconf-traceoptions.html

 

Thanks

Nitin Kr

python-six

I had a look at  /usr/lib/python2.7/site-packages/junos_eznc-2.1.7-py2.7.egg/jnpr/junos/device.py and changed the port 830 to 22 as I was able to join the juniper pulse with the command  ssh myu...@10.142.21.138 -p 830 -s netconf



I can't use pip install cryptography as my VM can't access to internet but I have cryptography1.3.1 installed

Can you guide to fix this bug.


Thanks in advance

--
You received this message because you are subscribed to the Google Groups "Junos Python EZ" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
junos-python-...@googlegroups.com.
Visit this group at
https://groups.google.com/group/junos-python-ez.
To view this discussion on the web visit
https://groups.google.com/d/msgid/junos-python-ez/7b798fba-39b7-4017-88e2-e1803591dff0%40googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.

mamado...@gmail.com

unread,
Apr 6, 2018, 12:45:14 PM4/6/18
to Junos Python EZ


Le vendredi 6 avril 2018 16:16:36 UTC+2, nitinkr a écrit :

Hi,

 

I need few details to debug:

 

Share me the output for

ssh myu...@10.142.21.138 -p 830 -s netconf


Hi Nitin Kr, 

[root@dvaiaasc02 juniper]# ssh myu...@10.142.21.138 -p 22 -s netconf
Password:
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <capabilities>
        <capability>urn:ietf:params:netconf:base:1.0</capability>
        <capability>urn:ietf:params:netconf:base:2.0</capability>
        <capability>http://xml.juniper.net/dmi/software/1.0</capability>
        <capability>http://xml.juniper.net/dmi/software/2.0</capability>
        <capability>http://xml.juniper.net/dmi/system/1.0</capability>
        <capability>http://xml.juniper.net/dmi/ive-sa/8.1R6</capability>
        <capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability>
        <capability>urn:ietf:params:netconf:capability:writable-running:1.0</capability>
    </capabilities>
    <session-id>22934</session-id>
</hello>
]]>]]>

 

 

when you say juniper pulse, can you share more details about the device (output of cli command “show version”)

 

System Version
8.1R6 (build 39491)
 

Can you enable netconf trace on the device and share the log file generated after playbook run (/var/log/netconf-ops.log)

 
I can get log into the device after playbook ran.
2018-04-06 18:28:24 - ive - [10.100.162.154] myuser(Admin Users)[.Administrators] - Received Netconf RPC request: <nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:5fda40f5-1aa2-4a34-949c-d07b7e573586"><get-configuration format="xml"/></nc:rpc>

It seems the device is blocked while  returning configure to my ansible server. Furthmore I can get the configuration by issuing the command in red hat VM.

ssh my...@10.142.21.138 -p 22 -s netconf < config   
with config file

<rpc message-id="12">
<get-config>
<source>
<running/>
</source>
</get-config>
</rpc>

Any idea about how to get configuration while using ansible.

Thanks in advance

To unsubscribe from this group and stop receiving emails from it, send an email to junos-python-ez+unsubscribe@googlegroups.com.
Visit this group at
https://groups.google.com/group/junos-python-ez.


To view this discussion on the web visit

Stacy W. Smith

unread,
Apr 6, 2018, 12:53:49 PM4/6/18
to mamado...@gmail.com, Junos Python EZ
On Apr 6, 2018, at 10:45 AM, mamado...@gmail.com wrote:

[root@dvaiaasc02 juniper]# ssh myu...@10.142.21.138 -p 22 -s netconf
Password:
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <capabilities>
        <capability>urn:ietf:params:netconf:base:1.0</capability>
        <capability>urn:ietf:params:netconf:base:2.0</capability>
        <capability>http://xml.juniper.net/dmi/software/1.0</capability>
        <capability>http://xml.juniper.net/dmi/software/2.0</capability>
        <capability>http://xml.juniper.net/dmi/system/1.0</capability>
        <capability>http://xml.juniper.net/dmi/ive-sa/8.1R6</capability>
        <capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability>
        <capability>urn:ietf:params:netconf:capability:writable-running:1.0</capability>
    </capabilities>
    <session-id>22934</session-id>
</hello>
]]>]]> 

when you say juniper pulse, can you share more details about the device (output of cli command “show version”)

 
System Version
8.1R6 (build 39491)


PyEZ and the Juniper.junos Ansible modules work with Junos. They do not support Pulse. It’s a completely different operating system.

—Stacy

mamado...@gmail.com

unread,
Apr 6, 2018, 2:28:57 PM4/6/18
to Junos Python EZ
Copy that.

Thanks stacy. 
Reply all
Reply to author
Forward
0 new messages