Skip to content

[yang-models] Add missing constraints in VLAN yang model #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
6 changes: 3 additions & 3 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1183,10 +1183,10 @@
"Vlan111|Ethernet0": {
"tagging_mode": "untagged"
},
"Vlan111|Ethernet1": {
"Vlan111|Ethernet10": {
"tagging_mode": "untagged"
},
"Vlan111|Ethernet2": {
"Vlan111|Ethernet20": {
"tagging_mode": "untagged"
},
"Vlan111|Ethernet3": {
Expand Down Expand Up @@ -2260,7 +2260,7 @@
"span": {
"direction": "RX",
"type": "SPAN",
"dst_port": "Ethernet2",
"dst_port": "Ethernet7",
"src_port": "Ethernet3,Ethernet4"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ def runVlanSpecialTest(self, test):
desc = self.SpecialTests[test]['desc']
self.logStartTest(desc)
jInput = json.loads(self.readJsonInput(test))
# check all Vlan from 1 to 4094
for i in range(4095):
# check all Vlan from 2 to 4094
for i in range(2,4095):
vlan = 'Vlan'+str(i)
jInput["sonic-vlan:sonic-vlan"]["sonic-vlan:VLAN"]["VLAN_LIST"]\
[0]["name"] = vlan
Expand Down
32 changes: 32 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests/vlan.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,37 @@
"VLAN_INTERFACE_INVALID_ENABLE_IPV6_LINK_LOCAL": {
"desc": "Enable the ipv6 link-local as true.",
"eStr": "Invalid value \"true\" in \"ipv6_use_link_local_only\" element."
},
"VLAN_MEMBERS_WITHOUT_CREATING_VLAN":{
"desc": "Vlan members without Creating Vlan",
"eStrKey": "LeafRef"
},
"VLAN_CREATE_DEFAULT_VLAN":{
"desc": "Try to create default Vlan (1)",
"eStr": "Vlan1 is default Vlan"
},
"VLAN_CREATE_VLAN_WITH_MISSMATCHING_NAME": {
"desc": "Create Vlan so that name doesn't match id",
"eStr": "The vlanid must correspond to the VLAN name"
},
"IP_PREFIX_WITHOUT_CREATNG_VLAN": {
"desc": "Create IP on not created Vlan",
"eStrKey": "LeafRef"
},
"MIRROR_SESSION_ON_VLAN_MEMBER_PORT": {
"desc": "Set mirror dst port to a Vlan member",
"eStr": "Port is used as a destination port in a mirror session"
},
"VLAN_ADD_PORT_CHANNEL_MEMBER": {
"desc": "Add port channel member to Vlan",
"eStr": "Port is a member of a port channel"
},
"VLAN_ADD_PORT_THAT_IS_UNTAGGED": {
"desc": "Add port that is already untagged",
"eStr": "Port is an untagged member in another VLAN"
},
"VLAN_ADD_PORT_THAT_IS_ROUTER_INTERFACE": {
"desc": "Add to Vlan port that is router interface",
"eStr": "Port is a router interface"
}
}
254 changes: 254 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/vlan.json
Original file line number Diff line number Diff line change
Expand Up @@ -719,5 +719,259 @@
]
}
}
},

