From 563c416463a1c55ff184adae0074f2e884ef9d8f Mon Sep 17 00:00:00 2001 From: Junchao-Mellanox <57339448+Junchao-Mellanox@users.noreply.github.com> Date: Sat, 6 Nov 2021 10:09:52 +0800 Subject: [PATCH] Allow interface type value none (#1902) This PR allow user to set none value to interface type. So there is a way to achieve the goal via CLI: config interface type XXX none config interface speed XXX 10000 config interface type XXX CR --- scripts/portconfig | 6 +++--- tests/config_an_test.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/portconfig b/scripts/portconfig index fde1d436d015..17b3255ef5a6 100755 --- a/scripts/portconfig +++ b/scripts/portconfig @@ -63,7 +63,7 @@ PORT_STATE_SUPPORTED_SPEEDS = "supported_speeds" VALID_INTERFACE_TYPE_SET = set(['CR','CR2','CR4','SR','SR2','SR4', 'LR','LR4','KR','KR4','CAUI','GMII', 'SFI','XLAUI','KR2','CAUI4','XAUI', - 'XFI','XGMII']) + 'XFI','XGMII', 'none']) class portconfig(object): """ @@ -166,7 +166,7 @@ class portconfig(object): def set_adv_interface_types(self, port, adv_interface_types): if self.verbose: print("Setting adv_interface_types %s on port %s" % (adv_interface_types, port)) - + if adv_interface_types != 'all': config_interface_type_list = [x.strip() for x in adv_interface_types.split(',')] config_interface_types = set(config_interface_type_list) @@ -179,7 +179,7 @@ class portconfig(object): print("Valid interface types:{}".format(','.join(VALID_INTERFACE_TYPE_SET))) exit(1) self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_ADV_INTERFACE_TYPES_CONFIG_FIELD_NAME: adv_interface_types}) - + def get_supported_speeds(self, port): if not self.namespace: state_db = SonicV2Connector(host="127.0.0.1") diff --git a/tests/config_an_test.py b/tests/config_an_test.py index 8b5c1178df8b..3f9864ec714b 100644 --- a/tests/config_an_test.py +++ b/tests/config_an_test.py @@ -17,7 +17,7 @@ @pytest.fixture(scope='module') def ctx(scope='module'): db = Db() - obj = {'config_db':db.cfgdb, 'namespace': ''} + obj = {'config_db':db.cfgdb, 'namespace': ''} yield obj @@ -56,6 +56,7 @@ def test_config_adv_speeds(self, ctx): def test_config_type(self, ctx): self.basic_check("type", ["Ethernet0", "CR4"], ctx) + self.basic_check("type", ["Ethernet0", "none"], ctx) self.basic_check("type", ["Invalid", "CR4"], ctx, operator.ne) self.basic_check("type", ["Ethernet0", ""], ctx, operator.ne) result = self.basic_check("type", ["Ethernet0", "Invalid"], ctx, operator.ne)