Skip to content

Commit

Permalink
Fix static check failures
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekrnv authored Sep 13, 2024
1 parent d7e7c21 commit a39999c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 9 additions & 3 deletions counterpoll/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
DEFLT_10_SEC= "default (10000)"
DEFLT_1_SEC = "default (1000)"


def is_dpu(db):
""" Check if the device is DPU """
platform_info = device_info.get_platform_info(db)
Expand Down Expand Up @@ -394,6 +395,7 @@ def disable(ctx):
fc_info['FLEX_COUNTER_STATUS'] = 'disable'
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", "FLOW_CNT_ROUTE", fc_info)


# ENI counter commands
@cli.group()
@click.pass_context
Expand All @@ -405,16 +407,17 @@ def eni(ctx):
click.echo("ENI counters are not supported on non DPU platforms")
exit(1)


@eni.command()
@click.argument('poll_interval', type=click.IntRange(1000, 30000))
@click.pass_context
def interval(ctx, poll_interval):
""" Set eni counter query interval """
eni_info = {}
if poll_interval is not None:
eni_info['POLL_INTERVAL'] = poll_interval
eni_info['POLL_INTERVAL'] = poll_interval
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", ENI, eni_info)


@eni.command()
@click.pass_context
def enable(ctx):
Expand All @@ -423,6 +426,7 @@ def enable(ctx):
eni_info['FLEX_COUNTER_STATUS'] = 'enable'
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", ENI, eni_info)


@eni.command()
@click.pass_context
def disable(ctx):
Expand All @@ -431,6 +435,7 @@ def disable(ctx):
eni_info['FLEX_COUNTER_STATUS'] = 'disable'
ctx.obj.mod_entry("FLEX_COUNTER_TABLE", ENI, eni_info)


@cli.command()
def show():
""" Show the counter configuration """
Expand Down Expand Up @@ -479,7 +484,8 @@ def show():
route_info.get("FLEX_COUNTER_STATUS", DISABLE)])

if is_dpu(config_db) and eni_info:
data.append(["ENI_STAT", eni_info.get("POLL_INTERVAL", DEFLT_10_SEC), eni_info.get("FLEX_COUNTER_STATUS", DISABLE)])
data.append(["ENI_STAT", eni_info.get("POLL_INTERVAL", DEFLT_10_SEC),
eni_info.get("FLEX_COUNTER_STATUS", DISABLE)])

click.echo(tabulate(data, headers=header, tablefmt="simple", missingval=""))

Expand Down
2 changes: 0 additions & 2 deletions tests/counterpoll_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,6 @@ def test_update_route_counter_interval(self):
@pytest.mark.parametrize("status", ["disable", "enable"])
def test_update_eni_status(self, status):
runner = CliRunner()
db = Db()

result = runner.invoke(counterpoll.cli, ["eni", status])
assert result.exit_code == 1
assert result.output == "ENI counters are not supported on non DPU platforms\n"
Expand Down

0 comments on commit a39999c

Please sign in to comment.