Project

General

Profile

« Previous | Next » 

Revision 08912c32

Added by Shimon Shtein over 6 years ago

Fixes #20966 - Added fast return to host power api

If the host does not support power actions (no BMC and the VM
does not support it - return `unprocessable_entity` and exit with
a message.

View differences:

app/controllers/api/v2/hosts_controller.rb
param :power_action, String, :required => true, :desc => N_("power action, valid actions are (on/start), (off/stop), (soft/reboot), (cycle/reset), (state/status)")
def power
unless @host.supports_power?
return render_error :custom_error, :status => :unprocessable_entity, :locals => { :message => _('Power operations are not enabled on this host.') }
end
valid_actions = PowerManager::SUPPORTED_ACTIONS
if valid_actions.include? params[:power_action]
render :json => { :power => @host.power.send(params[:power_action]) }, :status => :ok

Also available in: Unified diff