Implement plugin CLI hooks#3443
Merged
Merged
Conversation
Like the shell CLI hooks, the plugin CLI hooks are executed at various steps during the lab up/down process. The plugin hooks could be called before or after the CLI command is executed.
There was a problem hiding this comment.
Pull request overview
This PR introduces a unified CLI hook runner that adds plugin-based CLI hooks around existing shell-based CLI hooks, and wires it into the create, up, and down command flows so plugins can run pre-/post- hook logic during lab lifecycle operations.
Changes:
- Added
netsim/cli/_hooks.pyto execute plugin hooks before/after shell CLI hooks (pre_shell_*/post_shell_*), plus direct plugin hooks forcreate(output/post_output). - Switched
netlab up/netlab downto use the new hook runner instead ofexternal_commands.run_cli_hooks. - Documented plugin CLI hook behavior in
docs/dev/plugins.md.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
netsim/cli/up.py |
Replaces shell-hook execution calls with _hooks.run_cli_hooks(...) during up workflow steps. |
netsim/cli/down.py |
Replaces shell-hook execution calls with _hooks.run_cli_hooks(...) during down workflow steps. |
netsim/cli/external_commands.py |
Removes the old run_cli_hooks implementation (hook handling moved to _hooks.py). |
netsim/cli/create.py |
Adds plugin CLI hook execution for create (output and post_output). |
netsim/cli/_hooks.py |
New shared implementation for shell + plugin hook execution. |
docs/dev/plugins.md |
Adds documentation for plugin CLI hooks and their naming/registration conventions. |
Owner
Author
|
@Muddyblack -- here's the pretty generic implementation of plugin hooks for CLI commands. You can hook the plugin into ~20 different places ;) Speaking of which, it might be better to execute the VXLAN scripts in #3421 from the plugin hook? |
Muddyblack
requested changes
Jun 4, 2026
Collaborator
|
I also made a commit to #3421 which uses that now |
Muddyblack
approved these changes
Jun 5, 2026
ipspace
added a commit
that referenced
this pull request
Jun 5, 2026
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.
Like the shell CLI hooks, the plugin CLI hooks are executed at various steps during the lab up/down process. The plugin hooks could be called before or after the CLI command is executed.