Skip to content
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

Internal state machine implementation for firmware update #69

Merged
merged 1 commit into from
Jul 12, 2019

Conversation

miha-plesko
Copy link
Contributor

@miha-plesko miha-plesko commented May 30, 2019

Physical Server: Firmware Update

Below please find a complete list of the PRs to support this functionality.

a) Firmware Registry

b) Firmware Update Process


With this commit we implement internal state machine that carries out the firmware update process. We only request a single task no matter the number of servers to update firmware for because Redfish supports such bulk operation.

At this very moment we are not able to poll for update process status yet so we assume it succeeds immediately. Later, when redfish_client gem supports async operation polling, we'll be able to enhance this state machine as well.

Copy link
Contributor

@tadeboro tadeboro left a comment

Choose a reason for hiding this comment

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

The state machine and operation implementations are both fine:yes as far as I am concerned. There are a few minor issues with the Redfish fields that I described in the inline comments, but nothing major.

Thanks for great work this far.

protocol, url = compatible_firmware_url(update_service, firmware_binary)

response = update_service.post(
:path => update_service.Actions['#UpdateService.SimpleUpdate'].target,
Copy link
Contributor

Choose a reason for hiding this comment

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

You can write this as response = update_service.Actions["#UpdateService.SimpleUpdate"].post(:field => "target", ...).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sweet

}
)

if response.status.to_i != 200
Copy link
Contributor

Choose a reason for hiding this comment

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

If the Redfish service started the firmware update operation, it will return status 202, not 200.

And a nitpick: all of the RedfishClient::Responses that are returned by the Redfish client are guaranteed to return integer status, so no need to call to_i here.

update_action = update_service.Actions['#UpdateService.SimpleUpdate']
requested = update_action['TransferProtocol@Redfish.AllowableValues']
requested ||= begin
info = update_action['TransferProtocol@Redfish.ActionInfo'].Parameters.find { |p| p.Name == 'TransferProtocol' }
Copy link
Contributor

Choose a reason for hiding this comment

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

update_action["@Redfish.ActionInfo"] is the action info field name. And some semi-broken implementations provide none of the inspected fields, in which case we will get some nil related exception. We should probably do something like this here:

params = update_action['@Redfish.ActionInfo']&.Parameters || []
params.find { |p| p.Name == 'TransferProtocol' }&.AllowableValues

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh boy, was hoping that server either supports update_action or not. This fine=no :)

info = update_action['TransferProtocol@Redfish.ActionInfo'].Parameters.find { |p| p.Name == 'TransferProtocol' }
info&.AllowableValues
end
raise MiqException::MiqFirmwareUpdateError, 'Redfish supports zero transfer protocols' if requested.empty?
Copy link
Contributor

Choose a reason for hiding this comment

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

requested can be nil if both methods for obtaining supported protocols fail.

Copy link
Contributor Author

@miha-plesko miha-plesko left a comment

Choose a reason for hiding this comment

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

Thanks for a review @tadeboro , you comments actually make sense 👍 :)

protocol, url = compatible_firmware_url(update_service, firmware_binary)

response = update_service.post(
:path => update_service.Actions['#UpdateService.SimpleUpdate'].target,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sweet

update_action = update_service.Actions['#UpdateService.SimpleUpdate']
requested = update_action['TransferProtocol@Redfish.AllowableValues']
requested ||= begin
info = update_action['TransferProtocol@Redfish.ActionInfo'].Parameters.find { |p| p.Name == 'TransferProtocol' }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh boy, was hoping that server either supports update_action or not. This fine=no :)

With this commit we implement internal state machine that carries out
the firmware update process. We only request a single task no matter
the number of servers to update firmware for because Redfish supports
such bulk operation.

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
@miq-bot
Copy link
Member

miq-bot commented Jul 8, 2019

Checked commit xlab-si@38fd368 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
6 files checked, 0 offenses detected
Everything looks fine. 🏆

@miha-plesko
Copy link
Contributor Author

Travis should turn green when @gmcculloug pushes the button on ManageIQ/manageiq#18801

@miha-plesko miha-plesko reopened this Jul 12, 2019
@miha-plesko
Copy link
Contributor Author

@agrare the dependent core PR has been merged hence we're solid green here. I think @tadeboro was doing demo with this exact code few days ago so I'm confident it should work 💪

Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

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

Nice LGTM @miha-plesko

@agrare agrare merged commit 972d457 into ManageIQ:master Jul 12, 2019
@agrare agrare added this to the Sprint 116 Ending Jul 22, 2019 milestone Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants