module test-interface { namespace "http://github.com/Azure/interface"; prefix intf; import ietf-yang-types { prefix yang; } import ietf-inet-types { prefix inet; } import test-head { prefix head; revision-date 2019-07-01; } import test-port { prefix port; revision-date 2019-07-01; } revision 2019-07-01 { description "First Revision"; } container interface { container INTERFACE { description "INTERFACE part of config_db.json"; list INTERFACE_LIST { key "interface ip-prefix"; leaf interface { type leafref { path /port:port/port:PORT/port:PORT_LIST/port:port_name; } } leaf ip-prefix { type inet:ip-prefix; } leaf scope { type enumeration { enum global; enum local; } } leaf family { /* family leaf needed for backward compatibility Both ip4 and ip6 address are string in IETF RFC 6021, so must statement can check based on : or ., family should be IPv4 or IPv6 according. */ must "(contains(../ip-prefix, ':') and current()='IPv6') or (contains(../ip-prefix, '.') and current()='IPv4')"; type head:ip-family; } } /* end of INTERFACE_LIST */ } /* end of INTERFACE container */ } }