Skip to content

feat: --dry-run for network commands (0.9.13) - #201

Merged
metharda merged 3 commits into
metharda:mainfrom
Huseynteymurzade28:feature/network-dry-run
Nov 25, 2026
Merged

metharda merged 3 commits into
metharda:mainfrom
Huseynteymurzade28:feature/network-dry-run

Conversation

@Huseynteymurzade28

@Huseynteymurzade28 Huseynteymurzade28 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds --dry-run (-n) to the network commands, as asked in #23: each one shows what it would do, rule by rule, and changes nothing.

Covered: network start|stop|restart|ip-forwarding, ports setup|add|remove|apply|clear, dhcp clear|cleanup|renew.

  • Uses the same code as the real run for finding VMs, picking ports and selecting rules and leases, so the preview matches it. ports setup counts the rules it would remove as gone when picking ports.
  • Asks no questions, takes no locks, writes no files.
  • ports setup --dry-run does not start a stopped network or wait for VMs without an address.
  • Users may dry-run ports add and remove on their own VMs through the socket.
  • network vnc changes the VM's definition rather than the network, so it has no dry run and refuses the flag.

Behaviour change: these commands ignored arguments they don't take, so ports clear --dry-run (or a typo of it) would have cleared the rules. They now fail with a usage line.

Closes #23

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Code refactoring

Testing

  • New test_network_dry_run in lib/utils/test-suite.sh (stubbed iptables, virsh and dnsmasq): previews, no changes made, unknown arguments run nothing, socket policy. It fails when the flag is made a no-op.
  • test-suite.sh --quick passes except bc and the ISO tools, which are not installed on my machine (same before this change).
  • shfmt -i 2 -d (v3.8.0) and shellcheck -S error are clean.
  • Not run on a real libvirt host.

Documentation

  • Updated relevant documentation (help texts, docs/networking.md, docs/usage.md, CHANGELOG, completion)
  • Added examples if needed
  • Updated README if major feature

Checklist

  • Code follows project style
  • Comments added for complex logic
  • No new warnings generated
  • Tested on supported platforms

Huseynteymurzade28 and others added 3 commits November 25, 2026 13:38
- network start/stop/restart/ip-forwarding, ports setup/add/remove/apply/clear
  and dhcp clear/cleanup/renew show what they would change and change nothing
- These commands refuse arguments they don't take instead of running
- Users may dry-run ports add/remove on their own VMs

Closes metharda#23
@metharda
metharda merged commit 925b8bf into metharda:main Nov 25, 2026
6 checks passed
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.

dry-run option for network management

2 participants