MUST statement to check through all the key values in the list

Hi,

I need to implement following CLI in yang

inside from host 2.2.2.3 to 3.3.3.3
inside from host 2.2.2.2 to 3.3.3.2
inside from host 2.2.2.1 to 3.3.3.1

I implemented this as a list with both the IP’s as keys (both are unique). Now if someone tries ‘inside from host 2.2.2.1 to 3.3.3.4’, I need to reject this since 2.2.2.1 is already part of the list. Similarly ‘inside from host 2.2.2.4 to 3.3.3.1’ also need to be rejected since 3.3.3.1 is already part of list. How can we have a must statement for this? Basically I need to check all the existing values in the list and reject if the value entered is already present,

The way I have implemented the model is as below.

    container inside {
      tailf:cli-incomplete-no;
      container from {
        tailf:cli-incomplete-no;
        tailf:cli-compact-syntax;
        list host {
          tailf:cli-suppress-mode;
          tailf:cli-suppress-list-no;
          tailf:cli-delete-when-empty;
          key "host_ip to";
          leaf host_ip {
            tailf:cli-incomplete-command;
            type inet:ipv4-address;
          }
          leaf to {
            tailf:cli-expose-key-name;
            type inet:ipv4-address;
          }
        }

Please help.

hi,

this sounds like good use-case for YANG unique statement (link)…