-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose manager's Links object to allow caller to further process
Signed-off-by: Leslie Qi Wang <[email protected]>
- Loading branch information
1 parent
42c14ec
commit e74245f
Showing
3 changed files
with
76 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,10 @@ type Manager struct { | |
// ManagerNetworkProtocol which represents the network services for this | ||
// manager. | ||
networkProtocol string | ||
// OEMData are all OEM data under top level manager section | ||
OEMData map[string]interface{} | ||
// OEMLinks are all OEM data under link section | ||
OEMLinks map[string]interface{} | ||
// PartNumber shall contain a part number assigned by the organization that | ||
// is responsible for producing or manufacturing the manager. | ||
PartNumber string | ||
|
@@ -304,6 +308,7 @@ func (manager *Manager) UnmarshalJSON(b []byte) error { | |
ManagerForSwitches common.Links | ||
ManagerForSwitchesCount int `json:"[email protected]"` | ||
ManagerInChassis common.Link | ||
OEM map[string]interface{} `json:"Oem"` | ||
} | ||
var t struct { | ||
temp | ||
|
@@ -315,6 +320,7 @@ func (manager *Manager) UnmarshalJSON(b []byte) error { | |
VirtualMedia common.Link | ||
Links linkReference | ||
Actions actions | ||
OEM map[string]interface{} `json:"Oem"` | ||
} | ||
|
||
err := json.Unmarshal(b, &t) | ||
|
@@ -327,6 +333,8 @@ func (manager *Manager) UnmarshalJSON(b []byte) error { | |
manager.ethernetInterfaces = string(t.EthernetInterfaces) | ||
manager.logServices = string(t.LogServices) | ||
manager.networkProtocol = string(t.NetworkProtocol) | ||
manager.OEMData = t.OEM | ||
manager.OEMLinks = t.Links.OEM | ||
manager.remoteAccountService = string(t.RemoteAccountService) | ||
manager.serialInterfaces = string(t.SerialInterfaces) | ||
manager.virtualMedia = string(t.VirtualMedia) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,46 @@ package redfish | |
|
||
import ( | ||
"encoding/json" | ||
"github.com/stmcginnis/gofish/common" | ||
"reflect" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stmcginnis/gofish/common" | ||
) | ||
|
||
var oemLinksBody = ` | ||
{ | ||
"Dell": { | ||
"DellAttributes": [ | ||
{ | ||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Attributes" | ||
}, | ||
{ | ||
"@odata.id": "/redfish/v1/Managers/System.Embedded.1/Attributes" | ||
}, | ||
{ | ||
"@odata.id": "/redfish/v1/Managers/LifecycleController.Embedded.1/Attributes" | ||
} | ||
], | ||
"[email protected]": 3, | ||
"DellTimeService": { | ||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/DellTimeService" | ||
} | ||
} | ||
} | ||
` | ||
var oemDataBody = ` | ||
{ | ||
"Dell": { | ||
"DelliDRACCard": { | ||
"@odata.context": "/redfish/v1/$metadata#DelliDRACCard.DelliDRACCard", | ||
"@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/DelliDRACCard/iDRAC.Embedded.1-1_0x23_IDRACinfo", | ||
"@odata.type": "#DelliDRACCard.v1_1_0.DelliDRACCard", | ||
"IPMIVersion": "2.0", | ||
"URLString": "https://10.5.1.83:443" | ||
} | ||
} | ||
} | ||
` | ||
var managerBody = `{ | ||
"@Redfish.Copyright": "Copyright 2014-2019 DMTF. All rights reserved.", | ||
"@odata.context": "/redfish/v1/$metadata#Manager.Manager", | ||
|
@@ -92,8 +126,10 @@ var managerBody = `{ | |
], | ||
"ManagerInChassis": { | ||
"@odata.id": "/redfish/v1/Chassis/Chassis-1" | ||
} | ||
}, | ||
}, | ||
"Oem": | ||
` + oemLinksBody + | ||
` }, | ||
"Actions": { | ||
"#Manager.Reset": { | ||
"target": "/redfish/v1/Managers/BMC-1/Actions/Manager.Reset", | ||
|
@@ -102,8 +138,10 @@ var managerBody = `{ | |
"GracefulRestart" | ||
] | ||
} | ||
} | ||
}` | ||
}, | ||
"Oem": | ||
` + oemDataBody + | ||
` }` | ||
|
||
// TestManager tests the parsing of Manager objects. | ||
func TestManager(t *testing.T) { | ||
|
@@ -146,6 +184,20 @@ func TestManager(t *testing.T) { | |
if result.resetTarget != "/redfish/v1/Managers/BMC-1/Actions/Manager.Reset" { | ||
t.Errorf("Invalid Reset target: %s", result.resetTarget) | ||
} | ||
|
||
var expectedOEM map[string]interface{} | ||
if err := json.Unmarshal([]byte(oemLinksBody), &expectedOEM); err != nil { | ||
t.Errorf("Failed to unmarshall link body: %v", err) | ||
} | ||
if !reflect.DeepEqual(result.OEMLinks, expectedOEM) { | ||
t.Errorf("Invalid OEM Links: %+v", result.OEMLinks) | ||
} | ||
if err := json.Unmarshal([]byte(oemDataBody), &expectedOEM); err != nil { | ||
t.Errorf("Failed to unmarshall data body: %v", err) | ||
} | ||
if !reflect.DeepEqual(result.OEMData, expectedOEM) { | ||
t.Errorf("Invalid OEM Data: %+v", result.OEMData) | ||
} | ||
} | ||
|
||
// TestManagerUpdate tests the Update call. | ||
|