From 49484a7eea3e45274ad80a8b23a62c1cdb11ad5a Mon Sep 17 00:00:00 2001 From: Dmytro Shevchuk Date: Wed, 17 Feb 2021 06:53:20 -0800 Subject: [PATCH] [minigraph] set admin_status to down if port not in minigraph --- src/sonic-config-engine/minigraph.py | 5 + .../tests/sample_output/platform_output.json | 106 ++-- .../tests/simple-sample-graph.xml | 494 ++++++++++++++++++ 3 files changed, 552 insertions(+), 53 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 70f7f839f91b..568f6cc4f4e1 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -1364,6 +1364,11 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw for port in ports.values(): port['pfc_asym'] = 'off' + # make admin status to down if port not parsed from minigraph + for port in ports.keys(): + if 'admin_status' in ports[port] and port not in port_speeds_default: + ports[port]['admin_status'] = 'down' + # set physical port default admin status up for port in phyport_intfs: if port[0] in ports: diff --git a/src/sonic-config-engine/tests/sample_output/platform_output.json b/src/sonic-config-engine/tests/sample_output/platform_output.json index bcc0f3468caa..8cf405e311cc 100644 --- a/src/sonic-config-engine/tests/sample_output/platform_output.json +++ b/src/sonic-config-engine/tests/sample_output/platform_output.json @@ -145,7 +145,7 @@ "index": "24", "lanes": "94,95", "description": "Eth24/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth24/3", "pfc_asym": "off", @@ -155,7 +155,7 @@ "index": "32", "lanes": "126,127", "description": "Eth32/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth32/2", "pfc_asym": "off", @@ -165,7 +165,7 @@ "index": "25", "lanes": "96,97", "description": "Eth25/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth25/1", "pfc_asym": "off", @@ -175,7 +175,7 @@ "index": "32", "lanes": "124,125", "description": "Eth32/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth32/1", "pfc_asym": "off", @@ -185,7 +185,7 @@ "index": "23", "lanes": "90", "description": "Eth23/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth23/3", "pfc_asym": "off", @@ -195,7 +195,7 @@ "index": "23", "lanes": "91", "description": "Eth23/4", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth23/4", "pfc_asym": "off", @@ -205,7 +205,7 @@ "index": "24", "lanes": "92", "description": "Eth24/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth24/1", "pfc_asym": "off", @@ -215,7 +215,7 @@ "index": "24", "lanes": "93", "description": "Eth24/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth24/2", "pfc_asym": "off", @@ -225,7 +225,7 @@ "index": "13", "lanes": "50", "description": "Eth13/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth13/3", "pfc_asym": "off", @@ -235,7 +235,7 @@ "index": "13", "lanes": "51", "description": "Eth13/4", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth13/4", "pfc_asym": "off", @@ -245,7 +245,7 @@ "index": "14", "lanes": "52", "description": "Eth14/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth14/1", "pfc_asym": "off", @@ -255,7 +255,7 @@ "index": "14", "lanes": "53", "description": "Eth14/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth14/2", "pfc_asym": "off", @@ -265,7 +265,7 @@ "index": "14", "lanes": "54,55", "description": "Eth14/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth14/3", "pfc_asym": "off", @@ -275,7 +275,7 @@ "index": "25", "lanes": "99", "description": "Eth25/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth25/3", "pfc_asym": "off", @@ -285,7 +285,7 @@ "index": "15", "lanes": "56,57", "description": "Eth15/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth15/1", "pfc_asym": "off", @@ -295,7 +295,7 @@ "index": "29", "lanes": "113", "description": "Eth29/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth29/2", "pfc_asym": "off", @@ -405,7 +405,7 @@ "index": "28", "lanes": "111", "description": "Eth28/4", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth28/4", "pfc_asym": "off", @@ -435,7 +435,7 @@ "index": "4", "lanes": "12", "description": "Eth4/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth4/1", "pfc_asym": "off", @@ -445,7 +445,7 @@ "index": "4", "lanes": "13", "description": "Eth4/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth4/2", "pfc_asym": "off", @@ -455,7 +455,7 @@ "index": "15", "lanes": "58", "description": "Eth15/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth15/2", "pfc_asym": "off", @@ -475,7 +475,7 @@ "index": "15", "lanes": "59", "description": "Eth15/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth15/3", "pfc_asym": "off", @@ -485,7 +485,7 @@ "index": "10", "lanes": "38", "description": "Eth10/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth10/2", "pfc_asym": "off", @@ -495,7 +495,7 @@ "index": "20", "lanes": "78", "description": "Eth20/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth20/2", "pfc_asym": "off", @@ -505,7 +505,7 @@ "index": "18", "lanes": "68", "description": "Eth18/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth18/1", "pfc_asym": "off", @@ -515,7 +515,7 @@ "index": "4", "lanes": "14,15", "description": "Eth4/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth4/3", "pfc_asym": "off", @@ -525,7 +525,7 @@ "index": "23", "lanes": "89", "description": "Eth23/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth23/2", "pfc_asym": "off", @@ -535,7 +535,7 @@ "index": "23", "lanes": "88", "description": "Eth23/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth23/1", "pfc_asym": "off", @@ -545,7 +545,7 @@ "index": "30", "lanes": "118", "description": "Eth30/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth30/2", "pfc_asym": "off", @@ -555,7 +555,7 @@ "index": "30", "lanes": "119", "description": "Eth30/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth30/3", "pfc_asym": "off", @@ -565,7 +565,7 @@ "index": "30", "lanes": "116,117", "description": "Eth30/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth30/1", "pfc_asym": "off", @@ -575,7 +575,7 @@ "index": "29", "lanes": "114,115", "description": "Eth29/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth29/3", "pfc_asym": "off", @@ -586,7 +586,7 @@ "lanes": "80,81,82,83", "fec": "rs", "description": "Eth21", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth21", "pfc_asym": "off", @@ -606,7 +606,7 @@ "index": "22", "lanes": "86,87", "description": "Eth22/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth22/2", "pfc_asym": "off", @@ -616,7 +616,7 @@ "index": "28", "lanes": "110", "description": "Eth28/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth28/3", "pfc_asym": "off", @@ -626,7 +626,7 @@ "index": "22", "lanes": "84,85", "description": "Eth22/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth22/1", "pfc_asym": "off", @@ -636,7 +636,7 @@ "index": "8", "lanes": "31", "description": "Eth8/4", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth8/4", "pfc_asym": "off", @@ -646,7 +646,7 @@ "index": "13", "lanes": "49", "description": "Eth13/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth13/2", "pfc_asym": "off", @@ -656,7 +656,7 @@ "index": "13", "lanes": "48", "description": "Eth13/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth13/1", "pfc_asym": "off", @@ -666,7 +666,7 @@ "index": "12", "lanes": "46,47", "description": "Eth12/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth12/2", "pfc_asym": "off", @@ -676,7 +676,7 @@ "index": "8", "lanes": "30", "description": "Eth8/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth8/3", "pfc_asym": "off", @@ -686,7 +686,7 @@ "index": "8", "lanes": "29", "description": "Eth8/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth8/2", "pfc_asym": "off", @@ -697,7 +697,7 @@ "lanes": "40,41,42,43", "fec": "rs", "description": "Eth11", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth11", "pfc_asym": "off", @@ -708,7 +708,7 @@ "lanes": "120,121,122,123", "fec": "rs", "description": "Eth31", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth31", "pfc_asym": "off", @@ -718,7 +718,7 @@ "index": "8", "lanes": "28", "description": "Eth8/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth8/1", "pfc_asym": "off", @@ -728,7 +728,7 @@ "index": "17", "lanes": "66,67", "description": "Eth17/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth17/2", "pfc_asym": "off", @@ -739,7 +739,7 @@ "lanes": "60,61,62,63", "fec": "rs", "description": "Eth16", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth16", "pfc_asym": "off", @@ -749,7 +749,7 @@ "index": "17", "lanes": "64,65", "description": "Eth17/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth17/1", "pfc_asym": "off", @@ -759,7 +759,7 @@ "index": "12", "lanes": "44,45", "description": "Eth12/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth12/1", "pfc_asym": "off", @@ -770,7 +770,7 @@ "lanes": "20,21,22,23", "fec": "rs", "description": "Eth6", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth6", "pfc_asym": "off", @@ -780,7 +780,7 @@ "index": "20", "lanes": "79", "description": "Eth20/3", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth20/3", "pfc_asym": "off", @@ -790,7 +790,7 @@ "index": "18", "lanes": "69", "description": "Eth18/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth18/2", "pfc_asym": "off", @@ -800,7 +800,7 @@ "index": "7", "lanes": "24,25", "description": "Eth7/1", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth7/1", "pfc_asym": "off", @@ -810,7 +810,7 @@ "index": "7", "lanes": "26,27", "description": "Eth7/2", - "admin_status": "up", + "admin_status": "down", "mtu": "9100", "alias": "Eth7/2", "pfc_asym": "off", diff --git a/src/sonic-config-engine/tests/simple-sample-graph.xml b/src/sonic-config-engine/tests/simple-sample-graph.xml index 703a005ea5bc..a2b350ccd6b2 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph.xml @@ -388,6 +388,500 @@ 100000 Interface description + + DeviceInterface + + true + true + 1 + Eth3/1 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth3/2 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth3/3 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth3/4 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth10/1 + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + Eth25/2 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth1 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + Eth2/1 + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + Eth2/2 + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + Eth28/1 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth28/2 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth5/1 + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + Eth5/2 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth5/3 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth26 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + true + 1 + Eth9/3 + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + Eth27/1 + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + Eth27/2 + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + Eth29/1 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth20/1 + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + Eth19/3 + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + Eth10/3 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth19/1 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth19/2 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth18/3 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth18/4 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth19/1 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth19/2 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth18/3 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth18/4 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth9/1 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + Eth9/2 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + 5/1 + + false + 0 + 0 + 50000 + + + DeviceInterface + + true + true + 1 + 28/4 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + 3/3 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + 3/4 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + 4/1 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + true + 1 + 4/2 + + false + 0 + 0 + 25000 + true 0