"VLAN_MEMBERS_WITHOUT_CREATING_VLAN": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"name": "Ethernet0"
}
]
}
},
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN_MEMBER": {
"VLAN_MEMBER_LIST": [
{
"port": "Ethernet0",
"tagging_mode": "tagged",
"name": "Vlan100"
}
]
}
}
},
"VLAN_CREATE_DEFAULT_VLAN": {
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [
{
"name": "Vlan1"
}
]
}
}
},
"VLAN_CREATE_VLAN_WITH_MISSMATCHING_NAME": {
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [
{
"name": "Vlan10",
"vlanid":11
}
]
}
}
},
"IP_PREFIX_WITHOUT_CREATNG_VLAN": {
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [
{
"description": "server_vlan",
"name": "Vlan10"
}
]
},
"sonic-vlan:VLAN_INTERFACE": {
"VLAN_INTERFACE_IPPREFIX_LIST": [
{
"family": "IPv4",
"ip-prefix": "20.0.0.1/24",
"scope": "global",
"name": "Vlan100"
}
],
"VLAN_INTERFACE_LIST": [
{
"name": "Vlan100"
}
]
}
}
},
"MIRROR_SESSION_ON_VLAN_MEMBER_PORT": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"name": "Ethernet1",
"speed": 25000,
"lanes": "1"
},
{
"admin_status": "up",
"name": "Ethernet2",
"speed": 25000,
"lanes": "1"
}
]
}
},
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [
{
"name": "Vlan10"
}
]
},
"sonic-vlan:VLAN_MEMBER": {
"VLAN_MEMBER_LIST": [
{
"port": "Ethernet2",
"tagging_mode": "tagged",
"name": "Vlan10"
}
]
}
},
"sonic-mirror-session:sonic-mirror-session": {
"sonic-mirror-session:MIRROR_SESSION": {
"MIRROR_SESSION_LIST": [ {
"name":"mirror_session_dscp",
"type": "SPAN",
"src_port": "Ethernet1",
"dst_port": "Ethernet2"
}]
}
}
},
"VLAN_ADD_PORT_CHANNEL_MEMBER": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [{
"admin_status": "up",
"name": "Ethernet1",
"speed": 25000,
"lanes": "1"
}]
}
},
"sonic-portchannel:sonic-portchannel": {
"sonic-portchannel:PORTCHANNEL": {
"PORTCHANNEL_LIST": [
{
"admin_status": "up",
"min_links": "1",
"mtu": "9100",
"tpid": "0x8100",
"lacp_key": "auto",
"name": "PortChannel0001",
"fast_rate": "false",
"fallback" : "false",
"mode" : "routed"
}
]
},
"sonic-portchannel:PORTCHANNEL_MEMBER": {
"PORTCHANNEL_MEMBER_LIST": [
{
"name": "PortChannel0001",
"port": "Ethernet1"
}
]
}
},
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [
{
"name": "Vlan10"
}
]
},
"sonic-vlan:VLAN_MEMBER": {
"VLAN_MEMBER_LIST": [
{
"port": "Ethernet1",
"tagging_mode": "tagged",
"name": "Vlan10"
}
]
}
}
},
"VLAN_ADD_PORT_THAT_IS_UNTAGGED": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [{
"admin_status": "up",
"name": "Ethernet1",
"speed": 25000,
"lanes": "1"
}]
}
},
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [
{
"name": "Vlan10"
},
{
"name": "Vlan11"
}
]
},
"sonic-vlan:VLAN_MEMBER": {
"VLAN_MEMBER_LIST": [
{
"port": "Ethernet1",
"tagging_mode": "untagged",
"name": "Vlan10"
},
{
"port": "Ethernet1",
"tagging_mode": "tagged",
"name": "Vlan11"
}
]
}
}
},
"VLAN_ADD_PORT_THAT_IS_ROUTER_INTERFACE": {
"sonic-interface:sonic-interface": {
"sonic-interface:INTERFACE": {
"INTERFACE_LIST": [
{
"name": "Ethernet1"
}
]
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [{
"admin_status": "up",
"name": "Ethernet1",
"speed": 25000,
"lanes": "1"
}]
}
},
"sonic-vlan:sonic-vlan": {
"sonic-vlan:VLAN": {
"VLAN_LIST": [
{
"name": "Vlan10"
}
]
},
"sonic-vlan:VLAN_MEMBER": {
"VLAN_MEMBER_LIST": [
{
"port": "Ethernet1",
"tagging_mode": "untagged",
"name": "Vlan10"
}
]
}
}
}
}
Loading