Subject: [netmod] Case Statements in Groupings

From: JOEY BOYD <[email-masked]>
Date: Thu, 11 Feb 2016 20:00:37 +0000

Hi all,

Currently, it's not allowed to do the following as you cannot wrap case statements in a grouping.

grouping common-cases {
  case b {
    leaf b {
    }
  }

  case c {
    leaf c {
    }
  }
}

container alpha {
  choice my-first-choice {
    case a {
      leaf a {
      }
    }

    uses common-cases;
  }
}

container beta {
  choice my-second-choice {
    case d {
      leaf d {
      }
    }
    uses common-cases;
  }
}

I was wondering why this restriction is in place.  I know you have to be careful with name collisions but that's true of just a grouping of leafs.  Am I missing something?

Best Regards,
Joey

---

From: Martin Bjorklund <[email-masked]>
Date: Fri, 12 Feb 2016 10:47:38 +0100 (CET)

JOEY BOYD <[email-masked]> wrote:
> I was wondering why this restriction is in place.  I know you have to
> be careful with name collisions but that's true of just a grouping of
> leafs.  Am I missing something?

This could maybe have been considered.  Such a grouping would of
course only be allowed to be used in a choice, and it would be limited
to define *only* case nodes.  As such it is a bit different than other
groupings.

Note that you can achieve a similar effect by doing:

  grouping choice-with-common-cases {
    choice the-choice {
      case b {
        leaf b {
        }
      }

      case c {
        leaf c {
        }
      }
    }
  }

  container alpha {
    uses choice-with-common-cases {
      augment "the-choice" {
        case a {
          leaf a {
          }
        }
      }
    }
  }

  container beta {
    uses choice-with-common-cases {
      augment "the-choice" {
        case d {
          leaf d {
          }
        }
      }
    }
  }

/martin