Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ManagersProvidingService link from service root #382

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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