Add settings command to configure BMC - #180
Conversation
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
Correct Redfish settings operations: - patch EthernetInterface and account resources directly - treat ComputerSystem and Manager arguments as property names - select the first available ComputerSystem and Manager resource - validate property names and preserve scalar JSON types - reject invalid reset preservation modes instead of resetting everything Improve command behavior: - return Cobra errors rather than terminating with os.Exit - ensure Redfish clients are logged out on success and failure - bind inventory flags correctly and separate input from output formats - resolve SETTINGS_* environment variables for nested subcommands - support hostnames, IPv4, IPv6, and fully qualified endpoint URLs - load custom CA certificates for verified BMC connections Add regression coverage: - exercise Redfish reads, PATCH payloads, account updates, and resets - verify invalid properties and malformed values do not issue writes - cover JSON and YAML inventory lookup - test environment resolution and endpoint construction - verify custom and invalid CA certificate handling Update the README and manual pages to describe property selection, inventory formats, default resource selection, and supported environment variables. These changes prevent destructive reset behavior, fix updates that could silently produce no request, and align the settings implementation with its documented CLI contract. The HTTP-backed tests use real gofish request paths so future schema or request-handling regressions are caught without requiring access to physical BMC hardware. Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
There was a problem hiding this comment.
See synackd/bmc-configure for rebase with added tests/fixes. I tested the following on that branch.
One thing I noticed is that the secrets commands to not seem to read/write from secrets.json by default as is described. I had to specify --secrets-file secrets.json in the commands below for this to work.
listing settings (I assume this is like a help message):
Succeeded.
$ ./magellan settings list
Available setting categories:
NetworkProtocol Network service settings (SSH, HTTPS, IPMI, NTP, etc.)
EthernetInterface Network interface settings (IP, MAC, DHCP, etc.)
ComputerSystem System-level settings (boot order, asset tag, etc.)
Manager Manager properties (firmware version, model, etc.)
Accounts BMC user accounts (username, role, etc.)
Reset Factory reset the BMC manager
geting a setting:
Succeeded.
$ ./magellan --secrets-file secrets.json settings get --insecure 172.16.0.101 NetworkProtocol SSH
{"level":"warn","id":"https://172.16.0.101","time":"2026-08-26T13:50:08-06:00","caller":"/var/lib/admin/git/openchami/magellan/internal/util/bmc.go:32","message":"specific credentials not found, falling back to default"}
{"level":"info","id":"https://172.16.0.101","time":"2026-08-26T13:50:08-06:00","caller":"/var/lib/admin/git/openchami/magellan/internal/util/bmc.go:39","message":"default credentials found, using"}
{
"Port": 22,
"ProtocolEnabled": true
}
seting a setting:
Succeeded.
$ ./magellan --secrets-file secrets.json settings set --insecure 172.16.0.101 NetworkProtocol SSH '{"ProtocolEnabled":false,"Port":22}'
{"level":"warn","id":"https://172.16.0.101","time":"2026-08-26T13:51:56-06:00","caller":"/var/lib/admin/git/openchami/magellan/internal/util/bmc.go:32","message":"specific credentials not found, falling back to default"}
{"level":"info","id":"https://172.16.0.101","time":"2026-08-26T13:51:56-06:00","caller":"/var/lib/admin/git/openchami/magellan/internal/util/bmc.go:39","message":"default credentials found, using"}
Successfully set NetworkProtocol.SSH
$ ./magellan --secrets-file secrets.json settings get --insecure 172.16.0.101 NetworkProtocol SSH
{"level":"warn","id":"https://172.16.0.101","time":"2026-08-26T13:52:04-06:00","caller":"/var/lib/admin/git/openchami/magellan/internal/util/bmc.go:32","message":"specific credentials not found, falling back to default"}
{"level":"info","id":"https://172.16.0.101","time":"2026-08-26T13:52:04-06:00","caller":"/var/lib/admin/git/openchami/magellan/internal/util/bmc.go:39","message":"default credentials found, using"}
{
"Port": 22,
"ProtocolEnabled": false
}
reseting a BMC, preserving network and user settings:
Erred despite following the usage. Did not try without the config preservation as I'm operating on a real BMC.
$ ./magellan --secrets-file secrets.json settings reset --preserve-config PreserveNetworkAndUsers --insecure 172.16.0.101
{"level":"warn","id":"https://172.16.0.101","time":"2026-08-26T14:00:07-06:00","caller":"/var/lib/admin/git/openchami/magellan/internal/util/bmc.go:32","message":"specific credentials not found, falling back to default"}
{"level":"info","id":"https://172.16.0.101","time":"2026-08-26T14:00:07-06:00","caller":"/var/lib/admin/git/openchami/magellan/internal/util/bmc.go:39","message":"default credentials found, using"}
{"level":"info","time":"2026-08-26T14:00:09-06:00","caller":"/var/lib/admin/git/openchami/magellan/pkg/bmc/settings.go:305","message":"resetting manager 1 to defaults (type: PreserveNetworkAndUsers)"}
Error: failed to reset manager: unable to execute request, no target provided
|
Looks like this still needs quite a bit of touch-up. I'm going to rebase and fix this when I get a chance. |
I've already rebased on the branch I linked |
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
|
Took a look at the issues Devon mentioned and decided to join the fun with https://github.com/OpenCHAMI/magellan/tree/bmcdonald3/bmc-configure Secrets issueFor the secrets file, the The fix here was to make collect, power, and settings all register Error when resettingFor the comment about the error with setting reset, this comes from the gofish library: I don't think your BMC has an Rerunning Devon's tests: And then we get a little better error message here for the reset: And we don't have this on this BMC: |
|
Thanks for digging into this, @bmcdonald3! That message is a lot more helpful. For the secrets issue, I wonder if it would be beneficial to refactor the secrets default setting to be at the library level to be more DRY. I am currently in the process of refactoring the ochami CLI to use less globals to avoid issues like this as part of an effort to expand test coverage (as of writing unpublished, but will be soon). |
I think it would be even more beneficial to rework how the CLI is handling variables in general. It seems like the current way create issues with Viper and binding the params together and makes it a bit harder to keep track of which variables are being used and where. It seemed to work fine prior to that, but I think it's definitely time to reconsider this. |
b9cb247 to
a4a7cb2
Compare
Pull Request Template
Thank you for your contribution! Please ensure the following before submitting:
Checklist
make test(or equivalent) locally and all tests passgit commit -s) with my real name and email<filename>.licensesidecarLICENSES/directoryDescription
This PR adds a new
settingscommand that allows the user to configure the BMC via Redfish usingmagellanas described in #129.Fixes #129
Type of Change
For more info, see Contributing Guidelines.