Filter Operational Command Output for Container Elements Without an Identifier in NETCONF and Junos XML Protocol Sessions
In a NETCONF or Junos XML protocol session with a device running
Junos OS, a client application can request operational information
for the device and filter the output to select for a specific container
element and its descendants. To filter the operational command output
for a container element that does not have an identifier (<name>
or equivalent element), a client application
emits an RPC request for operational information and includes a <filter type="subtree">
element that encloses
the tag elements representing all levels in the operational command
output hierarchy from the root element down to the immediate parent
level of the container object. The container itself is represented
by an empty tag.
<rpc> <operational-request> <!-- optional tag elements representing the options --> <filter type="subtree"> <!-- opening tags for each parent of the requested level --> <level-or-container/> <!-- closing tags for each parent of the requested level --> </filter> </operational-request> </rpc>
The server returns the container node specified in the request
along with all of its descendants. The output is enclosed in an <rpc-reply>
element.
In the following example, the client application requests information
for the show system uptime
operational command, which corresponds
to the <get-system-uptime-information>
RPC request tag. The client selects for the <uptime-information/>
node in the output.
<rpc> <get-system-uptime-information> <filter type="subtree"> <system-uptime-information> <uptime-information/> </system-uptime-information> </filter> </get-system-uptime-information> </rpc>
The RPC reply returns the requested output, which includes
the <uptime-information>
element and
its descendants.
<rpc-reply xmlns:junos="URL"> <system-uptime-information xmlns="URL"> <uptime-information> <date-time junos:seconds="1447360705">12:38PM</date-time> <up-time junos:seconds="17982062">208 days, 3:01</up-time> <active-user-count junos:format="2 users">2</active-user-count> <load-average-1>0.10</load-average-1> <load-average-5>0.08</load-average-5> <load-average-15>0.08</load-average-15> </uptime-information> </system-uptime-information> </rpc-reply>
The client application can also select for specific leaf nodes
in the container by including those nodes as selection nodes, or empty
tags, within the container element in the request. To return just
the <up-time>
element in the output
for the previous example, the client emits the empty tag for that
node in the request.
<rpc> <get-system-uptime-information> <filter type="subtree"> <system-uptime-information> <uptime-information> <up-time/> </uptime-information> </system-uptime-information> </filter> </get-system-uptime-information> </rpc>
The RPC reply returns only the requested node.
<rpc-reply xmlns:junos="URL"> <system-uptime-information xmlns="URL"> <uptime-information> <up-time junos:seconds="17982062">208 days, 3:01</up-time> </uptime-information> </system-uptime-information> </rpc-reply>