class WavefrontCli::MaintenanceWindow
CLI coverage for the v2 'maintenancewindow' API.
Public Instance Methods
build_body()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 37 def build_body ret = { title: options[:'<title>'], startTimeInSeconds: window_start, endTimeInSeconds: window_end } ret[:reason] = options[:desc] if options[:desc] ret end
change_end_time(timestamp)
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 91 def change_end_time(timestamp) wf.update(options[:'<id>'], endTimeInSeconds: timestamp) end
descriptive_name()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 21 def descriptive_name 'maintenance window' end
do_close()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 86 def do_close cannot_noop! change_end_time(Time.now.to_i) end
do_create()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 25 def do_create body = build_body [%i[CustomerTags atag], %i[HostTags htag], %i[HostNames host]].each do |key, opt| k = ('relevant' + key.to_s).to_sym body[k] = options[opt] unless options[opt].empty? end wf.create(body) end
do_extend_by()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 68 def do_extend_by cannot_noop! to_add = parse_range_to_add old_end = wf.describe(options[:'<id>']).response.endTimeInSeconds change_end_time(old_end + to_add) end
do_extend_to()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 81 def do_extend_to cannot_noop! change_end_time(parse_time(options[:'<time>'])) end
do_ongoing()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 95 def do_ongoing ret = wf.ongoing exit if options[:noop] return ret unless ret.is_a?(Wavefront::Response) && ret.empty? ok_exit('No maintenance windows currently ongoing.') end
do_pending()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 105 def do_pending range = options[:'<hours>'].to_f range = 24 unless range.positive? ret = wf.pending(range) exit if options[:noop] return ret unless ret.is_a?(Wavefront::Response) && ret.empty? ok_exit(format('No maintenance windows in the next %<range>s hours.', range: range)) end
parse_range_to_add()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 75 def parse_range_to_add options[:'<time>'].to_seconds rescue ArgumentError abort "Could not parse time range '#{options[:'<time>']}'." end
validator_exception()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 17 def validator_exception Wavefront::Exception::InvalidMaintenanceWindowId end
validator_method()
click to toggle source
# File lib/wavefront-cli/maintenancewindow.rb, line 13 def validator_method :wf_maintenance_window_id? end
window_end()
click to toggle source
@return [Integer] end time of window, in seconds. If not
given as an option, end it in an hour
# File lib/wavefront-cli/maintenancewindow.rb, line 60 def window_end if options[:end] parse_time(options[:end]) else window_start + 3600 end end
window_start()
click to toggle source
@return [Integer] start time of window, in seconds. If not
given as an option, start it now
# File lib/wavefront-cli/maintenancewindow.rb, line 49 def window_start if options[:start] parse_time(options[:start]) else Time.now.to_i end end