[j-nsp] Unwanted newline characters in Netconf XML

Tore Anderson tore at fud.no
Wed Dec 2 02:04:41 EST 2015


Hi Dave,

* Dave Bell <me at geordish.org>

> 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!

Thanks for this pointer. I think I'll have to go to JTAC with this one
and references like these does help (in case they try to claim it's
working as intended).

> Have you tried upgrading to a later version of JunOS?

Tried now. Same behaviour in 15.1R2.

> 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.

Yeah, if <junos:comment> is the only thing that can contain newlines,
then I'd be fine with a hack like «$xml =~ s/\n//mg» before feeding the
output to the XML parser since I'm not interested in comments anyway.

> 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!

Works fine for me? Even in JUNOS versions as old as 11.4. Try:

{master:1}[edit]
tore at lab-ex4200# load merge terminal    
[Type ^D at a new line to end input]
/* This is a
 * multi-line
 * comment.
 */
protocols{} 
[edit]
  'protocols'
    warning: statement has no contents; ignored
load complete

{master:1}[edit]
tore at lab-ex4200# show | compare 
[edit]
+  /* This is a
+   * multi-line
+   * comment.
+   */
   protocols { ... }

{master:1}[edit]
tore at lab-ex4200# show | display xml | find junos:comment           
            <junos:comment>/* This is a
         * multi-line
         * comment.
         */</junos:comment>
            <protocols>

Some whitespace has appeared out of nowhere in this XML output too...

Tore


More information about the juniper-nsp mailing list