Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit effdfba

Browse files
author
root
committed
Support Firmware Interface
* Driver updated to support - default_firmware_interface and enabled_firmware_interfaces * Node updated to support - firmware_interface field can be specified - List the Firmware Components requires API 1.86
1 parent 1fcb806 commit effdfba

File tree

7 files changed

+138
-0
lines changed

7 files changed

+138
-0
lines changed

openstack/baremetal/v1/drivers/results.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ type Driver struct {
5151
// if no deploy interface is specified for the node.
5252
DefaultDeployInterface string `json:"default_deploy_interface"`
5353

54+
// The default firmware interface used for a node with a dynamic driver,
55+
// if no firmware interface is specified for the node.
56+
DefaultFirmwareInterface string `json:"default_firmware_interface"`
57+
5458
// The default inspection interface used for a node with a dynamic driver,
5559
// if no inspection interface is specified for the node.
5660
DefaultInspectInterface string `json:"default_inspect_interface"`
@@ -95,6 +99,9 @@ type Driver struct {
9599
// The enabled deploy interfaces for this driver.
96100
EnabledDeployInterfaces []string `json:"enabled_deploy_interfaces"`
97101

102+
// The enabled firmware interfaces for this driver.
103+
EnabledFirmwareInterfaces []string `json:"enabled_firmware_interfaces"`
104+
98105
// The enabled inspection interfaces for this driver.
99106
EnabledInspectInterfaces []string `json:"enabled_inspect_interfaces"`
100107

openstack/baremetal/v1/drivers/testing/fixtures.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ const SingleDriverDetails = `
104104
"default_boot_interface": "pxe",
105105
"default_console_interface": "no-console",
106106
"default_deploy_interface": "iscsi",
107+
"default_firmware_interface": "no-firmware",
107108
"default_inspect_interface": "no-inspect",
108109
"default_management_interface": "ipmitool",
109110
"default_network_interface": "flat",
@@ -125,6 +126,9 @@ const SingleDriverDetails = `
125126
"iscsi",
126127
"direct"
127128
],
129+
"enabled_firmware_interfaces": [
130+
"no-firmware"
131+
],
128132
"enabled_inspect_interfaces": [
129133
"no-inspect"
130134
],
@@ -281,6 +285,7 @@ var (
281285
DefaultBootInterface: "pxe",
282286
DefaultConsoleInterface: "no-console",
283287
DefaultDeployInterface: "iscsi",
288+
DefaultFirmwareInterface: "no-firmware",
284289
DefaultInspectInterface: "no-inspect",
285290
DefaultManagementInterface: "ipmitool",
286291
DefaultNetworkInterface: "flat",
@@ -293,6 +298,7 @@ var (
293298
EnabledBootInterfaces: []string{"pxe"},
294299
EnabledConsoleInterface: []string{"no-console"},
295300
EnabledDeployInterfaces: []string{"iscsi", "direct"},
301+
EnabledFirmwareInterfaces: []string{"no-firmware"},
296302
EnabledInspectInterfaces: []string{"no-inspect"},
297303
EnabledManagementInterfaces: []string{"ipmitool"},
298304
EnabledNetworkInterfaces: []string{"flat", "noop"},

openstack/baremetal/v1/nodes/requests.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ type CreateOpts struct {
211211
// A set of one or more arbitrary metadata key and value pairs.
212212
Extra map[string]interface{} `json:"extra,omitempty"`
213213

214+
// The firmware interface for a node, e.g. "redfish"
215+
FirmwareInterface string `json:"firmware_interface,omitempty"`
216+
214217
// The interface used for node inspection, e.g. “no-inspect”.
215218
InspectInterface string `json:"inspect_interface,omitempty"`
216219

@@ -889,3 +892,12 @@ func GetInventory(client *gophercloud.ServiceClient, id string) (r InventoryResu
889892
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
890893
return
891894
}
895+
896+
// ListFirmware return the list of Firmware components for the given Node.
897+
func ListFirmware(client *gophercloud.ServiceClient, id string) (r ListFirmwareResult) {
898+
resp, err := client.Get(firmwareListURL(client, id), &r.Body, &gophercloud.RequestOpts{
899+
OkCodes: []int{200},
900+
})
901+
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
902+
return
903+
}

openstack/baremetal/v1/nodes/results.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ type Node struct {
199199
// Deploy interface for a node, e.g. “iscsi”.
200200
DeployInterface string `json:"deploy_interface"`
201201

202+
// Firmware interface for a node, e.g. “redfish”.
203+
FirmwareInterface string `json:"firmware_interface"`
204+
202205
// Interface used for node inspection, e.g. “no-inspect”.
203206
InspectInterface string `json:"inspect_interface"`
204207

@@ -405,6 +408,7 @@ type NodeValidation struct {
405408
Boot DriverValidation `json:"boot"`
406409
Console DriverValidation `json:"console"`
407410
Deploy DriverValidation `json:"deploy"`
411+
Firmware DriverValidation `json:"firmware"`
408412
Inspect DriverValidation `json:"inspect"`
409413
Management DriverValidation `json:"management"`
410414
Network DriverValidation `json:"network"`
@@ -606,3 +610,35 @@ func (r InventoryResult) Extract() (*InventoryData, error) {
606610
err := r.ExtractInto(&data)
607611
return &data, err
608612
}
613+
614+
// ListFirmwareResult is the response from a ListFirmware operation. Call its Extract method
615+
// to interpret it as an array of FirmwareComponent structs.
616+
type ListFirmwareResult struct {
617+
gophercloud.Result
618+
}
619+
620+
// A particular Firmware Component for a node
621+
type FirmwareComponent struct {
622+
// The UTC date and time when the resource was created, ISO 8601 format.
623+
CreatedAt time.Time `json:"created_at"`
624+
// The UTC date and time when the resource was updated, ISO 8601 format. May be “null”.
625+
UpdatedAt *time.Time `json:"updated_at"`
626+
// The Component name
627+
Component string `json:"component"`
628+
// The initial version of the firmware component.
629+
InitialVersion string `json:"initial_version"`
630+
// The current version of the firmware component.
631+
CurrentVersion string `json:"current_version"`
632+
// The last firmware version updated for the component.
633+
LastVersionFlashed *string `json:"last_version_flashed"`
634+
}
635+
636+
// Extract interprets a ListFirmwareResult as an array of FirmwareComponent structs, if possible.
637+
func (r ListFirmwareResult) Extract() ([]FirmwareComponent, error) {
638+
var s struct {
639+
Components []FirmwareComponent `json:"firmware"`
640+
}
641+
642+
err := r.ExtractInto(&s)
643+
return s.Components, err
644+
}

openstack/baremetal/v1/nodes/testing/fixtures.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ const NodeListDetailBody = `
100100
"driver_internal_info": {},
101101
"extra": {},
102102
"fault": null,
103+
"firmware_interface": "no-firmware",
103104
"inspect_interface": "no-inspect",
104105
"inspection_finished_at": null,
105106
"inspection_started_at": null,
@@ -404,6 +405,7 @@ const SingleNodeBody = `
404405
"driver_internal_info": {},
405406
"extra": {},
406407
"fault": null,
408+
"firmwrae_interface": "no-firmware",
407409
"inspect_interface": "no-inspect",
408410
"inspection_finished_at": null,
409411
"inspection_started_at": null,
@@ -504,6 +506,10 @@ const NodeValidationBody = `
504506
"reason": "Cannot validate image information for node a62b8495-52e2-407b-b3cb-62775d04c2b8 because one or more parameters are missing from its instance_info and insufficent information is present to boot from a remote volume. Missing are: ['ramdisk', 'kernel', 'image_source']",
505507
"result": false
506508
},
509+
"firmware": {
510+
"reason": "Driver ipmi does not support firmware (disabled or no implemented).",
511+
"result": false
512+
},
507513
"inspect": {
508514
"reason": "Driver ipmi does not support inspect (disabled or not implemented).",
509515
"result": false
@@ -828,6 +834,29 @@ var NodeInventoryBody = fmt.Sprintf(`
828834
}
829835
`, inventorytest.InventorySample)
830836

837+
const NodeFirmwareListBody = `
838+
{
839+
"firmware": [
840+
{
841+
"created_at": "2023-10-03T18:30:00+00:00",
842+
"updated_at": null,
843+
"component": "bios",
844+
"initial_version": "U30 v2.36 (07/16/2020)",
845+
"current_version": "U30 v2.36 (07/16/2020)",
846+
"last_version_flashed": null
847+
},
848+
{
849+
"created_at": "2023-10-03T18:30:00+00:00",
850+
"updated_at": "2023-10-03T18:45:54+00:00",
851+
"component": "bmc",
852+
"initial_version": "iLO 5 v2.78",
853+
"current_version": "iLO 5 v2.81",
854+
"last_version_flashed": "iLO 5 v2.81"
855+
}
856+
]
857+
}
858+
`
859+
831860
var (
832861
createdAtFoo, _ = time.Parse(time.RFC3339, "2019-01-31T19:59:28+00:00")
833862
createdAtBar, _ = time.Parse(time.RFC3339, "2019-01-31T19:59:29+00:00")
@@ -872,6 +901,7 @@ var (
872901
BootInterface: "pxe",
873902
ConsoleInterface: "no-console",
874903
DeployInterface: "iscsi",
904+
FirmwareInterface: "no-firmware",
875905
InspectInterface: "no-inspect",
876906
ManagementInterface: "ipmitool",
877907
NetworkInterface: "flat",
@@ -1192,6 +1222,28 @@ var (
11921222
NodeInventoryData = nodes.InventoryData{
11931223
Inventory: inventorytest.Inventory,
11941224
}
1225+
1226+
createdAtFirmware, _ = time.Parse(time.RFC3339, "2023-10-03T18:30:00+00:00")
1227+
updatedAtFirmware, _ = time.Parse(time.RFC3339, "2023-10-03T18:45:54+00:00")
1228+
lastVersion = "iLO 5 v2.81"
1229+
NodeFirmwareList = []nodes.FirmwareComponent{
1230+
{
1231+
CreatedAt: createdAtFirmware,
1232+
UpdatedAt: nil,
1233+
Component: "bios",
1234+
InitialVersion: "U30 v2.36 (07/16/2020)",
1235+
CurrentVersion: "U30 v2.36 (07/16/2020)",
1236+
LastVersionFlashed: nil,
1237+
},
1238+
{
1239+
CreatedAt: createdAtFirmware,
1240+
UpdatedAt: &updatedAtFirmware,
1241+
Component: "bmc",
1242+
InitialVersion: "iLO 5 v2.78",
1243+
CurrentVersion: "iLO 5 v2.81",
1244+
LastVersionFlashed: &lastVersion,
1245+
},
1246+
}
11951247
)
11961248

11971249
// HandleNodeListSuccessfully sets up the test server to respond to a server List request.
@@ -1597,3 +1649,13 @@ func HandleGetInventorySuccessfully(t *testing.T) {
15971649
fmt.Fprintf(w, NodeInventoryBody)
15981650
})
15991651
}
1652+
1653+
// HandleListFirmware
1654+
func HandleListFirmwareSuccessfully(t *testing.T) {
1655+
th.Mux.HandleFunc("/nodes/1234asdf/firmware", func(w http.ResponseWriter, r *http.Request) {
1656+
th.TestMethod(t, r, "GET")
1657+
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
1658+
w.WriteHeader(http.StatusOK)
1659+
fmt.Fprintf(w, NodeFirmwareListBody)
1660+
})
1661+
}

openstack/baremetal/v1/nodes/testing/requests_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,3 +730,14 @@ func TestGetInventory(t *testing.T) {
730730
th.AssertNoErr(t, err)
731731
th.AssertEquals(t, "x86_64", compatData.CPUArch)
732732
}
733+
734+
func TestListFirmware(t *testing.T) {
735+
th.SetupHTTP()
736+
defer th.TeardownHTTP()
737+
HandleListFirmwareSuccessfully(t)
738+
739+
c := client.ServiceClient()
740+
actual, err := nodes.ListFirmware(c, "1234asdf").Extract()
741+
th.AssertNoErr(t, err)
742+
th.CheckDeepEquals(t, NodeFirmwareList, actual)
743+
}

openstack/baremetal/v1/nodes/urls.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@ func maintenanceURL(client *gophercloud.ServiceClient, id string) string {
8181
func inventoryURL(client *gophercloud.ServiceClient, id string) string {
8282
return client.ServiceURL("nodes", id, "inventory")
8383
}
84+
85+
func firmwareListURL(client *gophercloud.ServiceClient, id string) string {
86+
return client.ServiceURL("nodes", id, "firmware")
87+
}

0 commit comments

Comments
 (0)