diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 20446953ee..4975a45b19 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -40,8 +40,12 @@ chassis_backend_role = 'ChassisBackendRouter' backend_device_types = ['BackEndToRRouter', 'BackEndLeafRouter'] console_device_types = ['MgmtTsToR'] dhcp_server_enabled_device_types = ['BmcMgmtToRRouter'] +mgmt_device_types = ['BmcMgmtToRRouter', 'MgmtToRRouter', 'MgmtTsToR'] leafrouter_device_types = ['LeafRouter'] +# Counters disabled on management devices +mgmt_disabled_counters = ["BUFFER_POOL_WATERMARK", "PFCWD", "PG_DROP", "PG_WATERMARK", "PORT_BUFFER_DROP", "QUEUE", "QUEUE_WATERMARK"] + VLAN_SUB_INTERFACE_SEPARATOR = '.' VLAN_SUB_INTERFACE_VLAN_ID = '10' @@ -2069,6 +2073,10 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw if current_device and current_device['type'] in dhcp_server_enabled_device_types: results['DEVICE_METADATA']['localhost']['dhcp_server'] = 'enabled' + # Disable unsupported counters on management devices + if current_device and current_device['type'] in mgmt_device_types: + results["FLEX_COUNTER_TABLE"] = {counter: {"FLEX_COUNTER_STATUS": "disable"} for counter in mgmt_disabled_counters} + # Enable bgp-suppress-fib by default for leafrouter if current_device and current_device['type'] in leafrouter_device_types: results['DEVICE_METADATA']['localhost']['suppress-fib-pending'] = 'enabled' diff --git a/src/sonic-config-engine/tests/simple-sample-graph-m0.xml b/src/sonic-config-engine/tests/simple-sample-graph-m0.xml new file mode 100644 index 0000000000..43193b7eb6 --- /dev/null +++ b/src/sonic-config-engine/tests/simple-sample-graph-m0.xml @@ -0,0 +1,914 @@ + + + + + + false + switch-m0 + 10.0.0.56 + ARISTA01M1 + 10.0.0.57 + 1 + 10 + 3 + + + switch-m0 + FC00::71 + ARISTA01M1 + FC00::72 + 1 + 10 + 3 + + + false + switch-m0 + 10.0.0.64 + ARISTA01MX + 10.0.0.65 + 1 + 10 + 3 + + + switch-m0 + FC00::81 + ARISTA01MX + FC00::82 + 1 + 10 + 3 + + + false + switch-m0 + 10.0.0.58 + ARISTA02M1 + 10.0.0.59 + 1 + 10 + 3 + + + switch-m0 + FC00::75 + ARISTA02M1 + FC00::76 + 1 + 10 + 3 + + + false + switch-m0 + 10.0.0.66 + ARISTA02MX + 10.0.0.67 + 1 + 10 + 3 + + + switch-m0 + FC00::85 + ARISTA02MX + FC00::86 + 1 + 10 + 3 + + + false + switch-m0 + 10.0.0.60 + ARISTA03M1 + 10.0.0.61 + 1 + 10 + 3 + + + switch-m0 + FC00::79 + ARISTA03M1 + FC00::7A + 1 + 10 + 3 + + + false + switch-m0 + 10.0.0.62 + ARISTA04M1 + 10.0.0.63 + 1 + 10 + 3 + + + switch-m0 + FC00::7D + ARISTA04M1 + FC00::7E + 1 + 10 + 3 + + + + + 65100 + switch-m0 + + +
10.0.0.57
+ + + +
+ +
10.0.0.65
+ + + +
+ +
10.0.0.59
+ + + +
+ +
10.0.0.67
+ + + +
+ +
10.0.0.61
+ + + +
+ +
10.0.0.63
+ + + +
+ + BGPPeer +
10.1.0.32
+ + + + BGPSLBPassive + 10.255.0.0/25 +
+ + BGPPeer +
10.1.0.32
+ + + + BGPVac + 192.168.0.0/21 +
+
+ +
+ + 65200 + ARISTA01M1 + + + + 64001 + ARISTA01MX + + + + 65200 + ARISTA02M1 + + + + 64002 + ARISTA02MX + + + + 65200 + ARISTA03M1 + + + + 65200 + ARISTA04M1 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + HostIP1 + Loopback0 + + FC00:1::32/128 + + FC00:1::32/128 + + + + + HostIP + eth0 + + 10.0.0.100/24 + + 10.0.0.100/24 + + + + + + + switch-m0 + + + PortChannel101 + etp49 + + + + PortChannel103 + etp50 + + + + PortChannel105 + etp51 + + + + PortChannel106 + etp52 + + + + + + ab1 + fortyGigE0/8 + 192.0.0.1;192.0.0.2 + 1000 + 1000 + 192.168.0.0/27 + + + ab4 + fortyGigE0/8 + 192.0.0.1;192.0.0.2 + 1001 + 1001 + 192.168.0.32/27 + + + kk1 + fortyGigE0/12 + 192.0.0.1;192.0.0.2 + 2020 + 2020 + Tagged + 192.168.0.0/28 + + + ab2 + fortyGigE0/12 + 192.0.0.1;192.0.0.2 + 2000 + 2000 + Tagged + 192.168.0.240/27 + + + ab3 + fortyGigE0/12 + 192.0.0.1;192.0.0.2 + 2001 + 2001 + 192.168.0.240/27 + + + + + + PortChannel1 + 10.0.0.56/31 + + + + PortChannel1 + FC00::71/126 + + + + PortChannel1001 + 10.0.0.57/31 + + + + PortChannel1001 + FC00::72/126 + + + + fortyGigE0/0 + 10.0.0.58/31 + + + + fortyGigE0/0 + FC00::75/126 + + + + ab1 + 192.168.0.1/27 + + + + + + PortChannel1 + DataAcl + DataPlane + + + SNMP + SNMP_ACL + SNMP + + + + + + + + + + DeviceInterfaceLink + ARISTA01M1 + Ethernet1 + switch-m0 + etp49 + 10000 + + + DeviceInterfaceLink + ARISTA01MX + Ethernet1 + switch-m0 + etp47 + 1000 + + + DeviceInterfaceLink + ARISTA02M1 + Ethernet1 + switch-m0 + etp50 + 10000 + + + DeviceInterfaceLink + ARISTA02MX + Ethernet1 + switch-m0 + etp48 + 1000 + + + DeviceInterfaceLink + ARISTA03M1 + Ethernet1 + switch-m0 + etp51 + 10000 + + + DeviceInterfaceLink + ARISTA04M1 + Ethernet1 + switch-m0 + etp52 + 10000 + + + DeviceInterfaceLink + switch-m0 + etp1 + Servers0 + eth0 + + + DeviceInterfaceLink + switch-m0 + etp2 + Servers1 + eth0 + + + + + switch-m0 + Nokia-M0-7215 + AAA00PrdStr00 + + + ARISTA04M1 + Arista + + + ARISTA02M1 + Arista + + + ARISTA02MX + Arista + + + ARISTA01MX + Arista + + + ARISTA01M1 + Arista + + + ARISTA03M1 + Arista + + + + + + + + DeviceInterface + + true + 1 + fortyGigE0/0 + + false + 0 + 0 + 10000 + + + DeviceInterface + + true + 1 + Ethernet1 + + false + 0 + 0 + 10000 + + + DeviceInterface + + true + 1 + Ethernet2 + + false + 0 + 0 + 10000 + + + DeviceInterface + + true + 1 + fortyGigE0/4 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + 1 + fortyGigE0/8 + + false + 0 + 0 + 40000 + Interface description + + + DeviceInterface + + true + 1 + fortyGigE0/12 + + false + 0 + 0 + 100000 + Interface description + + + DeviceInterface + + true + 1 + fortyGigE0/16 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/20 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/24 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/28 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/32 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/36 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/40 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/44 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/48 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/52 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/56 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/60 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/64 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/68 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/72 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/76 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/80 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/84 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/88 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/92 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/96 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/100 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/104 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/108 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/112 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/116 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/120 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/124 + + false + 0 + 0 + 100000 + + + true + 0 + Force10-S6000 + + + DeviceInterface + + 1 + Management1 + false + mgmt1 + 1000 + + + + + + + + switch-m0 + + + DeploymentId + + 1 + + + + + + + switch-m0 + Nokia-M0-7215 +
diff --git a/src/sonic-config-engine/tests/simple-sample-graph-case-acl-type-bmcdata.xml b/src/sonic-config-engine/tests/simple-sample-graph-mx.xml similarity index 83% rename from src/sonic-config-engine/tests/simple-sample-graph-case-acl-type-bmcdata.xml rename to src/sonic-config-engine/tests/simple-sample-graph-mx.xml index 6c29fb47e4..db34102010 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph-case-acl-type-bmcdata.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph-mx.xml @@ -2,138 +2,91 @@ - - switch-t0 - 10.1.0.32 - BGPMonitor - 10.20.30.40 - 30 - 10 - 3 + + false + switch-mx + 10.0.0.64 + ARISTA01M0 + 10.0.0.65 + 1 + 10 + 3 + + + switch-mx + FC00::81 + ARISTA01M0 + FC00::82 + 1 + 10 + 3 false - switch-t0 - 10.0.0.56 - ARISTA01T1 - 10.0.0.57 + switch-mx + 10.0.0.66 + ARISTA02M0 + 10.0.0.67 1 - 180 - 60 + 10 + 3 - switch-t0 - FC00::71 - ARISTA01T1 - FC00::72 + switch-mx + FC00::85 + ARISTA02M0 + FC00::86 1 - 180 - 60 - - - false - switch-t0 - 10.0.0.58 - ARISTA02T1 - 10.0.0.59 - 1 - 180 - 60 - - - switch-t0 - FC00::75 - ARISTA02T1 - FC00::76 - 1 - 180 - 60 - - - switch-t0 - FC00::75 - ARISTA02T1 - FC00::76 - 1 - 180 - 60 - - - false - switch-t0 - 10.2.0.20 - CHASSIS_PEER - 10.2.0.21 - 1 - 180 - 60 - voq + 10 + 3 - 1 - - BGPMonitor - - - BGPPeer -
10.1.0.32
- - - -
-
- -
- - 65100 - switch-t0 + 64001 + switch-mx -
10.0.0.57
+
10.0.0.65
-
10.0.0.59
+
10.0.0.67
- -
10.2.0.21
+ + BGPPeer +
10.1.0.32
+ BGPSLBPassive + 10.255.0.0/25 +
+ + BGPPeer +
10.1.0.32
+ + + + BGPVac + 192.168.0.0/21
- 64600 - ARISTA01T1 - - - - 64600 - ARISTA02T1 - - - - 64600 - ARISTA03T1 - - - - 64600 - ARISTA04T1 + 65100 + ARISTA01M0 65100 - CHASSIS_PEER + ARISTA02M0
@@ -173,13 +126,8 @@ - switch-t0 + switch-mx - - PortChannel1 - fortyGigE0/4 - - @@ -293,54 +241,47 @@ DeviceInterfaceLink + ARISTA01M0 + Ethernet1 + switch-mx + etp47 1000 - ARISTA01T1 - et1 - true - switch-t0 - fortyGigE0/8 - true - - DeviceMgmtLink + + DeviceInterfaceLink + ARISTA02M0 + Ethernet1 + switch-mx + etp48 1000 - switch-t0 - fortyGigE0/16 - true - ChassisMTS1 - mgmt0 - true - - DeviceMgmtLink - 1000 - switch-t0 - Management1 - switch-m0 - Management1 - true + + DeviceInterfaceLink + switch-mx + etp1 + Servers0 + eth0 + + + DeviceInterfaceLink + switch-mx + etp2 + Servers1 + eth0 - - switch-t0 - Force10-S6000 + + switch-mx + Arista-720DT-G48S4 AAA00PrdStr00 - - ARISTA01T1 + + ARISTA01M0 Arista - - ARISTA02T1 - Arista - - - ARISTA03T1 - Arista - - - ARISTA04T1 + + ARISTA02M0 Arista @@ -778,7 +719,7 @@ - switch-t0 + switch-mx DeploymentId @@ -790,6 +731,6 @@ - switch-t0 - Force10-S6000 + switch-mx + Arista-720DT-G48S4 diff --git a/src/sonic-config-engine/tests/test_minigraph_case.py b/src/sonic-config-engine/tests/test_minigraph_case.py index 74503e3e63..45ca5cdcce 100644 --- a/src/sonic-config-engine/tests/test_minigraph_case.py +++ b/src/sonic-config-engine/tests/test_minigraph_case.py @@ -521,8 +521,8 @@ class TestCfgGenCaseInsensitive(TestCase): 'type': 'BMCDATAV6', } # TC1: Minigraph contains acl table type BmcData - sample_graph = os.path.join(self.test_dir,'simple-sample-graph-case-acl-type-bmcdata.xml') - result = minigraph.parse_xml(sample_graph) + sample_mx_graph = os.path.join(self.test_dir,'simple-sample-graph-mx.xml') + result = minigraph.parse_xml(sample_mx_graph) self.assertIn('ACL_TABLE_TYPE', result) self.assertIn('BMCDATA', result['ACL_TABLE_TYPE']) self.assertIn('BMCDATAV6', result['ACL_TABLE_TYPE']) @@ -550,3 +550,22 @@ class TestCfgGenCaseInsensitive(TestCase): self.assertEqual(len(mgmt_intf.keys()), 1) self.assertTrue(('eth0', 'FC00:1::32/64') in mgmt_intf.keys()) self.assertTrue(ipaddress.ip_address(u'fc00:1::1') == mgmt_intf[('eth0', 'FC00:1::32/64')]['gwaddr']) + + def test_mgmt_device_disable_counters(self): + expected_mgmt_disabled_counters = ["BUFFER_POOL_WATERMARK", "PFCWD", "PG_DROP", "PG_WATERMARK", "PORT_BUFFER_DROP", "QUEUE", "QUEUE_WATERMARK"] + expected_mgmt_enabled_counters = ["ACL", "PORT", "RIF"] + # TC1: For M0 and Mx minigraph, counters are configured as expected + mgmt_graphs = ['simple-sample-graph-mx.xml', 'simple-sample-graph-m0.xml'] + for graph in mgmt_graphs: + graph_path = os.path.join(self.test_dir, graph) + result = minigraph.parse_xml(graph_path) + self.assertIn('FLEX_COUNTER_TABLE', result) + for counter in expected_mgmt_disabled_counters: + self.assertIn(counter, result['FLEX_COUNTER_TABLE']) + self.assertDictEqual(result['FLEX_COUNTER_TABLE'][counter], {'FLEX_COUNTER_STATUS': 'disable'}) + for counter in expected_mgmt_enabled_counters: + if counter in result['FLEX_COUNTER_TABLE']: + self.assertDictEqual(result['FLEX_COUNTER_TABLE'][counter], {'FLEX_COUNTER_STATUS': 'enable'}) + # TC2: For other minigraph, result should not contain FLEX_COUNTER_TABLE + result = minigraph.parse_xml(self.sample_graph) + self.assertNotIn('FLEX_COUNTER_TABLE', result)