py-junos-eznc icon indicating copy to clipboard operation
py-junos-eznc copied to clipboard

Pipe raw CLI output for commands without RPC equiv

Open mirceaulinic opened this issue 7 years ago • 0 comments

As per our discussion in the forums, I am going to add the facility to pipe the output.

For some obscure reasons, although the device returns all these details (or at lease this is what logs show), ncclient does not receive that.

Logs from device:

Oct 21 00:23:29 [1709] Incoming: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:4fbc76f2-2e45-40cd-9010-2845524715aa"><command format="text">show configuration | display set | match napalm</command></nc:rpc>]]>]]>
Oct 21 00:23:29 [1709] Outgoing: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/12.1X47/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:4fbc76f2-2e45-40cd-9010-2845524715aa">
Oct 21 00:23:29 [1709] Outgoing: <pipe>
Oct 21 00:23:29 [1709] Outgoing: <more-match-string>
Oct 21 00:23:29 [1709] Outgoing: napalm
Oct 21 00:23:29 [1709] Outgoing: </more-match-string>
Oct 21 00:23:29 [1709] Outgoing: </pipe>
Oct 21 00:23:29 [1709] Outgoing: <configuration-information>
Oct 21 00:23:29 [1709] Outgoing: <configuration-output>
Oct 21 00:23:29 [1709] Outgoing: set version 12.1X47-D20.7
Oct 21 00:23:29 [1709] Outgoing: set system host-name vsrx
Oct 21 00:23:29 [1709] Outgoing: set system root-authentication encrypted-password "$1$5MhDFyrI$NBBMndW1POqbN.0QEA4z0."
Oct 21 00:23:29 [1709] Outgoing: set system root-authentication ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
Oct 21 00:23:29 [1709] Outgoing: set system login user napalm uid 2001
Oct 21 00:23:29 [1709] Outgoing: set system login user napalm class super-user
Oct 21 00:23:29 [1709] Outgoing: set system login user napalm authentication encrypted-password "$1$pCXIxJmC$jiy.wgJUSlfPQ1NBO0s7U1"
Oct 21 00:23:29 [1709] Outgoing: set system login user vagrant uid 2000
Oct 21 00:23:29 [1709] Outgoing: set system login user vagrant class super-user
Oct 21 00:23:29 [1709] Outgoing: set system login user vagrant authentication ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
Oct 21 00:23:29 [1709] Outgoing: set system services ssh root-login allow
Oct 21 00:23:29 [1709] Outgoing: set system services netconf ssh
Oct 21 00:23:29 [1709] Outgoing: set system services netconf traceoptions file netconf-ops.log
Oct 21 00:23:29 [1709] Outgoing: set system services netconf traceoptions file size 3m
Oct 21 00:23:29 [1709] Outgoing: set system services netconf traceoptions file files 20
Oct 21 00:23:29 [1709] Outgoing: set system services netconf traceoptions file world-readable
Oct 21 00:23:29 [1709] Outgoing: set system services netconf traceoptions flag all
Oct 21 00:23:29 [1709] Outgoing: set system services web-management http interface ge-0/0/0.0
Oct 21 00:23:29 [1709] Outgoing: set system syslog user * any emergency
Oct 21 00:23:29 [1709] Outgoing: set system syslog file messages any any
Oct 21 00:23:29 [1709] Outgoing: set system syslog file messages authorization info
Oct 21 00:23:29 [1709] Outgoing: set system syslog file interactive-commands interactive-commands any
Oct 21 00:23:29 [1709] Outgoing: set system license autoupdate url https://ae1.juniper.net/junos/key_retrieval
Oct 21 00:23:29 [1709] Outgoing: set interfaces ge-0/0/0 unit 0 family inet dhcp
Oct 21 00:23:29 [1709] Outgoing: set security forwarding-options family inet6 mode packet-based
Oct 21 00:23:29 [1709] Outgoing: set security forwarding-options family mpls mode packet-based
Oct 21 00:23:29 [1709] Outgoing: </configuration-output>
Oct 21 00:23:29 [1709] Outgoing: </configuration-information>
Oct 21 00:23:29 [1709] Outgoing: </rpc-reply>
Oct 21 00:23:29 [1709] Outgoing: ]]>]]>

What arrives in ncclient, when executing the get operation https://github.com/ncclient/ncclient/blob/master/ncclient/operations/retrieve.py#L75

<?xml version="1.0" encoding="UTF-8"?><rpc-reply message-id="urn:uuid:4fbc76f2-2e45-40cd-9010-2845524715aa">
<configuration-information>
<configuration-output>
set version 12.1X47-D20.7
set system host-name vsrx
set system root-authentication encrypted-password "$1$5MhDFyrI$NBBMndW1POqbN.0QEA4z0."
set system root-authentication ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
set system login user napalm uid 2001
set system login user napalm class super-user
set system login user napalm authentication encrypted-password "$1$pCXIxJmC$jiy.wgJUSlfPQ1NBO0s7U1"
set system login user vagrant uid 2000
set system login user vagrant class super-user
set system login user vagrant authentication ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
set system services ssh root-login allow
set system services netconf ssh
set system services netconf traceoptions file netconf-ops.log
set system services netconf traceoptions file size 3m
set system services netconf traceoptions file files 20
set system services netconf traceoptions file world-readable
set system services netconf traceoptions flag all
set system services web-management http interface ge-0/0/0.0
set system syslog user * any emergency
set system syslog file messages any any
set system syslog file messages authorization info
set system syslog file interactive-commands interactive-commands any
set system license autoupdate url https://ae1.juniper.net/junos/key_retrieval
set interfaces ge-0/0/0 unit 0 family inet dhcp
set security forwarding-options family inet6 mode packet-based
set security forwarding-options family mpls mode packet-based
</configuration-output>
</configuration-information>
</rpc-reply>

Which is almost the same, just that the pipe tag is not there:

Oct 21 00:23:29 [1709] Outgoing: <pipe>
Oct 21 00:23:29 [1709] Outgoing: <more-match-string>
Oct 21 00:23:29 [1709] Outgoing: napalm
Oct 21 00:23:29 [1709] Outgoing: </more-match-string>
Oct 21 00:23:29 [1709] Outgoing: </pipe>

That's not such a big issue, as anyway we have this info and we'll probably need to handle the filtering based on the input request.

Any thoughts on this?

mirceaulinic avatar Oct 21 '16 00:10 mirceaulinic