Subject: [netmod] Choice Case vs Container+When in RFC7950

From: Qin Wu <[email-masked]>
Date: Tue, 2 Apr 2019 01:13:52 +0000

Hi, Folks:
Choice case seems interchangeable with Container+when, here is the example of Choice case
     container system {
       description
         "Contains various system parameters.";
       choice services {
         description
           "Configure externally available services.";
         case ssh {
           description
             "SSH service-specific configuration.";
           // more leafs, containers, and stuff here...
         }
         case tls {
           description
             "TLS service-specific configuration.";
           // more leafs, containers, and stuff here...
         }
       }
     }
I think it can be replaced with container+when representation as follows:
    container system {
       description
         "Contains various system parameters.";
       container services {
         description
           "Configure externally available services.";
         leaf transport {
           enum ssh {
            description
             "ssh";
          }
           enum tls {
           description
            "tls";
          }
         }
         container "ssh" {
           when "../transport=ssh" {
            description
            "active only when the transport is ssh";
           }
           description
             "SSH service-specific configuration.";
           // more leafs, containers, and stuff here...
         }
         container "tls" {
           when "../transport=tls" {
            description
            "active only when the transport is tls";
           }
           description
             "TLS service-specific configuration.";
           // more leafs, containers, and stuff here...
         }
       }
     }
However I didn't see any guidance on when to use Choice case or when to use Container+when?
Any thought about this?

-Qin

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Tue, 2 Apr 2019 08:05:13 +0200

I prefer choice since a choice says clearly upfront that what follows
are N alternatives. With when statements, I have to keep all the when
statements in my mind to derive the conclusion that the model defines
alternatives. And the transport leaf in your when construction is
redundant.

/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         <https://www.jacobs-university.de/>