Skip to content

Commit

Permalink
Yang model modifications (sonic-net#12)
Browse files Browse the repository at this point in the history
* [sonic-head.yang]: Minor modification for enumeration of ip-type in ACL yang models.

[sonic-vlan.yang]: modify vlan table key from vlanid(int) to vlan_name(string).

[yangModelTesting.py] Fix Test Code and JSON input.

* [sonic-acl.yang]: Present Enumeration similar to config DB.

* [sonic-head.yang]: Minor update in enumeration
  • Loading branch information
Praveen Chaudhary authored and zhenggen-xu committed Dec 11, 2019
1 parent 452c179 commit d3fb685
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def run(self):
for test in self.tests:
test = test.strip()
if test in self.ExceptionTests:
self.runExceptionTest(test);
ret = ret + self.runExceptionTest(test);
except Exception as e:
printExceptionDetails()
raise e
Expand Down
22 changes: 11 additions & 11 deletions src/sonic-yang-mgmt/tests/yang-model-tests/yangTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN_INTERFACE": {
"VLAN_INTERFACE_LIST": [{
"vlanid": 100,
"vlan_name": "Vlan100",
"ip-prefix": "2a04:5555:66:7777::1/64",
"scope": "global",
"family": "IPv4"
}]
},
"sonic-vlan:VLAN": {
"VLAN_LIST": [{
"vlanid": 100,
"vlan_name": "Vlan100",
"description": "server_vlan"
}]
}
Expand All @@ -22,7 +22,7 @@
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [{
"vlanid": 100,
"vlan_name": "Vlan100",
"description": "server_vlan",
"dhcp_servers": [
"10.186.72.566"
Expand All @@ -34,18 +34,18 @@
}
},

"VLAN_HAS_NON_EXIST_PORT": {
"VLAN_WITH_NON_EXIST_PORT": {
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN_MEMBER": {
"VLAN_MEMBER_LIST": [{
"vlanid": 100,
"vlan_name": "Vlan100",
"port": "Ethernet156",
"tagging_mode": "tagged"
}]
},
"sonic-vlan:VLAN": {
"VLAN_LIST": [{
"vlanid": 100,
"vlan_name": "Vlan100",
"description": "server_vlan"
}]
}
Expand Down Expand Up @@ -77,18 +77,18 @@
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN_MEMBER": {
"VLAN_MEMBER_LIST": [{
"vlanid": 200,
"vlan_name": "Vlan200",
"port": "Ethernet0",
"tagging_mode": "tagged"
}]
},
"sonic-vlan:VLAN": {
"VLAN_LIST": [{
"vlanid": 100,
"vlan_name": "Vlan100",
"description": "server_vlan"
},
{
"vlanid": 300,
"vlan_name": "Vlan300",
"description": "ipmi_vlan"
}
]
Expand All @@ -112,14 +112,14 @@
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN_MEMBER": {
"VLAN_MEMBER_LIST": [{
"vlanid": 100,
"vlan_name": 100,
"port": "Ethernet0",
"tagging_mode": "non-tagged"
}]
},
"sonic-vlan:VLAN": {
"VLAN_LIST": [{
"vlanid": 100,
"vlan_name": "Vlan100",
"description": "server_vlan"
}]
}
Expand Down
8 changes: 4 additions & 4 deletions src/sonic-yang-mgmt/yang-models/sonic-acl.yang
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module sonic-acl {
choice ip_prefix {

case ip4_prefix {
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV4' or .='IPV4ANY' or .='ARP'])";
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV4' or .='IPv4ANY' or .='ARP'])";
leaf SRC_IP {
type inet:ipv4-prefix;
}
Expand All @@ -88,7 +88,7 @@ module sonic-acl {
}

case ip6_prefix {
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPV6ANY'])";
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPv6ANY'])";
leaf SRC_IPV6 {
type inet:ipv6-prefix;
}
Expand Down Expand Up @@ -170,7 +170,7 @@ module sonic-acl {
choice icmp {

case icmp4 {
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV4' or .='IPV4ANY' or .='ARP'])";
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV4' or .='IPv4ANY' or .='ARP'])";
leaf ICMP_TYPE {
type uint8 {
range 1..44;
Expand All @@ -185,7 +185,7 @@ module sonic-acl {
}

case icmp6 {
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPV6ANY'])";
when "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPv6ANY'])";
leaf ICMPV6_TYPE {
type uint8 {
range 1..44;
Expand Down
8 changes: 4 additions & 4 deletions src/sonic-yang-mgmt/yang-models/sonic-head.yang
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ module sonic-head {
enum NON_IP;
enum IPV4;
enum IPV6;
enum IPV4ANY;
enum NON_IPv4;
enum IPV6ANY;
enum IPv4ANY;
enum NON_IP4;
enum IPv6ANY;
enum NON_IPv6;
enum ARP;
}
Expand All @@ -69,4 +69,4 @@ module sonic-head {
enum priority_tagged;
}
}
}
}
1 change: 1 addition & 0 deletions src/sonic-yang-mgmt/yang-models/sonic-interface.yang
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module sonic-interface {
}

leaf ip-prefix {
/* TODO: this should be custom, not inet:ip-prefix.*/
type inet:ip-prefix;
}

Expand Down
8 changes: 7 additions & 1 deletion src/sonic-yang-mgmt/yang-models/sonic-port.yang
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module sonic-port{

leaf description {
type string {
length 1..255;
length 0..255;
}
}

Expand All @@ -75,6 +75,12 @@ module sonic-port{
mandatory true;
type head:admin_status;
}

leaf fec {
type string {
pattern "rc|fc|None";
}
}
} /* end of list PORT_LIST */

} /* end of container PORT */
Expand Down
22 changes: 14 additions & 8 deletions src/sonic-yang-mgmt/yang-models/sonic-vlan.yang
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ module sonic-vlan {

list VLAN_INTERFACE_LIST {

key "vlanid ip-prefix";
key "vlan_name ip-prefix";

leaf vlanid {
leaf vlan_name {
type leafref {
path ../../../VLAN/VLAN_LIST/vlanid;
path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:vlan_name";
}
}

Expand Down Expand Up @@ -81,7 +81,13 @@ module sonic-vlan {

list VLAN_LIST {

key "vlanid";
key "vlan_name";

leaf vlan_name {
type string {
pattern 'Vlan([0-9]{1,3}|[0-3][0-9]{4}|[4][0][0-8][0-9]|[4][0][9][0-4])';
}
}

leaf vlanid {
type uint16 {
Expand Down Expand Up @@ -114,7 +120,7 @@ module sonic-vlan {
/* leaf-list members are unique by default */

type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:port_name;
path "/port:sonic-port/port:PORT/port:PORT_LIST/port:port_name";
}
}
}
Expand All @@ -128,11 +134,11 @@ module sonic-vlan {

list VLAN_MEMBER_LIST {

key "vlanid port";
key "vlan_name port";

leaf vlanid {
leaf vlan_name {
type leafref {
path ../../../VLAN/VLAN_LIST/vlanid;
path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:vlan_name";
}
}

Expand Down

0 comments on commit d3fb685

Please sign in to comment.