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

Skip to content

Commit 0242dd7

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 0242dd7

File tree

8 files changed

+152
-4
lines changed

8 files changed

+152
-4
lines changed

internal/acceptance/openstack/baremetal/v1/baremetal.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ func CreateNode(t *testing.T, client *gophercloud.ServiceClient) (*nodes.Node, e
1616
t.Logf("Attempting to create bare metal node: %s", name)
1717

1818
node, err := nodes.Create(client, nodes.CreateOpts{
19-
Name: name,
20-
Driver: "ipmi",
21-
BootInterface: "ipxe",
22-
RAIDInterface: "agent",
19+
Name: name,
20+
Driver: "ipmi",
21+
BootInterface: "ipxe",
22+
FirmwareInterface: "no-firmware",
23+
RAIDInterface: "agent",
2324
DriverInfo: map[string]interface{}{
2425
"ipmi_port": "6230",
2526
"ipmi_username": "admin",

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: 13 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

@@ -411,6 +414,7 @@ type StepInterface string
411414
const (
412415
InterfaceBIOS StepInterface = "bios"
413416
InterfaceDeploy StepInterface = "deploy"
417+
InterfaceFirmware StepInterface = "firmware"
414418
InterfaceManagement StepInterface = "management"
415419
InterfacePower StepInterface = "power"
416420
InterfaceRAID StepInterface = "raid"
@@ -889,3 +893,12 @@ func GetInventory(client *gophercloud.ServiceClient, id string) (r InventoryResu
889893
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
890894
return
891895
}
896+
897+
// ListFirmware return the list of Firmware components for the given Node.
898+
func ListFirmware(client *gophercloud.ServiceClient, id string) (r ListFirmwareResult) {
899+
resp, err := client.Get(firmwareListURL(client, id), &r.Body, &gophercloud.RequestOpts{
900+
OkCodes: []int{200},
901+
})
902+
_, r.Header, r.Err = gophercloud.ParseResponse(resp, err)
903+
return
904+
}

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: 69 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+
"firmware_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 not 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",
@@ -906,6 +936,10 @@ var (
906936
Result: false,
907937
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']",
908938
},
939+
Firmware: nodes.DriverValidation{
940+
Result: false,
941+
Reason: "Driver ipmi does not support firmware (disabled or not implemented).",
942+
},
909943
Inspect: nodes.DriverValidation{
910944
Result: false,
911945
Reason: "Driver ipmi does not support inspect (disabled or not implemented).",
@@ -975,6 +1009,7 @@ var (
9751009
BootInterface: "pxe",
9761010
ConsoleInterface: "no-console",
9771011
DeployInterface: "iscsi",
1012+
FirmwareInterface: "no-firmware",
9781013
InspectInterface: "no-inspect",
9791014
ManagementInterface: "ipmitool",
9801015
NetworkInterface: "flat",
@@ -1023,6 +1058,7 @@ var (
10231058
BootInterface: "pxe",
10241059
ConsoleInterface: "no-console",
10251060
DeployInterface: "iscsi",
1061+
FirmwareInterface: "no-firmware",
10261062
InspectInterface: "no-inspect",
10271063
ManagementInterface: "ipmitool",
10281064
NetworkInterface: "flat",
@@ -1192,6 +1228,28 @@ var (
11921228
NodeInventoryData = nodes.InventoryData{
11931229
Inventory: inventorytest.Inventory,
11941230
}
1231+
1232+
createdAtFirmware, _ = time.Parse(time.RFC3339, "2023-10-03T18:30:00+00:00")
1233+
updatedAtFirmware, _ = time.Parse(time.RFC3339, "2023-10-03T18:45:54+00:00")
1234+
lastVersion = "iLO 5 v2.81"
1235+
NodeFirmwareList = []nodes.FirmwareComponent{
1236+
{
1237+
CreatedAt: createdAtFirmware,
1238+
UpdatedAt: nil,
1239+
Component: "bios",
1240+
InitialVersion: "U30 v2.36 (07/16/2020)",
1241+
CurrentVersion: "U30 v2.36 (07/16/2020)",
1242+
LastVersionFlashed: nil,
1243+
},
1244+
{
1245+
CreatedAt: createdAtFirmware,
1246+
UpdatedAt: &updatedAtFirmware,
1247+
Component: "bmc",
1248+
InitialVersion: "iLO 5 v2.78",
1249+
CurrentVersion: "iLO 5 v2.81",
1250+
LastVersionFlashed: &lastVersion,
1251+
},
1252+
}
11951253
)
11961254

11971255
// HandleNodeListSuccessfully sets up the test server to respond to a server List request.
@@ -1244,6 +1302,7 @@ func HandleNodeCreationSuccessfully(t *testing.T, response string) {
12441302
"ipmi_port": "6230",
12451303
"ipmi_username": "admin"
12461304
},
1305+
"firmware_interface": "no-firmware",
12471306
"name": "foo"
12481307
}`)
12491308

@@ -1597,3 +1656,13 @@ func HandleGetInventorySuccessfully(t *testing.T) {
15971656
fmt.Fprintf(w, NodeInventoryBody)
15981657
})
15991658
}
1659+
1660+
// HandleListFirmware
1661+
func HandleListFirmwareSuccessfully(t *testing.T) {
1662+
th.Mux.HandleFunc("/nodes/1234asdf/firmware", func(w http.ResponseWriter, r *http.Request) {
1663+
th.TestMethod(t, r, "GET")
1664+
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
1665+
w.WriteHeader(http.StatusOK)
1666+
fmt.Fprintf(w, NodeFirmwareListBody)
1667+
})
1668+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func TestCreateNode(t *testing.T) {
104104
"deploy_ramdisk": "http://172.22.0.1/images/tinyipa-stable-rocky.gz",
105105
"ipmi_password": "admin",
106106
},
107+
FirmwareInterface: "no-firmware",
107108
}).Extract()
108109
th.AssertNoErr(t, err)
109110

@@ -730,3 +731,14 @@ func TestGetInventory(t *testing.T) {
730731
th.AssertNoErr(t, err)
731732
th.AssertEquals(t, "x86_64", compatData.CPUArch)
732733
}
734+
735+
func TestListFirmware(t *testing.T) {
736+
th.SetupHTTP()
737+
defer th.TeardownHTTP()
738+
HandleListFirmwareSuccessfully(t)
739+
740+
c := client.ServiceClient()
741+
actual, err := nodes.ListFirmware(c, "1234asdf").Extract()
742+
th.AssertNoErr(t, err)
743+
th.CheckDeepEquals(t, NodeFirmwareList, actual)
744+
}

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)