-
Notifications
You must be signed in to change notification settings - Fork 120
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
added the ability to take networkDeviceFunctions, pcieDevices and networkPorts from Controller #301
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -75,9 +75,11 @@ type ControllerCapabilities struct { | |
} | ||
} | ||
|
||
// Controllers shall describe a network controller ASIC that makes up part of a | ||
// Controller shall describe a network controller ASIC that makes up part of a | ||
// NetworkAdapter. | ||
type Controllers struct { | ||
type Controller struct { | ||
common.Entity | ||
|
||
// ControllerCapabilities shall contain the capabilities of this controller. | ||
ControllerCapabilities ControllerCapabilities | ||
// FirmwarePackageVersion shall be the version number of the user-facing | ||
|
@@ -109,15 +111,15 @@ type Controllers struct { | |
PCIeDevicesCount int | ||
} | ||
|
||
// UnmarshalJSON unmarshals a Controllers object from the raw JSON. | ||
func (controllers *Controllers) UnmarshalJSON(b []byte) error { | ||
type temp Controllers | ||
// UnmarshalJSON unmarshals a Controller object from the raw JSON. | ||
func (controller *Controller) UnmarshalJSON(b []byte) error { | ||
type temp Controller | ||
type links struct { | ||
NetworkPorts common.Links | ||
NetworkPortsCount int `json:"[email protected]"` | ||
NetworkDeviceFunctions common.Links | ||
NetworkDeviceFunctionsCount int `json:"[email protected]"` | ||
PCIeDevice common.Link | ||
PCIeDevices common.Links | ||
PCIeDevicesCount int `json:"[email protected]"` | ||
} | ||
|
||
|
@@ -132,17 +134,80 @@ func (controllers *Controllers) UnmarshalJSON(b []byte) error { | |
} | ||
|
||
// Extract the links to other entities for later | ||
*controllers = Controllers(t.temp) | ||
controllers.networkPorts = t.Links.NetworkPorts.ToStrings() | ||
controllers.NetworkPortsCount = t.Links.NetworkPortsCount | ||
controllers.networkDeviceFunctions = t.Links.NetworkDeviceFunctions.ToStrings() | ||
controllers.NetworkDeviceFunctionsCount = t.Links.NetworkDeviceFunctionsCount | ||
controllers.pcieDevices = t.Links.NetworkDeviceFunctions.ToStrings() | ||
controllers.PCIeDevicesCount = t.Links.NetworkDeviceFunctionsCount | ||
*controller = Controller(t.temp) | ||
controller.networkPorts = t.Links.NetworkPorts.ToStrings() | ||
controller.NetworkPortsCount = t.Links.NetworkPortsCount | ||
controller.networkDeviceFunctions = t.Links.NetworkDeviceFunctions.ToStrings() | ||
controller.NetworkDeviceFunctionsCount = t.Links.NetworkDeviceFunctionsCount | ||
controller.pcieDevices = t.Links.PCIeDevices.ToStrings() | ||
controller.PCIeDevicesCount = t.Links.NetworkDeviceFunctionsCount | ||
|
||
return nil | ||
} | ||
|
||
// PCIeDevices gets all PCIeDevices for this controller. | ||
func (controller *Controller) PCIeDevices() ([]*PCIeDevice, error) { | ||
var result []*PCIeDevice | ||
|
||
collectionError := common.NewCollectionError() | ||
for _, pciedeviceLink := range controller.pcieDevices { | ||
pciedevice, err := GetPCIeDevice(controller.GetClient(), pciedeviceLink) | ||
if err != nil { | ||
collectionError.Failures[pciedeviceLink] = err | ||
} else { | ||
result = append(result, pciedevice) | ||
} | ||
} | ||
|
||
if collectionError.Empty() { | ||
return result, nil | ||
} | ||
|
||
return result, collectionError | ||
} | ||
|
||
// NetworkDeviceFunction gets all NetworkDeviceFunction for this controller. | ||
func (controller *Controller) NetworkDeviceFunctions() ([]*NetworkDeviceFunction, error) { | ||
var result []*NetworkDeviceFunction | ||
|
||
collectionError := common.NewCollectionError() | ||
for _, networkDeviceLink := range controller.networkDeviceFunctions { | ||
networkDeviceFunction, err := GetNetworkDeviceFunction(controller.GetClient(), networkDeviceLink) | ||
if err != nil { | ||
collectionError.Failures[networkDeviceLink] = err | ||
} else { | ||
result = append(result, networkDeviceFunction) | ||
} | ||
} | ||
|
||
if collectionError.Empty() { | ||
return result, nil | ||
} | ||
|
||
return result, collectionError | ||
} | ||
|
||
// NetworkPorts gets all NetworkPorts for this controller. | ||
func (controller *Controller) NetworkPorts() ([]*NetworkPort, error) { | ||
var result []*NetworkPort | ||
|
||
collectionError := common.NewCollectionError() | ||
for _, networkPortLink := range controller.networkPorts { | ||
networkPort, err := GetNetworkPort(controller.GetClient(), networkPortLink) | ||
if err != nil { | ||
collectionError.Failures[networkPortLink] = err | ||
} else { | ||
result = append(result, networkPort) | ||
} | ||
} | ||
|
||
if collectionError.Empty() { | ||
return result, nil | ||
} | ||
|
||
return result, collectionError | ||
} | ||
|
||
// DataCenterBridging shall describe the capability, status, | ||
// and configuration values related to Data Center Bridging (DCB) for a | ||
// controller. | ||
|
@@ -176,9 +241,9 @@ type NetworkAdapter struct { | |
ODataType string `json:"@odata.type"` | ||
// Assembly shall be a link to a resource of type Assembly. | ||
assembly string | ||
// Controllers shall contain the set of network controllers ASICs that make | ||
// Controller shall contain the set of network controllers ASICs that make | ||
// up this NetworkAdapter. | ||
Controllers []Controllers | ||
controllers []*Controller | ||
// Description provides a description of this resource. | ||
Description string | ||
// Manufacturer shall contain a value that represents the manufacturer of | ||
|
@@ -218,6 +283,7 @@ func (networkadapter *NetworkAdapter) UnmarshalJSON(b []byte) error { | |
Assembly common.Link | ||
NetworkDeviceFunctions common.Link | ||
NetworkPorts common.Link | ||
Controllers []*Controller | ||
Actions actions | ||
} | ||
|
||
|
@@ -232,7 +298,7 @@ func (networkadapter *NetworkAdapter) UnmarshalJSON(b []byte) error { | |
networkadapter.networkDeviceFunctions = t.NetworkDeviceFunctions.String() | ||
networkadapter.networkPorts = t.NetworkPorts.String() | ||
networkadapter.resetSettingsToDefaultTarget = t.Actions.ResetSettingsToDefault.Target | ||
|
||
networkadapter.controllers = t.Controllers | ||
return nil | ||
} | ||
|
||
|
@@ -308,3 +374,10 @@ func (networkadapter *NetworkAdapter) NetworkPorts() ([]*NetworkPort, error) { | |
func (networkadapter *NetworkAdapter) ResetSettingsToDefault() error { | ||
return networkadapter.Post(networkadapter.resetSettingsToDefaultTarget, nil) | ||
} | ||
|
||
func (networkadapter *NetworkAdapter) Controllers() []*Controller { | ||
for i := range networkadapter.controllers { | ||
networkadapter.controllers[i].SetClient(networkadapter.GetClient()) | ||
} | ||
return networkadapter.controllers | ||
} |
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 |
---|---|---|
|
@@ -52,11 +52,7 @@ var networkAdapterBody = strings.NewReader( | |
"[email protected]": 1, | ||
"NetworkPorts": [{ | ||
"@odata.id": "/redfish/v1/NetworkAdapters/Port-1" | ||
}, | ||
{ | ||
"@odata.id": "/redfish/v1/NetworkAdapters/Port-2" | ||
} | ||
], | ||
}], | ||
"[email protected]": 2, | ||
"PCIeDevices": [{ | ||
"@odata.id": "/redfish/v1/NetworkAdapters/PCIeDevice-1" | ||
|
@@ -108,21 +104,31 @@ func TestNetworkAdapter(t *testing.T) { | |
t.Errorf("Received invalid name: %s", result.Name) | ||
} | ||
|
||
if !result.Controllers[0].ControllerCapabilities.DataCenterBridging.Capable { | ||
stmcginnis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if !result.controllers[0].ControllerCapabilities.DataCenterBridging.Capable { | ||
t.Error("DCB should be enabled") | ||
} | ||
|
||
if result.Controllers[0].ControllerCapabilities.NPIV.MaxDeviceLogins != 1024 { | ||
if result.controllers[0].ControllerCapabilities.NPIV.MaxDeviceLogins != 1024 { | ||
t.Errorf("Received incorrect Controller NPIC max device logins: %d", | ||
result.Controllers[0].ControllerCapabilities.NPIV.MaxDeviceLogins) | ||
result.controllers[0].ControllerCapabilities.NPIV.MaxDeviceLogins) | ||
} | ||
|
||
if result.controllers[0].PCIeInterface.MaxPCIeType != Gen4PCIeTypes { | ||
t.Errorf("Received incorrect max PCIe type: %s", result.controllers[0].PCIeInterface.MaxPCIeType) | ||
} | ||
|
||
if result.Controllers[0].PCIeInterface.MaxPCIeType != Gen4PCIeTypes { | ||
t.Errorf("Received incorrect max PCIe type: %s", result.Controllers[0].PCIeInterface.MaxPCIeType) | ||
if result.controllers[0].PCIeInterface.PCIeType != Gen4PCIeTypes { | ||
t.Errorf("Received incorrect PCIe type: %s", result.controllers[0].PCIeInterface.PCIeType) | ||
} | ||
|
||
if result.Controllers[0].PCIeInterface.PCIeType != Gen4PCIeTypes { | ||
t.Errorf("Received incorrect PCIe type: %s", result.Controllers[0].PCIeInterface.PCIeType) | ||
if PCIeTypes(result.controllers[0].pcieDevices[0]) != "/redfish/v1/NetworkAdapters/PCIeDevice-1" { | ||
t.Errorf("Received incorrect PCIeDevice Link: %s", "/redfish/v1/NetworkAdapters/PCIeDevice-1") | ||
} | ||
if PCIeTypes(result.controllers[0].networkPorts[0]) != "/redfish/v1/NetworkAdapters/Port-1" { | ||
t.Errorf("Received incorrect NetworkPorts Link: %s", "/redfish/v1/NetworkAdapters/Port-1") | ||
} | ||
if PCIeTypes(result.controllers[0].networkDeviceFunctions[0]) != "/redfish/v1/NetworkAdapters/DeviceFunction-1" { | ||
t.Errorf("Received incorrect NetworkDeviceFunctions Link: %s", "/redfish/v1/NetworkAdapters/DeviceFunction-1") | ||
} | ||
|
||
if result.resetSettingsToDefaultTarget != "/redfish/v1/NetworkAdapter/Actions/NetworkAdapter.ResetSettingsToDefault" { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little concerned about changing the existing struct name in case someone is explicitly defining a variable type with it. But I think that is a low risk.
The bigger issue is
Controller
is not a top level API object, so it does not include thecommon.Entity
properties. If you are seeing a system adding this, they may not be following the actual spec for the object.https://redfish.dmtf.org/schemas/v1/NetworkAdapter.v1_10_0.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the unit tests. This still needs to be addressed though. Is that something you are able to do?