Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static Lag support changes in sonic-utilities #2436

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2051,8 +2051,11 @@ def portchannel(db, ctx, namespace):
@click.option('--fast-rate', default='false',
type=click.Choice(['true', 'false'],
case_sensitive=False))
@click.option('--static', default='false',
type=click.Choice(['true', 'false'],
case_sensitive=False))
@click.pass_context
def add_portchannel(ctx, portchannel_name, min_links, fallback, fast_rate):
def add_portchannel(ctx, portchannel_name, min_links, fallback, fast_rate, static):
"""Add port channel"""

fvs = {
Expand All @@ -2066,6 +2069,8 @@ def add_portchannel(ctx, portchannel_name, min_links, fallback, fast_rate):
fvs['min_links'] = str(min_links)
if fallback != 'false':
fvs['fallback'] = 'true'
if static != 'false':
fvs['static'] = 'true'

db = ValidatedConfigDBConnector(ctx.obj['db'])
if ADHOC_VALIDATION:
Expand Down
12 changes: 9 additions & 3 deletions show/interfaces/portchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ def get_teamshow_result(self):
self.summary[team_id]['ports'] = ''
continue
state = self.teamsraw[team_id]
info['protocol'] = "LACP"
info['protocol'] += "(A)" if state['runner.active'] == "true" else '(I)'
if state['setup.runner_name'] == "lacp":
info['protocol'] = "LACP"
info['protocol'] += "(A)" if state['runner.active'] == "true" else '(I)'
else:
info['protocol'] = "NONE"
info['protocol'] += "(A)"

portchannel_status = self.get_portchannel_status(team)
if portchannel_status is None:
Expand All @@ -129,7 +133,9 @@ def get_teamshow_result(self):
for port in ports:
status = self.get_portchannel_member_status(team, port)
pstate = self.db.get_all(self.db.STATE_DB, PORT_CHANNEL_MEMBER_STATE_TABLE_PREFIX+team+'|'+port)
selected = True if pstate['runner.aggregator.selected'] == "true" else False
selected = True if pstate['link.up'] == "true" else False
if state['setup.runner_name'] == "lacp":
selected = True if pstate['runner.aggregator.selected'] == "true" else False
if clicommon.get_interface_naming_mode() == "alias":
alias = clicommon.InterfaceAliasConverter().name_to_alias(port)
info["ports"] += alias + "("
Expand Down
2 changes: 2 additions & 0 deletions tests/dump_input/portchannel/state_db.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"LAG_TABLE|PortChannel001":{
"setup.runner_name": "lacp",
"runner.active": "true",
"runner.fallback": "false",
"runner.fast_rate": "false",
Expand All @@ -10,6 +11,7 @@
"team_device.ifinfo.ifindex": "137"
},
"LAG_TABLE|PortChannel002":{
"setup.runner_name": "lacp",
"runner.active": "true",
"runner.fallback": "false",
"runner.fast_rate": "false",
Expand Down
2 changes: 2 additions & 0 deletions tests/interfaces_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
0002 PortChannel0002 LACP(A)(Up) Ethernet116(S)
0003 PortChannel0003 LACP(A)(Up) Ethernet120(S)
0004 PortChannel0004 LACP(A)(Up) N/A
0100 PortChannel0100 NONE(A)(Up) N/A
1001 PortChannel1001 N/A
"""

Expand All @@ -140,6 +141,7 @@
0002 PortChannel0002 LACP(A)(Up) etp30(S)
0003 PortChannel0003 LACP(A)(Up) etp31(S)
0004 PortChannel0004 LACP(A)(Up) N/A
0100 PortChannel0100 NONE(A)(Up) N/A
1001 PortChannel1001 N/A
"""

Expand Down
2 changes: 2 additions & 0 deletions tests/ipv6_link_local_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
+------------------+----------+
| PortChannel0004 | Disabled |
+------------------+----------+
| PortChannel0100 | Disabled |
+------------------+----------+
| Vlan1000 | Disabled |
+------------------+----------+
| Vlan2000 | Disabled |
Expand Down
6 changes: 6 additions & 0 deletions tests/mock_tables/appl_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@
"tpid": "0x88A8",
"oper_status": "up"
},
"LAG_TABLE:PortChannel0100": {
"admin_status": "up",
"mtu": "9100",
"tpid": "0x88A8",
"oper_status": "up"
},
"SWITCH_TABLE:switch": {
"vxlan_port": "13550"
},
Expand Down
12 changes: 12 additions & 0 deletions tests/mock_tables/asic0/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"ifinfo.ifindex": "100"
},
"LAG_TABLE|PortChannel0001": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "71",
Expand All @@ -142,6 +143,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel0002": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "72",
Expand All @@ -152,6 +154,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel0003": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "73",
Expand All @@ -162,6 +165,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel0004": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "74",
Expand All @@ -171,6 +175,14 @@
"setup.kernel_team_mode_name": "loadbalance",
"runner.active": "true"
},
"LAG_TABLE|PortChannel0100": {
"setup.runner_name": "loadbalance",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "74",
"setup.pid": "56",
"state": "ok",
"setup.kernel_team_mode_name": "loadbalance"
},
"FAN_INFO|fan1": {
"drawer_name": "drawer1",
"presence": "True",
Expand Down
12 changes: 12 additions & 0 deletions tests/mock_tables/asic1/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"ifinfo.ifindex": "100"
},
"LAG_TABLE|PortChannel0001": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "71",
Expand All @@ -142,6 +143,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel0002": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "72",
Expand All @@ -152,6 +154,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel0003": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "73",
Expand All @@ -162,6 +165,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel0004": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "74",
Expand All @@ -171,6 +175,14 @@
"setup.kernel_team_mode_name": "loadbalance",
"runner.active": "true"
},
"LAG_TABLE|PortChannel0100": {
"setup.runner_name": "loadbalance",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "74",
"setup.pid": "56",
"state": "ok",
"setup.kernel_team_mode_name": "loadbalance"
},
"FAN_INFO|fan1": {
"drawer_name": "drawer1",
"presence": "True",
Expand Down
4 changes: 4 additions & 0 deletions tests/mock_tables/asic2/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"ifinfo.ifindex": "100"
},
"LAG_TABLE|PortChannel1015": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "71",
Expand All @@ -140,6 +141,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel1016": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "72",
Expand All @@ -150,6 +152,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel4011": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "73",
Expand All @@ -160,6 +163,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel4012": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "74",
Expand Down
7 changes: 7 additions & 0 deletions tests/mock_tables/config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,13 @@
"tpid": "0x8100",
"mtu": "9100"
},
"PORTCHANNEL|PortChannel0100": {
"admin_status": "up",
"min_links": "1",
"tpid": "0x8100",
"static": "true",
"mtu": "9100"
},
"PORTCHANNEL_MEMBER|PortChannel1001|Ethernet32": {
"NULL": "NULL"
},
Expand Down
12 changes: 12 additions & 0 deletions tests/mock_tables/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@
"ifinfo.ifindex": "100"
},
"LAG_TABLE|PortChannel0001": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "71",
Expand All @@ -497,6 +498,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel0002": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "72",
Expand All @@ -507,6 +509,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel0003": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "73",
Expand All @@ -517,6 +520,7 @@
"runner.active": "true"
},
"LAG_TABLE|PortChannel0004": {
"setup.runner_name": "lacp",
"runner.fallback": "false",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "74",
Expand All @@ -526,6 +530,14 @@
"setup.kernel_team_mode_name": "loadbalance",
"runner.active": "true"
},
"LAG_TABLE|PortChannel0100": {
"setup.runner_name": "loadbalance",
"team_device.ifinfo.dev_addr": "52:54:00:f2:e1:23",
"team_device.ifinfo.ifindex": "74",
"setup.pid": "56",
"state": "ok",
"setup.kernel_team_mode_name": "loadbalance"
},
"FAN_INFO|fan1": {
"drawer_name": "drawer1",
"presence": "True",
Expand Down
8 changes: 8 additions & 0 deletions tests/mock_tables/t1/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@
"ttl": -0.001,
"type": "hash",
"value": {
"setup.runner_name": "lacp",
"runner.active": "true",
"runner.fallback": "false",
"runner.fast_rate": "false",
Expand All @@ -1192,6 +1193,7 @@
"ttl": -0.001,
"type": "hash",
"value": {
"setup.runner_name": "lacp",
"runner.active": "true",
"runner.fallback": "false",
"runner.fast_rate": "false",
Expand All @@ -1207,6 +1209,7 @@
"ttl": -0.001,
"type": "hash",
"value": {
"setup.runner_name": "lacp",
"runner.active": "true",
"runner.fallback": "false",
"runner.fast_rate": "false",
Expand All @@ -1222,6 +1225,7 @@
"ttl": -0.001,
"type": "hash",
"value": {
"setup.runner_name": "lacp",
"runner.active": "true",
"runner.fallback": "false",
"runner.fast_rate": "false",
Expand All @@ -1237,6 +1241,7 @@
"ttl": -0.001,
"type": "hash",
"value": {
"setup.runner_name": "lacp",
"runner.active": "true",
"runner.fallback": "false",
"runner.fast_rate": "false",
Expand All @@ -1252,6 +1257,7 @@
"ttl": -0.001,
"type": "hash",
"value": {
"setup.runner_name": "lacp",
"runner.active": "true",
"runner.fallback": "false",
"runner.fast_rate": "false",
Expand All @@ -1267,6 +1273,7 @@
"ttl": -0.001,
"type": "hash",
"value": {
"setup.runner_name": "lacp",
"runner.active": "true",
"runner.fallback": "false",
"runner.fast_rate": "false",
Expand All @@ -1282,6 +1289,7 @@
"ttl": -0.001,
"type": "hash",
"value": {
"setup.runner_name": "lacp",
"runner.active": "true",
"runner.fallback": "false",
"runner.fast_rate": "false",
Expand Down
26 changes: 26 additions & 0 deletions tests/portchannel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,32 @@ def test_add_portchannel_with_invalid_fast_rate(self, fast_rate):
assert result.exit_code != 0
assert 'Invalid value for "--fast-rate"' in result.output

@pytest.mark.parametrize("static", ["False", "True", "false", "true"])
def test_add_portchannel_with_static_adhoc_validation(self, static):
config.ADHOC_VALIDATION = True
runner = CliRunner()
db = Db()
obj = {'db':db.cfgdb}

# add a portchannel with fats rate
result = runner.invoke(config.config.commands["portchannel"].commands["add"], ["PortChannel0101", "--static", static], obj=obj)
print(result.exit_code)
print(result.output)
assert result.exit_code == 0

@pytest.mark.parametrize("static", ["Fls", "tru"])
def test_add_portchannel_with_invalid_static(self, static):
runner = CliRunner()
db = Db()
obj = {'db':db.cfgdb}

# add a portchannel with invalid fats rate
result = runner.invoke(config.config.commands["portchannel"].commands["add"], ["PortChannel0101", "--static", static], obj=obj)
print(result.exit_code)
print(result.output)
assert result.exit_code != 0
assert 'Invalid value for "--static"' in result.output

def test_add_portchannel_member_with_invalid_name(self):
runner = CliRunner()
db = Db()
Expand Down