Skip to content

[multi-asic][warm_restart] add Multi-ASIC support for warm_restart commands#99

Closed
stepanblyschak wants to merge 2 commits intomasterfrom
masic-warm-restart
Closed

[multi-asic][warm_restart] add Multi-ASIC support for warm_restart commands#99
stepanblyschak wants to merge 2 commits intomasterfrom
masic-warm-restart

Conversation

@stepanblyschak
Copy link
Owner

What I did

How I did it

How to verify it

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@stepanblyschak stepanblyschak force-pushed the masic-warm-restart branch 4 times, most recently from 6e8a875 to 2fa8538 Compare October 16, 2025 13:57
@stepanblyschak stepanblyschak changed the title [warm_restart] add Multi-ASIC support for warm_restart commands [multi-asic][warm_restart] add Multi-ASIC support for warm_restart commands Oct 17, 2025
state_db = ctx.obj['state_db']
config_db = ctx.obj['db']
def warm_restart_enable(ctx, namespace, module):
if namespace is not None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: if namespace and namespace not in ctx.obj["all_namespaces"]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need check None, which means user did not provide. '' - is global ns



@warm_restart.command('enable')
@click.option('--namespace', '-n', 'namespace', default=None, help='Namespace name')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use this decorator instead, you won't namespace validation inside funtion:

@click.option('-n', '--namespace', help='Namespace name', required=True if multi_asic.is_multi_asic() else False,
              type=click.Choice(multi_asic.get_namespace_list()), default=multi_asic.DEFAULT_NAMESPACE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will reduce the number of changes in this file

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oleksandrivantsiv I see the benefit of doing this, but not sure how to mock multi_asic functions later in a test case. Since this decorator runs on module import time, it likelly needs reloading module after mock setup. I tried this but seems this does not play well with ClickRunner I will check what I can do.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oleksandrivantsiv I find it less suitable for this command. The choice enumerates asic namesapces while my commands use global and asic namespaces. Also makes mocking harder
The only benefit of choice is CLI feedback, but this is not a user facing CLI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants