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
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
</VlanInterface>
<VlanInterface>
<Name>ab2</Name>
<AttachTo>fortyGigE0/4</AttachTo>
<AttachTo>PortChannel01</AttachTo>
<DhcpRelays>192.0.0.1</DhcpRelays>
<Dhcpv6Relays>fc02:2000::3;fc02:2000::4</Dhcpv6Relays>
<VlanID>2000</VlanID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
</VlanInterface>
<VlanInterface>
<Name>ab2</Name>
<AttachTo>fortyGigE0/4</AttachTo>
<AttachTo>PortChannel01</AttachTo>
<DhcpRelays>192.0.0.1</DhcpRelays>
<Dhcpv6Relays>fc02:2000::3;fc02:2000::4</Dhcpv6Relays>
<VlanID>2000</VlanID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
</VlanInterface>
<VlanInterface>
<Name>ab2</Name>
<AttachTo>fortyGigE0/4</AttachTo>
<AttachTo>PortChannel01</AttachTo>
<DhcpRelays>192.0.0.1</DhcpRelays>
<Dhcpv6Relays>fc02:2000::3;fc02:2000::4</Dhcpv6Relays>
<VlanID>2000</VlanID>
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/simple-sample-graph-case.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
</VlanInterface>
<VlanInterface>
<Name>ab2</Name>
<AttachTo>fortyGigE0/4</AttachTo>
<AttachTo>PortChannel01</AttachTo>
<DhcpRelays>192.0.0.1</DhcpRelays>
<Dhcpv6Relays>fc02:2000::3;fc02:2000::4</Dhcpv6Relays>
<VlanID>2000</VlanID>
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/t0-sample-graph-two-mgmt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
</VlanInterface>
<VlanInterface>
<Name>Vlan2000</Name>
<AttachTo>fortyGigE0/112;fortyGigE0/116;fortyGigE0/120</AttachTo>
<AttachTo>PortChannel01;PortChannel02;PortChannel03</AttachTo>
<NoDhcpRelay>False</NoDhcpRelay>
<StaticDHCPRelay>0.0.0.0/0</StaticDHCPRelay>
<FhrpProtoType i:nil="true"/>
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/t0-sample-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
</VlanInterface>
<VlanInterface>
<Name>Vlan2000</Name>
<AttachTo>fortyGigE0/112;fortyGigE0/116;fortyGigE0/120</AttachTo>
<AttachTo>PortChannel01;PortChannel02;PortChannel03</AttachTo>
<NoDhcpRelay>False</NoDhcpRelay>
<StaticDHCPRelay>0.0.0.0/0</StaticDHCPRelay>
<FhrpProtoType i:nil="true"/>
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/test_minigraph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_minigraph_vlan_members(self):
output = self.run_script(argument)
expected = {
'Vlan1000|Ethernet8': {'tagging_mode': 'untagged'},
'Vlan2000|Ethernet4': {'tagging_mode': 'untagged'}
'Vlan2000|PortChannel01': {'tagging_mode': 'untagged'}
}
self.assertEqual(
utils.to_dict(output.strip()),
Expand Down
7 changes: 2 additions & 5 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1185,10 +1185,7 @@
"Vlan111|Ethernet0": {
"tagging_mode": "untagged"
},
"Vlan111|Ethernet1": {
"tagging_mode": "untagged"
},
"Vlan111|Ethernet2": {
"Vlan111|PortChannel0004": {
"tagging_mode": "untagged"
},
"Vlan111|Ethernet3": {
Expand Down Expand Up @@ -2262,7 +2259,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,9 @@ 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(1,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
28 changes: 28 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,33 @@
"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_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 can be untagged in at most one VLAN"
},
"VLAN_ADD_PORT_THAT_IS_ROUTER_INTERFACE": {
"desc": "Add to Vlan port that is router interface",
"eStr": "Port is a router interface"
}
}
243 changes: 243 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,248 @@
]
}
}
},

"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_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": "untagged",
"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