Confd_load deletion of path

module ne {
    container net {
        container dns {
            leaf enabled { type boolean; default true; }
            list dns-server {
                key index;
                leaf index { type uint8; }
                leaf server-ip { ietf-inet:ip-address; mandatory true; }
        }
    }
}

cat /opt/dhcp_dns_list.xml
<config xmlns="http://tail-f.com/ns/config/1.0">
  <ne xmlns="urn:params:xml:ns:yang:ne">
  <net>
  <dns>
    <dns-server>
      <index>0</index>
      <server-ip>9.2.5.1</server-ip>
    </dns-server>
  </dns>
  </net>
  </ne>
</config>

confd_load -l -p /ne/net/dns/dns-server /opt/dhcp_dns_list.xml

The above keeps deleting the entire contents of /ne/net/dns before it loads the xml, shouldn’t it only delete the contents of the list dns-server? ie if I set enabled to false, after I run confd_load it’s set to the default of true.

How do I get it to just delete and replace the list?

With -p you are telling ConfD to delete the path; with -l you ask for load-override operation, unless you provide also -m or -r. In your case -m should be used.

See the manpage or confd_load --help.

-m merges. I’m not sure if it’s clear or not, I want the list deleted and replaced, but I want the “enabled” leaf to remain untouched.

If I send a 2-element list with -m, it just replaces the elements with the matching indexes. I want the entire list cleared and a new one inserted, but for enabled leaf to remain untouched.

If we use a path according to the YANG model you provided:
confd_load -l -p /net/dns/dns-server -m dhcp_dns_list.xml
or with the path according to the XML you provided:
confd_load -l -p /ne/net/dns/dns-server -m dhcp_dns_list.xml

As @mvf wrote, -p /some/path first delete everything under /some/path and -m dhcp_dns_list.xml merges the data in the dhcp_dns_list.xml without deleting the enabled leaf data.

How do I delete the contents of dns-server though? -m merges, so if I have for example the following in the db:

ne {
    net {
        dns{
            disabled;
            dns-server 0 {
                server-ip 192.168.2.1;
            }
            dns-server 1 {
                server-ip 192.168.2.2;
            }
        }
    }
}

And I call the above xml with -m, it results in:

ne {
    net {
        dns{
            disabled;
            dns-server 0 {
                server-ip 9.2.5.1;
            }
            dns-server 1 {
                server-ip 192.168.2.2;
            }
        }
    }
}

It preserves the enabled leaf ok, but it’s not deleting the contents of dns-server, just merging existing and new.
After the load, I want it to look like:

ne {
    net {
        dns{
            disabled;
            dns-server 0 {
                server-ip 9.2.5.1;
            }
        }
    }
}

What I’m hearing is that if I want to wipe the list clean, but leave the leaf untouched… I need to read the enabled flag out of the db, and insert it into my xml, in order to preserve its state?

Here’s my issue, if I use confd_load to “print” /ne/net/dns/dns-server, it omits the enabled leaf, even if it’s set (this is expected, I’m requesting the path to the list, not the path to its parent container).

If I then use confd_load to “load” the output of that to /ne/net/dns/dns-server, it overwrites the whole container, not just the list.

Have you actually tested our suggestion?
confd_load -l -p /ne/net/dns/dns-server -m dhcp_dns_list.xml

Example:

$ confd_load -Fj -p /ne
ne {
    net {
        dns {
            enabled;
            dns-server 0 {
                server-ip 192.168.2.1;
            }
            dns-server 1 {
                server-ip 192.168.2.2;
            }
        }
    }
}
$ cat dhcp_dns_list.xml 
<config xmlns="http://tail-f.com/ns/config/1.0">
  <ne xmlns="urn:params:xml:ns:yang:ne">
    <net>
      <dns>
        <dns-server>
          <index>0</index>
          <server-ip>9.2.5.1</server-ip>
        </dns-server>
      </dns>
    </net>
  </ne>
</config>
$ confd_load -l -p /ne/net/dns/dns-server -m dhcp_dns_list.xml
$ confd_load -Fj -p /ne
ne {
    net {
        dns {
            enabled;
            dns-server 0 {
                server-ip 9.2.5.1;
            }
        }
    }
}

I’m not sure what I was doing differently before, but the merge wasn’t working for me, it was either deleting the leaf and list, or leaving the leaf and only partially replacing the list.

Now it works.

Thanks for your help.