[j-nsp] Unwanted newline characters in Netconf XML

Dave Bell me at geordish.org
Tue Dec 1 08:40:16 EST 2015


It certainly looks like a bug to me. I've tested it in our lab on an
MX running 12.3R8, and get the same problem as you.

Interestingly this conflicts with their documentation:
"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."
http://www.juniper.net/documentation/en_US/junos13.2/topics/task/operational/netconf-operational-request-output-format.html

Clearly this is not identical!

Have you tried upgrading to a later version of JunOS?

With actually no information about what you are actually trying to do,
I don't see there being a massive issue with stripping out new lines.
I can't think of anything other than comments that might allow a line
break. In fact I've just been playing with trying to put a line break
in a comment, and that doesn't even seem to work!

Regards,
Dave

On 1 December 2015 at 13:21, Tore Anderson <tore at fud.no> wrote:
> I'm assuming this must be a JUNOS bug?
>
> $ echo '<rpc><get-interface-information/></rpc>' | ssh -s lab-ex netconf
> [...]
> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/12.3R10/junos">
> <interface-information xmlns="http://xml.juniper.net/junos/12.3R10/junos-interface" junos:style="normal">
> <physical-interface>
> <name>
> ge-0/0/0
> </name>
> [...]
>
> The newline characters immediately following <name> and preceeding
> </name> becomes part of the node value - that is, the interface name
> becomes "\nge-0/0/0\n" instead of "ge-0/0/0". (This does not happen
> only with interface names, pretty much any value is wrapped in these
> newline characters.)
>
> This in turn makes using XPath with expressions such as for example
> «//physical-interface[name="ge-0/0/0"]» to fail miserably.
>
> A simple workaround is to strip all the newline characters from the XML
> string before feeding it to the XML parser. But that of course will
> also break nodes may actually contain newlines - <junos:comment> comes
> to mind, are there others?
>
> I'm far from being an expert on XML or Netconf for that matter, so I'm
> wondering if anyone else on the list ran into this issue (surely yes?)
> and if so if there's a better way to deal with it?
>
> Interestingly, running "show interfaces | display xml" from the JUNOS
> shell looks much better:
>
> <rpc-reply xmlns:junos="http://xml.juniper.net/junos/12.3R10/junos">
>     <interface-information xmlns="http://xml.juniper.net/junos/12.3R10/junos-interface" junos:style="normal">
>         <physical-interface>
>             <name>ge-0/0/0</name>
> [...]
>
> If I could only convince the Netconf service to give me its replay
> formatted in this way instead everything would have worked well.
>
> Tore
> _______________________________________________
> juniper-nsp mailing list juniper-nsp at puck.nether.net
> https://puck.nether.net/mailman/listinfo/juniper-nsp


More information about the juniper-nsp mailing list