morpheus-cli 4.1.4 → 4.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/morpheus.rb +5 -0
- data/lib/morpheus/api.rb +2 -2
- data/lib/morpheus/api/api_client.rb +47 -12
- data/lib/morpheus/api/appliance_settings_interface.rb +30 -0
- data/lib/morpheus/api/auth_interface.rb +14 -10
- data/lib/morpheus/api/clouds_interface.rb +7 -0
- data/lib/morpheus/api/clusters_interface.rb +17 -5
- data/lib/morpheus/api/custom_instance_types_interface.rb +2 -3
- data/lib/morpheus/api/deployments_interface.rb +7 -0
- data/lib/morpheus/api/execute_schedules_interface.rb +2 -3
- data/lib/morpheus/api/groups_interface.rb +7 -0
- data/lib/morpheus/api/license_interface.rb +9 -2
- data/lib/morpheus/api/load_balancers_interface.rb +7 -0
- data/lib/morpheus/api/logs_interface.rb +11 -2
- data/lib/morpheus/api/monitoring_alerts_interface.rb +45 -0
- data/lib/morpheus/api/monitoring_checks_interface.rb +2 -2
- data/lib/morpheus/api/monitoring_interface.rb +13 -8
- data/lib/morpheus/api/power_schedules_interface.rb +2 -3
- data/lib/morpheus/api/servers_interface.rb +5 -2
- data/lib/morpheus/api/setup_interface.rb +25 -7
- data/lib/morpheus/api/task_sets_interface.rb +7 -1
- data/lib/morpheus/api/tasks_interface.rb +7 -0
- data/lib/morpheus/api/virtual_images_interface.rb +2 -3
- data/lib/morpheus/api/whitelabel_settings_interface.rb +60 -0
- data/lib/morpheus/cli.rb +18 -14
- data/lib/morpheus/cli/access_token_command.rb +18 -2
- data/lib/morpheus/cli/appliance_settings_command.rb +303 -0
- data/lib/morpheus/cli/apps.rb +4 -3
- data/lib/morpheus/cli/archives_command.rb +0 -21
- data/lib/morpheus/cli/blueprints_command.rb +2 -2
- data/lib/morpheus/cli/cli_command.rb +32 -8
- data/lib/morpheus/cli/clouds.rb +6 -11
- data/lib/morpheus/cli/clusters.rb +346 -117
- data/lib/morpheus/cli/command_error.rb +4 -0
- data/lib/morpheus/cli/commands/standard/man_command.rb +1 -1
- data/lib/morpheus/cli/containers_command.rb +2 -1
- data/lib/morpheus/cli/credentials.rb +49 -4
- data/lib/morpheus/cli/deployments.rb +2 -2
- data/lib/morpheus/cli/dot_file.rb +2 -2
- data/lib/morpheus/cli/error_handler.rb +6 -3
- data/lib/morpheus/cli/execute_schedules_command.rb +1 -1
- data/lib/morpheus/cli/groups.rb +4 -4
- data/lib/morpheus/cli/hosts.rb +3 -2
- data/lib/morpheus/cli/image_builder_command.rb +0 -21
- data/lib/morpheus/cli/instances.rb +17 -4
- data/lib/morpheus/cli/library_container_types_command.rb +1 -1
- data/lib/morpheus/cli/library_layouts_command.rb +1 -1
- data/lib/morpheus/cli/library_upgrades_command.rb +1 -1
- data/lib/morpheus/cli/license.rb +185 -72
- data/lib/morpheus/cli/load_balancers.rb +4 -4
- data/lib/morpheus/cli/login.rb +4 -0
- data/lib/morpheus/cli/logs_command.rb +132 -0
- data/lib/morpheus/cli/mixins/infrastructure_helper.rb +2 -2
- data/lib/morpheus/cli/mixins/logs_helper.rb +65 -0
- data/lib/morpheus/cli/mixins/monitoring_helper.rb +410 -28
- data/lib/morpheus/cli/mixins/print_helper.rb +14 -4
- data/lib/morpheus/cli/monitoring_alerts_command.rb +800 -0
- data/lib/morpheus/cli/monitoring_apps_command.rb +85 -28
- data/lib/morpheus/cli/monitoring_checks_command.rb +60 -27
- data/lib/morpheus/cli/monitoring_contacts_command.rb +54 -79
- data/lib/morpheus/cli/monitoring_groups_command.rb +62 -23
- data/lib/morpheus/cli/monitoring_incidents_command.rb +91 -70
- data/lib/morpheus/cli/network_pools_command.rb +39 -23
- data/lib/morpheus/cli/power_schedules_command.rb +1 -1
- data/lib/morpheus/cli/remote.rb +834 -275
- data/lib/morpheus/cli/roles.rb +100 -38
- data/lib/morpheus/cli/tasks.rb +1 -1
- data/lib/morpheus/cli/user_settings_command.rb +20 -12
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/virtual_images.rb +1 -1
- data/lib/morpheus/cli/whitelabel_settings_command.rb +546 -0
- data/lib/morpheus/cli/whoami.rb +1 -1
- data/lib/morpheus/cli/workflows.rb +2 -2
- data/lib/morpheus/terminal.rb +22 -8
- metadata +11 -2
@@ -8,9 +8,10 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
8
8
|
set_command_name :'monitor-apps'
|
9
9
|
|
10
10
|
register_subcommands :list, :get, :add, :update, :remove
|
11
|
-
register_subcommands :mute, :unmute
|
11
|
+
register_subcommands :mute, :unmute
|
12
12
|
register_subcommands :'mute-all' => :mute_all
|
13
13
|
register_subcommands :'unmute-all' => :unmute_all
|
14
|
+
#register_subcommands :history
|
14
15
|
|
15
16
|
def connect(opts)
|
16
17
|
@api_client = establish_remote_appliance_connection(opts)
|
@@ -82,6 +83,11 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
82
83
|
# opts.on(nil,'--statistics', "Display Statistics") do |val|
|
83
84
|
# options[:show_statistics] = true
|
84
85
|
# end
|
86
|
+
opts.on('-a','--all', "Display All Details (History, Notifications)") do
|
87
|
+
options[:show_history] = true
|
88
|
+
options[:show_notifications] = true
|
89
|
+
options[:show_statistics] = true
|
90
|
+
end
|
85
91
|
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
86
92
|
end
|
87
93
|
optparse.parse!(args)
|
@@ -105,6 +111,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
105
111
|
print_dry_run @monitoring_apps_interface.dry.get(monitor_app['id'])
|
106
112
|
return
|
107
113
|
end
|
114
|
+
# get by ID to sideload associated checks
|
108
115
|
json_response = @monitoring_apps_interface.get(monitor_app['id'])
|
109
116
|
monitor_app = json_response['monitorApp']
|
110
117
|
if options[:json]
|
@@ -118,7 +125,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
118
125
|
return 0
|
119
126
|
end
|
120
127
|
|
121
|
-
print_h1 "Monitoring App Details"
|
128
|
+
print_h1 "Monitoring App Details", [], options
|
122
129
|
print cyan
|
123
130
|
description_cols = {
|
124
131
|
"ID" => lambda {|it| it['id'] },
|
@@ -129,7 +136,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
129
136
|
"Availability" => lambda {|it| it['availability'] ? "#{it['availability'].to_f.round(3).to_s}%" : "N/A"},
|
130
137
|
"Response Time" => lambda {|it| it['lastTimer'] ? "#{it['lastTimer']}ms" : "N/A" }
|
131
138
|
}
|
132
|
-
print_description_list(description_cols, monitor_app)
|
139
|
+
print_description_list(description_cols, monitor_app, options)
|
133
140
|
|
134
141
|
## Chart Stats
|
135
142
|
|
@@ -137,7 +144,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
137
144
|
## Checks in this app
|
138
145
|
checks = json_response["checks"]
|
139
146
|
if checks && !checks.empty?
|
140
|
-
print_h2 "Checks"
|
147
|
+
print_h2 "Checks", options
|
141
148
|
print_checks_table(checks, options)
|
142
149
|
else
|
143
150
|
# print "\n"
|
@@ -147,13 +154,19 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
147
154
|
## Check Groups in this app
|
148
155
|
check_groups = json_response["checkGroups"]
|
149
156
|
if check_groups && !check_groups.empty?
|
150
|
-
print_h2 "Groups"
|
157
|
+
print_h2 "Groups", options
|
151
158
|
print_check_groups_table(check_groups, options)
|
152
159
|
else
|
153
160
|
# print "\n"
|
154
161
|
# puts "No check groups in this monitoring app"
|
155
162
|
end
|
156
163
|
|
164
|
+
## Checks in this check group
|
165
|
+
if (!checks || checks.empty?) && (check_groups || check_groups.empty?)
|
166
|
+
print "\n", yellow
|
167
|
+
puts "This monitor app is empty, it contains no checks or groups."
|
168
|
+
end
|
169
|
+
|
157
170
|
## Open Incidents
|
158
171
|
open_incidents = json_response["openIncidents"]
|
159
172
|
if open_incidents && !open_incidents.empty?
|
@@ -174,7 +187,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
174
187
|
issues = history_items
|
175
188
|
if history_items && !history_items.empty?
|
176
189
|
print_h2 "History"
|
177
|
-
|
190
|
+
print_monitor_app_history_table(history_items, options)
|
178
191
|
print_results_pagination(history_json_response, {:label => "event", :n_label => "events"})
|
179
192
|
else
|
180
193
|
print "\n"
|
@@ -247,7 +260,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
247
260
|
if history_items.empty?
|
248
261
|
print cyan,"No history found.",reset,"\n"
|
249
262
|
else
|
250
|
-
|
263
|
+
print_monitor_app_history_table(history_items, options)
|
251
264
|
print_results_pagination(json_response, {:label => "event", :n_label => "events"})
|
252
265
|
end
|
253
266
|
print reset,"\n"
|
@@ -277,15 +290,18 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
277
290
|
opts.on('--inUptime [on|off]', String, "Affects Availability. Default is on.") do |val|
|
278
291
|
params['inUptime'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
279
292
|
end
|
280
|
-
opts.on('--
|
281
|
-
|
293
|
+
opts.on('--muted [on|off]', String, "Muted, Turns Affects Availability off.") do |val|
|
294
|
+
params['muted'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
295
|
+
end
|
296
|
+
opts.on('--checks LIST', Array, "Checks to include in this app, comma separated list of names or IDs.") do |list|
|
297
|
+
if list.size == 1 && ('[]' == list[0]) # clear array
|
282
298
|
params['checks'] = []
|
283
299
|
else
|
284
300
|
params['checks'] = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
285
301
|
end
|
286
302
|
end
|
287
|
-
opts.on('--
|
288
|
-
if list.size == 1 &&
|
303
|
+
opts.on('--groups LIST', Array, "Check Groups to include in this app, comma separated list of names or IDs.") do |list|
|
304
|
+
if list.size == 1 && ('[]' == list[0]) # clear array
|
289
305
|
params['checkGroups'] = []
|
290
306
|
else
|
291
307
|
params['checkGroups'] = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
@@ -314,13 +330,35 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
314
330
|
else
|
315
331
|
# merge -O options into normally parsed options
|
316
332
|
params.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
317
|
-
if params['
|
318
|
-
|
333
|
+
if params['name'].nil?
|
334
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'type' => 'text', 'fieldLabel' => 'Name', 'required' => true, 'description' => 'The name of this alert rule.'}], options[:options])
|
335
|
+
params['name'] = v_prompt['name']
|
319
336
|
end
|
320
|
-
if params['
|
321
|
-
|
337
|
+
if params['severity'].nil?
|
338
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'severity', 'type' => 'text', 'fieldLabel' => 'Severity', 'required' => false, 'description' => 'Max Severity. Determines the maximum severity level this app can incur on an incident when failing. Default is critical', 'defaultValue' => 'critical'}], options[:options])
|
339
|
+
params['severity'] = v_prompt['severity'] unless v_prompt['severity'].to_s.empty?
|
340
|
+
end
|
341
|
+
if params['inUptime'].nil? && params['muted'].nil?
|
342
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'inUptime', 'type' => 'checkbox', 'fieldLabel' => 'Affects Availability', 'required' => false, 'description' => 'Affects Availability. Default is on.', 'defaultValue' => true}], options[:options])
|
343
|
+
params['inUptime'] = v_prompt['inUptime'] unless v_prompt['inUptime'].to_s.empty?
|
344
|
+
end
|
345
|
+
|
346
|
+
# Checks
|
347
|
+
prompt_results = prompt_for_checks(params, options, @api_client)
|
348
|
+
if prompt_results[:success]
|
349
|
+
params['checks'] = prompt_results[:data] unless prompt_results[:data].nil?
|
350
|
+
else
|
351
|
+
return 1
|
322
352
|
end
|
323
|
-
|
353
|
+
|
354
|
+
# Check Groups
|
355
|
+
prompt_results = prompt_for_check_groups(params, options, @api_client)
|
356
|
+
if prompt_results[:success]
|
357
|
+
params['checkGroups'] = prompt_results[:data] unless prompt_results[:data].nil?
|
358
|
+
else
|
359
|
+
return 1
|
360
|
+
end
|
361
|
+
|
324
362
|
payload = {'monitorApp' => params}
|
325
363
|
end
|
326
364
|
@monitoring_apps_interface.setopts(options)
|
@@ -363,15 +401,18 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
363
401
|
opts.on('--inUptime [on|off]', String, "Affects Availability. Default is on.") do |val|
|
364
402
|
params['inUptime'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
365
403
|
end
|
366
|
-
opts.on('--
|
367
|
-
|
404
|
+
opts.on('--muted [on|off]', String, "Muted, Turns Affects Availability off.") do |val|
|
405
|
+
params['muted'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
406
|
+
end
|
407
|
+
opts.on('--checks LIST', Array, "Checks to include in this app, comma separated list of names or IDs.") do |list|
|
408
|
+
if list.size == 1 && ('[]' == list[0]) # clear array
|
368
409
|
params['checks'] = []
|
369
410
|
else
|
370
411
|
params['checks'] = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
371
412
|
end
|
372
413
|
end
|
373
|
-
opts.on('--
|
374
|
-
if list.size == 1 &&
|
414
|
+
opts.on('--groups LIST', Array, "Check Groups to include in this app, comma separated list of names or IDs.") do |list|
|
415
|
+
if list.size == 1 && ('[]' == list[0]) # clear array
|
375
416
|
params['checkGroups'] = []
|
376
417
|
else
|
377
418
|
params['checkGroups'] = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
@@ -397,13 +438,27 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
397
438
|
else
|
398
439
|
# merge -O options into normally parsed options
|
399
440
|
params.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
441
|
+
|
442
|
+
# Checks
|
400
443
|
if params['checks']
|
401
|
-
|
444
|
+
prompt_results = prompt_results(params, options, @api_client)
|
445
|
+
if prompt_results[:success]
|
446
|
+
params['checks'] = prompt_results[:data] unless prompt_results[:data].nil?
|
447
|
+
else
|
448
|
+
return 1
|
449
|
+
end
|
402
450
|
end
|
451
|
+
|
452
|
+
# Check Groups
|
403
453
|
if params['checkGroups']
|
404
|
-
|
454
|
+
prompt_results = prompt_for_check_groups(params, options, @api_client)
|
455
|
+
if prompt_results[:success]
|
456
|
+
params['checkGroups'] = prompt_results[:data] unless prompt_results[:data].nil?
|
457
|
+
else
|
458
|
+
return 1
|
459
|
+
end
|
405
460
|
end
|
406
|
-
|
461
|
+
|
407
462
|
payload = {'monitorApp' => params}
|
408
463
|
end
|
409
464
|
@monitoring_apps_interface.setopts(options)
|
@@ -427,11 +482,12 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
427
482
|
|
428
483
|
def mute(args)
|
429
484
|
options = {}
|
430
|
-
params = {
|
485
|
+
params = {}
|
431
486
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
432
487
|
opts.banner = subcommand_usage("[name]")
|
433
488
|
opts.on(nil, "--disable", "Unmute instead, the same as the unmute command") do
|
434
489
|
params['enabled'] = false
|
490
|
+
params['muted'] = false
|
435
491
|
end
|
436
492
|
opts.footer = "Mute a monitoring app. This prevents it from creating new incidents." + "\n" +
|
437
493
|
"[name] is required. This is the name or id of a monitoring app."
|
@@ -477,7 +533,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
477
533
|
|
478
534
|
def unmute(args)
|
479
535
|
options = {}
|
480
|
-
params = {'enabled' => false}
|
536
|
+
params = {'muted' => false, 'enabled' => false}
|
481
537
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
482
538
|
opts.banner = subcommand_usage("[name]")
|
483
539
|
build_common_options(opts, options, [:payload, :json, :dry_run, :remote, :quiet])
|
@@ -521,10 +577,11 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
521
577
|
|
522
578
|
def mute_all(args)
|
523
579
|
options = {}
|
524
|
-
params = {
|
580
|
+
params = {}
|
525
581
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
526
582
|
opts.banner = subcommand_usage()
|
527
583
|
opts.on(nil, "--disable", "Unmute instead, the same as the unmute-all command") do
|
584
|
+
params['muted'] = false
|
528
585
|
params['enabled'] = false
|
529
586
|
end
|
530
587
|
opts.footer = "Mute all monitoring apps. This prevents the creation of new incidents."
|
@@ -569,7 +626,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
569
626
|
|
570
627
|
def unmute_all(args)
|
571
628
|
options = {}
|
572
|
-
params = {'enabled' => false}
|
629
|
+
params = {'muted' => false, 'enabled' => false}
|
573
630
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
574
631
|
opts.banner = subcommand_usage()
|
575
632
|
build_common_options(opts, options, [:payload, :json, :dry_run, :remote, :quiet])
|
@@ -614,7 +671,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
614
671
|
params = {}
|
615
672
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
616
673
|
opts.banner = subcommand_usage("[name]")
|
617
|
-
build_common_options(opts, options, [:json, :dry_run, :quiet])
|
674
|
+
build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :quiet, :remote])
|
618
675
|
end
|
619
676
|
optparse.parse!(args)
|
620
677
|
if args.count < 1
|
@@ -84,6 +84,11 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
84
84
|
# opts.on(nil,'--statistics', "Display Statistics") do |val|
|
85
85
|
# options[:show_statistics] = true
|
86
86
|
# end
|
87
|
+
opts.on('-a','--all', "Display All Details (History, Notifications)") do
|
88
|
+
options[:show_history] = true
|
89
|
+
options[:show_notifications] = true
|
90
|
+
options[:show_statistics] = true
|
91
|
+
end
|
87
92
|
build_common_options(opts, options, [:json, :csv, :fields, :dry_run, :remote])
|
88
93
|
end
|
89
94
|
optparse.parse!(args)
|
@@ -107,8 +112,11 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
107
112
|
print_dry_run @monitoring_checks_interface.dry.get(check['id'])
|
108
113
|
return
|
109
114
|
end
|
115
|
+
|
116
|
+
# get by ID to sideload associated checks
|
110
117
|
json_response = @monitoring_checks_interface.get(check['id'])
|
111
118
|
check = json_response['check']
|
119
|
+
|
112
120
|
if options[:json]
|
113
121
|
puts as_json(json_response, options, 'check')
|
114
122
|
return 0
|
@@ -164,9 +172,9 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
164
172
|
|
165
173
|
check_groups = json_response["groups"]
|
166
174
|
if check_groups && !check_groups.empty?
|
167
|
-
print_h2 "Groups"
|
168
|
-
|
169
|
-
print_check_groups_table(check_groups, options)
|
175
|
+
print_h2 "Check Groups"
|
176
|
+
print as_pretty_table(check_groups, [:id, :name], options)
|
177
|
+
#print_check_groups_table(check_groups, options)
|
170
178
|
else
|
171
179
|
# print "\n"
|
172
180
|
# puts "This check is not in any check groups."
|
@@ -184,18 +192,17 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
184
192
|
## Open Incidents
|
185
193
|
|
186
194
|
open_incidents = json_response["openIncidents"]
|
195
|
+
|
187
196
|
if open_incidents && !open_incidents.empty?
|
188
197
|
print_h2 "Open Incidents"
|
189
|
-
|
190
|
-
|
191
|
-
# todo: move this to MonitoringHelper ?
|
192
|
-
# print_incidents_table(issues, options)
|
198
|
+
print_incidents_table(open_incidents)
|
199
|
+
# print_results_pagination(size: open_incidents.size, total: open_incidents.size)
|
193
200
|
else
|
194
201
|
print "\n", cyan
|
195
|
-
puts "No open incidents for this
|
202
|
+
puts "No open incidents for this monitoring app"
|
196
203
|
end
|
197
204
|
|
198
|
-
## History
|
205
|
+
## History
|
199
206
|
if options[:show_history]
|
200
207
|
# history_items = json_response["history"]
|
201
208
|
# gotta go get it
|
@@ -293,15 +300,12 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
293
300
|
def add(args)
|
294
301
|
options = {:skip_booleanize => true}
|
295
302
|
params = {'inUptime' => true, 'severity' => 'critical'}
|
303
|
+
check_type_code = nil
|
296
304
|
check_type = nil
|
297
305
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
298
306
|
opts.banner = subcommand_usage("[name] -t CODE")
|
299
|
-
opts.on('-t', '--type CODE', "Check Type Code
|
300
|
-
|
301
|
-
params['checkType'] = {'id' => val.to_i}
|
302
|
-
else
|
303
|
-
params['checkType'] = {'code' => val}
|
304
|
-
end
|
307
|
+
opts.on('-t', '--type CODE', "Check Type Code") do |val|
|
308
|
+
check_type_code = val
|
305
309
|
end
|
306
310
|
opts.on('--name VALUE', String, "Name") do |val|
|
307
311
|
params['name'] = val
|
@@ -345,7 +349,36 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
345
349
|
payload = options[:payload]
|
346
350
|
else
|
347
351
|
params.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
348
|
-
#
|
352
|
+
# merge in arbitrary option values
|
353
|
+
if params['name'].nil?
|
354
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'type' => 'text', 'fieldLabel' => 'Name', 'required' => true, 'description' => 'The name of this check.'}], options[:options])
|
355
|
+
params['name'] = v_prompt['name']
|
356
|
+
end
|
357
|
+
|
358
|
+
# Check Type
|
359
|
+
# rescue pre 3.6.5 error with maxResults.toLong()
|
360
|
+
available_check_types = []
|
361
|
+
begin
|
362
|
+
available_check_types = @monitoring_checks_interface.list_check_types({max:1000})['checkTypes']
|
363
|
+
rescue RestClient::Exception => e
|
364
|
+
available_check_types = @monitoring_checks_interface.list_check_types({})['checkTypes']
|
365
|
+
end
|
366
|
+
if available_check_types && available_check_types.size > 0
|
367
|
+
options[:options]['type'] = check_type_code if check_type_code
|
368
|
+
check_types_dropdown = available_check_types.collect {|it| {'name' => it['name'], 'value' => it['code']} }
|
369
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'type', 'type' => 'select', 'selectOptions' => check_types_dropdown, 'fieldLabel' => 'Check Type', 'required' => true, 'description' => 'The check type code.'}], options[:options])
|
370
|
+
check_type_code = v_prompt['type']
|
371
|
+
end
|
372
|
+
if check_type_code
|
373
|
+
params['checkType'] = {'code' => check_type_code}
|
374
|
+
end
|
375
|
+
|
376
|
+
# todo: load check type optionTypes and prompt accordingly..
|
377
|
+
|
378
|
+
# include arbitrary -O options
|
379
|
+
extra_passed_options = options[:options].reject {|k,v| k.is_a?(Symbol) || ['type'].include?(k)}
|
380
|
+
params.deep_merge!(extra_passed_options)
|
381
|
+
|
349
382
|
payload = {'check' => params}
|
350
383
|
end
|
351
384
|
@monitoring_checks_interface.setopts(options)
|
@@ -359,7 +392,7 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
359
392
|
elsif !options[:quiet]
|
360
393
|
check = json_response['check']
|
361
394
|
print_green_success "Added check #{check['name']}"
|
362
|
-
_get(check['id'],
|
395
|
+
_get(check['id'], options)
|
363
396
|
end
|
364
397
|
return 0
|
365
398
|
rescue RestClient::Exception => e
|
@@ -425,7 +458,7 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
425
458
|
puts as_json(json_response, options)
|
426
459
|
elsif !options[:quiet]
|
427
460
|
print_green_success "Updated check #{check['name']}"
|
428
|
-
_get(check['id'],
|
461
|
+
_get(check['id'], options)
|
429
462
|
end
|
430
463
|
return 0
|
431
464
|
rescue RestClient::Exception => e
|
@@ -437,11 +470,12 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
437
470
|
|
438
471
|
def mute(args)
|
439
472
|
options = {}
|
440
|
-
params = {
|
473
|
+
params = {}
|
441
474
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
442
475
|
opts.banner = subcommand_usage("[name]")
|
443
476
|
opts.on(nil, "--disable", "Disable mute state instead, the same as unmute") do
|
444
477
|
params['enabled'] = false
|
478
|
+
params['muted'] = false
|
445
479
|
end
|
446
480
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :quiet, :remote])
|
447
481
|
opts.footer = "Mute a check. This prevents it from creating new incidents." + "\n" +
|
@@ -476,7 +510,7 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
476
510
|
else
|
477
511
|
print_green_success "Unmuted check #{check['name']}"
|
478
512
|
end
|
479
|
-
_get(check['id'],
|
513
|
+
_get(check['id'], options)
|
480
514
|
end
|
481
515
|
return 0
|
482
516
|
rescue RestClient::Exception => e
|
@@ -520,7 +554,7 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
520
554
|
puts as_json(json_response, options)
|
521
555
|
elsif !options[:quiet]
|
522
556
|
print_green_success "Unmuted check #{check['name']}"
|
523
|
-
_get(check['id'],
|
557
|
+
_get(check['id'], options)
|
524
558
|
end
|
525
559
|
return 0
|
526
560
|
rescue RestClient::Exception => e
|
@@ -531,10 +565,11 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
531
565
|
|
532
566
|
def mute_all(args)
|
533
567
|
options = {}
|
534
|
-
params = {
|
568
|
+
params = {}
|
535
569
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
536
570
|
opts.banner = subcommand_usage()
|
537
571
|
opts.on(nil, "--disable", "Disable mute state instead, the same as unmute-all") do
|
572
|
+
params['muted'] = false
|
538
573
|
params['enabled'] = false
|
539
574
|
end
|
540
575
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :quiet, :remote])
|
@@ -579,7 +614,7 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
579
614
|
|
580
615
|
def unmute_all(args)
|
581
616
|
options = {}
|
582
|
-
params = {'enabled' => false}
|
617
|
+
params = {'muted' => false, 'enabled' => false}
|
583
618
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
584
619
|
opts.banner = subcommand_usage()
|
585
620
|
build_common_options(opts, options, [:payload, :json, :dry_run, :quiet, :remote])
|
@@ -624,7 +659,7 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
624
659
|
params = {}
|
625
660
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
626
661
|
opts.banner = subcommand_usage("[name]")
|
627
|
-
build_common_options(opts, options, [:json, :dry_run, :quiet, :remote])
|
662
|
+
build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :quiet, :remote])
|
628
663
|
end
|
629
664
|
optparse.parse!(args)
|
630
665
|
if args.count != 1
|
@@ -717,8 +752,6 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
717
752
|
end
|
718
753
|
end
|
719
754
|
|
720
|
-
private
|
721
|
-
|
722
|
-
|
755
|
+
private
|
723
756
|
|
724
757
|
end
|