Skip to content

Commit 563c416

Browse files
Allow interface type value none (sonic-net#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
1 parent 095bf54 commit 563c416

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

scripts/portconfig

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ PORT_STATE_SUPPORTED_SPEEDS = "supported_speeds"
6363
VALID_INTERFACE_TYPE_SET = set(['CR','CR2','CR4','SR','SR2','SR4',
6464
'LR','LR4','KR','KR4','CAUI','GMII',
6565
'SFI','XLAUI','KR2','CAUI4','XAUI',
66-
'XFI','XGMII'])
66+
'XFI','XGMII', 'none'])
6767

6868
class portconfig(object):
6969
"""
@@ -166,7 +166,7 @@ class portconfig(object):
166166
def set_adv_interface_types(self, port, adv_interface_types):
167167
if self.verbose:
168168
print("Setting adv_interface_types %s on port %s" % (adv_interface_types, port))
169-
169+
170170
if adv_interface_types != 'all':
171171
config_interface_type_list = [x.strip() for x in adv_interface_types.split(',')]
172172
config_interface_types = set(config_interface_type_list)
@@ -179,7 +179,7 @@ class portconfig(object):
179179
print("Valid interface types:{}".format(','.join(VALID_INTERFACE_TYPE_SET)))
180180
exit(1)
181181
self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_ADV_INTERFACE_TYPES_CONFIG_FIELD_NAME: adv_interface_types})
182-
182+
183183
def get_supported_speeds(self, port):
184184
if not self.namespace:
185185
state_db = SonicV2Connector(host="127.0.0.1")

tests/config_an_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@pytest.fixture(scope='module')
1818
def ctx(scope='module'):
1919
db = Db()
20-
obj = {'config_db':db.cfgdb, 'namespace': ''}
20+
obj = {'config_db':db.cfgdb, 'namespace': ''}
2121
yield obj
2222

2323

@@ -56,6 +56,7 @@ def test_config_adv_speeds(self, ctx):
5656

5757
def test_config_type(self, ctx):
5858
self.basic_check("type", ["Ethernet0", "CR4"], ctx)
59+
self.basic_check("type", ["Ethernet0", "none"], ctx)
5960
self.basic_check("type", ["Invalid", "CR4"], ctx, operator.ne)
6061
self.basic_check("type", ["Ethernet0", ""], ctx, operator.ne)
6162
result = self.basic_check("type", ["Ethernet0", "Invalid"], ctx, operator.ne)

0 commit comments

Comments
 (0)