Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
arista-hpandya committed Sep 5, 2024
1 parent 4602a99 commit 9efdf5d
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 59 deletions.
8 changes: 5 additions & 3 deletions pfc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def configPfcPrio(self, status, interface, priority):

namespace_str = f" for namespace {self.multi_asic.current_namespace}" if multi_asic.is_multi_asic() else ''
if status == 'on' and priority in enable_prio:
click.echo('Priority {0} has already been enabled on {1}{2}'.format(priority, interfacei, namespace_str))
click.echo('Priority {0} has already been enabled on {1}{2}'.format(priority, interface, namespace_str))
return

if status == 'off' and priority not in enable_prio:
Expand Down Expand Up @@ -122,7 +122,10 @@ def showPfcPrio(self, interface):
"""The user specifies an interface but we cannot find it"""
namespace_str = f"Namespace {self.multi_asic.current_namespace}" if multi_asic.is_multi_asic() else ''
if interface and interface not in intfs:
click.echo('Cannot find interface {0} for {1}'.format(interface, namespace_str))
if multi_asic.is_multi_asic():
click.echo('Cannot find interface {0} for {1}'.format(interface, namespace_str))
else:
click.echo('Cannot find interface {0}'.format(interface))
return

if interface:
Expand Down Expand Up @@ -194,4 +197,3 @@ def showPrio(interface, namespace):
config.add_command(configPrio, "priority")
show.add_command(showAsym, "asymmetric")
show.add_command(showPrio, "priority")

1 change: 0 additions & 1 deletion tests/multi_asic_pfc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,3 @@ def teardown_class(cls):

super().teardown_class()
os.environ.pop("UTILITIES_UNIT_TESTING_TOPOLOGY")

2 changes: 1 addition & 1 deletion tests/pfc_input/assert_show_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

pfc_cannot_find_intf = """\
Cannot find interface Ethernet1234 for
Cannot find interface Ethernet1234
"""

