Two containers with same name but visible at different time

Hi Team,
I am writing model for one CLI which looks like below,

Router(conf-voi-serv)#media-address range 1.1.1.1 2.2.2.2 port-range ?
<8000-48198> minimum port number

Router(conf-voi-serv)#media-address range 1.1.1.1 2.2.2.2 port-range 8000 ?
<8000-48198> maximum port number

Router(conf-voi-serv)#$ss range 1.1.1.1 2.2.2.2 port-range 8000 8002 ?

Router(conf-voi-serv)#$ss range 1.1.1.1 2.2.2.2 port-range 8000 8002
Router(cfg-media-addr-range)#?
Media Address Range configuration commands:
default Set a command to its defaults
exit Exit from media address range configuration mode
no Negate a command or set its defaults
port-range media address port range

Router(cfg-media-addr-range)#po
Router(cfg-media-addr-range)#port-range ?
<5500-65498> Start media address extended port

Router(cfg-media-addr-range)#port-range 5500 ?
<5500-65498> Stop media address extended port

Router(cfg-media-addr-range)#port-range 5500 5600 ?

Router(cfg-media-addr-range)#port-range 5500 5600

Router(cfg-media-addr-range)#do show run | s media-address
media-address range 1.1.1.1 2.2.2.2 port-range 8000 8002
port-range 5500 5600

Now I have written yang model for above as,
container media-address {
description
“Voice Media IP Address Range”;
when “…/type = ‘voip’”;
tailf:cli-incomplete-no;
container range {
description
“Address range”;
tailf:cli-incomplete-command;
list ipv4 {
tailf:cli-drop-node-name;
tailf:cli-mode-name “cfg-media-addr-range”;
key “startipv4address endipv4address”;
leaf startipv4address {
description
“Enter start ip address”;
tailf:cli-suppress-range;
type inet:ipv4-address;
}
leaf endipv4address {
description
“Enter end ip address”;
tailf:cli-suppress-range;
type inet:ipv4-address;
}
}
uses config-port-range-grouping;
uses config-extended-port-range-grouping;
}
grouping config-port-range-grouping{
container port-range {
description
“Port range”;
tailf:cli-flatten-container;
tailf:cli-hide-in-submode;
leaf minport{
description
“minimum port number”;
tailf:cli-drop-node-name;
must “. mod 2 = 0” {
error-message “min_port value must be even”;
}
type uint16 {
range “8000…48198”;
}
}
}
grouping config-extended-port-range-grouping{
container port-range-extended {
description
“media address port range”;
tailf:alt-name “port-range”;
tailf:cli-sequence-commands;
tailf:cli-compact-syntax;
presence true;
leaf minport{
description
“Start media address extended port”;
tailf:cli-drop-node-name;
must “. mod 2 = 0” {
error-message “min_port value must be even”;
}
type uint16 {
range “5500…65498”;
}
}
}

But on confd I am unable to see port-range (8800…) one as both containers have same name .Can u please help on this ?
ubuntu-xenial(config)# voice service voip
ubuntu-xenial(conf-voi-serv)# media-address ?
Possible completions:
range voice-vrf
ubuntu-xenial(conf-voi-serv)# media-address range ?
Possible completions:
<startipv4address:IPv4 address> <startipv6address:IPv6 address>
ubuntu-xenial(conf-voi-serv)# media-address range 6.6.6.6 7.7.7.7 ?
Possible completions:
port-range
ubuntu-xenial(conf-voi-serv)# media-address range 6.6.6.6 7.7.7.7 port-range ?
Possible completions:
<unsignedShort, 5500 … 65498>
ubuntu-xenial(conf-voi-serv)# media-address range 6.6.6.6 7.7.7.7 port-range

Here 5500 port is visible not 8000 one .
Can someone pls reply at the earliest.

Can someone pls reply ??

Not sure, but it seems like you are looking for the YANG “refine” statement.
https://tools.ietf.org/html/rfc7950#section-7.13.2

Actually i tried refine statement but since both groupings are at same place thats why refine is also not working.
container media-address {
description
“Voice Media IP Address Range”;
when “…/type = ‘voip’”;
container range {
description
“Address range”;
tailf:cli-incomplete-no;
list ipv4 {
tailf:cli-drop-node-name;
tailf:cli-mode-name “cfg-media-addr-range”;
key “startipv4address endipv4address”;
leaf startipv4address {
description
“Enter start ip address”;
tailf:cli-suppress-range;
type inet:ipv4-address;
}
leaf endipv4address {
description
“Enter end ip address”;
tailf:cli-suppress-range;
type inet:ipv4-address;
}
uses config-port-range-grouping;
uses config-extended-port-range-grouping;
}
list ipv6 {
tailf:cli-drop-node-name;
tailf:cli-mode-name “cfg-media-addr-range”;
key “startipv6address endipv6address” ;
leaf startipv6address {
description
“Start IPv6 address”;
tailf:cli-suppress-range;
type inet:ipv6-address;
}
leaf endipv6address {
description
“End IPv6 address”;
tailf:cli-suppress-range;
type inet:ipv6-address;
}
uses config-port-range-grouping;
uses config-extended-port-range-grouping {
when “…/ipv6/port-range/minport”;
}
}
}
list voice-vrf {
description
“voice vrf id”;
tailf:cli-mode-name “cfg-media-addr-vrf”;
key vrfname;
leaf vrfname {
description
“VRF name”;
tailf:cli-suppress-range;
type string;
}
uses config-port-range-grouping;
uses config-extended-port-range-grouping {
when “…/voice-vrf/port-range/minport”;
}
}
}

Why would you want two containers instead of one that you refine according to your needs?
Do you have some sort of need to display both the “port-range” and “port-range-extended” containers over other non-CLI interfaces (e.g. NETCONF)?

We can have it one grouping and refine it . That’s not an issue . But i want normal port-range to be visible when configuring media-address and another extended port-range in submode “cfg-media-addr-range”.
Router(conf-voi-serv)#media-address range 1.1.1.1 2.2.2.2 port-range ?
<8000-48198> minimum port number

Router(conf-voi-serv)#media-address range 1.1.1.1 2.2.2.2 port-range 8000 ?
<8000-48198> maximum port number

Router(conf-voi-serv)#$ss range 1.1.1.1 2.2.2.2 port-range 8000 8002 ?

Router(conf-voi-serv)#$ss range 1.1.1.1 2.2.2.2 port-range 8000 8002
Router(cfg-media-addr-range)#?
Media Address Range configuration commands:
port-range media address port range
Router(cfg-media-addr-range)#port-range ?
<5500-65498> Start media address extended port

How this can be done ? The problem is coming as both have same names.

Perhaps you can achieve something like that with a choice instead:

container port-range {
      ...
      choice port-ranges {
        case miniport {...; tailf:cli-drop-node-name; leaf miniport {...}}
        case miniport2 {...; tailf:cli-drop-node-name; leaf miniport2 {...}}
      }
}