Module: ForemanOpentofu::Api::V2::HostsControllerPowerOverride

Defined in:
app/controllers/concerns/foreman_opentofu/api/v2/hosts_controller_power_override.rb

Instance Method Summary collapse

Instance Method Details

#powerObject



5
6
7
8
9
10
11
# File 'app/controllers/concerns/foreman_opentofu/api/v2/hosts_controller_power_override.rb', line 5

def power
  if ForemanOpentofu::PowerCapability.power_change_disabled_for_host?(@host)
    return render_error :custom_error, status: :unprocessable_entity, locals: { message: _('Power change operations are not enabled on this host.') }
  end

  super
end

#power_statusObject



13
14
15
16
17
18
# File 'app/controllers/concerns/foreman_opentofu/api/v2/hosts_controller_power_override.rb', line 13

def power_status
  result = PowerManager::PowerStatus.safe_power_state(@host, timeout: params[:timeout])
  result[:statusText] = _('Power change operations are not enabled on this host.') if ForemanOpentofu::PowerCapability.power_change_disabled_for_host?(@host)

  render json: result
end