Skip to content
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

[chassis] add condition is yang model to make lanes not mandatory for chassis #19968

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@
</SubInterface>
</SubInterfaces>
<IPInterfaces>
<IPInterface>
<Name i:nil="true"/>
<AttachTo>Eth1/1/47</AttachTo>
<Prefix>27.1.1.1/24</Prefix>
</IPInterface>
</IPInterfaces>
<DownstreamSummaries/>
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
Expand Down Expand Up @@ -206,11 +201,6 @@
<PortChannelInterfaces>
</PortChannelInterfaces>
<IPInterfaces>
<IPInterface>
<Name i:nil="true"/>
<AttachTo>Eth1/1/47</AttachTo>
<Prefix>27.1.1.1/24</Prefix>
</IPInterface>
</IPInterfaces>
<VlanInterfaces>
</VlanInterfaces>
Expand Down Expand Up @@ -261,13 +251,6 @@
</LinkMetadataDeclaration>
<PngDec>
<DeviceInterfaceLinks>
<DeviceLinkBase>
<ElementType>DeviceInterfaceLink</ElementType>
<EndDevice>IXIA-EBGP</EndDevice>
<EndPort>Ethernet1</EndPort>
<StartDevice>str2-8808-lc2-1</StartDevice>
<StartPort>Eth1/1/47</StartPort>
</DeviceLinkBase>
<DeviceLinkBase i:type="DeviceInterfaceLink">
<ElementType>DeviceInterfaceLink</ElementType>
<Bandwidth>100000</Bandwidth>
Expand Down Expand Up @@ -402,20 +385,6 @@
<DeviceInfo>
<AutoNegotiation>true</AutoNegotiation>
<EthernetInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
<a:EthernetInterface>
<ElementType>DeviceInterface</ElementType>
<AlternateSpeeds i:nil="true"/>
<EnableAutoNegotiation>true</EnableAutoNegotiation>
<EnableFlowControl>true</EnableFlowControl>
<Index>1</Index>
<InterfaceName>Ethernet1/1/47</InterfaceName>
<InterfaceType i:nil="true"/>
<MultiPortsInterface>false</MultiPortsInterface>
<PortName>47</PortName>
<Priority>0</Priority>
<Speed>100000</Speed>
<SonicName>Ethernet47</SonicName>
</a:EthernetInterface>
</EthernetInterfaces>
<FlowControl>true</FlowControl>
<Height>0</Height>
Expand Down
26 changes: 15 additions & 11 deletions src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,15 +1020,26 @@ def test_minigraph_dhcp(self):
"'Vlan2000': {'dhcpv6_servers': ['fc02:2000::3', 'fc02:2000::4']}}"
)
)

def test_minigraph_packet_chassis_acl(self):
argument = ['-m', self.packet_chassis_graph, '-p', self.packet_chassis_port_ini, '-v', "ACL_TABLE"]

def test_minigraph_packet_chassis_acl_local_host(self):
# CFGGEN_UNIT_TESTING is set to '2' in the set_up function
# this causes the port_table to have ports from the previous test
# causing yang validation to fail

os.environ["CFGGEN_UNIT_TESTING"] = ""
argument = ['-m', self.packet_chassis_graph, '-v', "ACL_TABLE"]
output = self.run_script(argument)
print(output)
self.assertEqual(
utils.to_dict(output.strip()),
utils.to_dict("{'SNMP_ACL': {'policy_desc': 'SNMP_ACL', 'type': 'CTRLPLANE', 'stage': 'ingress', 'services': ['SNMP']}, 'SSH_ONLY': {'policy_desc': 'SSH_ONLY', 'type': 'CTRLPLANE', 'stage': 'ingress', 'services': ['SSH']}}")
)

# set it back to the original value
os.environ["CFGGEN_UNIT_TESTING"] = "2"

def test_minigraph_packet_chassis_acl_namespace(self):

argument = ['-m', self.packet_chassis_graph, '-p', self.packet_chassis_port_ini, '-n', "asic1", '-v', "ACL_TABLE"]
output = self.run_script(argument)
self.assertEqual(
Expand All @@ -1045,20 +1056,13 @@ def test_minigraph_bgp_packet_chassis_peer(self):
)

def test_minigraph_bgp_packet_chassis_static_route(self):
argument = ['-m', self.packet_chassis_graph, '-p', self.packet_chassis_port_ini, '-v', "STATIC_ROUTE"]
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),
utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false', 'bfd':'true'}}")
)

