Skip to content

Commit

Permalink
Expose ManagersProvidingService link from service root
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsli committed Nov 11, 2024
1 parent 5c1df48 commit 594ab4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions serviceroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ type Service struct {

// Sessions shall contain the link to a collection of Sessions.
sessions string
// ManagerProvidingService shall contain a link to a resource of type Manager that represents the manager providing
// ManagerProvidingServiceLink shall contain a link to a resource of type Manager that represents the manager providing
// this Redfish service.
managerProvidingService string
ManagerProvidingServiceLink string
}

// UnmarshalJSON unmarshals a Service object from the raw JSON.
Expand Down Expand Up @@ -277,7 +277,7 @@ func (serviceroot *Service) UnmarshalJSON(b []byte) error {
serviceroot.updateService = t.UpdateService.String()

serviceroot.sessions = t.Links.Sessions.String()
serviceroot.managerProvidingService = t.Links.ManagerProvidingService.String()
serviceroot.ManagerProvidingServiceLink = t.Links.ManagerProvidingService.String()

return nil
}
Expand Down Expand Up @@ -474,10 +474,10 @@ func (serviceroot *Service) CreateSession(username, password string) (*redfish.A

// ManagerProvidingService gets the manager for this Redfish service.
func (serviceroot *Service) ManagerProvidingService() (*redfish.Manager, error) {
if serviceroot.managerProvidingService == "" {
if serviceroot.ManagerProvidingServiceLink == "" {
return nil, nil
}
return redfish.GetManager(serviceroot.GetClient(), serviceroot.managerProvidingService)
return redfish.GetManager(serviceroot.GetClient(), serviceroot.ManagerProvidingServiceLink)
}

// PowerEquipment gets the powerEquipment instances of this service.
Expand Down
7 changes: 7 additions & 0 deletions serviceroot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ var serviceRootBody = strings.NewReader(
"@odata.id": "/redfish/v1/JsonSchemas"
},
"Links": {
"ManagerProvidingService": {
"@odata.id": "/redfish/v1/Managers/1"
},
"Sessions": {
"@odata.id": "/redfish/v1/Sessions"
}
Expand Down Expand Up @@ -195,6 +198,10 @@ func TestServiceRoot(t *testing.T) {
if result.updateService != "/redfish/v1/UpdateService" {
t.Errorf("Invalid UpdateService link: %s", result.updateService)
}

if result.ManagerProvidingServiceLink != "/redfish/v1/Managers/1" {
t.Errorf("Invalid ManagerProvidingService link: %s", result.ManagerProvidingServiceLink)
}
}

const oem = `{
Expand Down

0 comments on commit 594ab4b

Please sign in to comment.