Skip to content

Commit ef7ec96

Browse files
committed
feat: integrate Redfish API implementation from fork
This commit integrates the complete Redfish API implementation from: https://github.com/nmgaston/console Key features: - Redfish API v1 implementation with OpenAPI specification - ComputerSystem resource management with system discovery - Session management and authentication (Basic Auth and X-Auth-Token) - Power state management (On, Off, Reset, ForceOff, etc.) - Boot override configuration support (Once, Continuous, Disabled) - BIOS version, processor summary, and memory summary support - Metadata and OData service endpoints - Message registry support (Base.1.22.0) - Complete test coverage with Postman collections and integration tests - CI/CD workflows for automated testing Testing: - Unit tests for all handlers and use cases - Integration tests using Newman/Postman - Automated CI/CD pipeline for Redfish API validation This is a pre-release candidate of the Redfish feature.
1 parent 4d3e507 commit ef7ec96

47 files changed

Lines changed: 21826 additions & 47 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Redfish API Integration Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop, redfish ]
6+
pull_request:
7+
branches: [ main, develop, redfish ]
8+
9+
jobs:
10+
redfish-newman-tests:
11+
name: Redfish Newman/Postman Tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Harden Runner
16+
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
17+
with:
18+
egress-policy: audit
19+
20+
- name: Checkout code
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a
25+
with:
26+
go-version: '1.24.x'
27+
28+
- name: Install dependencies
29+
run: go mod download
30+
31+
- name: Install Newman
32+
run: npm install -g newman newman-reporter-htmlextra --ignore-scripts
33+
34+
- name: Create results directory
35+
run: mkdir -p redfish/tests/postman/results
36+
37+
- name: Make test script executable
38+
run: chmod +x redfish/tests/run_tests.sh
39+
40+
- name: Run Redfish API tests with Newman
41+
run: ./redfish/tests/run_tests.sh
42+
env:
43+
CI: "true"
44+
REDFISH_USE_MOCK: "true"
45+
HTTP_TLS_ENABLED: "false"
46+
HTTP_PORT: "8181"
47+
48+
- name: Upload Newman test results
49+
if: always()
50+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
51+
with:
52+
name: newman-redfish-results
53+
path: redfish/tests/postman/results/

.gitignore

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
1-
# IDE
2-
.idea
3-
.vscode
4-
# Config
5-
.env
6-
.DS_store
7-
#certs
8-
**/*.pem
9-
**/*.crt
10-
**/*.key
11-
**/*.yml
12-
**/*.yaml
13-
!config/config.yml
14-
# Binaries for programs and plugins
15-
*.exe
16-
*.exe~
17-
*.dll
18-
*.so
19-
*.dylib
20-
bin/
21-
*.db
22-
*.db-journal
23-
__debug_bin*
24-
*.app
25-
26-
# Test binary, built with `go test -c`
27-
*.test
28-
29-
# Output of the go coverage tool, specifically when used with LiteIDE
30-
*.out
31-
32-
# Dependency directories (remove the comment below to include it)
33-
vendor/
34-
# ...ignore the ui folder
35-
**/ui/*
36-
# ...but keep the folder
37-
!**/ui/.gitkeep
38-
# Documentation files
39-
doc/openapi.json
1+
# IDE
2+
.idea
3+
.vscode
4+
# Config
5+
.env
6+
.DS_store
7+
#certs
8+
**/*.pem
9+
**/*.crt
10+
**/*.key
11+
**/*.yml
12+
**/*.yaml
13+
!config/config.yml
14+
# Redfish OpenAPI files
15+
!redfish/openapi/*.yaml
16+
# Binaries for programs and plugins
17+
*.exe
18+
*.exe~
19+
*.dll
20+
*.so
21+
*.dylib
22+
bin/
23+
*.db
24+
*.db-journal
25+
__debug_bin*
26+
*.app
27+
28+
# Test binary, built with `go test -c`
29+
*.test
30+
31+
# Output of the go coverage tool, specifically when used with LiteIDE
32+
*.out
33+
34+
# Dependency directories (remove the comment below to include it)
35+
vendor/
36+
# ...ignore the ui folder
37+
**/ui/*
38+
# ...but keep the folder
39+
!**/ui/.gitkeep
40+
# Documentation files
41+
doc/openapi.json
42+
# Newman test results
43+
**/postman/results/

