[j-nsp] certain commands executed on CLI provide additional information over corresponding RPCs

Martin T m4rtntns at gmail.com
Mon Mar 12 09:34:23 EDT 2018


On Fri, Mar 9, 2018 at 8:32 PM, Phil Shafer <phil at juniper.net> wrote:
> Martin T writes:
>>However, the actual point of my question was, that where do "show ipv6
>>neighbors" and similar commands take the column names and the answer
>>seems to be, that this is hard-coded in the binary. For example
>>nd6info in case of "show ipv6 neighbors".
>
> No, this isn't true.  The CLI uses descriptions provided by the
> developer to turn XML into human-readable text.  Use "show ipv6
> neighbors | display xml" to see the raw XML.  The nd6info utility
> can generate it's own text version, but the UI plumbing invokes it
> with the "-X" option to make XML content instead.  The two are
> likely similar, but the CLI doesn't use the text from nh6info.  The
> idea is to push all UI content into a single consistent code path.
>
> FYI: You might want to take a look at libxo which allows binaries
> to generate both XML and text (and HTML and JSON) from the same
> source code path.
>
>     http://juniper.github.io/libxo/libxo-manual.html
>
> This is now part of FreeBSD, so one can say "df --libxo:XP" and get
> pretty-printed XML output on a stock BSD system.
>
> (And no, we haven't moved nd6info over to libxo yet, but we should.)
>
> Thanks,
>  Phil

Saku, Phil,

ok, I see. I didn't thought it from that angle. While for my specific
script it would be convenient to have this CLI meta-data in the
back-end data, then I guess it is indeed much better approach to keep
those two separate.


Phil,

ok. Thanks for this information! In addition, this libxo is a clever
approach. The reason I thought that column names are provided by the
nd6info binary is that it contains printf format string(%-28s %-18s
%-11s %-4u %-3s %-6s) and column descriptions:

$ strings nd6info | grep Linklayer
IPv6 Address                 Linklayer Address  State       Exp  Rtr
Secure Interface
$

In addition, I didn't know that cli invokes it with "-X" option.
Still, this makes one think where does cli take those column
descriptions? My guess is that it comes from libnd6info-render.so
library.


regards,
Martin


More information about the juniper-nsp mailing list