Confdc error: No must statements conditions annotations are not reflecting in schema

My yang file as follows below.

    must "current() = 1 or
              current() = 2 or
              current() = 3 or
              current() = 6 or
              current() = 7 or
              current() = 8" {

            }

MY annotate file

must “(current() = ‘1’)” +
“or (current() = ‘2’)” +
“or (current() = ‘3’)” +
“or (current() = ‘4’)” +
“or (current() = ‘5’)” +
“or (current() = ‘6’)” +
“or (current() = ‘7’)” +
“or (current() = ‘8’)” +
“or (current() = ‘9’)”{

In my case compilation is successful, but my annotations are not reflecting. Plz help here

It is a bit unclear what you are trying to do - as we don’t know structure of your node that has must statement (leaf type etc.).

Can you try to edit some existing example, e.g. “examples.confd/intro/1-2-3-start-query-model” (and just paste diff)? With your extra item & must statement so people here can try reproducing and give hints. Plus an example of commands that you try to run & that are against your expected result…

Here are additional details.

my Yang file.

typedef port-number {
        tailf:info "1, 2, 3, 7, 8, 9";
        type uint16;
    }
    grouping port-config {
        leaf port {
            description "port number";
            tailf:info "port number";
            type port-number;
            must "current() = 1 or
                  current() = 2 or
                  current() = 3 or
                  current() = 7 or
                  current() = 8 or
                  current() = 9" {
                error-message "Invalid port configuration. Allowed
                               ports are 1, 2, 3, 7, 8, 9";
            } 
        }

MY Annotate file

tailf:annotate-module "f5-allowed-ips" {
        tailf:annotate-statement "typedef[name='port-number']" {
            tailf:info "1, 2, 3, 4, 5, 6, 7, 8, 9";
        }
        
    }
    tailf:annotate "/oc-sys:system/f5-allowed-ips:allowed-ips/f5-allowed-ips:allowed-ip/f5-allowed-ips:config/f5-allowed-ips:ip-config/f5-allowed-ips:ipv4/f5-allowed-ips:ipv4/f5-allowed-ips:port" {
        must "(current() = '1')" +
             "or (current() = '2')" +
             "or (current() = '3')" +
             "or (current() = '4')" +
             "or (current() = '5')" +
             "or (current() = '6')" +
             "or (current() = '7')" +
             "or (current() = '8')" +
             "or (current() = '9')" "{
              error-message "Invalid port configuration. Allowed
                        ports are 1, 2, 3, 4, 5, 6, 7, 8, 9";
            }
    }
}

Here I add additional ports to the list. When I am trying to configure the ports, 4, 5, 6, It showing invalid ports, actually it supposed to be accept it, In case my annotate schema is reflected.

$ default-1(config)# system allowed-ips allowed-ip ts config ipv4 address 1.2.3.4 port 4 prefix-length 24
$ default-1(config-allowed-ip-ts)# commit
Aborted: 'system allowed-ips allowed-ip ts config ipv4 port' (value "4"): Invalid port configuration. Allowed
ports are 1, 2, 3, 7, 8, 9
default-1(config-allowed-ip-ts)#

Plz help here

Instead of a “must” statement try using a “range” statement. Example:

typedef port-number {
  type uint16 {
    range "1..9" {
      error-message "Invalid port configuration. Allowed ports are 1, 2, 3, 4, 5, 6, 7, 8, 9";
    }
  }
}
1 Like

My guess is that your current solution with tailf:annotate works in a way that it added second must statement next to the original one. So even though new must conditions are OK, the “old” one still blocks your attempt to use value 4/5/6.

Best solution would be like @cohult suggests.
If you keep must restriction approach, you may need to update/remove original must using deviate (instead of tailf:annotate) YANG statement, and either remove it, or replace with updated version…

1 Like