diff --git a/counterpoll/main.py b/counterpoll/main.py index 73483d3681..62d9f70067 100644 --- a/counterpoll/main.py +++ b/counterpoll/main.py @@ -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) @@ -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 @@ -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): @@ -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): @@ -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 """ @@ -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="")) diff --git a/tests/counterpoll_test.py b/tests/counterpoll_test.py index b39f0cf2d1..6c165498c5 100644 --- a/tests/counterpoll_test.py +++ b/tests/counterpoll_test.py @@ -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"