clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
212 stars 72 forks source link

with-defaults basic-mode is not honored on get-config #384

Closed pheller closed 1 year ago

pheller commented 1 year ago

Clixon reports

<capability>urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=explicit&amp;also-supported=report-all,trim,report-all-tagged</capability>

However, a get-config rpc that omits the with-defaults element seems to contain default data:

<?xml version="1.0" encoding="utf-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="121">
  <get-config>
    <source>
      <running/>
    </source>
  </get-config>
</rpc>
<?xml version="1.0" encoding="utf-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="121">
  <data>
    <system xmlns="http://openconfig.net/yang/system">
      <ntp>
        <config>
          <enabled>false</enabled>
          ...

And from the YANG:

  grouping system-ntp-config {
    description
      "Configuration data for system-wide NTP operation.";

    leaf enabled {
      type boolean;
      default false;
      ...

However, if I repeat the same get-config and include the with-defaults attribute with a value matching the server-advertised basic-mode, the response is as expected:

<?xml version="1.0" encoding="utf-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="123">
  <get-config>
    <source>
      <running/>
    </source>
    <ncwd:with-defaults xmlns:ncwd="urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults">explicit</ncwd:with-defaults>
  </get-config>
</rpc>

yields:

<?xml version="1.0" encoding="utf-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="9">
  <data/>
</rpc-reply>
pheller commented 1 year ago

There is a covering test, though it appears to expect the following to be within the response:

<interface><name>eth1</name><mtu>1500</mtu><status>ok</status></interface>

I think mtu should be omitted and status retained per RFC 6243 2.3.1:

2.3.1. 'explicit' Basic Mode Retrieval

When data is retrieved from a server using the 'explicit' basic mode, and the parameter is not present, data nodes MUST be reported if explicitly set by the client, even if they contain the schema default value. Non-configuration data nodes containing the schema default value MUST be reported.

olofhagsand commented 1 year ago

Fixed and merged, please verify

pheller commented 1 year ago

Looks good to me. Thanks!