argument = ['-m', self.packet_chassis_graph, '-p', self.packet_chassis_port_ini, '-n', "asic1", '-v', "STATIC_ROUTE"]
output = self.run_script(argument)
self.assertEqual(
utils.to_dict(output.strip()),
utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2', 'ifname': 'PortChannel40,PortChannel50', 'advertise':'false', 'bfd':'true'}}")
)

os.environ["CFGGEN_UNIT_TESTING_TOPOLOGY"] = ""
def test_minigraph_bgp_packet_chassis_vlan_subintf(self):
argument = ['-m', self.packet_chassis_graph, '-p', self.packet_chassis_port_ini, '-n', "asic1", '-v', "VLAN_SUB_INTERFACE"]
output = self.run_script(argument)
Expand Down
26 changes: 23 additions & 3 deletions src/sonic-yang-models/tests/yang_model_tests/tests/port.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,27 @@
"eStrKey" : "InvalidValue",
"eStr": ["dom_polling"]
},
"PORT_AUTO_FEC_TEST": {
"desc": "PORT_AUTO_FEC_TEST validate auto mode in fec."
}
"PORT_AUTO_FEC_TEST": {
"desc": "PORT_AUTO_FEC_TEST validate auto mode in fec."
},
"PORT_NO_LANES_NEGATIVE_TEST": {
"desc": "PORT_NO_LANES_NEGATIVE_TEST no lanes.",
"eStrKey": "Mandatory",
"eStr": ["Missing"]
},
"PORT_VOQ_CHASSIS_WITH_NO_LANES": {
"desc": "PORT_VOQ_CHASSIS_WITH_NO_LANES no failure."
},
"PORT_PACKET_CHASSIS_WITH_NO_LANES": {
"desc": "PORT_PACKET_CHASSIS_WITH_NO_LANES no failure."
},
"PORT_FABRIC_WITH_NO_LANES": {
"desc": "PORT_FABRIC_WITH_NO_LANES no failure."
},
"PORT_VOQ_CHASSIS_WITH_LANES": {
"desc": "PORT_VOQ_CHASSIS_WITH_LANES no failure."
}



}
102 changes: 102 additions & 0 deletions src/sonic-yang-models/tests/yang_model_tests/tests_config/port.json
Original file line number Diff line number Diff line change
Expand Up @@ -804,5 +804,107 @@
]
}
}
},
"PORT_NO_LANES_NEGATIVE_TEST": {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet0",
"alias": "etp1a",
"speed": 100000,
"role": "Ext"
}
]
}
}
},
"PORT_VOQ_CHASSIS_WITH_NO_LANES": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
"switch_type": "voq"
}
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet0",
"alias": "etp1a",
"speed": 100000,
"role": "Ext"
}
]
}
}
},
"PORT_VOQ_CHASSIS_WITH_LANES": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
"switch_type": "voq",
"asic_name": "asic0"
}
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet0",
"alias": "etp1a",
"speed": 100000,
"role": "Ext",
"lanes": "60, 61"
}
]
}
}
},
"PORT_PACKET_CHASSIS_WITH_NO_LANES": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
"switch_type": "chassis-packet"
}
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet0",
"alias": "etp1a",
"speed": 100000,
"role": "Ext"

}
]
}
}
},
"PORT_FABRIC_WITH_NO_LANES": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
"switch_type": "fabric"
}
}
},
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"name": "Ethernet0",
"alias": "etp1a",
"speed": 100000,
"role": "Int"

}
]
}
}
}
}
10 changes: 10 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-port.yang
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module sonic-port{
prefix ext;
}

import sonic-device_metadata {
prefix sdm;
}

import sonic-macsec {
prefix macsec;
}
Expand Down Expand Up @@ -67,6 +71,12 @@ module sonic-port{
}

leaf lanes {
when "not(not(/sdm:sonic-device_metadata/sdm:DEVICE_METADATA/sdm:localhost/sdm:asic_name) and
((/sdm:sonic-device_metadata/sdm:DEVICE_METADATA/sdm:localhost/sdm:switch_type='voq') or
(/sdm:sonic-device_metadata/sdm:DEVICE_METADATA/sdm:localhost/sdm:switch_type='chassis-packet') or
(/sdm:sonic-device_metadata/sdm:DEVICE_METADATA/sdm:localhost/sdm:switch_type='fabric')))";

description "Number of hardware lanes for the port. This is mandatory for all devices except for chassis devices";
mandatory true;
type string {
length 1..128;
Expand Down
Loading