config/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type (
2727
EA `yaml:"ea"`
2828
Auth `yaml:"auth"`
2929
UI `yaml:"ui"`
30+
Redfish `yaml:"redfish"`
3031
}
3132

3233
// App -.
@@ -110,6 +111,10 @@ type (
110111
UI struct {
111112
ExternalURL string `yaml:"externalUrl" env:"UI_EXTERNAL_URL"`
112113
}
114+
// Redfish -.
115+
Redfish struct {
116+
EnvironmentUUID string `yaml:"environment_uuid" env:"REDFISH_ENV_UUID"`
117+
}
113118
)
114119

115120
// getPreferredIPAddress detects the most likely candidate IP address for this machine.
@@ -197,6 +202,9 @@ func defaultConfig() *Config {
197202
UI: UI{
198203
ExternalURL: "",
199204
},
205+
Redfish: Redfish{
206+
EnvironmentUUID: "",
207+
},
200208
}
201209
}
202210

config/config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ ui:
5454
# - Ignored: When building without 'noui' tag (embedded UI is served normally)
5555
# Example: https://ui.example.com
5656
externalUrl: ""
57-
57+
redfish:
58+
# Optional: Set a fixed UUID for this Redfish service instance
59+
# If not set, a persistent UUID will be auto-generated and stored in ~/.config/dmt-redfish-service/service_uuid
60+
# environment_uuid: ""

