Skip to content

Explore/magellan serve#132

Open
alexlovelltroy wants to merge 3 commits into
feature/RFD-133-Explorefrom
explore/magellan-serve
Open

Explore/magellan serve#132
alexlovelltroy wants to merge 3 commits into
feature/RFD-133-Explorefrom
explore/magellan-serve

Conversation

@alexlovelltroy

Copy link
Copy Markdown
Member

This pull request introduces a major new "serve" subcommand to run Magellan as a persistent REST API service for BMC inventory and power operations, as well as significant enhancements to the power command interface and several dependency updates. The most important changes are grouped below.

New REST API Service:

  • Adds the serve subcommand (cmd/serve.go) to run Magellan as a long-lived REST daemon, exposing endpoints for BMC inventory and power operations, with support for TLS and bearer token authentication.
  • Implements REST handlers for health checks, inventory, power state, reset types, and power actions, including vendor-neutral operations and raw Redfish reset types (internal/server/handlers.go).
  • Adds middleware for structured request logging and bearer token enforcement to support auditing and security (internal/server/middleware.go).
  • Adds new server-related configuration defaults in cmd/root.go.

Power Command Enhancements:

  • Introduces vendor-neutral power operations (--operation), confirmation/wait logic (--wait, --wait-timeout), and improves flag validation and error handling in cmd/power.go. Also replaces raw Redfish reset type handling to use the updated gofish schema. [1] [2] [3] [4] [5]
  • Updates flag handling to avoid shorthand collisions (notably -l), and adds a test to guard against future flag conflicts (cmd/power.go, cmd/power_test.go). [1] [2]

Dependency and Module Updates:

  • Updates Go version to 1.26.0 and refreshes many dependencies to their latest versions in go.mod, including gofish, cobra, viper, zerolog, and others, ensuring compatibility and security.

These changes lay the foundation for Magellan to be used as a shared backend service for other OpenCHAMI tools, enhance the CLI's flexibility and safety, and modernize the codebase's dependencies.

For more info, see Contributing Guidelines.

- Updated imports from redfish to schemas in various files to align with the new package structure.
- Modified Client interface methods to return types from schemas instead of redfish.
- Adjusted implementations in GenericClient to accommodate the new schemas types.
- Updated tests to reflect changes in the types used for power states and reset types.
- Refactored functions in collect, crawler, power, service, and update packages to utilize schemas types.
- Introduced helper functions to dereference optional numeric fields for better handling of nil values.

Signed-off-by: Alex Lovell-Troy <alex@lovelltroy.org>
…BMC layer

Signed-off-by: Alex Lovell-Troy <alex@lovelltroy.org>
- Add middleware for request logging and bearer token authentication in the server.
- Create response handling functions for JSON responses and error messages.
- Develop the main server structure to handle API routes for inventory and power operations.
- Implement health check endpoints for liveness and readiness.
- Introduce a mock Redfish service for testing power state transitions.
- Add power transition logic with confirmation and escalation handling.
- Create tests for various power operations, including success, timeout, and escalation scenarios.
- Enhance service layer to support power transition operations.

Signed-off-by: Alex Lovell-Troy <alex@lovelltroy.org>
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.

1 participant