morpheus-cli 5.5.3 → 5.5.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/api_client.rb +12 -0
- data/lib/morpheus/api/appliance_settings_interface.rb +15 -0
- data/lib/morpheus/api/cypher_interface.rb +1 -2
- data/lib/morpheus/api/guidance_settings_interface.rb +17 -0
- data/lib/morpheus/api/monitoring_settings_interface.rb +25 -0
- data/lib/morpheus/api/network_server_groups_interface.rb +7 -0
- data/lib/morpheus/cli/cli_command.rb +10 -1
- data/lib/morpheus/cli/commands/appliance_settings_command.rb +57 -2
- data/lib/morpheus/cli/commands/backup_settings_command.rb +1 -1
- data/lib/morpheus/cli/commands/catalog_item_types_command.rb +6 -1
- data/lib/morpheus/cli/commands/cypher_command.rb +3 -0
- data/lib/morpheus/cli/commands/guidance_command.rb +2 -2
- data/lib/morpheus/cli/commands/guidance_settings.rb +148 -0
- data/lib/morpheus/cli/commands/log_settings_command.rb +1 -1
- data/lib/morpheus/cli/commands/monitoring_settings.rb +228 -0
- data/lib/morpheus/cli/commands/network_server_groups_command.rb +222 -0
- data/lib/morpheus/cli/commands/provisioning_settings_command.rb +1 -1
- data/lib/morpheus/cli/commands/reports_command.rb +10 -0
- data/lib/morpheus/cli/commands/service_catalog_command.rb +36 -2
- data/lib/morpheus/cli/commands/whitelabel_settings_command.rb +1 -1
- data/lib/morpheus/cli/credentials.rb +2 -1
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +14 -12
- data/lib/morpheus/cli/mixins/rest_command.rb +5 -1
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +35 -12
- data/lib/morpheus/cli/option_types.rb +14 -7
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +13 -0
- data/lib/morpheus/ext/string.rb +6 -4
- data/lib/morpheus/routes.rb +39 -7
- data/test/test_case.rb +3 -0
- metadata +8 -2
@@ -294,7 +294,7 @@ EOT
|
|
294
294
|
if records.nil? || records.empty?
|
295
295
|
print cyan,"No #{rest_label_plural.downcase} found.",reset,"\n"
|
296
296
|
else
|
297
|
-
print as_pretty_table(records, rest_list_column_definitions(options).upcase_keys!, options)
|
297
|
+
print as_pretty_table(records, rest_list_column_definitions(options.merge({:parent_record => parent_record})).upcase_keys!, options)
|
298
298
|
print_results_pagination(json_response) if json_response['meta']
|
299
299
|
end
|
300
300
|
print reset,"\n"
|
@@ -318,17 +318,15 @@ EOT
|
|
318
318
|
verify_args!(args:args, optparse:optparse, min:2)
|
319
319
|
connect(options)
|
320
320
|
parse_get_options!(args.count > 1 ? args[1..-1] : [], options, params)
|
321
|
-
|
321
|
+
_get(args[0], args[1..-1].join(" "), params, options)
|
322
|
+
end
|
323
|
+
|
324
|
+
def _get(parent_id, id, params, options)
|
322
325
|
parent_record = rest_parent_find_by_name_or_id(parent_id)
|
323
326
|
if parent_record.nil?
|
324
327
|
return 1, "#{rest_parent_label} not found for '#{parent_id}"
|
325
328
|
end
|
326
329
|
parent_id = parent_record['id']
|
327
|
-
id = args[1..-1].join(" ")
|
328
|
-
_get(parent_id, id, params, options)
|
329
|
-
end
|
330
|
-
|
331
|
-
def _get(parent_id, id, params, options)
|
332
330
|
if id !~ /\A\d{1,}\Z/
|
333
331
|
record = rest_find_by_name_or_id(parent_id, id)
|
334
332
|
if record.nil?
|
@@ -342,7 +340,7 @@ EOT
|
|
342
340
|
return
|
343
341
|
end
|
344
342
|
json_response = rest_interface.get(parent_id, id, params)
|
345
|
-
render_response_for_get(json_response, options)
|
343
|
+
render_response_for_get(json_response, options.merge({:parent_record => parent_record}))
|
346
344
|
return 0, nil
|
347
345
|
end
|
348
346
|
|
@@ -357,14 +355,19 @@ EOT
|
|
357
355
|
print_h2 "Option Types", options
|
358
356
|
print format_option_types_table(record['optionTypes'], options, rest_object_key)
|
359
357
|
end
|
358
|
+
render_response_details_for_get(record, options)
|
360
359
|
print reset,"\n"
|
361
360
|
end
|
362
361
|
end
|
363
362
|
|
363
|
+
def render_response_details_for_get(record, options)
|
364
|
+
# override for custom details
|
365
|
+
end
|
366
|
+
|
364
367
|
def add(args)
|
365
368
|
parent_id, parent_record = nil, nil
|
366
369
|
record_type_id = nil
|
367
|
-
options = {}
|
370
|
+
options = {:options => {:context_map => rest_option_context_map}}
|
368
371
|
option_types = respond_to?("add_#{rest_key}_option_types", true) ? send("add_#{rest_key}_option_types") : []
|
369
372
|
advanced_option_types = respond_to?("add_#{rest_key}_advanced_option_types", true) ? send("add_#{rest_key}_advanced_option_types") : []
|
370
373
|
type_option_type = option_types.find {|it| it['fieldName'] == 'type'}
|
@@ -473,7 +476,7 @@ EOT
|
|
473
476
|
end
|
474
477
|
if my_option_types && !my_option_types.empty?
|
475
478
|
# remove redundant fieldContext
|
476
|
-
my_option_types.each do |option_type|
|
479
|
+
my_option_types.each do |option_type|
|
477
480
|
if option_type['fieldContext'] == rest_object_key
|
478
481
|
option_type['fieldContext'] = nil
|
479
482
|
end
|
@@ -491,6 +494,26 @@ EOT
|
|
491
494
|
v_prompt.booleanize! # 'on' => true
|
492
495
|
record_payload.deep_merge!(v_prompt)
|
493
496
|
end
|
497
|
+
if respond_to?("#{rest_key}_add_prompt", true)
|
498
|
+
record_payload = send("#{rest_key}_add_prompt", record_payload, record_type, parent_record, options)
|
499
|
+
end
|
500
|
+
# permissions
|
501
|
+
if rest_perms_config[:enabled]
|
502
|
+
if rest_perms_config[:version] == 2
|
503
|
+
perms = prompt_permissions_v2(options.deep_merge(rest_perms_config[:options] || {}), rest_perms_config[:excludes] || [])
|
504
|
+
else
|
505
|
+
perms = prompt_permissions(options.deep_merge(rest_perms_config[:options] || {}), rest_perms_config[:excludes] || [])
|
506
|
+
end
|
507
|
+
unless rest_perms_config[:name].nil?
|
508
|
+
perms.transform_keys! {|k| k == 'resourcePermissions' ? rest_perms_config[:name] : k}
|
509
|
+
end
|
510
|
+
unless rest_perms_config[:context].nil?
|
511
|
+
perms_context = {}
|
512
|
+
perms_context[rest_perms_config[:context]] = perms
|
513
|
+
perms = perms_context
|
514
|
+
end
|
515
|
+
record_payload.merge!(perms)
|
516
|
+
end
|
494
517
|
payload[rest_object_key] = record_payload
|
495
518
|
end
|
496
519
|
rest_interface.setopts(options)
|
@@ -502,8 +525,8 @@ EOT
|
|
502
525
|
if json_response['success']
|
503
526
|
render_response(json_response, options, rest_object_key) do
|
504
527
|
record = json_response[rest_object_key]
|
505
|
-
print_green_success "Added #{rest_label.downcase} #{record['name'] || record['id']}"
|
506
|
-
return _get(parent_id, record[
|
528
|
+
print_green_success "Added #{rest_label.downcase} #{record.nil? ? json_response['id'] : record['name'] || record['id']}"
|
529
|
+
return _get(parent_id, record.nil? ? json_response['id'] : record['id'], {}, options)
|
507
530
|
end
|
508
531
|
else
|
509
532
|
print red
|
@@ -55,7 +55,7 @@ module Morpheus
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
def self.prompt(option_types, options={}, api_client=nil, api_params={}, no_prompt=false, paging_enabled=false, ignore_empty=false)
|
58
|
+
def self.prompt(option_types, options={}, api_client=nil, api_params={}, no_prompt=false, paging_enabled=false, ignore_empty=false, skip_sort = false)
|
59
59
|
paging_enabled = false if Morpheus::Cli.windows?
|
60
60
|
no_prompt = no_prompt || options[:no_prompt]
|
61
61
|
results = {}
|
@@ -89,12 +89,18 @@ module Morpheus
|
|
89
89
|
# puts "Options Prompt #{options}"
|
90
90
|
# Sort options by default, group, advanced
|
91
91
|
# add displayOrder if it's missing, so it doesn't end up using a random order
|
92
|
-
if !option_types.find {|it| it['displayOrder'] }
|
93
|
-
|
94
|
-
end
|
92
|
+
# if !option_types.find {|it| it['displayOrder'] && it['displayOrder'] != 0 }
|
93
|
+
# option_types.each_with_index {|it, i| it['displayOrder'] = i+1 }
|
94
|
+
# end
|
95
95
|
cur_field_group = 'default'
|
96
96
|
prompt_local_credentials = true
|
97
|
-
|
97
|
+
# reject help only options..
|
98
|
+
option_types.reject! {|it| it[:for_help_only]}
|
99
|
+
# sort options
|
100
|
+
if !skip_sort
|
101
|
+
option_types = self.sort_option_types(option_types)
|
102
|
+
end
|
103
|
+
option_types.each do |option_type|
|
98
104
|
next if option_type['localCredential'] && !prompt_local_credentials
|
99
105
|
context_map = results
|
100
106
|
value = nil
|
@@ -998,8 +1004,9 @@ module Morpheus
|
|
998
1004
|
def self.password_prompt(option_type)
|
999
1005
|
value_found = false
|
1000
1006
|
while !value_found do
|
1001
|
-
# readline is still echoing secret with 'NUL:'' so just use $stdin on windows
|
1002
|
-
|
1007
|
+
# readline is still echoing secret with 'NUL:'' so just use $stdin on windows
|
1008
|
+
# and some other environments? just use noecho unless running unit tests
|
1009
|
+
if Morpheus::Cli.windows? || !Morpheus::Cli.testing?
|
1003
1010
|
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }#{optional_label(option_type)}#{option_type['defaultValue'] ? ' ['+'************'+']' : ''}: "
|
1004
1011
|
input = $stdin.noecho(&:gets).chomp!
|
1005
1012
|
else
|
data/lib/morpheus/cli/version.rb
CHANGED
data/lib/morpheus/cli.rb
CHANGED
@@ -77,6 +77,19 @@ module Morpheus
|
|
77
77
|
Dir[File.dirname(__FILE__) + "/cli/commands/**/*.rb"].each {|file| load file }
|
78
78
|
end
|
79
79
|
|
80
|
+
# hack needed for unit tests right now
|
81
|
+
@@testing = false unless defined?(@@testing)
|
82
|
+
|
83
|
+
# hack needed for unit tests right now
|
84
|
+
def self.enable_test_mode
|
85
|
+
@@testing = true
|
86
|
+
end
|
87
|
+
|
88
|
+
# hack needed for unit tests right now
|
89
|
+
def self.testing?
|
90
|
+
defined?(@@testing) && @@testing == true
|
91
|
+
end
|
92
|
+
|
80
93
|
# require all CLI modules now (on require)
|
81
94
|
load!
|
82
95
|
|
data/lib/morpheus/ext/string.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
class String
|
2
2
|
|
3
3
|
def pluralize
|
4
|
+
# hacky version of this until we want to depend on ActiveSupport
|
4
5
|
value = self.dup
|
5
6
|
if value == ""
|
6
7
|
value
|
7
8
|
elsif value[-1].chr == "y"
|
8
9
|
value[0..-2] + "ies"
|
9
10
|
elsif value[-1].chr == "s"
|
10
|
-
if value[-2..-1] == "
|
11
|
-
value
|
12
|
-
else
|
11
|
+
if value[-2..-1] == "ss"
|
13
12
|
value + "es"
|
13
|
+
else
|
14
|
+
value
|
14
15
|
end
|
15
16
|
else
|
16
17
|
value + "s"
|
@@ -18,13 +19,14 @@ class String
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def singularize
|
22
|
+
# hacky version of this until we want to depend on ActiveSupport
|
21
23
|
value = self.dup
|
22
24
|
if value == ""
|
23
25
|
value
|
24
26
|
elsif value.size > 3 && value[-3..-1] == "ies"
|
25
27
|
value[0..-4] + "y"
|
26
28
|
elsif value.size > 2 && value[-3..-1] == "ses"
|
27
|
-
value[0..-
|
29
|
+
value[0..-2]
|
28
30
|
elsif value[-1] == "s"
|
29
31
|
value[0..-2]
|
30
32
|
else
|
data/lib/morpheus/routes.rb
CHANGED
@@ -123,8 +123,8 @@ module Morpheus::Routes
|
|
123
123
|
admin: {
|
124
124
|
accounts: {}, # Tenants
|
125
125
|
:'service-plans' => [
|
126
|
-
"
|
127
|
-
"
|
126
|
+
"#!prices",
|
127
|
+
"#!pricesets"
|
128
128
|
],
|
129
129
|
roles: {},
|
130
130
|
users: {},
|
@@ -132,7 +132,19 @@ module Morpheus::Routes
|
|
132
132
|
integrations: {},
|
133
133
|
policies: {},
|
134
134
|
health: ["logs"],
|
135
|
-
settings:
|
135
|
+
settings: [
|
136
|
+
"#!appliance",
|
137
|
+
"#!whitelabel",
|
138
|
+
"provisioning",
|
139
|
+
"monitoring",
|
140
|
+
"backups",
|
141
|
+
"logs",
|
142
|
+
"#!guidance",
|
143
|
+
"environments",
|
144
|
+
"software-licenses",
|
145
|
+
"#!license",
|
146
|
+
"#!utilities"
|
147
|
+
],
|
136
148
|
},
|
137
149
|
:'user-settings' => {}, # User Settings (Profile)
|
138
150
|
} unless defined?(SITE_MAP)
|
@@ -161,14 +173,34 @@ module Morpheus::Routes
|
|
161
173
|
# find the one with smallest match index
|
162
174
|
|
163
175
|
# map well known aliases
|
164
|
-
case(path.
|
165
|
-
when "
|
176
|
+
case(path.dasherize.pluralize)
|
177
|
+
when "servers","hosts","vms","virtual-machines"
|
166
178
|
# actually should be "/infrastructure/inventory" unless id is passed, show route uses /servers though
|
167
179
|
path = "/infrastructure/servers"
|
168
|
-
when "
|
180
|
+
when "computes", "inventories"
|
169
181
|
path = "/infrastructure/inventory"
|
170
|
-
when "
|
182
|
+
when "tenants"
|
171
183
|
path = "/admin/accounts"
|
184
|
+
when "appliance-settings"
|
185
|
+
path = "/admin/settings/#!appliance"
|
186
|
+
when "whitelabel-settings"
|
187
|
+
path = "/admin/settings/#!whitelabel"
|
188
|
+
when "provisioning-settings"
|
189
|
+
path = "/admin/settings/#!provisioning"
|
190
|
+
when "monitoring-settings","monitor-settings"
|
191
|
+
path = "/admin/settings/monitoring"
|
192
|
+
when "backup-settings"
|
193
|
+
path = "/admin/settings/backups"
|
194
|
+
when "log-settings"
|
195
|
+
path = "/admin/settings/logs"
|
196
|
+
when "guidance-settings"
|
197
|
+
path = "/admin/settings/#!guidance"
|
198
|
+
when "environments"
|
199
|
+
path = "/admin/settings/environments"
|
200
|
+
when "software-licenses"
|
201
|
+
path = "/admin/settings/software-licenses"
|
202
|
+
when "license"
|
203
|
+
path = "/admin/settings/#!license"
|
172
204
|
end
|
173
205
|
# dasherize path and attempt to match the plural first
|
174
206
|
plural_path = path.pluralize
|
data/test/test_case.rb
CHANGED
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: 5.5.3
|
4
|
+
version: 5.5.3.2
|
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:
|
14
|
+
date: 2023-02-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -235,6 +235,7 @@ files:
|
|
235
235
|
- lib/morpheus/api/group_policies_interface.rb
|
236
236
|
- lib/morpheus/api/groups_interface.rb
|
237
237
|
- lib/morpheus/api/guidance_interface.rb
|
238
|
+
- lib/morpheus/api/guidance_settings_interface.rb
|
238
239
|
- lib/morpheus/api/health_interface.rb
|
239
240
|
- lib/morpheus/api/image_builder_boot_scripts_interface.rb
|
240
241
|
- lib/morpheus/api/image_builder_image_builds_interface.rb
|
@@ -273,6 +274,7 @@ files:
|
|
273
274
|
- lib/morpheus/api/monitoring_groups_interface.rb
|
274
275
|
- lib/morpheus/api/monitoring_incidents_interface.rb
|
275
276
|
- lib/morpheus/api/monitoring_interface.rb
|
277
|
+
- lib/morpheus/api/monitoring_settings_interface.rb
|
276
278
|
- lib/morpheus/api/network_dhcp_relays_interface.rb
|
277
279
|
- lib/morpheus/api/network_dhcp_servers_interface.rb
|
278
280
|
- lib/morpheus/api/network_domain_records_interface.rb
|
@@ -286,6 +288,7 @@ files:
|
|
286
288
|
- lib/morpheus/api/network_proxies_interface.rb
|
287
289
|
- lib/morpheus/api/network_routers_interface.rb
|
288
290
|
- lib/morpheus/api/network_security_servers_interface.rb
|
291
|
+
- lib/morpheus/api/network_server_groups_interface.rb
|
289
292
|
- lib/morpheus/api/network_servers_interface.rb
|
290
293
|
- lib/morpheus/api/network_services_interface.rb
|
291
294
|
- lib/morpheus/api/network_static_routes_interface.rb
|
@@ -406,6 +409,7 @@ files:
|
|
406
409
|
- lib/morpheus/cli/commands/get_prompt_command.rb
|
407
410
|
- lib/morpheus/cli/commands/groups.rb
|
408
411
|
- lib/morpheus/cli/commands/guidance_command.rb
|
412
|
+
- lib/morpheus/cli/commands/guidance_settings.rb
|
409
413
|
- lib/morpheus/cli/commands/health_command.rb
|
410
414
|
- lib/morpheus/cli/commands/history_command.rb
|
411
415
|
- lib/morpheus/cli/commands/hosts.rb
|
@@ -445,6 +449,7 @@ files:
|
|
445
449
|
- lib/morpheus/cli/commands/monitoring_contacts_command.rb
|
446
450
|
- lib/morpheus/cli/commands/monitoring_groups_command.rb
|
447
451
|
- lib/morpheus/cli/commands/monitoring_incidents_command.rb
|
452
|
+
- lib/morpheus/cli/commands/monitoring_settings.rb
|
448
453
|
- lib/morpheus/cli/commands/network_dhcp_relays_command.rb
|
449
454
|
- lib/morpheus/cli/commands/network_dhcp_servers_command.rb
|
450
455
|
- lib/morpheus/cli/commands/network_domains_command.rb
|
@@ -456,6 +461,7 @@ files:
|
|
456
461
|
- lib/morpheus/cli/commands/network_pools_command.rb
|
457
462
|
- lib/morpheus/cli/commands/network_proxies_command.rb
|
458
463
|
- lib/morpheus/cli/commands/network_routers_command.rb
|
464
|
+
- lib/morpheus/cli/commands/network_server_groups_command.rb
|
459
465
|
- lib/morpheus/cli/commands/network_services_command.rb
|
460
466
|
- lib/morpheus/cli/commands/network_static_routes_command.rb
|
461
467
|
- lib/morpheus/cli/commands/network_transport_zones_command.rb
|