Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-800

The validate rules of "min-elements" is not consistent with the RFC6020

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Cannot Reproduce
    • None
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    • 8887

    Description

      I am using yangtools boron-sr4. I think the validate rules of "min-elements" is not consistent with the RFC6020.

      See https://tools.ietf.org/html/rfc6020#page-63

      7.7.3. The min-elements Statement

      If "min-elements" exists in the leaf-list or list, and the leaf-list's or list's closest ancestor node is neither a non-presence container nor a case node. The "min-elements" constraint is enforced if the ancestor node exists.

      But in fact the yang-data-impl's rule is like this:

      if (constraints.isMandatory() || (minElements != null && minElements > 0)) {
      final YangInstanceIdentifier childId = id.node(NodeIdentifier.create(child.getQName()));
      LOG.debug("Adding mandatory child {}", childId);
      builder.add(childId.toOptimized());
      } }
      }
      It means that if "min-elements" is exist, the list or leaf-list node must exist.

      Consider a yang module like this:
      list layer-protocol {
      container eth-cep-pac {
      list vlan-spec

      { key 'vlan-id'; uses TypeDefinition:zte-vlan-spec; min-elements 1; }

      leaf mac-adress-learning-range

      { type uint64; }
      }
      container eth-nep-pac {
      leaf total-potential-eth-capacity { type uint64; }

      leaf available-eth-capacity

      { type uint64; }

      }
      }
      If I put "layer-protocol" without "eth-cep-pac" into configuration datastore, IllegalArgumentException occurred " missing mandatory descendant /eth-cep-pac/vlan-spec"

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            angelanzhe@gmail.com anzhe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: