Subject: [netmod] Question about updating YANG modules

From: William Ivory <[email-masked]>
Date: Tue, 19 Apr 2016 07:30:14 +0000

Hi,

Section 10 of the YANG RFC covers updating modules while maintaining backwards-compatibiility.  I have a question about whether the following statement allows for a string type to be replaced with a union comprising solely of string types, so long as the overall set of strings accepted was no more restrictive?  This would allow us to reuse some existing types.

   o  A "type" statement may be replaced with another "type" statement
      that does not change the syntax or semantics of the type.  For
      example, an inline type definition may be replaced with a typedef,
      but an int8 type cannot be replaced by an int16, since the syntax
      would change.

I can see that changing int8 to int16 changes the syntax, but does changing from string to a union of strings change the syntax according to this definition?

Thanks,

William

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Tue, 19 Apr 2016 09:40:41 +0200

A type is essentially defining a set of allowed values.

If this set of values does not change (and the semantics associated
with the values do not change), then you can change the type used in
the type statement.

/js

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

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>

---

From: William Ivory <[email-masked]>
Date: Tue, 19 Apr 2016 08:02:24 +0000

OK - but changing from int8 to int16 still allows all previously allowed values, and simply adds some more, making it less restrictive.  That isn't allowed though as noted in the bullet point from section 10 below.

What about extending a union that previously included say just strings to include int8 as well - is that allowed under section 10 rules?

Thanks,

William

-----Original Message-----
From: Juergen Schoenwaelder [mailto:[email-masked]] 
Sent: 19 April 2016 08:41
To: William Ivory <[email-masked]>
Cc: [email-masked]
Subject: Re: [netmod] Question about updating YANG modules

If this set of values does not change (and the semantics associated with the values do not change), then you can change the type used in the type statement.

/js

> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.ietf.org_mail
> man_listinfo_netmod&d=CwIBAg&c=IL_XqQWOjubgfqINi2jTzg&r=GByLeg9jZvOv_A
> lgBo9uvdDrxizlOR7l_SnTXowyJU8&m=eNnaJYadAK0Fvw2MfBD-jQYKBdoeq28VUey6fK
> A5B6s&s=lzSZQBGv2Xz2LtMHfvwQmV0K6i7olWuSvPFW9XEkA8M&e=

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
Fax:   +49 421 200 3103         <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.jacobs-2Duniversity.de_&d=CwIBAg&c=IL_XqQWOjubgfqINi2jTzg&r=GByLeg9jZvOv_AlgBo9uvdDrxizlOR7l_SnTXowyJU8&m=eNnaJYadAK0Fvw2MfBD-jQYKBdoeq28VUey6fKA5B6s&s=Dkya3b9AFYKFTljkbVtJKVHNDqJ5HzrP5jMxydI1FB4&e= >

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Tue, 19 Apr 2016 10:12:04 +0200

On Tue, Apr 19, 2016 at 08:02:24AM +0000, William Ivory wrote:

> OK - but changing from int8 to int16 still allows all previously
> allowed values, and simply adds some more, making it less
> restrictive.  That isn't allowed though as noted in the bullet point
> from section 10 below.

Obviously, the set of allowed values changes when you replace int8 with
int16.
 
> What about extending a union that previously included say just strings to include int8 as well - is that allowed under section 10 rules?

This is an interesting question. Assuming you had

  leaf a { type string; }

and you change it to

  leaf a { type union { type int8; type string; } }

then for the XML encoding the set of values does not change however
for the JSON encoding it does change. See the JSON document for
subtleties associated with unions.

To prevent damage for encodings that carry some type information, we
might need a stricter interpretation of YANG compatibility rules...

/js

---

From: William Ivory <[email-masked]>
Date: Tue, 19 Apr 2016 08:20:36 +0000

So would it be a fair summary to say that it is allowed to change from a specific type to a union consisting only of those types, but that adding different types on top of the existing type is not recommended.

Which JSON document are you referring to?

Thanks,

William

-----Original Message-----
From: Juergen Schoenwaelder [mailto:[email-masked]] 
Sent: 19 April 2016 09:12
To: William Ivory <[email-masked]>
Cc: [email-masked]
Subject: Re: [netmod] Question about updating YANG modules

On Tue, Apr 19, 2016 at 08:02:24AM +0000, William Ivory wrote:

> allowed values, and simply adds some more, making it less restrictive.  
> That isn't allowed though as noted in the bullet point from section 10 
> below.

Obviously, the set of allowed values changes when you replace int8 with int16.

  leaf a { type string; }

and you change it to

then for the XML encoding the set of values does not change however for the JSON encoding it does change. See the JSON document for subtleties associated with unions.

To prevent damage for encodings that carry some type information, we might need a stricter interpretation of YANG compatibility rules...

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1 | 28759 Bremen | Germany
Fax:   +49 421 200 3103         <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.jacobs-2Duniversity.de_&d=CwIBAg&c=IL_XqQWOjubgfqINi2jTzg&r=GByLeg9jZvOv_AlgBo9uvdDrxizlOR7l_SnTXowyJU8&m=wSZwDXcoblI354__Ryu63C-eCizA9MGZlpaNGr9oamA&s=zU0Z5HyUEKygBVYhh9EtdPH-AfQ7IeFuMllqL3wEWs0&e= >

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Tue, 19 Apr 2016 10:25:44 +0200

> Which JSON document are you referring to?

https://tools.ietf.org/html/draft-ietf-netmod-yang-json-10

/js