pfc_show_asymmetric_all = """\
Expand Down
111 changes: 57 additions & 54 deletions tests/pfc_input/pfc_test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,35 +168,35 @@
'asic0'],
'rc': 0,
'rc_output': show_asym_intf_one_masic
},
},
'pfc_show_asymmetric_intf_all_masic': {'cmd': ['show', 'asymmetric',
'Ethernet0'],
'rc': 0,
'rc_output': show_asym_intf_all_masic
},
},
'pfc_show_asymmetric_intf_fake_one_masic': {'cmd': ['show', 'asymmetric',
'Ethernet1234', '--namespace',
'asic0'],
'rc': 0,
'rc_output': show_asym_intf_fake_one_masic
},
'Ethernet1234', '--namespace',
'asic0'],
'rc': 0,
'rc_output': show_asym_intf_fake_one_masic
},
'pfc_show_priority_all_asic0_masic': {'cmd': ['show', 'priority',
'--namespace', 'asic0'],
'rc': 0,
'rc_output': show_prio_all_asic0_masic
},
'rc': 0,
'rc_output': show_prio_all_asic0_masic
},
'pfc_show_priority_all_asic1_masic': {'cmd': ['show', 'priority',
'--namespace', 'asic1'],
'rc': 0,
'rc_output': show_prio_all_asic1_masic
},
'--namespace', 'asic1'],
'rc': 0,
'rc_output': show_prio_all_asic1_masic
},
'pfc_show_priority_all_masic': {'cmd': ['show', 'priority'],
'rc': 0,
'rc_output': show_prio_all_masic
},
'rc': 0,
'rc_output': show_prio_all_masic
},
'pfc_show_priority_intf_one_masic': {'cmd': ['show', 'priority',
'Ethernet0', '--namespace',
'asic0'],
'Ethernet0', '--namespace',
'asic0'],
'rc': 0,
'rc_output': show_prio_intf_one_masic
},
Expand All @@ -206,21 +206,21 @@
'rc_output': show_prio_intf_all_masic
},
'pfc_show_priority_intf_fake_one_masic': {'cmd': ['show', 'priority',
'Ethernet1234', '--namespace',
'asic0'],
'rc': 0,
'rc_output': show_prio_intf_fake_one_masic
},
'Ethernet1234', '--namespace',
'asic0'],
'rc': 0,
'rc_output': show_prio_intf_fake_one_masic
},
'pfc_show_priority_intf_fake_all_masic': {'cmd': ['show', 'priority',
'Ethernet1234'],
'Ethernet1234'],
'rc': 0,
'rc_output': show_prio_intf_fake_all_masic
},
},
'pfc_config_asymmetric_one_masic': {'cmd': ['config', 'asymmetric',
'on', 'Ethernet0', '--namespace',
'asic0'],
'rc': 0,
'cmp_args': [['asic0','PORT','Ethernet0','pfc_asym','on']]
'cmp_args': [['asic0', 'PORT', 'Ethernet0', 'pfc_asym', 'on']]
},
'pfc_config_asymmetric_invalid_one_masic': {'cmd': ['config', 'asymmetric',
'onn', 'Ethernet0', '--namespace',
Expand All @@ -231,12 +231,12 @@
'asymmetric --help" for help.\n\n'
'Error: Invalid value for "[on|off]": '
'invalid choice: onn. (choose from on, off)')
},
},
'pfc_config_asymmetric_all_masic': {'cmd': ['config', 'asymmetric',
'on', 'Ethernet0'],
'rc': 0,
'cmp_args': [['asic0','PORT','Ethernet0','pfc_asym','on'],
['asic1','PORT','Ethernet0','pfc_asym','on']]
'cmp_args': [['asic0', 'PORT', 'Ethernet0', 'pfc_asym', 'on'],
['asic1', 'PORT', 'Ethernet0', 'pfc_asym', 'on']]
},
'pfc_config_asymmetric_invalid_all_masic': {'cmd': ['config', 'asymmetric',
'onn', 'Ethernet0'],
Expand All @@ -246,38 +246,41 @@
'asymmetric --help" for help.\n\n'
'Error: Invalid value for "[on|off]": '
'invalid choice: onn. (choose from on, off)')
},
},
'pfc_config_priority_one_masic': {'cmd': ['config', 'priority',
'on', 'Ethernet0', '5',
'--namespace', 'asic0'],
'rc': 0,
'cmp_args': [['asic0','PORT_QOS_MAP','Ethernet0','pfc_enable','3,4,5']]
'cmp_args': [['asic0', 'PORT_QOS_MAP', 'Ethernet0',
'pfc_enable', '3,4,5']]
},
'pfc_config_priority_invalid_one_masic': {'cmd': ['config', 'priority',
'onn', 'Ethernet0', '5',
'--namespace', 'asic0'],
'rc': 2,
'rc_msg': ('Usage: cli config priority [OPTIONS] '
'[on|off] INTERFACE [0|1|2|3|4|5|6|7]\n'
'Try "cli config priority --help" for '
'help.\n\nError: Invalid value for '
'"[on|off]": invalid choice: onn. '
'(choose from on, off)')
},
'rc': 2,
'rc_msg': ('Usage: cli config priority [OPTIONS] '
'[on|off] INTERFACE [0|1|2|3|4|5|6|7]\n'
'Try "cli config priority --help" for '
'help.\n\nError: Invalid value for '
'"[on|off]": invalid choice: onn. '
'(choose from on, off)')
},
'pfc_config_priority_all_masic': {'cmd': ['config', 'priority',
'on', 'Ethernet0', '5'],
'rc': 0,
'cmp_args': [['asic0','PORT_QOS_MAP','Ethernet0','pfc_enable','3,4,5'],
['asic1','PORT_QOS_MAP','Ethernet0', 'pfc_enable', '3,4,5']]
},
'on', 'Ethernet0', '5'],
'rc': 0,
'cmp_args': [['asic0', 'PORT_QOS_MAP', 'Ethernet0',
'pfc_enable', '3,4,5'],
['asic1', 'PORT_QOS_MAP', 'Ethernet0',
'pfc_enable', '3,4,5']]
},
'pfc_config_priority_invalid_all_masic': {'cmd': ['config', 'priority',
'onn', 'Ethernet0', '5'],
'rc': 2,
'rc_msg': ('Usage: cli config priority [OPTIONS] '
'[on|off] INTERFACE [0|1|2|3|4|5|6|7]\n'
'Try "cli config priority --help" for '
'help.\n\nError: Invalid value for '
'"[on|off]": invalid choice: onn. '
'(choose from on, off)')
},
'onn', 'Ethernet0', '5'],
'rc': 2,
'rc_msg': ('Usage: cli config priority [OPTIONS] '
'[on|off] INTERFACE [0|1|2|3|4|5|6|7]\n'
'Try "cli config priority --help" for '
'help.\n\nError: Invalid value for '
'"[on|off]": invalid choice: onn. '
'(choose from on, off)')
},
}

0 comments on commit 9efdf5d

Please sign in to comment.