17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/api/v2/downtime_controller.rb', line 17
def create
begin
options = {
:comment => downtime_params[:reason] || _('Host requested downtime')
}
options[:all_services] = downtime_params[:all_services] if downtime_params.key? :all_services
if downtime_params.key? :duration
options[:start_time] = Time.now.to_i
options[:end_time] = Time.now.to_i + downtime_params[:duration].to_i
end
@host.downtime_host(options)
rescue StandardError => e
Foreman::Logging.exception('Failed to request downtime', e)
render :json => { 'message' => e.message }, :status => :unprocessable_entity
return
end
render :json => { 'message' => 'OK' }
end
|