Repository navigation
Implement generic device hooks - #4021
Merged
Merged
Conversation
The 'device quirks' system is expanded into generic 'device hooks' -- methods in the device '_Quirks' object that can do whatever we need them to do. The infrastructure changes in this commit: * Add 'exec_device_hook' method that calls any device object method with node, topology, and any extra parameters supplied by the caller. The parameters cannot be checked in advance :(. The function returns the method results or None to allow the caller to check whether the hook was executed. * Use 'exec_device_hook' to implement 'exec_device_quirk' * Add 'hooks' debugging parameter
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
An active documentation issue remains because the new hooks debug flag is not listed in the relevant debug-flag documentation.
1 open issue
What changed in this PR
This pull request expands device quirks into generic device hooks while preserving the existing quirk API.
Changes:
- Added
exec_device_hookfor invoking device methods with extra parameters and returning results. - Refactored
exec_device_quirkto use the generic hook executor. - Added the
hooksCLI debugging flag.
This pull request is ready to be approved.
| File | Description |
|---|---|
netsim/devices/__init__.py |
Implements generic device-hook dispatch and retains quirk compatibility. |
netsim/cli/__init__.py |
Registers the new hooks debugging option. Documentation for the flag should be added alongside the existing quirks documentation. |
Review effort: Lite
Deploying netlab with
|
| Latest commit: |
5f98f48
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://df103006.netlab.pages.dev |
| Branch Preview URL: | https://device-hook.netlab.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The 'device quirks' system is expanded into generic 'device hooks' -- methods in the device '_Quirks' object that can do whatever we need them to do. The infrastructure changes in this commit: