Subject: [netmod] how to reuse a container defined in a module b from module a

From: Prasad Sanampudi <[email-masked]>
Date: Wed, 25 Feb 2015 20:28:01 -0600

hi,

say, a module A defined a container ,

module A {
container  common {
   leaf foo {
      type string;
   }
}
}

now, say I have a module B with a container

module B {
   container x {

   }
}

if contianer B/x wants to hold A/common, is it possible ?

I want the net effect to be the following
B/x/foo should be valid.

thank you
Prasad

---

From: Phil Shafer <[email-masked]>
Date: Wed, 25 Feb 2015 22:13:59 -0500

>I want the net effect to be the following

IF A want's common to be reused, it needs to put it in a grouping, like:

module A {
    grouping common {
        leaf foo { ... }
    }
}

module B {
    import A;
    container x {
        uses A:common;
    }
}

Thanks,
 Phil

---

From: Prasad Sanampudi <[email-masked]>
Date: Wed, 25 Feb 2015 21:39:24 -0600

Thanks Phil.

I am trying to improve my understanding of yang authoring.
since, grouping promotes reuse, should yang authors use 'grouping'
construct in yang models to promote reuse of their schema ?

thanks
Prasad

---

From: Phil Shafer <[email-masked]>
Date: Wed, 25 Feb 2015 22:47:06 -0500

>construct in yang models to promote reuse of their schema ?

When reasonable, definitely.

Thanks,
 Phil

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Thu, 26 Feb 2015 08:47:07 +0100

> construct in yang models to promote reuse of their schema ?

In principle yes but writing truly reusable groupings is not as easy
as it sounds. Writing meaningful description clauses that work in
several usage contexts is often more difficult than one might think.

And of course, we likely do not want to encourage vendors to reuse
standard models in their private namespaces instead of implementing
the standard models in their official namespace.

/js

-- 
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/>