Skip to content

Add support for baremetal bios endpoint#2171

Merged
jtopjian merged 1 commit intogophercloud:masterfrom
bfournie:ironic-bios-endpoint
May 26, 2021
Merged

Add support for baremetal bios endpoint#2171
jtopjian merged 1 commit intogophercloud:masterfrom
bfournie:ironic-bios-endpoint

Conversation

@bfournie
Copy link
Copy Markdown
Contributor

@bfournie bfournie commented May 21, 2021

For #2165.

The baremetal bios endpoint has been available in the Ironic API since
version 1.40 and is documented in the API reference here -
https://docs.openstack.org/api-ref/baremetal/?expanded=#node-bios-nodes.
It provides a list of all bios settings by node or a particular setting on a node.

The ironic API code is here:
https://github.com/openstack/ironic/blob/master/ironic/api/controllers/v1/bios.py#L57

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented May 21, 2021

Build failed.

@coveralls
Copy link
Copy Markdown

coveralls commented May 21, 2021

Coverage Status

Coverage increased (+0.03%) to 79.903% when pulling fb569ec on bfournie:ironic-bios-endpoint into e94bc6d on gophercloud:master.

@zaneb
Copy link
Copy Markdown
Contributor

zaneb commented May 24, 2021

Looks reasonable to me :)

Copy link
Copy Markdown
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bfournie Thanks for submitting this. I've left two comments for review. Please let me know if you have any questions.

var s BIOSSettings
err := r.ExtractInto(&s)
return &s.Settings, err
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you have works, but I think the following version more closely matches other functions within Gophercloud:

// Extract interprets a BIOSSettingsResult as an array of BIOSSetting structs, if possible.
func (r BIOSSettingsResult) Extract() ([]BIOSSetting, error) {
  var s struct {
    Settings []BIOSSetting `json:"bios"`
  }
  err := r.ExtractInto(&s)
  return s.Settings, err
}

You can then remove the BIOSSettings type as it's no longer used.

This change will require an update to the unit tests, but it's a small update.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a good change. Updated.

}

// Get one BIOS Setting for the given Node.
func GetSingleBIOSSetting(client *gophercloud.ServiceClient, id string, setting string) (r SingleBIOSSettingResult) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total nit pick: How about GetBIOSSetting? The use of "Get" (instead of "List") and the singular use of "Setting" implies that a single item will be returned. This is not a required change, though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that naming is more clear. Fixed.

For gophercloud#2165.

The baremetal bios endpoint has been available in the Ironic API since
version 1.40 and is documented in the API reference here -
https://docs.openstack.org/api-ref/baremetal/?expanded=#node-bios-nodes.
It provides a list of all bios settings by node or a particular
setting on a node.

The ironic API code is here:
https://github.com/openstack/ironic/blob/master/ironic/api/controllers/v1/bios.py#L57
@bfournie bfournie force-pushed the ironic-bios-endpoint branch from 3bbc8be to fb569ec Compare May 25, 2021 01:25
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci bot commented May 25, 2021

Build failed.

Copy link
Copy Markdown
Contributor

@jtopjian jtopjian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you!

@jtopjian jtopjian merged commit c093259 into gophercloud:master May 26, 2021
@bfournie bfournie deleted the ironic-bios-endpoint branch May 26, 2021 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants