Skip to content

Commit

Permalink
Allow interface type value none (#1902)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junchao-Mellanox authored and judyjoseph committed Nov 6, 2021
1 parent 53f066c commit 32e530f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions scripts/portconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion tests/config_an_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 32e530f

Please sign in to comment.