Skip to content

Cannot get child using XPATH #414

@dima1308

Description

@dima1308

When I execute the following query:

<get>
  <filter type="subtree">
    <rb-tg-if:interfaces xmlns:rb-tg-if="http://siklu.com/yang/tg/interfaces"/>
  </filter>
</get>

I get the following response:

<?xml version="1.0" encoding="utf-8"?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <interfaces xmlns="http://siklu.com/yang/tg/interfaces">
    <host>
      <state>
        <mac-address>00:24:a4:16:51:a1</mac-address>
        <counters>
          <in-octets>157432</in-octets>
          <in-pkts>3730</in-pkts>
          <in-discards>0</in-discards>
          <in-errors>0</in-errors>
          <in-no-rule-discards>4</in-no-rule-discards>
          <out-octets>6791986</out-octets>
          <out-pkts>60877</out-pkts>
          <out-discards>0</out-discards>
          <out-errors>0</out-errors>
        </counters>
      </state>
    </host>
    <ports>
      <name>eth1</name>
      <alias>myeth1</alias>
      <admin-status>up</admin-status>
      <copper-specific-config>
        <auto-negotiate>true</auto-negotiate>
      </copper-specific-config>
      <connector-type>RJ-45</connector-type>
      <port-speed>10Gbps</port-speed>
      <state>
        <oper-status>up</oper-status>
        <actual-duplex-mode>full</actual-duplex-mode>
        <actual-port-speed>1Gbps</actual-port-speed>
        <counters>
          <in-octets>6407339</in-octets>
          <in-pkts>55797</in-pkts>
          <in-discards>0</in-discards>
          <in-errors>0</in-errors>
          <in-no-rule-discards>5</in-no-rule-discards>
          <out-octets>532508</out-octets>
          <out-pkts>8699</out-pkts>
          <out-discards>0</out-discards>
          <out-errors>0</out-errors>
        </counters>
      </state>
    </ports>
    <ports>
      <name>eth2</name>
      <alias>myeth2</alias>
      <admin-status>up</admin-status>
      <copper-specific-config>
        <auto-negotiate>true</auto-negotiate>
        <pse-out>true</pse-out>
      </copper-specific-config>
      <connector-type>RJ-45</connector-type>
      <port-speed>1Gbps</port-speed>
      <state>
        <oper-status>down</oper-status>
        <counters>
          <in-octets>0</in-octets>
          <in-pkts>0</in-pkts>
          <in-discards>0</in-discards>
          <in-errors>0</in-errors>
          <in-no-rule-discards>0</in-no-rule-discards>
          <out-octets>0</out-octets>
          <out-pkts>0</out-pkts>
          <out-discards>0</out-discards>
          <out-errors>0</out-errors>
        </counters>
      </state>
    </ports>
    <ports>
      <name>eth3</name>
      <alias>myeth3</alias>
      <admin-status>up</admin-status>
      <copper-specific-config>
        <auto-negotiate>true</auto-negotiate>
      </copper-specific-config>
      <connector-type>SFP+</connector-type>
      <port-speed>10Gbps</port-speed>
      <state>
        <oper-status>down</oper-status>
        <counters>
          <in-octets>0</in-octets>
          <in-pkts>0</in-pkts>
          <in-discards>0</in-discards>
          <in-errors>0</in-errors>
          <in-no-rule-discards>0</in-no-rule-discards>
          <out-octets>0</out-octets>
          <out-pkts>0</out-pkts>
          <out-discards>0</out-discards>
          <out-errors>0</out-errors>
        </counters>
      </state>
    </ports>
    <rf-interface>
      <name>rf-23654789</name>
      <state>
        <oper-status>up</oper-status>
        <counters>
          <in-octets>22536898</in-octets>
          <in-pkts>33518</in-pkts>
          <in-discards>0</in-discards>
          <in-errors>0</in-errors>
          <in-no-rule-discards>0</in-no-rule-discards>
          <out-octets>4706450</out-octets>
          <out-pkts>31432</out-pkts>
          <out-discards>0</out-discards>
          <out-errors>0</out-errors>
        </counters>
      </state>
    </rf-interface>
    <tunnels>
      <name>tunnel-1</name>
      <oper-status>unknown</oper-status>
      <counters>
        <in-octets>0</in-octets>
        <in-pkts>0</in-pkts>
        <in-discards>0</in-discards>
        <in-errors>0</in-errors>
        <in-no-rule-discards>0</in-no-rule-discards>
        <out-octets>0</out-octets>
        <out-pkts>0</out-pkts>
        <out-discards>0</out-discards>
        <out-errors>0</out-errors>
      </counters>
    </tunnels>
  </interfaces>
