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

Add power operations to physical server #5

Merged
merged 1 commit into from
Jun 7, 2018

Conversation

tadeboro
Copy link
Contributor

@tadeboro tadeboro commented Jun 1, 2018

This commit implements parts of the functionality that is used by the
power operations controls, exposed in physical server UI.

@miq-bot add_label wip

@miq-bot miq-bot changed the title Add power operations to physical server [WIP] Add power operations to physical server Jun 1, 2018
@miq-bot miq-bot added the wip label Jun 1, 2018
@tadeboro
Copy link
Contributor Author

tadeboro commented Jun 4, 2018

@miq-bot remove_label wip

@tadeboro
Copy link
Contributor Author

tadeboro commented Jun 4, 2018

@miq-bot assign @gtanzillo

@miq-bot miq-bot changed the title [WIP] Add power operations to physical server Add power operations to physical server Jun 4, 2018
@miq-bot miq-bot removed the wip label Jun 4, 2018
end

def restart_to_sys_setup(_args, _options = {})
$redfish_log.error("Restarting to system setup is not supported.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to raise error as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

I just noticed the note above the code. Does that note imply that raised errors are not interpreted properly in the UI? I wonder if the notification system should be used? Like https://github.com/ManageIQ/manageiq/pull/15624/files#diff-0811ad92c7ad82e70f192721e7f910d0R56

@gtanzillo what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I raised an exception in my initial implementation here, but since this only fills evm log with useless stack traces with no UI change whatsoever, I changed this to simply log an error message at this stage.

I did implement a quick prototype that uses notification system to inform user about the errors, but in order to have it fully functional, I would need to update core a bit by adding our messages.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, @tadeboro.

I have checked Lenovo provider and they are also not raising any errors. As you pointed out, this should be handled in the core. The PR that I referenced was also used in the end instead of having the Notifications in the provider, so I would keep this as it is for the time being.

def restart_mgmt_controller(_server, _options = {})
# TODO(tadeboro): This operation is not well defined, since server can
# (and usually is) managed by more that one manager.
$redfish_log.error("Restarting management controller is not supported.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, I would rather raise an error as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See previous comment.


def reset_server(reset_type, server, options = {})
$redfish_log.info("Requesting #{reset_type} for #{server.ems_ref}.")
with_provider_connection(options) do |client|
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the options that above methods receieve actually related to the connection options that you are using here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked again and no, they are not used for this purpose. They are basically useless since in the current implementation they only contain subset of fields from the server object that we can access anyhow. I will rework the power operations and ignore them completely for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thanks.

with_provider_connection(options) do |client|
system = client.find(server.ems_ref)
if system.nil?
$redfish_log.error("#{server.ems_ref} does not exist anymore.")
Copy link
Contributor

Choose a reason for hiding this comment

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

We have to understand if log entry is sufficient, because this will again not get the correct into to the caller - it just silently failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again, see other comments on why things are the way they are.

return
end

response = system.Actions["#ComputerSystem.Reset"].post(
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to move such const strings into more resilient form? At least a predefined const that will define this string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel that extracting a string just for the sake of extraction is useless and in this particular case harmful to the readability and comprehension of the code. At the moment, this is the only place that uses this operation name. If we need to restart server from more places than one in the future, we will extract the whole "restart the server" functionality into separate function and not replicate the post call invocation all over the place, still keeping this operation name confined to a single place.

This commit implements parts of the functionality that is used by the
power operations controls, exposed in physical server UI.
@miq-bot
Copy link
Member

miq-bot commented Jun 6, 2018

Checked commit xlab-si@caa1cd9 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
11 files checked, 1 offense detected

**

  • 💣 💥 🔥 🚒 - Linter/Yaml - missing config files

Copy link
Contributor

@gberginc gberginc left a comment

Choose a reason for hiding this comment

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

LGTM

@gberginc
Copy link
Contributor

gberginc commented Jun 6, 2018

@agrare Can you help with the review of this one?

@agrare agrare assigned agrare and unassigned gtanzillo Jun 7, 2018
@agrare agrare added the enhancement New feature or request label Jun 7, 2018
# completely useless tool.

def power_on(server, _options)
reset_server(server, "On")
Copy link
Member

Choose a reason for hiding this comment

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

I was going to say reset_server didn't make sense for the function name, but then I saw the API call was ComputerSystem.Reset so 👍

end

def restart_to_sys_setup(_args, _options)
$redfish_log.error("Restarting to system setup is not supported.")
Copy link
Member

Choose a reason for hiding this comment

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

Hm we should have a supports feature for this so the UI/API can check if the method is supported before calling it, something to do in a followup as I'm not sure any of that exists for physical server power ops.

def restart_mgmt_controller(_server, _options)
# TODO(tadeboro): This operation is not well defined, since server can
# (and usually is) managed by more that one manager.
$redfish_log.error("Restarting management controller is not supported.")
Copy link
Member

Choose a reason for hiding this comment

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

Same here

:field => "target", :payload => { "ResetType" => reset_type }
)
if [200, 202, 204].include?(response.status)
$redfish_log.info("#{reset_type} for #{server.ems_ref} started.")
Copy link
Member

Choose a reason for hiding this comment

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

Is there a task id/ref returned that can be used to wait for the operation to complete? If so we might want to optionally wait for that to finish since most of our operations are expected to be synchronous.

if [200, 202, 204].include?(response.status)
$redfish_log.info("#{reset_type} for #{server.ems_ref} started.")
else
$redfish_log.error("#{reset_type} for #{server.ems_ref} failed.")
Copy link
Member

Choose a reason for hiding this comment

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

When the API call fails is there any error message returned that we can print to help diagnose the failure?

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.

Couple of comments but they can be addressed in a follow-up PR

@agrare agrare merged commit caa1cd9 into ManageIQ:master Jun 7, 2018
agrare added a commit that referenced this pull request Jun 7, 2018
Add power operations to physical server
@agrare agrare added this to the Sprint 88 Ending Jun 18, 2018 milestone Jun 7, 2018
@tadeboro tadeboro deleted the power-ops branch June 8, 2018 07:55
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.

5 participants