morpheus-cli 4.1.7 → 4.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +2 -2
- data/README.md +22 -10
- data/lib/morpheus/api/api_client.rb +13 -1
- data/lib/morpheus/api/approvals_interface.rb +35 -0
- data/lib/morpheus/api/integrations_interface.rb +29 -0
- data/lib/morpheus/api/jobs_interface.rb +86 -0
- data/lib/morpheus/cli.rb +3 -0
- data/lib/morpheus/cli/appliance_settings_command.rb +13 -7
- data/lib/morpheus/cli/approvals_command.rb +236 -0
- data/lib/morpheus/cli/backup_settings_command.rb +11 -8
- data/lib/morpheus/cli/cli_command.rb +1 -1
- data/lib/morpheus/cli/clouds.rb +6 -1
- data/lib/morpheus/cli/clusters.rb +11 -9
- data/lib/morpheus/cli/groups.rb +3 -2
- data/lib/morpheus/cli/integrations_command.rb +97 -0
- data/lib/morpheus/cli/jobs_command.rb +930 -0
- data/lib/morpheus/cli/log_settings_command.rb +4 -4
- data/lib/morpheus/cli/monitoring_apps_command.rb +3 -3
- data/lib/morpheus/cli/monitoring_checks_command.rb +2 -2
- data/lib/morpheus/cli/monitoring_groups_command.rb +3 -2
- data/lib/morpheus/cli/monitoring_incidents_command.rb +3 -2
- data/lib/morpheus/cli/option_types.rb +21 -6
- data/lib/morpheus/cli/tenants_command.rb +3 -3
- data/lib/morpheus/cli/users.rb +17 -23
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/whitelabel_settings_command.rb +2 -2
- data/morpheus-cli.gemspec +1 -1
- metadata +9 -3
@@ -3,9 +3,9 @@ require 'morpheus/cli/cli_command'
|
|
3
3
|
class Morpheus::Cli::LogSettingsCommand
|
4
4
|
include Morpheus::Cli::CliCommand
|
5
5
|
include Morpheus::Cli::AccountsHelper
|
6
|
-
set_command_hidden
|
7
|
-
set_command_name :'log-settings'
|
8
6
|
|
7
|
+
set_command_name :'log-settings'
|
8
|
+
set_command_hidden
|
9
9
|
register_subcommands :get, :update
|
10
10
|
register_subcommands :enable_integration, :disable_integration
|
11
11
|
register_subcommands :add_syslog_rule, :remove_syslog_rule
|
@@ -147,8 +147,8 @@ class Morpheus::Cli::LogSettingsCommand
|
|
147
147
|
end
|
148
148
|
|
149
149
|
if !options[:integrations].nil?
|
150
|
-
if options[:integrations].reject { |rule| rule['name']
|
151
|
-
print_red_alert "Invalid integration: name
|
150
|
+
if options[:integrations].reject { |rule| rule['name'] }.count > 0
|
151
|
+
print_red_alert "Invalid integration: name is required"
|
152
152
|
return 1
|
153
153
|
end
|
154
154
|
payload['logSettings']['integrations'] = options[:integrations]
|
@@ -486,8 +486,8 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
486
486
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
487
487
|
opts.banner = subcommand_usage("[name]")
|
488
488
|
opts.on(nil, "--disable", "Unmute instead, the same as the unmute command") do
|
489
|
-
params['enabled'] = false
|
490
489
|
params['muted'] = false
|
490
|
+
params['enabled'] = false
|
491
491
|
end
|
492
492
|
opts.footer = "Mute a monitoring app. This prevents it from creating new incidents." + "\n" +
|
493
493
|
"[name] is required. This is the name or id of a monitoring app."
|
@@ -517,7 +517,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
517
517
|
if options[:json]
|
518
518
|
puts as_json(json_response, options)
|
519
519
|
elsif !options[:quiet]
|
520
|
-
if params['
|
520
|
+
if params['muted'] != false
|
521
521
|
print_green_success "Muted app #{monitor_app['name']}"
|
522
522
|
else
|
523
523
|
print_green_success "Unmuted app #{monitor_app['name']}"
|
@@ -611,7 +611,7 @@ class Morpheus::Cli::MonitoringAppsCommand
|
|
611
611
|
puts as_json(json_response, options)
|
612
612
|
elsif !options[:quiet]
|
613
613
|
num_updated = json_response['updated']
|
614
|
-
if params['
|
614
|
+
if params['muted'] != false
|
615
615
|
print_green_success "Muted #{num_updated} apps"
|
616
616
|
else
|
617
617
|
print_green_success "Unmuted #{num_updated} apps"
|
@@ -505,7 +505,7 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
505
505
|
if options[:json]
|
506
506
|
puts as_json(json_response, options)
|
507
507
|
elsif !options[:quiet]
|
508
|
-
if params['
|
508
|
+
if params['muted'] != false
|
509
509
|
print_green_success "Muted check #{check['name']}"
|
510
510
|
else
|
511
511
|
print_green_success "Unmuted check #{check['name']}"
|
@@ -599,7 +599,7 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
599
599
|
puts as_json(json_response, options)
|
600
600
|
elsif !options[:quiet]
|
601
601
|
num_updated = json_response['updated']
|
602
|
-
if params['
|
602
|
+
if params['muted'] != false
|
603
603
|
print_green_success "Muted #{num_updated} checks"
|
604
604
|
else
|
605
605
|
print_green_success "Unmuted #{num_updated} checks"
|
@@ -445,6 +445,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
445
445
|
opts.banner = subcommand_usage("[name]")
|
446
446
|
opts.on(nil, "--disable", "Disable mute, the same as unmute") do
|
447
447
|
params['enabled'] = false
|
448
|
+
params['muted'] = false
|
448
449
|
end
|
449
450
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote, :quiet])
|
450
451
|
opts.footer = "Mute a check group. This prevents it from creating new incidents." + "\n" +
|
@@ -474,7 +475,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
474
475
|
if options[:json]
|
475
476
|
puts as_json(json_response, options)
|
476
477
|
elsif !options[:quiet]
|
477
|
-
if params['
|
478
|
+
if params['muted'] != false
|
478
479
|
print_green_success "Muted group #{check_group['name']}"
|
479
480
|
else
|
480
481
|
print_green_success "Unmuted group #{check_group['name']}"
|
@@ -568,7 +569,7 @@ class Morpheus::Cli::MonitoringGroupsCommand
|
|
568
569
|
puts as_json(json_response, options)
|
569
570
|
elsif !options[:quiet]
|
570
571
|
num_updated = json_response['updated']
|
571
|
-
if params['
|
572
|
+
if params['muted'] != false
|
572
573
|
print_green_success "Muted #{num_updated} check groups"
|
573
574
|
else
|
574
575
|
print_green_success "Unmuted #{num_updated} check groups"
|
@@ -587,7 +587,7 @@ class Morpheus::Cli::MonitoringIncidentsCommand
|
|
587
587
|
if options[:json]
|
588
588
|
puts as_json(json_response, options)
|
589
589
|
elsif !options[:quiet]
|
590
|
-
if params['
|
590
|
+
if params['muted'] != false
|
591
591
|
print_green_success "Muted incident #{incident['id']}"
|
592
592
|
else
|
593
593
|
print_green_success "Unmuted incident #{incident['id']}"
|
@@ -651,6 +651,7 @@ class Morpheus::Cli::MonitoringIncidentsCommand
|
|
651
651
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
652
652
|
opts.banner = subcommand_usage()
|
653
653
|
opts.on(nil, "--disable", "Disable mute state instead, the same as unmute-all") do
|
654
|
+
params['muted'] = false
|
654
655
|
params['enabled'] = false
|
655
656
|
end
|
656
657
|
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :quiet, :remote])
|
@@ -680,7 +681,7 @@ class Morpheus::Cli::MonitoringIncidentsCommand
|
|
680
681
|
puts as_json(json_response, options)
|
681
682
|
elsif !options[:quiet]
|
682
683
|
num_updated = json_response['updated']
|
683
|
-
if params['
|
684
|
+
if params['muted'] != false
|
684
685
|
print_green_success "Muted #{num_updated} open incidents"
|
685
686
|
else
|
686
687
|
print_green_success "Unmuted #{num_updated} open incidents"
|
@@ -35,7 +35,7 @@ module Morpheus
|
|
35
35
|
prompt(option_types, options, api_client, api_params, true)
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.prompt(option_types, options={}, api_client=nil,api_params={}, no_prompt=false)
|
38
|
+
def self.prompt(option_types, options={}, api_client=nil, api_params={}, no_prompt=false, paging_enabled=false)
|
39
39
|
results = {}
|
40
40
|
options = options || {}
|
41
41
|
# puts "Options Prompt #{options}"
|
@@ -153,7 +153,7 @@ module Morpheus
|
|
153
153
|
# I suppose the entered value should take precedence
|
154
154
|
# api_params = api_params.merge(options) # this might be good enough
|
155
155
|
# dup it
|
156
|
-
value = select_prompt(option_type,api_client, (api_params || {}).merge(results))
|
156
|
+
value = select_prompt(option_type, api_client, (api_params || {}).merge(results), options[:no_prompt], nil, paging_enabled)
|
157
157
|
elsif option_type['type'] == 'hidden'
|
158
158
|
value = option_type['defaultValue']
|
159
159
|
input = value
|
@@ -245,7 +245,7 @@ module Morpheus
|
|
245
245
|
Thread.current[:_last_select]
|
246
246
|
end
|
247
247
|
|
248
|
-
def self.select_prompt(option_type,api_client, api_params={}, no_prompt=false, use_value=nil)
|
248
|
+
def self.select_prompt(option_type,api_client, api_params={}, no_prompt=false, use_value=nil, paging_enabled=false)
|
249
249
|
value_found = false
|
250
250
|
value = nil
|
251
251
|
default_value = option_type['defaultValue']
|
@@ -320,6 +320,12 @@ module Morpheus
|
|
320
320
|
end
|
321
321
|
end
|
322
322
|
end
|
323
|
+
|
324
|
+
page_size = Readline.get_screen_size[0] - 6
|
325
|
+
if paging_enabled && page_size < select_options.count
|
326
|
+
paging = {:cur_page => 0, :page_size => page_size, :total => select_options.count}
|
327
|
+
end
|
328
|
+
|
323
329
|
while !value_found do
|
324
330
|
Readline.completion_append_character = ""
|
325
331
|
Readline.basic_word_break_characters = ''
|
@@ -336,7 +342,9 @@ module Morpheus
|
|
336
342
|
}
|
337
343
|
matches
|
338
344
|
}
|
339
|
-
|
345
|
+
|
346
|
+
has_more_pages = paging && (paging[:cur_page] * paging[:page_size]) < paging[:total]
|
347
|
+
input = Readline.readline("#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}#{!default_value.to_s.empty? ? ' ['+default_value.to_s+']' : ''} ['?' for#{has_more_pages && paging[:cur_page] > 0 ? ' more ' : ' '}options]: ", false).to_s
|
340
348
|
input = input.chomp.strip
|
341
349
|
if input.empty? && default_value
|
342
350
|
input = default_value.to_s
|
@@ -351,7 +359,8 @@ module Morpheus
|
|
351
359
|
|
352
360
|
if input == '?'
|
353
361
|
help_prompt(option_type)
|
354
|
-
display_select_options(option_type, select_options)
|
362
|
+
display_select_options(option_type, select_options, paging)
|
363
|
+
paging[:cur_page] = (paging[:cur_page] + 1) * paging[:page_size] < paging[:total] ? paging[:cur_page] + 1 : 0 if paging
|
355
364
|
elsif !value.nil? || option_type['required'] != true
|
356
365
|
value_found = true
|
357
366
|
end
|
@@ -505,8 +514,14 @@ module Morpheus
|
|
505
514
|
api_client.options.options_for_source(source,params)['data']
|
506
515
|
end
|
507
516
|
|
508
|
-
def self.display_select_options(opt, select_options = [])
|
517
|
+
def self.display_select_options(opt, select_options = [], paging = nil)
|
509
518
|
header = opt['fieldLabel'] ? "#{opt['fieldLabel']} Options" : "Options"
|
519
|
+
if paging
|
520
|
+
offset = paging[:cur_page] * paging[:page_size]
|
521
|
+
limit = [offset + paging[:page_size], select_options.count].min - 1
|
522
|
+
header = "#{header} (#{offset+1}-#{limit+1} of #{paging[:total]})"
|
523
|
+
select_options = select_options[(offset)..(limit)]
|
524
|
+
end
|
510
525
|
puts "\n#{header}"
|
511
526
|
puts "==============="
|
512
527
|
select_options.each do |option|
|
@@ -43,7 +43,7 @@ class Morpheus::Cli::TenantsCommand
|
|
43
43
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
44
44
|
opts.banner = subcommand_usage()
|
45
45
|
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
46
|
-
opts.footer = "List tenants
|
46
|
+
opts.footer = "List tenants."
|
47
47
|
end
|
48
48
|
optparse.parse!(args)
|
49
49
|
connect(options)
|
@@ -53,7 +53,7 @@ class Morpheus::Cli::TenantsCommand
|
|
53
53
|
@accounts_interface.setopts(options)
|
54
54
|
if options[:dry_run]
|
55
55
|
print_dry_run @accounts_interface.dry.list(params)
|
56
|
-
return
|
56
|
+
return 0
|
57
57
|
end
|
58
58
|
json_response = @accounts_interface.list(params)
|
59
59
|
render_result = render_with_format(json_response, options, 'accounts')
|
@@ -64,7 +64,7 @@ class Morpheus::Cli::TenantsCommand
|
|
64
64
|
subtitles += parse_list_subtitles(options)
|
65
65
|
print_h1 title, subtitles
|
66
66
|
if accounts.empty?
|
67
|
-
|
67
|
+
print cyan,"No tenants found.",reset,"\n"
|
68
68
|
else
|
69
69
|
print_accounts_table(accounts)
|
70
70
|
print_results_pagination(json_response)
|
data/lib/morpheus/cli/users.rb
CHANGED
@@ -53,32 +53,26 @@ class Morpheus::Cli::Users
|
|
53
53
|
return
|
54
54
|
end
|
55
55
|
json_response = @users_interface.list(account_id, params)
|
56
|
+
render_result = render_with_format(json_response, options, 'users')
|
57
|
+
return 0 if render_result
|
56
58
|
users = json_response['users']
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
|
60
|
+
title = "Morpheus Users"
|
61
|
+
subtitles = []
|
62
|
+
if account
|
63
|
+
subtitles << "Account: #{account['name']}".strip
|
64
|
+
end
|
65
|
+
subtitles += parse_list_subtitles(options)
|
66
|
+
print_h1 title, subtitles, options
|
67
|
+
if users.empty?
|
68
|
+
print cyan,"No users found.",reset,"\n"
|
66
69
|
else
|
67
|
-
|
68
|
-
|
69
|
-
if account
|
70
|
-
subtitles << "Account: #{account['name']}".strip
|
71
|
-
end
|
72
|
-
subtitles += parse_list_subtitles(options)
|
73
|
-
print_h1 title, subtitles, options
|
74
|
-
if users.empty?
|
75
|
-
puts yellow,"No users found.",reset
|
76
|
-
else
|
77
|
-
print_users_table(users, options)
|
78
|
-
print_results_pagination(json_response)
|
79
|
-
end
|
80
|
-
print reset,"\n"
|
70
|
+
print_users_table(users, options)
|
71
|
+
print_results_pagination(json_response)
|
81
72
|
end
|
73
|
+
print reset,"\n"
|
74
|
+
return 0
|
75
|
+
|
82
76
|
rescue RestClient::Exception => e
|
83
77
|
print_rest_exception(e, options)
|
84
78
|
return 1
|
data/lib/morpheus/cli/version.rb
CHANGED
@@ -3,9 +3,9 @@ require 'morpheus/cli/cli_command'
|
|
3
3
|
class Morpheus::Cli::WhitelabelSettingsCommand
|
4
4
|
include Morpheus::Cli::CliCommand
|
5
5
|
# include Morpheus::Cli::AccountsHelper
|
6
|
-
set_command_hidden
|
7
|
-
set_command_name :'whitelabel-settings'
|
8
6
|
|
7
|
+
set_command_name :'whitelabel-settings'
|
8
|
+
set_command_hidden
|
9
9
|
register_subcommands :get, :update
|
10
10
|
register_subcommands :update_images, :reset_image, :download_image, :view_image
|
11
11
|
set_default_subcommand :get
|
data/morpheus-cli.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.required_ruby_version = '>= 2.
|
21
|
+
spec.required_ruby_version = '>= 2.5.1' # according to http.rb doc
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
spec.add_dependency 'term-ansicolor', '~> 1.3.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morpheus-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Estes
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-11-
|
14
|
+
date: 2019-11-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- lib/morpheus/api/accounts_interface.rb
|
163
163
|
- lib/morpheus/api/api_client.rb
|
164
164
|
- lib/morpheus/api/appliance_settings_interface.rb
|
165
|
+
- lib/morpheus/api/approvals_interface.rb
|
165
166
|
- lib/morpheus/api/apps_interface.rb
|
166
167
|
- lib/morpheus/api/archive_buckets_interface.rb
|
167
168
|
- lib/morpheus/api/archive_files_interface.rb
|
@@ -192,6 +193,8 @@ files:
|
|
192
193
|
- lib/morpheus/api/image_builder_preseed_scripts_interface.rb
|
193
194
|
- lib/morpheus/api/instance_types_interface.rb
|
194
195
|
- lib/morpheus/api/instances_interface.rb
|
196
|
+
- lib/morpheus/api/integrations_interface.rb
|
197
|
+
- lib/morpheus/api/jobs_interface.rb
|
195
198
|
- lib/morpheus/api/key_pairs_interface.rb
|
196
199
|
- lib/morpheus/api/library_compute_type_layouts_interface.rb
|
197
200
|
- lib/morpheus/api/library_container_scripts_interface.rb
|
@@ -258,6 +261,7 @@ files:
|
|
258
261
|
- lib/morpheus/cli/account_groups_command.rb
|
259
262
|
- lib/morpheus/cli/accounts.rb
|
260
263
|
- lib/morpheus/cli/appliance_settings_command.rb
|
264
|
+
- lib/morpheus/cli/approvals_command.rb
|
261
265
|
- lib/morpheus/cli/apps.rb
|
262
266
|
- lib/morpheus/cli/archives_command.rb
|
263
267
|
- lib/morpheus/cli/auth_command.rb
|
@@ -312,6 +316,8 @@ files:
|
|
312
316
|
- lib/morpheus/cli/image_builder_command.rb
|
313
317
|
- lib/morpheus/cli/instance_types.rb
|
314
318
|
- lib/morpheus/cli/instances.rb
|
319
|
+
- lib/morpheus/cli/integrations_command.rb
|
320
|
+
- lib/morpheus/cli/jobs_command.rb
|
315
321
|
- lib/morpheus/cli/key_pairs.rb
|
316
322
|
- lib/morpheus/cli/library.rb
|
317
323
|
- lib/morpheus/cli/library_container_scripts_command.rb
|
@@ -399,7 +405,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
399
405
|
requirements:
|
400
406
|
- - ">="
|
401
407
|
- !ruby/object:Gem::Version
|
402
|
-
version:
|
408
|
+
version: 2.5.1
|
403
409
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
404
410
|
requirements:
|
405
411
|
- - ">="
|