Subject: [netmod] YANG question

From: "Alexander Clemm (alex)" <[email-masked]>
Date: Fri, 21 Dec 2012 01:26:56 +0000

Hello YANG experts,

I have a quick question:  is it possible to specify for an augmentation of a list, that the augmenting information needs to be unique?

I would like to do something like (to modify the example in RFC 6020 slighly)

     import interface-module {
         prefix "if";
     }
     augment "/if:interfaces/if:ifEntry" {
         when "if:ifType='foobar'";
         unique "foobarNumber";
         leaf foobarNumber {
             type foobarNumber;
         }
     }

Can I do this?  RFC 6020 section 7.15.1 does not list "unique" under the substatements that are allowed.  On the other hand, the "uniqueness" property does not refer to information in the augmented module (which would be understandably illegal to introduce), but only in the information that is added.

How can I accomplish what I need to do?

Thanks
--- Alex

---

From: "Lisa Huang (yihuan)" <[email-masked]>
Date: Fri, 21 Dec 2012 06:30:04 +0000

Alex,

Where did you see "uniqueness” property does not refer to information in the augmented module" in RFC 6020?

Since unique could apply to optional leaf, I do not understand why it can not apply to augment module ( but as you said, section 7.15.1 does not list "unique" in the sub statements.

I could not think of another way as both must and unique are not allowed in 7.15.1

Thanks,

Lisa

From: "Alexander Clemm (alex)" <[email-masked]<mailto:[email-masked]>>
Date: Thursday, December 20, 2012 5:26 PM
To: "[email-masked]<mailto:[email-masked]>" <[email-masked]<mailto:[email-masked]>>
Subject: [netmod] YANG question

Hello YANG experts,

         unique “foobarNumber”;
         leaf foobarNumber {
             type foobarNumber;
         }
     }

Can I do this?  RFC 6020 section 7.15.1 does not list “unique” under the substatements that are allowed.  On the other hand, the “uniqueness” property does not refer to information in the augmented module (which would be understandably illegal to introduce), but only in the information that is added.

Thanks
--- Alex

---

From: Martin Bjorklund <[email-masked]>
Date: Fri, 21 Dec 2012 08:26:56 +0100 (CET)

Hi,

"Alexander Clemm (alex)" <[email-masked]> wrote:
> Hello YANG experts,
> 
> I have a quick question: is it possible to specify for an augmentation of a
> list, that the augmenting information needs to be unique?
> 
> Can I do this?

No, unfortunately.  (I am sure Lada can come up with an XPath
expression involving preceding-sibling or something that solves this
:)

/martin

---

From: Jernej Tuljak <[email-masked]>
Date: Fri, 21 Dec 2012 10:03:40 +0100

Dne 21.12.2012 2:26, pis(e Alexander Clemm (alex):
>
> Hello YANG experts,
>
> I have a quick question:  is it possible to specify for an 
> augmentation of a list, that the augmenting information needs to be 
> unique?
>
> Can I do this?  RFC 6020 section 7.15.1 does not list "unique" under 
> the substatements that are allowed.  On the other hand, the 
> "uniqueness" property does not refer to information in the augmented 
> module (which would be understandably illegal to introduce), but only 
> in the information that is added.
>

Like Martin already suggested you can work around this by putting a 
must-stmt constaint on valid foobarNumber data nodes, not on the list 
itself. For your example that would probably be the following statement 
block as a child to leaf foobarNumber:

must 
"not(parent::if:ifEntry/preceding-sibling::if:ifEntry[current()=pfx:foobarNumber])" 
{
     error-message "Violated uniqueness constraint for pfx:foobarNumber"
}

where pfx is the prefix of the augmenting module.

However, I'm not entirely sure how you would handle a multi-valued 
unique (if you augmented two leafs and wanted both of them to be part of 
the same uniqueness constraint). That would probably require some more 
thinking.

Jernej

> Thanks
>
> --- Alex
>
>
>
> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod

---

From: Ladislav Lhotka <[email-masked]>
Date: Fri, 21 Dec 2012 15:00:08 +0100

> the same uniqueness constraint). That would probably require some more 

Here is an example for two nodes "foo" and "bar" that are required to be unique, it could be done analogically for any number of nodes:

  augment "/if:interfaces/if:interface" {
    when "if:type='other'";
    leaf foo {
      type uint8;
      must "not(../preceding-sibling::if:interface[foo = current() "
         + "and bar = current()/../bar])" {
        error-message "Violated uniqueness of foo & bar.";
      }
    }
    leaf bar {
      type string;
    }
  }

Lada

-- 
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: "Alexander Clemm (alex)" <[email-masked]>
Date: Fri, 21 Dec 2012 17:42:49 +0000

Lada, Jernej, Martin,
thank you for your responses!  Will go with the xpath expression then.
Happy holidays
--- Alex

-----Original Message-----
From: [email-masked] [mailto:[email-masked]] On Behalf Of Ladislav Lhotka
Sent: Friday, December 21, 2012 6:00 AM
To: [email-masked]
Subject: Re: [netmod] YANG question

Jernej Tuljak <[email-masked]> writes:

> itself. For your example that would probably be the following 
> statement block as a child to leaf foobarNumber:
>
> must
> unique (if you augmented two leafs and wanted both of them to be part 
> of the same uniqueness constraint). That would probably require some 
> more thinking.

Lada