Class: WavefrontCli::MaintenanceWindow
- Inherits:
-
Base
- Object
- Base
- WavefrontCli::MaintenanceWindow
show all
- Includes:
- Wavefront::Mixins
- Defined in:
- lib/wavefront-cli/maintenancewindow.rb
Overview
CLI coverage for the v2 ‘maintenancewindow’ API.
Instance Attribute Summary
Attributes inherited from Base
#klass, #klass_word, #options, #wf
Instance Method Summary
collapse
Methods inherited from Base
#check_status, #dispatch, #display, #do_delete, #do_describe, #do_import, #do_list, #do_search, #do_tag_add, #do_tag_clear, #do_tag_delete, #do_tag_set, #do_tags, #do_undelete, #do_update, #format_var, #handle_error, #handle_response, #import_to_create, #initialize, #load_display_class, #load_file, #mk_creds, #mk_opts, #run, #validate_id, #validate_input, #validate_opts, #validate_tags
Instance Method Details
#change_end_time(ts) ⇒ Object
65
66
67
|
# File 'lib/wavefront-cli/maintenancewindow.rb', line 65
def change_end_time(ts)
wf.update(options[:'<id>'], { endTimeInSeconds: ts })
end
|
#do_close ⇒ Object
61
62
63
|
# File 'lib/wavefront-cli/maintenancewindow.rb', line 61
def do_close
change_end_time(Time.now.to_i)
end
|
#do_create ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/wavefront-cli/maintenancewindow.rb', line 20
def do_create
body = { title: options[:'<title>'] }
body[:startTimeInSeconds] = if options[:start]
parse_time(options[:start])
else
Time.now.to_i
end
body[:endTimeInSeconds] = if options[:end]
parse_time(options[:end])
else
body[:startTimeInSeconds] + 3600
end
body[:reason] = options[:desc] if options[:desc]
[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 ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/wavefront-cli/maintenancewindow.rb', line 46
def do_extend_by
begin
to_add = options[:'<time>'].to_seconds
rescue
abort "Could not parse time range '#{options[:'<time>']}'."
end
old_end = wf.describe(options[:'<id>']).response.endTimeInSeconds
change_end_time(old_end + to_add)
end
|
#do_extend_to ⇒ Object
57
58
59
|
# File 'lib/wavefront-cli/maintenancewindow.rb', line 57
def do_extend_to
change_end_time(parse_time(options[:'<time>']))
end
|
#validator_exception ⇒ Object
16
17
18
|
# File 'lib/wavefront-cli/maintenancewindow.rb', line 16
def validator_exception
Wavefront::Exception::InvalidMaintenanceWindowId
end
|
#validator_method ⇒ Object
12
13
14
|
# File 'lib/wavefront-cli/maintenancewindow.rb', line 12
def validator_method
:wf_maintenance_window_id?
end
|