</data>

Now, I'm only trying to get a list of interface names using the following query:

<get>
  <filter xmlns:rb-tg-if="http://siklu.com/yang/tg/interfaces" type="xpath"
          select="/rb-tg-if:interfaces/rb-tg-if:ports/rb-tg-if:name"/>
</get>

I got the expected result:

<?xml version="1.0" encoding="utf-8"?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <interfaces xmlns="http://siklu.com/yang/tg/interfaces">
    <ports>
      <name>eth1</name>
    </ports>
    <ports>
      <name>eth2</name>
    </ports>
    <ports>
      <name>eth3</name>
    </ports>
  </interfaces>
</data>

Next, I am trying to get interfaces with alias='myeth2':

<get>
  <filter xmlns:rb-tg-if="http://siklu.com/yang/tg/interfaces" type="xpath"
          select="/rb-tg-if:interfaces/rb-tg-if:ports[rb-tg-if:alias='myeth2']"/>
</get>

I received the following result, as expected (we have one interface matching the condition):

<?xml version="1.0" encoding="utf-8"?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <interfaces xmlns="http://siklu.com/yang/tg/interfaces">
    <ports>
      <name>eth2</name>
      <alias>myeth2</alias>
      <admin-status>up</admin-status>
      <copper-specific-config>
        <auto-negotiate>true</auto-negotiate>
        <pse-out>true</pse-out>
      </copper-specific-config>
      <connector-type>RJ-45</connector-type>
      <port-speed>1Gbps</port-speed>
      <state>
        <oper-status>down</oper-status>
        <counters>
          <in-octets>0</in-octets>
          <in-pkts>0</in-pkts>
          <in-discards>0</in-discards>
          <in-errors>0</in-errors>
          <in-no-rule-discards>0</in-no-rule-discards>
          <out-octets>0</out-octets>
          <out-pkts>0</out-pkts>
          <out-discards>0</out-discards>
          <out-errors>0</out-errors>
        </counters>
      </state>
    </ports>
  </interfaces>
</data>

And now, I'm trying to get only the name of the interface matching the same condition as above:

<get>
  <filter xmlns:rb-tg-if="http://siklu.com/yang/tg/interfaces" type="xpath"
          select="/rb-tg-if:interfaces/rb-tg-if:ports[rb-tg-if:alias='myeth2']/rb-tg-if:name"/>
</get>

I got an empty response - which is not expected since the previous query returns one record matching the condition:

<?xml version="1.0" encoding="utf-8"?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>

if I change the query as shown below, I got both values: name and alias in the response:
The request:

<get>
  <filter xmlns:rb-tg-if="http://siklu.com/yang/tg/interfaces" type="xpath"
          select="/rb-tg-if:interfaces/rb-tg-if:ports[rb-tg-if:alias='myeth2']/rb-tg-if:alias"/>
</get>

The response:

<?xml version="1.0" encoding="utf-8"?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <interfaces xmlns="http://siklu.com/yang/tg/interfaces">
    <ports>
      <name>eth2</name>
      <alias>myeth2</alias>
    </ports>
  </interfaces>
</data>

In this case, I expect to get output that will only include alias

We use CLIXON from Jan 20, 2023, hash: b3dcee9

To summarize, I saw two issues:

  1. In some cases, an empty response for the request
  2. Not expected value in the response.

Please see attached yang models we use: yang.zip

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions