[j-nsp] How to catch invalid value/option for a command in SLAX script?

Tore Anderson tore at fud.no
Tue Jul 12 01:10:49 EDT 2016


* Phil Shafer <phil at juniper.net>

> But the newlines are my fault.  The initial XML output for JUNOS
> generated newlines after each tag open/close/data call to ease
> debugging for developers, and also because I thought it would make
> the XML->text renderer in the CLI easier.  By the time I realized
> the latter was false, the former was shipping.  So XML output from
> JUNOS looked like:
> 
> <tag>
> data
> </tag>
> 
> which means that leading and trailing newlines are present on some
> data fields.  It's been corrected in many places, and some libraries
> have options to automatically remove them.

Ah, so you're the one to blame for the mounds of torn-out hair around my
desk... ;-)

There are more of these yet to be fixed, unfortunately. For example:

$ echo '<rpc><get-interface-information/></rpc>' | ssh -s lab-ex4200 netconf
[...]
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/15.1R4/junos">
<interface-information xmlns="http://xml.juniper.net/junos/15.1R4/junos-interface" junos:style="normal">
<physical-interface>
<name>
ge-0/0/0
</name>
[...]

This in turn means that XPath expressions such as
«/physical-interface[name="ge-0/0/0"]» don't work, which is a _major_
pain in the arse.

http://www.juniper.net/documentation/en_US/junos15.1/topics/task/operational/netconf-operational-request-output-format.html
states that «the NETCONF server returns the information in XML-tagged
format, which is identical to the output displayed in the CLI when you
include the | display xml option after the operational mode command»,
which is simply not true. Compare with the above output:

$ ssh lab-ex4200 'show interfaces | display xml'
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/15.1R4/junos">
    <interface-information xmlns="http://xml.juniper.net/junos/15.1R4/junos-interface" junos:style="normal">
        <physical-interface>
            <name>ge-0/0/0</name>
[...]

There's also something fishy going on with whitespace magically
appearing inside <junos:comment> tags. I'll demonstrate. First I add a
comment to the config:

$ cat << EOF | ssh lab-ex4200 -s netconf
> <rpc><edit-config>
> <target><candidate/></target>
> <config>
> <configuration>
> <junos:comment>/* This is a multi-line
> * comment whose lines are
> * NOT indented in any way */</junos:comment>
> <system/>
> </configuration>
> </config>
> </edit-config></rpc>
> <rpc><commit/></rpc>
> ]]>]]>
> EOF

Fetching this comment back via NetConf works as expected:

$ echo '<rpc><get-configuration/></rpc>' | ssh lab-ex4200 -s netconf
[...]
    <junos:comment>/* This is a multi-line
* comment whose lines are
* NOT indented in any way */</junos:comment>

Fetching it via CLI and «| display xml» on the other hand:

$ ssh lab-ex4200 'show configuration | display xml'
[...]
            <junos:comment>/* This is a multi-line
        * comment whose lines are
        * NOT indented in any way */</junos:comment>
^^^^^^^^ wtf?

I tried my luck with JTAC on these issues in case 2015-1202-0037 last
year, but that didn't go anywhere useful. Maybe you can open an
internal bug issue or something instead and hopefully these issues will
get fixed eventually.

Tore


More information about the juniper-nsp mailing list