morpheus-cli 4.1.4 → 4.1.5
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -34,7 +34,8 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
34
34
|
params = {}
|
35
35
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
36
36
|
opts.banner = subcommand_usage()
|
37
|
-
build_common_options(opts, options, [:list, :query, :json, :csv, :yaml, :fields, :json, :dry_run])
|
37
|
+
build_common_options(opts, options, [:list, :query, :json, :csv, :yaml, :fields, :json, :dry_run, :remote])
|
38
|
+
opts.footer = "List monitoring contacts."
|
38
39
|
end
|
39
40
|
optparse.parse!(args)
|
40
41
|
connect(options)
|
@@ -79,7 +80,7 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
79
80
|
def get(args)
|
80
81
|
options = {}
|
81
82
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
82
|
-
opts.banner = subcommand_usage("[
|
83
|
+
opts.banner = subcommand_usage("[contact]")
|
83
84
|
opts.on(nil,'--history', "Display History") do |val|
|
84
85
|
options[:show_history] = true
|
85
86
|
end
|
@@ -87,11 +88,12 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
87
88
|
options[:show_notifications] = true
|
88
89
|
end
|
89
90
|
build_common_options(opts, options, [:json, :csv, :fields, :dry_run, :remote])
|
91
|
+
opts.footer = "Get details about a monitoring contact." + "\n" +
|
92
|
+
"[contact] is required. This is the name or ID of the contact. Supports 1-N [contact] arguments."
|
90
93
|
end
|
91
94
|
optparse.parse!(args)
|
92
95
|
if args.count < 1
|
93
|
-
|
94
|
-
exit 1
|
96
|
+
raise_command_error "wrong number of arguments, expected 1-N and got (#{args.count}) #{args.join(' ')}\n#{optparse}"
|
95
97
|
end
|
96
98
|
connect(options)
|
97
99
|
id_list = parse_id_list(args)
|
@@ -109,8 +111,10 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
109
111
|
print_dry_run @monitoring_contacts_interface.dry.get(contact['id'])
|
110
112
|
return
|
111
113
|
end
|
112
|
-
|
113
|
-
|
114
|
+
# save a request
|
115
|
+
# json_response = @monitoring_contacts_interface.get(contact['id'])
|
116
|
+
# contact = json_response['contact']
|
117
|
+
json_response = {'contact' => contact}
|
114
118
|
|
115
119
|
if options[:json]
|
116
120
|
puts as_json(json_response, options, "contact")
|
@@ -130,16 +134,16 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
130
134
|
"Name" => 'name',
|
131
135
|
"Email" => 'emailAddress',
|
132
136
|
"Mobile" => 'smsAddress',
|
133
|
-
|
137
|
+
"Slack Hook" => 'slackHook'
|
134
138
|
}
|
135
|
-
description_cols
|
139
|
+
description_cols.delete("Slack Hook") if contact['slackHook'].to_s.empty?
|
136
140
|
puts as_description_list(contact, description_cols)
|
137
141
|
|
138
142
|
## Notifications
|
139
143
|
# show notify events here...
|
140
144
|
|
141
|
-
print reset
|
142
|
-
|
145
|
+
print reset
|
146
|
+
return 0
|
143
147
|
rescue RestClient::Exception => e
|
144
148
|
print_rest_exception(e, options)
|
145
149
|
exit 1
|
@@ -163,19 +167,36 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
163
167
|
opts.on("--slackHook STRING", String, "Contact slack hook") do |val|
|
164
168
|
params['slackHook'] = val == 'null' ? nil : val
|
165
169
|
end
|
166
|
-
build_common_options(opts, options, [:json, :dry_run, :quiet])
|
170
|
+
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :quiet, :remote])
|
171
|
+
opts.footer = "Create a monitoring contact." + "\n" +
|
172
|
+
"[name] is required. This is the name of the new contact."
|
167
173
|
end
|
168
174
|
optparse.parse!(args)
|
169
175
|
connect(options)
|
170
|
-
|
176
|
+
if args.count > 1
|
177
|
+
raise_command_error "wrong number of arguments, expected 0-1 and got (#{args.count}) #{args.join(' ')}\n#{optparse}"
|
178
|
+
end
|
179
|
+
if args[0]
|
180
|
+
params['name'] = args[0]
|
181
|
+
end
|
171
182
|
begin
|
172
|
-
|
173
|
-
if
|
174
|
-
|
175
|
-
|
176
|
-
exit 1
|
183
|
+
params.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
184
|
+
if params['name'].nil?
|
185
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'type' => 'text', 'fieldLabel' => 'Name', 'required' => true, 'description' => 'The name of this contact.'}], options[:options])
|
186
|
+
params['name'] = v_prompt['name']
|
177
187
|
end
|
178
|
-
|
188
|
+
if params['emailAddress'].nil?
|
189
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'emailAddress', 'type' => 'text', 'fieldLabel' => 'Email', 'required' => false, 'description' => 'Contact email address.'}], options[:options])
|
190
|
+
params['emailAddress'] = v_prompt['emailAddress'] unless v_prompt['emailAddress'].to_s.empty?
|
191
|
+
end
|
192
|
+
if params['smsAddress'].nil?
|
193
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'smsAddress', 'type' => 'text', 'fieldLabel' => 'Mobile', 'required' => false, 'description' => 'Contact sms address, or phone number.'}], options[:options])
|
194
|
+
params['smsAddress'] = v_prompt['smsAddress'] unless v_prompt['smsAddress'].to_s.empty?
|
195
|
+
end
|
196
|
+
# if params['slackHook'].nil?
|
197
|
+
# v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'slackHook', 'type' => 'text', 'fieldLabel' => 'Slack Hook', 'required' => false, 'description' => 'Contact slack hook.'}], options[:options])
|
198
|
+
# params['slackHook'] = v_prompt['slackHook'] unless v_prompt['slackHook'].to_s.empty?
|
199
|
+
# end
|
179
200
|
payload = {
|
180
201
|
'contact' => {}
|
181
202
|
}
|
@@ -192,7 +213,7 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
192
213
|
puts as_json(json_response, options)
|
193
214
|
elsif !options[:quiet]
|
194
215
|
print_green_success "Created contact (#{contact['id']}) #{contact['name']}"
|
195
|
-
#_get(contact['id'],
|
216
|
+
#_get(contact['id'], options)
|
196
217
|
end
|
197
218
|
|
198
219
|
rescue RestClient::Exception => e
|
@@ -205,7 +226,7 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
205
226
|
options = {}
|
206
227
|
params = {}
|
207
228
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
208
|
-
opts.banner = subcommand_usage("[
|
229
|
+
opts.banner = subcommand_usage("[contact]")
|
209
230
|
opts.on("--name STRING", String, "Contact name") do |val|
|
210
231
|
params['name'] = val
|
211
232
|
end
|
@@ -218,12 +239,13 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
218
239
|
opts.on("--slackHook STRING", String, "Contact slack hook") do |val|
|
219
240
|
params['slackHook'] = val == 'null' ? nil : val
|
220
241
|
end
|
221
|
-
build_common_options(opts, options, [:json, :dry_run, :quiet])
|
242
|
+
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :quiet, :remote])
|
243
|
+
opts.footer = "Update a monitoring contact." + "\n" +
|
244
|
+
"[contact] is required. This is the name or ID of the contact."
|
222
245
|
end
|
223
246
|
optparse.parse!(args)
|
224
|
-
if args.count
|
225
|
-
|
226
|
-
exit 1
|
247
|
+
if args.count != 1
|
248
|
+
raise_command_error "wrong number of arguments, expected 1 and got (#{args.count}) #{args.join(' ')}\n#{optparse}"
|
227
249
|
end
|
228
250
|
connect(options)
|
229
251
|
|
@@ -247,11 +269,12 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
247
269
|
end
|
248
270
|
|
249
271
|
json_response = @monitoring_contacts_interface.update(contact["id"], payload)
|
272
|
+
contact = json_response['contact']
|
250
273
|
if options[:json]
|
251
274
|
puts as_json(json_response, options)
|
252
275
|
elsif !options[:quiet]
|
253
|
-
print_green_success "Updated contact #{contact['id']}"
|
254
|
-
_get(contact['id'],
|
276
|
+
print_green_success "Updated contact (#{contact['id']}) #{contact['name']}"
|
277
|
+
_get(contact['id'], options)
|
255
278
|
end
|
256
279
|
|
257
280
|
rescue RestClient::Exception => e
|
@@ -264,17 +287,18 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
264
287
|
def remove(args)
|
265
288
|
options = {}
|
266
289
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
267
|
-
opts.banner = subcommand_usage("[
|
290
|
+
opts.banner = subcommand_usage("[contact]")
|
268
291
|
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
292
|
+
opts.footer = "Delete a monitoring contact." + "\n" +
|
293
|
+
"[contact] is required. This is the name or ID of the contact. Supports 1-N [contact] arguments."
|
269
294
|
end
|
270
295
|
optparse.parse!(args)
|
271
296
|
if args.count < 1
|
272
|
-
|
273
|
-
exit 1
|
297
|
+
raise_command_error "wrong number of arguments, expected 1-N and got (#{args.count}) #{args.join(' ')}\n#{optparse}"
|
274
298
|
end
|
275
299
|
connect(options)
|
276
300
|
id_list = parse_id_list(args)
|
277
|
-
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to delete
|
301
|
+
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to delete #{id_list.size == 1 ? 'contact' : 'contacts'} #{anded_list(id_list)}?", options)
|
278
302
|
exit 1
|
279
303
|
end
|
280
304
|
return run_command_for_each_arg(id_list) do |arg|
|
@@ -303,55 +327,6 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
303
327
|
end
|
304
328
|
end
|
305
329
|
|
306
|
-
def reopen(args)
|
307
|
-
options = {}
|
308
|
-
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
309
|
-
opts.banner = subcommand_usage("[id list]")
|
310
|
-
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
311
|
-
end
|
312
|
-
optparse.parse!(args)
|
313
|
-
if args.count < 1
|
314
|
-
puts optparse
|
315
|
-
exit 1
|
316
|
-
end
|
317
|
-
connect(options)
|
318
|
-
id_list = parse_id_list(args)
|
319
|
-
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to reopen #{id_list.size == 1 ? 'contact' : 'contacts'} #{anded_list(id_list)}?", options)
|
320
|
-
exit 1
|
321
|
-
end
|
322
|
-
return run_command_for_each_arg(id_list) do |arg|
|
323
|
-
_reopen(arg, options)
|
324
|
-
end
|
325
|
-
end
|
326
|
-
|
327
|
-
def _reopen(id, options)
|
328
|
-
|
329
|
-
begin
|
330
|
-
contact = find_contact_by_name_or_id(id)
|
331
|
-
already_open = contact['status'] == 'open'
|
332
|
-
if already_open
|
333
|
-
print bold,yellow,"contact #{contact['id']} is already open",reset,"\n"
|
334
|
-
return false
|
335
|
-
end
|
336
|
-
@monitoring_contacts_interface.setopts(options)
|
337
|
-
if options[:dry_run]
|
338
|
-
print_dry_run @monitoring_contacts_interface.dry.reopen(contact['id'])
|
339
|
-
return
|
340
|
-
end
|
341
|
-
json_response = @monitoring_contacts_interface.reopen(contact['id'])
|
342
|
-
if options[:json]
|
343
|
-
print JSON.pretty_generate(json_response)
|
344
|
-
print "\n"
|
345
|
-
elsif !options[:quiet]
|
346
|
-
print_green_success json_response["msg"] || "contact #{contact['id']} is now open"
|
347
|
-
# _get(contact['id'] {})
|
348
|
-
end
|
349
|
-
rescue RestClient::Exception => e
|
350
|
-
print_rest_exception(e, options)
|
351
|
-
exit 1
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
330
|
private
|
356
331
|
|
357
332
|
def print_contacts_table(contacts, opts={})
|
@@ -83,6 +83,11 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
83
83
|
# opts.on(nil,'--statistics', "Display Statistics") do |val|
|
84
84
|
# options[:show_statistics] = true
|
85
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
|
86
91
|
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
87
92
|
end
|
88
93
|
optparse.parse!(args)
|
@@ -106,8 +111,10 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
106
111
|
print_dry_run @monitoring_groups_interface.dry.get(check_group['id'])
|
107
112
|
return
|
108
113
|
end
|
114
|
+
# get by ID to sideload associated checks
|
109
115
|
json_response = @monitoring_groups_interface.get(check_group['id'])
|
110
116
|
check_group = json_response['checkGroup']
|
117
|
+
|
111
118
|
if options[:json]
|
112
119
|
puts as_json(json_response, options, "checkGroup")
|
113
120
|
return 0
|
@@ -145,8 +152,8 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
145
152
|
# print as_pretty_table(check_groups, [:id, {"Check Group" => :name}], options)
|
146
153
|
print_checks_table(checks, options)
|
147
154
|
else
|
148
|
-
|
149
|
-
|
155
|
+
print "\n", yellow
|
156
|
+
puts "No Checks"
|
150
157
|
end
|
151
158
|
|
152
159
|
## Open Incidents
|
@@ -157,8 +164,8 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
157
164
|
print_incidents_table(open_incidents)
|
158
165
|
# print_results_pagination(size: open_incidents.size, total: open_incidents.size)
|
159
166
|
else
|
160
|
-
print "\n", cyan
|
161
|
-
puts "No open incidents for this check group"
|
167
|
+
# print "\n", cyan
|
168
|
+
# puts "No open incidents for this check group"
|
162
169
|
end
|
163
170
|
|
164
171
|
## History (plain old Hash)
|
@@ -170,7 +177,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
170
177
|
issues = history_items
|
171
178
|
if history_items && !history_items.empty?
|
172
179
|
print_h2 "History"
|
173
|
-
|
180
|
+
print_check_group_history_table(history_items, options)
|
174
181
|
print_results_pagination(history_json_response, {:label => "event", :n_label => "events"})
|
175
182
|
else
|
176
183
|
print "\n"
|
@@ -241,7 +248,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
241
248
|
if history_items.empty?
|
242
249
|
print cyan,"No history found.",reset,"\n"
|
243
250
|
else
|
244
|
-
|
251
|
+
print_check_group_history_table(history_items, options)
|
245
252
|
print_results_pagination(json_response, {:label => "event", :n_label => "events"})
|
246
253
|
end
|
247
254
|
print reset,"\n"
|
@@ -253,7 +260,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
253
260
|
|
254
261
|
def add(args)
|
255
262
|
options = {}
|
256
|
-
params = {
|
263
|
+
params = {}
|
257
264
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
258
265
|
opts.banner = subcommand_usage("[name]")
|
259
266
|
opts.on('--name VALUE', String, "Name") do |val|
|
@@ -266,13 +273,13 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
266
273
|
params['minHappy'] = val.to_i
|
267
274
|
end
|
268
275
|
opts.on('--severity VALUE', String, "Max Severity. Determines the maximum severity level this group can incur on an incident when failing. Default is critical") do |val|
|
269
|
-
params['severity'] = val
|
276
|
+
params['severity'] = val.to_s.downcase
|
270
277
|
end
|
271
278
|
opts.on('--inUptime [on|off]', String, "Affects Availability. Default is on.") do |val|
|
272
279
|
params['inUptime'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
273
280
|
end
|
274
|
-
opts.on('--checks LIST', Array, "Checks to include in this group, comma separated list of IDs") do |list|
|
275
|
-
if list.size == 1 &&
|
281
|
+
opts.on('--checks LIST', Array, "Checks to include in this group, comma separated list of names or IDs.") do |list|
|
282
|
+
if list.size == 1 && ('[]' == list[0]) # clear array
|
276
283
|
params['checks'] = []
|
277
284
|
else
|
278
285
|
params['checks'] = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
@@ -301,9 +308,35 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
301
308
|
else
|
302
309
|
# merge -O options into normally parsed options
|
303
310
|
params.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
304
|
-
if params['
|
305
|
-
|
311
|
+
if params['name'].nil?
|
312
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'type' => 'text', 'fieldLabel' => 'Name', 'required' => true, 'description' => 'The name of this contact.'}], options[:options])
|
313
|
+
params['name'] = v_prompt['name']
|
314
|
+
end
|
315
|
+
if params['description'].nil?
|
316
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'type' => 'text', 'fieldLabel' => 'Description', 'required' => false, 'description' => 'Contact email address.'}], options[:options])
|
317
|
+
params['description'] = v_prompt['description'] unless v_prompt['description'].to_s.empty?
|
318
|
+
end
|
319
|
+
if params['minHappy'].nil?
|
320
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'minHappy', 'type' => 'text', 'fieldLabel' => 'Min. Checks', 'required' => false, 'description' => 'Min Checks. This specifies the minimum number of checks within the group that must be happy to keep the group from becoming unhealthy.', 'defaultValue' => 1}], options[:options])
|
321
|
+
params['minHappy'] = v_prompt['minHappy'] unless v_prompt['minHappy'].to_s.empty?
|
322
|
+
end
|
323
|
+
if params['severity'].nil?
|
324
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'severity', 'type' => 'text', 'fieldLabel' => 'Severity', 'required' => false, 'description' => 'Max Severity. Determines the maximum severity level this group can incur on an incident when failing. Default is critical', 'defaultValue' => 'critical'}], options[:options])
|
325
|
+
params['severity'] = v_prompt['severity'] unless v_prompt['severity'].to_s.empty?
|
306
326
|
end
|
327
|
+
if params['inUptime'].nil?
|
328
|
+
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])
|
329
|
+
params['inUptime'] = v_prompt['inUptime'] unless v_prompt['inUptime'].to_s.empty?
|
330
|
+
end
|
331
|
+
|
332
|
+
# Checks
|
333
|
+
prompt_results = prompt_for_checks(params, options, @api_client)
|
334
|
+
if prompt_results[:success]
|
335
|
+
params['checks'] = prompt_results[:data] unless prompt_results[:data].nil?
|
336
|
+
else
|
337
|
+
return 1
|
338
|
+
end
|
339
|
+
|
307
340
|
# todo: prompt?
|
308
341
|
payload = {'checkGroup' => params}
|
309
342
|
end
|
@@ -318,7 +351,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
318
351
|
elsif !options[:quiet]
|
319
352
|
check_group = json_response['checkGroup']
|
320
353
|
print_green_success "Added check group #{check_group['name']}"
|
321
|
-
_get(check_group['id'],
|
354
|
+
_get(check_group['id'], options)
|
322
355
|
end
|
323
356
|
return 0
|
324
357
|
rescue RestClient::Exception => e
|
@@ -348,8 +381,8 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
348
381
|
opts.on('--inUptime [on|off]', String, "Affects Availability. Default is on.") do |val|
|
349
382
|
params['inUptime'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
350
383
|
end
|
351
|
-
opts.on('--checks LIST', Array, "Checks to include in this group, comma separated list of IDs") do |list|
|
352
|
-
if list.size == 1 &&
|
384
|
+
opts.on('--checks LIST', Array, "Checks to include in this group, comma separated list of names or IDs.") do |list|
|
385
|
+
if list.size == 1 && ('[]' == list[0]) # clear array
|
353
386
|
params['checks'] = []
|
354
387
|
else
|
355
388
|
params['checks'] = list.collect {|it| it.to_s.strip.empty? ? nil : it.to_s.strip }.compact.uniq
|
@@ -375,10 +408,15 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
375
408
|
else
|
376
409
|
# merge -O options into normally parsed options
|
377
410
|
params.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
411
|
+
# Checks
|
378
412
|
if params['checks']
|
379
|
-
|
413
|
+
prompt_results = prompt_for_checks(params, options, @api_client)
|
414
|
+
if prompt_results[:success]
|
415
|
+
params['checks'] = prompt_results[:data] unless prompt_results[:data].nil?
|
416
|
+
else
|
417
|
+
return 1
|
418
|
+
end
|
380
419
|
end
|
381
|
-
# todo: prompt?
|
382
420
|
payload = {'checkGroup' => params}
|
383
421
|
end
|
384
422
|
@monitoring_groups_interface.setopts(options)
|
@@ -391,7 +429,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
391
429
|
puts as_json(json_response, options)
|
392
430
|
elsif !options[:quiet]
|
393
431
|
print_green_success "Updated check group #{check_group['name']}"
|
394
|
-
_get(check_group['id'],
|
432
|
+
_get(check_group['id'], options)
|
395
433
|
end
|
396
434
|
return 0
|
397
435
|
rescue RestClient::Exception => e
|
@@ -441,7 +479,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
441
479
|
else
|
442
480
|
print_green_success "Unmuted group #{check_group['name']}"
|
443
481
|
end
|
444
|
-
_get(
|
482
|
+
_get(check_group['id'], options)
|
445
483
|
end
|
446
484
|
return 0
|
447
485
|
rescue RestClient::Exception => e
|
@@ -485,7 +523,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
485
523
|
puts as_json(json_response, options)
|
486
524
|
elsif !options[:quiet]
|
487
525
|
print_green_success "Unmuted group #{check_group['name']}"
|
488
|
-
_get(check_group['id'],
|
526
|
+
_get(check_group['id'], options)
|
489
527
|
end
|
490
528
|
return 0
|
491
529
|
rescue RestClient::Exception => e
|
@@ -496,10 +534,11 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
496
534
|
|
497
535
|
def mute_all(args)
|
498
536
|
options = {}
|
499
|
-
params = {
|
537
|
+
params = {}
|
500
538
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
501
539
|
opts.banner = subcommand_usage()
|
502
540
|
opts.on(nil, "--disable", "Disable mute, the same as unmute-all") do
|
541
|
+
params['muted'] = false
|
503
542
|
params['enabled'] = false
|
504
543
|
end
|
505
544
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote, :quiet])
|
@@ -544,7 +583,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
544
583
|
|
545
584
|
def unmute_all(args)
|
546
585
|
options = {}
|
547
|
-
params = {'enabled' => false}
|
586
|
+
params = {'muted' => false, 'enabled' => false}
|
548
587
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
549
588
|
opts.banner = subcommand_usage()
|
550
589
|
build_common_options(opts, options, [:payload, :json, :dry_run, :remote, :quiet])
|
@@ -589,7 +628,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
589
628
|
params = {}
|
590
629
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
591
630
|
opts.banner = subcommand_usage("[name]")
|
592
|
-
build_common_options(opts, options, [:json, :dry_run, :quiet])
|
631
|
+
build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :quiet, :remote])
|
593
632
|
end
|
594
633
|
optparse.parse!(args)
|
595
634
|
if args.count < 1
|