Skip to content

Implement plugin CLI hooks#3443

Merged
ipspace merged 3 commits into
devfrom
plugin-post-output
Jun 5, 2026
Merged

Implement plugin CLI hooks#3443
ipspace merged 3 commits into
devfrom
plugin-post-output

Conversation

@ipspace
Copy link
Copy Markdown
Owner

@ipspace ipspace commented Jun 4, 2026

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.

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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.py to execute plugin hooks before/after shell CLI hooks (pre_shell_*/post_shell_*), plus direct plugin hooks for create (output/post_output).
  • Switched netlab up / netlab down to use the new hook runner instead of external_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.

Comment thread netsim/cli/_hooks.py
Comment thread netsim/cli/_hooks.py Outdated
Comment thread netsim/cli/_hooks.py Outdated
@ipspace ipspace requested a review from Muddyblack June 4, 2026 16:03
@ipspace
Copy link
Copy Markdown
Owner Author

ipspace commented Jun 4, 2026

@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?

Comment thread netsim/cli/up.py
@Muddyblack
Copy link
Copy Markdown
Collaborator

I also made a commit to #3421 which uses that now

ipspace added a commit that referenced this pull request Jun 5, 2026
@ipspace ipspace merged commit 6bd7a03 into dev Jun 5, 2026
13 checks passed
@ipspace ipspace deleted the plugin-post-output branch June 5, 2026 08:52
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.

3 participants