Repository navigation
NetBox host source, diagnostics, batch runner and safety flags - #1
Merged
Merged
Conversation
Adds --source netbox, info/sensors/sel/power status, parallel per-host results with exit codes, --dry-run/--yes, request timeout, masked verbose output, and tests.
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.
Summary
Makes sm-cli usable as an operations tool on top of NetBox: it can resolve BMC address and credentials from NetBox, read diagnostics, work on many hosts in parallel, and guards changes. Existing command syntax and
inventory.yamlkeep working.Changes
Host sources
--source netbox(orSMCLI_SOURCE=netbox): device →oob_ip→ assigned interface → custom fieldsipmi_username/ipmi_password, usingNETBOX_URL/NETBOX_TOKEN. Credentials only in memory.--rack,--site,--tag,--role(paginated).--inventory <file|->for the file source.New read-only commands
power status,info(model, serial, BIOS/BMC firmware, power, health),sensors [--problems](Thermal + Power),sel [--since] [--limit] [--manager](event log, newest first, follows paging).Runner
--parallel(default 5); one result per host;-o json; exit code 1 if any host failed; summary on stderr.--timeoutper request (default 15s) — previously none, a dead BMC could hang.Safety
--dry-runfor all changing commands (only discovery GETs are sent).--yes.-vlogs requests to stderr with password fields masked;user <name> - <host>reads the password from stdin.json.Marshalinstead of string formatting.power shutdown(GracefulShutdown).Fixes
-vnever worked:SetVerbosewas called before flags were parsed.aclwas registered twice (inmain.goandcmd/acl.go).CurrentHost/RedfishPathstate replaced by a per-hosthost.Client(needed for parallel runs).Other
httptest) and aTestworkflow (gofmt, vet,go test -race) on PRs andmain.Testing
go vet,gofmt,go test -race ./...pass.power status,info,sensors,selon cpu-r5-10;power status --rack C.W15 --role server→ 37 ok.--dry-run(no request sent) and the--yesguard; no power/boot/media/user/acl change was made on real hardware.Notes
Managers/1/...), as before.1.1.0) triggers the existing release workflow.