go.mod

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ go 1.25
77
require (
88
github.com/Masterminds/squirrel v1.5.4
99
github.com/coreos/go-oidc/v3 v3.17.0
10+
github.com/getkin/kin-openapi v0.133.0
1011
github.com/device-management-toolkit/go-wsman-messages/v2 v2.36.1
1112
github.com/gin-contrib/cors v1.7.6
1213
github.com/gin-contrib/pprof v1.5.3
@@ -17,6 +18,8 @@ require (
1718
github.com/golang-migrate/migrate/v4 v4.19.1
1819
github.com/gorilla/websocket v1.5.3
1920
github.com/ilyakaznacheev/cleanenv v1.5.0
21+
github.com/labstack/gommon v0.4.2
22+
github.com/oapi-codegen/runtime v1.1.2
2023
github.com/jackc/pgx/v5 v5.8.0
2124
github.com/prometheus/client_golang v1.23.2
2225
github.com/rs/zerolog v1.34.0
@@ -29,9 +32,9 @@ require (
2932

3033
require (
3134
al.essio.dev/pkg/shellescape v1.5.1 // indirect
35+
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
3236
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
3337
github.com/danieljoos/wincred v1.2.2 // indirect
34-
github.com/getkin/kin-openapi v0.133.0 // indirect
3538
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
3639
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
3740
github.com/goccy/go-yaml v1.18.0 // indirect
@@ -57,6 +60,8 @@ require (
5760
github.com/quic-go/qpack v0.6.0 // indirect
5861
github.com/quic-go/quic-go v0.57.0 // indirect
5962
github.com/ryanuber/go-glob v1.0.0 // indirect
63+
github.com/valyala/bytebufferpool v1.0.0 // indirect
64+
github.com/valyala/fasttemplate v1.2.2 // indirect
6065
github.com/woodsbury/decimal128 v1.4.0 // indirect
6166
github.com/zalando/go-keyring v0.2.6 // indirect
6267
go.yaml.in/yaml/v2 v2.4.2 // indirect

go.sum

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8
99
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
1010
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
1111
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
12+
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
13+
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
14+
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
1215
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
1316
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
17+
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
1418
github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=
1519
github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=
1620
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
@@ -158,6 +162,7 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
158162
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
159163
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
160164
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
165+
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
161166
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
162167
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
163168
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
@@ -168,6 +173,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
168173
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
169174
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
170175
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
176+
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
177+
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
171178
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
172179
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
173180
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
@@ -204,6 +211,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
204211
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
205212
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
206213
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
214+
github.com/oapi-codegen/runtime v1.1.2 h1:P2+CubHq8fO4Q6fV1tqDBZHCwpVpvPg7oKiYzQgXIyI=
215+
github.com/oapi-codegen/runtime v1.1.2/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg=
207216
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
208217
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
209218
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY=
@@ -246,6 +255,7 @@ github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkB
246255
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
247256
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
248257
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
258+
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
249259
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
250260
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
251261
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -265,6 +275,10 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
265275
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
266276
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
267277
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
278+
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
279+
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
280+
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
281+
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
268282
github.com/woodsbury/decimal128 v1.4.0 h1:xJATj7lLu4f2oObouMt2tgGiElE5gO6mSWUjQsBgUlc=
269283
github.com/woodsbury/decimal128 v1.4.0/go.mod h1:BP46FUrVjVhdTbKT+XuQh2xfQaGki9LMIRJSFuh6THU=
270284
github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s=

internal/app/app.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func Run(cfg *config.Config) {
5050
// Use case
5151
usecases := usecase.NewUseCases(database, log, CertStore)
5252

53-
handler := setupHTTPHandler(cfg, log, usecases)
53+
handler := setupHTTPHandler(cfg, log, usecases, database)
5454

5555
ciraServer := setupCIRAServer(cfg, log, database, usecases)
5656

@@ -65,7 +65,7 @@ func Run(cfg *config.Config) {
6565
shutdownServers(log, httpServer, ciraServer)
6666
}
6767

68-
func setupHTTPHandler(cfg *config.Config, log logger.Interface, usecases *usecase.Usecases) *gin.Engine {
68+
func setupHTTPHandler(cfg *config.Config, log logger.Interface, usecases *usecase.Usecases, database *db.SQL) *gin.Engine {
6969
if os.Getenv("GIN_MODE") != "debug" {
7070
gin.SetMode(gin.ReleaseMode)
7171
}
@@ -77,7 +77,7 @@ func setupHTTPHandler(cfg *config.Config, log logger.Interface, usecases *usecas
7777
defaultConfig.AllowHeaders = cfg.AllowedHeaders
7878

7979
handler.Use(cors.New(defaultConfig))
80-
httpapi.NewRouter(handler, log, *usecases, cfg)
80+
httpapi.NewRouter(handler, log, *usecases, cfg, database)
8181

8282
// Optionally enable pprof endpoints (e.g., for staging) via env ENABLE_PPROF=true
8383
if os.Getenv("ENABLE_PPROF") == "true" {

internal/controller/httpapi/router.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,22 @@ import (
1212
v2 "github.com/device-management-toolkit/console/internal/controller/httpapi/v2"
1313
openapi "github.com/device-management-toolkit/console/internal/controller/openapi"
1414
"github.com/device-management-toolkit/console/internal/usecase"
15+
"github.com/device-management-toolkit/console/pkg/db"
1516
"github.com/device-management-toolkit/console/pkg/logger"
17+
redfish "github.com/device-management-toolkit/console/redfish"
1618
)
1719

18-
// NewRouter -.
19-
func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases, cfg *config.Config) {
20+
// NewRouter sets up the HTTP router with redfish support.
21+
func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases, cfg *config.Config, database *db.SQL) {
2022
// Options
2123
handler.Use(gin.Logger())
2224
handler.Use(gin.Recovery())
2325

26+
// Initialize redfish directly
27+
if err := redfish.Initialize(handler, l, database, &t, cfg); err != nil {
28+
l.Fatal("Failed to initialize redfish: " + err.Error())
29+
}
30+
2431
// Initialize Fuego adapter
2532
fuegoAdapter := openapi.NewFuegoAdapter(t, l)
2633
fuegoAdapter.RegisterRoutes()
@@ -72,4 +79,9 @@ func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases, cfg
7279
{
7380
v2.NewAmtRoutes(h3, t.Devices, l)
7481
}
82+
83+
// Register redfish routes directly
84+
if err := redfish.RegisterRoutes(handler, l); err != nil {
85+
l.Fatal("Failed to register redfish routes: " + err.Error())
86+
}
7587
}

0 commit comments

Comments
 (0)