0

My code is as follows.

1.

grouping policy-attributes {
    container qospolicies {
        list qospolicy {
            key "uuid";
            uses attrs:base-attributes;
            uses qos-policy-attributes;
            uses bandwidth-limit-attributes;
            uses dscp-marking-attributes;
        }
    }
}

The grouping with the list

2.

grouping bandwidth-limit-rules-attributes {
    list bandwidth-limit-rule{
    leaf qos-rule-id {
        type yang:uuid;
        description "The rule id of the associated rule";
    }
    leaf max-kbps {
        type uint64;
        description "The maximum KBPS value";
    }
    leaf max-burst-kbps {
        type uint64;
        description "The burst over the maximum KBPS value";
    }
    leaf policy-id {
        type yang:uuid;
        description "The policy id to which the rule is associated";
    }
    }
}

3.

grouping dscp-marking-rules-attributes {
    list dscp-marking-rule{
    leaf qos-rule-id {
        type yang:uuid;
        description "The rule id of the associated rule";
    }
    leaf dscp-mark {
        type uint8{
        range "0 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38
        | 40 | 46 | 48 | 56 ";}
        description "the value of dscp mark";
    }
    leaf policy-id {
        type yang:uuid;
        description "the policy id to which the rule is associated";
    }
    }
}

The grouping bandwidth-limit-rules-attributes has the list with leaves. Also the bandwidth-limit-rules-attributes is used in the grouping policy-attributes. I would like to know if it is valid to have the bandwidth-limit-rules-attributes in policy-attributes.

Adam
  • 5,403
  • 6
  • 31
  • 38
  • A side note: `key "uuid"` means that you must have a leaf with such name directly as a substatement of the `list` or directly in one of the groupings used by that list. I hope, that this is satisfied by some of the other groupings that you have there. – Piotr Babij Jun 16 '16 at 07:25

1 Answers1

0

Yes, you can have a list as a substatement to a grouping. Here's the list of possible substatements for a grouping from RFC6020 (YANG 1.0).

 +--------------+---------+-------------+
 | substatement | section | cardinality |
 +--------------+---------+-------------+
 | anyxml       | 7.10    | 0..n        |
 | choice       | 7.9     | 0..n        |
 | container    | 7.5     | 0..n        |
 | description  | 7.19.3  | 0..1        |
 | grouping     | 7.11    | 0..n        |
 | leaf         | 7.6     | 0..n        |
 | leaf-list    | 7.7     | 0..n        |
 | list         | 7.8     | 0..n        | <--
 | reference    | 7.19.4  | 0..1        |
 | status       | 7.19.2  | 0..1        |
 | typedef      | 7.3     | 0..n        |
 | uses         | 7.12    | 0..n        |
 +--------------+---------+-------------+

Using the grouping inside your policy-attributes grouping is also valid:

grouping policy-attributes {
    container qospolicies {
        list qospolicy {
            key uuid;
            /*
            uses attrs:base-attributes;
            uses qos-policy-attributes;
            uses bandwidth-limit-attributes;
            uses dscp-marking-attributes;
            */
            uses bandwidth-limit-rules-attributes;
        }
    }
}
Community
  • 1
  • 1
predi
  • 5,528
  • 32
  • 60
  • This is is not a valid YANG `list` because of a different reason. There must be a uuid `leaf` in the grouping or in the list because of the `key uuid;` statement. – Piotr Babij Jun 16 '16 at 07:28
  • @Piotr, the definitions are valid. Groupings need not assume the way in which they are used. I would even say that this is bad practice. – predi Jun 16 '16 at 07:42
  • I just meant that if you have a declaration of key in a list then this key must exist. The designer of the list must ensure that, not the designer of the grouping. I am not quite sure what you mean with the augmentation here. It fixes a problem inside the `policy-attributes` grouping, but why fix it from outside? – Piotr Babij Jun 16 '16 at 08:04
  • @PiotrBabij, you claimed that the `list` inside my grouping definition was invalid, which is untrue. It only becomes invalid if the `grouping` is used in a certain way. My augment does not "fix" the grouping, since it was never broken in the first place. While I agree that such a definition should be avoided, it is not invalid. – predi Jun 16 '16 at 08:22
  • OK, there must be something I do not understand here. Are you saying that it is valid to specify a list key that refer to a non-existing leaf? This is what has been done in the `qospolicy list`. – Piotr Babij Jun 16 '16 at 08:28
  • @PiotrBabij, it is, if done within grouping scope. The leaf may exist where the grouping is used. You cannot know that until the grouping is actually used. – predi Jun 16 '16 at 08:33
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/114816/discussion-between-piotr-babij-and-predi). – Piotr Babij Jun 16 '16 at 08:34
  • I've edited the answer according to [this](http://stackoverflow.com/a/37856888/878469) answer. Let's hope one of the commented `uses` provides the missing leaf. – predi Jun 16 '16 at 10:48
  • Thanks a lot for your help :) – Pramod Raghavendra Jayathirth Jun 20 '16 at 21:07