morpheus-cli 3.6.28 → 3.6.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/morpheus/api/api_client.rb +16 -0
- data/lib/morpheus/api/cloud_folders_interface.rb +47 -0
- data/lib/morpheus/api/cloud_resource_pools_interface.rb +47 -0
- data/lib/morpheus/api/network_types_interface.rb +26 -0
- data/lib/morpheus/api/reports_interface.rb +77 -0
- data/lib/morpheus/api/security_group_rules_interface.rb +6 -0
- data/lib/morpheus/api/security_groups_interface.rb +21 -15
- data/lib/morpheus/cli.rb +3 -0
- data/lib/morpheus/cli/accounts.rb +1 -1
- data/lib/morpheus/cli/apps.rb +2 -2
- data/lib/morpheus/cli/archives_command.rb +18 -18
- data/lib/morpheus/cli/blueprints_command.rb +1 -1
- data/lib/morpheus/cli/boot_scripts_command.rb +6 -6
- data/lib/morpheus/cli/cli_command.rb +4 -0
- data/lib/morpheus/cli/cloud_datastores_command.rb +58 -20
- data/lib/morpheus/cli/cloud_folders_command.rb +463 -0
- data/lib/morpheus/cli/cloud_resource_pools_command.rb +707 -0
- data/lib/morpheus/cli/clouds.rb +2 -0
- data/lib/morpheus/cli/hosts.rb +33 -8
- data/lib/morpheus/cli/instances.rb +79 -54
- data/lib/morpheus/cli/library_option_lists_command.rb +1 -1
- data/lib/morpheus/cli/library_option_types_command.rb +1 -1
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +11 -2
- data/lib/morpheus/cli/monitoring_contacts_command.rb +1 -1
- data/lib/morpheus/cli/monitoring_incidents_command.rb +1 -1
- data/lib/morpheus/cli/network_services_command.rb +7 -3
- data/lib/morpheus/cli/networks_command.rb +164 -63
- data/lib/morpheus/cli/option_types.rb +16 -15
- data/lib/morpheus/cli/policies_command.rb +76 -9
- data/lib/morpheus/cli/preseed_scripts_command.rb +2 -2
- data/lib/morpheus/cli/remote.rb +26 -28
- data/lib/morpheus/cli/reports_command.rb +594 -0
- data/lib/morpheus/cli/security_group_rules.rb +5 -1
- data/lib/morpheus/cli/security_groups.rb +882 -45
- data/lib/morpheus/cli/tasks.rb +158 -23
- data/lib/morpheus/cli/tenants_command.rb +1 -1
- data/lib/morpheus/cli/users.rb +1 -1
- data/lib/morpheus/cli/version.rb +1 -1
- metadata +9 -2
@@ -211,7 +211,7 @@ class Morpheus::Cli::LibraryOptionTypesCommand
|
|
211
211
|
#params = options[:options] || {}
|
212
212
|
params = Morpheus::Cli::OptionTypes.no_prompt(update_option_type_option_types, options[:options], @api_client, options[:params])
|
213
213
|
if params.empty?
|
214
|
-
print_red_alert "Specify
|
214
|
+
print_red_alert "Specify at least one option to update"
|
215
215
|
puts optparse
|
216
216
|
exit 1
|
217
217
|
end
|
@@ -317,7 +317,10 @@ module Morpheus::Cli::ProvisioningHelper
|
|
317
317
|
|
318
318
|
available_versions = options_interface.options_for_source('instanceVersions',{groupId: group_id, cloudId: cloud_id, instanceTypeId: instance_type['id']})['data']
|
319
319
|
default_version_value = payload['instance']['version'] ? payload['instance']['version'] : payload['version']
|
320
|
-
default_layout_value = payload['instance']['layout'] ? payload['instance']['layout']['
|
320
|
+
default_layout_value = payload['instance']['layout'] ? payload['instance']['layout'] : payload['layout']
|
321
|
+
if default_layout_value && default_layout_value.is_a?(Hash)
|
322
|
+
default_layout_value = default_layout_value['id']
|
323
|
+
end
|
321
324
|
# JD: version is always nil because it is not stored in the blueprint or config !!
|
322
325
|
# so for now, infer the version from the layout
|
323
326
|
# requires api 3.6.2 to get "layouts" from /options/versions
|
@@ -341,6 +344,12 @@ module Morpheus::Cli::ProvisioningHelper
|
|
341
344
|
version_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'version', 'type' => 'select', 'fieldLabel' => 'Version', 'selectOptions' => available_versions, 'required' => version_is_required, 'skipSingleOption' => true, 'autoPickOption' => true, 'description' => 'Select which version of the instance type to be provisioned.', 'defaultValue' => default_version_value}],options[:options],api_client,{groupId: group_id, cloudId: cloud_id, instanceTypeId: instance_type['id']})
|
342
345
|
version_value = version_prompt['version']
|
343
346
|
end
|
347
|
+
# JD: there is a bug here, the version needs to be passed perhaps? or the optionSource methods need updating...
|
348
|
+
# could just allow for now ...
|
349
|
+
# if options[:options]["layout"]
|
350
|
+
# layout_id = options[:options]["layout"]
|
351
|
+
# ...
|
352
|
+
# end
|
344
353
|
layout_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'layout', 'type' => 'select', 'fieldLabel' => 'Layout', 'optionSource' => 'layoutsForCloud', 'required' => true, 'description' => 'Select which configuration of the instance type to be provisioned.', 'defaultValue' => default_layout_value}],options[:options],api_client,{groupId: group_id, cloudId: cloud_id, instanceTypeId: instance_type['id'], version: version_value})
|
345
354
|
layout_id = layout_prompt['layout']
|
346
355
|
layout = instance_type['instanceTypeLayouts'].find{ |lt| lt['id'] == layout_id.to_i}
|
@@ -432,7 +441,7 @@ module Morpheus::Cli::ProvisioningHelper
|
|
432
441
|
option_type_list = option_type_list.reject {|opt| ['resourcePool','resourcePoolId','azureResourceGroupId'].include?(opt['fieldName']) }
|
433
442
|
end
|
434
443
|
|
435
|
-
instance_config_payload = Morpheus::Cli::OptionTypes.prompt(option_type_list, options[:options], @api_client, {groupId: group_id, cloudId: cloud_id, zoneId: cloud_id, instanceTypeId: instance_type['id'], version:
|
444
|
+
instance_config_payload = Morpheus::Cli::OptionTypes.prompt(option_type_list, options[:options], @api_client, {groupId: group_id, cloudId: cloud_id, zoneId: cloud_id, instanceTypeId: instance_type['id'], version: version_value})
|
436
445
|
payload.deep_merge!(instance_config_payload)
|
437
446
|
|
438
447
|
## Advanced Options
|
@@ -231,7 +231,7 @@ class Morpheus::Cli::MonitoringContactsCommand
|
|
231
231
|
contact = find_contact_by_name_or_id(args[0])
|
232
232
|
|
233
233
|
if params.empty?
|
234
|
-
print_red_alert "Specify
|
234
|
+
print_red_alert "Specify at least one option to update"
|
235
235
|
puts optparse
|
236
236
|
exit 1
|
237
237
|
end
|
@@ -35,8 +35,8 @@ class Morpheus::Cli::NetworkServicesCommand
|
|
35
35
|
params = {}
|
36
36
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
37
37
|
opts.banner = subcommand_usage()
|
38
|
-
build_common_options(opts, options, [:list, :json, :yaml, :csv, :fields, :
|
39
|
-
opts.footer = "List network services."
|
38
|
+
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
39
|
+
opts.footer = "List network services (Integrations)."
|
40
40
|
end
|
41
41
|
optparse.parse!(args)
|
42
42
|
connect(options)
|
@@ -81,7 +81,11 @@ class Morpheus::Cli::NetworkServicesCommand
|
|
81
81
|
print cyan
|
82
82
|
print as_pretty_table(rows, columns, options)
|
83
83
|
print reset
|
84
|
-
|
84
|
+
if json_response['meta']
|
85
|
+
print_results_pagination(json_response, {:label => "network service", :n_label => "network services"})
|
86
|
+
else
|
87
|
+
print_results_pagination({'meta'=>{'total'=>rows.size,'size'=>rows.size,'max'=>options[:max] || rows.size,'offset'=>0}}, {:label => "network service", :n_label => "network services"})
|
88
|
+
end
|
85
89
|
end
|
86
90
|
print reset,"\n"
|
87
91
|
return 0
|
@@ -11,7 +11,8 @@ class Morpheus::Cli::NetworksCommand
|
|
11
11
|
set_command_name :networks
|
12
12
|
|
13
13
|
register_subcommands :list, :get, :add, :update, :remove #, :generate_pool
|
14
|
-
|
14
|
+
register_subcommands :'types' => :list_types
|
15
|
+
|
15
16
|
# set_default_subcommand :list
|
16
17
|
|
17
18
|
def initialize()
|
@@ -21,6 +22,7 @@ class Morpheus::Cli::NetworksCommand
|
|
21
22
|
def connect(opts)
|
22
23
|
@api_client = establish_remote_appliance_connection(opts)
|
23
24
|
@networks_interface = @api_client.networks
|
25
|
+
@network_types_interface = @api_client.network_types
|
24
26
|
@clouds_interface = @api_client.clouds
|
25
27
|
@options_interface = @api_client.options
|
26
28
|
end
|
@@ -154,6 +156,7 @@ class Morpheus::Cli::NetworksCommand
|
|
154
156
|
"Primary DNS" => 'dnsPrimary',
|
155
157
|
"Secondary DNS" => 'dnsSecondary',
|
156
158
|
"Pool" => lambda {|it| it['pool'] ? it['pool']['name'] : '' },
|
159
|
+
"VPC" => lambda {|it| it['zonePool'] ? it['zonePool']['name'] : '' },
|
157
160
|
"DHCP" => lambda {|it| it['dhcpServer'] ? 'Yes' : 'No' },
|
158
161
|
"Allow IP Override" => lambda {|it| it['allowStaticOverride'] ? 'Yes' : 'No' },
|
159
162
|
"Visibility" => lambda {|it| it['visibility'].to_s.capitalize },
|
@@ -323,6 +326,22 @@ class Morpheus::Cli::NetworksCommand
|
|
323
326
|
# allow arbitrary -O options
|
324
327
|
payload['network'].deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
325
328
|
|
329
|
+
# Name
|
330
|
+
if options['name']
|
331
|
+
payload['network']['name'] = options['name']
|
332
|
+
else
|
333
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'description' => 'Name for this network.'}], options)
|
334
|
+
payload['network']['name'] = v_prompt['name']
|
335
|
+
end
|
336
|
+
|
337
|
+
# Description
|
338
|
+
if options['description']
|
339
|
+
payload['network']['description'] = options['description']
|
340
|
+
else
|
341
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false, 'description' => 'Description of network.'}], options)
|
342
|
+
payload['network']['description'] = v_prompt['description']
|
343
|
+
end
|
344
|
+
|
326
345
|
# Cloud
|
327
346
|
cloud = nil
|
328
347
|
if options[:cloud]
|
@@ -350,62 +369,92 @@ class Morpheus::Cli::NetworksCommand
|
|
350
369
|
end
|
351
370
|
payload['network']['type'] = {'id' => network_type_id.to_i }
|
352
371
|
|
353
|
-
|
354
|
-
|
355
|
-
|
372
|
+
network_type = nil
|
373
|
+
json_response = @network_types_interface.get(network_type_id)
|
374
|
+
if json_response["networkType"]
|
375
|
+
network_type = json_response["networkType"]
|
356
376
|
else
|
357
|
-
|
358
|
-
|
377
|
+
print_red_alert "Network Type not found by id '#{network_type_id}'"
|
378
|
+
return 1
|
359
379
|
end
|
380
|
+
network_type_option_types = network_type['optionTypes']
|
381
|
+
if network_type_option_types && network_type_option_types.size > 0
|
382
|
+
# prompt for option types
|
383
|
+
# JD: 3.6.2 has fieldContext: 'domain' , which is wrong
|
384
|
+
network_type_option_types.each do |option_type|
|
385
|
+
# if option_type['fieldContext'] == 'domain'
|
386
|
+
# option_type['fieldContext'] = 'network'
|
387
|
+
# end
|
388
|
+
option_type['fieldContext'] = nil
|
389
|
+
end
|
390
|
+
network_type_params = Morpheus::Cli::OptionTypes.prompt(network_type_option_types,options[:options],@api_client, {zoneId: cloud['id']})
|
391
|
+
payload['network'].deep_merge!(network_type_params)
|
360
392
|
|
361
|
-
#
|
362
|
-
if options['description']
|
363
|
-
payload['network']['description'] = options['description']
|
364
|
-
else
|
365
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false, 'description' => 'Description of network.'}], options)
|
366
|
-
payload['network']['description'] = v_prompt['description']
|
367
|
-
end
|
393
|
+
#todo: special handling of type: 'aciVxlan'
|
368
394
|
|
369
|
-
# Gateway
|
370
|
-
if options['gateway']
|
371
|
-
payload['network']['gateway'] = options['gateway']
|
372
395
|
else
|
373
|
-
|
374
|
-
|
375
|
-
|
396
|
+
# DEFAULT INPUTS
|
397
|
+
|
398
|
+
# Gateway
|
399
|
+
if options['gateway']
|
400
|
+
payload['network']['gateway'] = options['gateway']
|
401
|
+
else
|
402
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'gateway', 'fieldLabel' => 'Gateway', 'type' => 'text', 'required' => false, 'description' => ''}], options)
|
403
|
+
payload['network']['gateway'] = v_prompt['gateway']
|
404
|
+
end
|
376
405
|
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
406
|
+
# DNS Primary
|
407
|
+
if options['dnsPrimary']
|
408
|
+
payload['network']['dnsPrimary'] = options['dnsPrimary']
|
409
|
+
else
|
410
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'dnsPrimary', 'fieldLabel' => 'DNS Primary', 'type' => 'text', 'required' => false, 'description' => ''}], options)
|
411
|
+
payload['network']['dnsPrimary'] = v_prompt['dnsPrimary']
|
412
|
+
end
|
384
413
|
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
414
|
+
# DNS Secondary
|
415
|
+
if options['dnsSecondary']
|
416
|
+
payload['network']['dnsSecondary'] = options['dnsSecondary']
|
417
|
+
else
|
418
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'dnsSecondary', 'fieldLabel' => 'DNS Secondary', 'type' => 'text', 'required' => false, 'description' => ''}], options)
|
419
|
+
payload['network']['dnsSecondary'] = v_prompt['dnsSecondary']
|
420
|
+
end
|
392
421
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
422
|
+
# CIDR
|
423
|
+
if options['cidr']
|
424
|
+
payload['network']['cidr'] = options['cidr']
|
425
|
+
else
|
426
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'cidr', 'fieldLabel' => 'CIDR', 'type' => 'text', 'required' => false, 'description' => ''}], options)
|
427
|
+
payload['network']['cidr'] = v_prompt['cidr']
|
428
|
+
end
|
429
|
+
|
430
|
+
# VLAN ID
|
431
|
+
if options['vlanId']
|
432
|
+
payload['network']['vlanId'] = options['vlanId']
|
433
|
+
else
|
434
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'vlanId', 'fieldLabel' => 'VLAN ID', 'type' => 'number', 'required' => false, 'description' => ''}], options)
|
435
|
+
payload['network']['vlanId'] = v_prompt['vlanId']
|
436
|
+
end
|
437
|
+
|
438
|
+
# DHCP Server
|
439
|
+
if options['dhcpServer'] != nil
|
440
|
+
payload['network']['dhcpServer'] = options['dhcpServer']
|
441
|
+
else
|
442
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'dhcpServer', 'fieldLabel' => 'DHCP Server', 'type' => 'checkbox', 'required' => false, 'description' => ''}], options)
|
443
|
+
payload['network']['dhcpServer'] = v_prompt['dhcpServer']
|
444
|
+
end
|
445
|
+
|
446
|
+
# Allow IP Override
|
447
|
+
if options['allowStaticOverride'] != nil
|
448
|
+
payload['network']['allowStaticOverride'] = options['allowStaticOverride']
|
449
|
+
else
|
450
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'allowStaticOverride', 'fieldLabel' => 'Allow IP Override', 'type' => 'checkbox', 'required' => false, 'description' => ''}], options)
|
451
|
+
payload['network']['allowStaticOverride'] = v_prompt['allowStaticOverride']
|
452
|
+
end
|
400
453
|
|
401
|
-
# VLAN ID
|
402
|
-
if options['vlanId']
|
403
|
-
payload['network']['vlanId'] = options['vlanId']
|
404
|
-
else
|
405
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'vlanId', 'fieldLabel' => 'VLAN ID', 'type' => 'number', 'required' => false, 'description' => ''}], options)
|
406
|
-
payload['network']['vlanId'] = v_prompt['vlanId']
|
407
454
|
end
|
408
455
|
|
456
|
+
## IPAM Options
|
457
|
+
|
409
458
|
# Network Pool
|
410
459
|
if options['pool']
|
411
460
|
payload['network']['pool'] = options['pool'].to_i
|
@@ -415,23 +464,9 @@ class Morpheus::Cli::NetworksCommand
|
|
415
464
|
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'pool', 'fieldLabel' => 'Network Pool', 'type' => 'text', 'required' => false, 'description' => ''}], options)
|
416
465
|
payload['network']['pool'] = v_prompt['pool'].to_i if v_prompt['pool']
|
417
466
|
end
|
418
|
-
|
419
|
-
# DHCP Server
|
420
|
-
if options['dhcpServer'] != nil
|
421
|
-
payload['network']['dhcpServer'] = options['dhcpServer']
|
422
|
-
else
|
423
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'dhcpServer', 'fieldLabel' => 'DHCP Server', 'type' => 'checkbox', 'required' => false, 'description' => ''}], options)
|
424
|
-
payload['network']['dhcpServer'] = v_prompt['dhcpServer']
|
425
|
-
end
|
426
|
-
|
427
|
-
# Allow IP Override
|
428
|
-
if options['allowStaticOverride'] != nil
|
429
|
-
payload['network']['allowStaticOverride'] = options['allowStaticOverride']
|
430
|
-
else
|
431
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'allowStaticOverride', 'fieldLabel' => 'Allow IP Override', 'type' => 'checkbox', 'required' => false, 'description' => ''}], options)
|
432
|
-
payload['network']['allowStaticOverride'] = v_prompt['allowStaticOverride']
|
433
|
-
end
|
434
467
|
|
468
|
+
## Advanced Options
|
469
|
+
|
435
470
|
# Network Domain
|
436
471
|
if options['domain']
|
437
472
|
payload['network']['networkDomain'] = {'id' => options['domain'].to_i}
|
@@ -909,10 +944,76 @@ class Morpheus::Cli::NetworksCommand
|
|
909
944
|
end
|
910
945
|
end
|
911
946
|
|
947
|
+
def list_types(args)
|
948
|
+
options = {}
|
949
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
950
|
+
opts.banner = subcommand_usage()
|
951
|
+
opts.on( '-c', '--cloud CLOUD', "Cloud Name or ID" ) do |val|
|
952
|
+
options[:cloud] = val
|
953
|
+
end
|
954
|
+
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
955
|
+
opts.footer = "List host types."
|
956
|
+
end
|
957
|
+
optparse.parse!(args)
|
958
|
+
connect(options)
|
959
|
+
begin
|
960
|
+
params = {}
|
961
|
+
params.merge!(parse_list_options(options))
|
962
|
+
if options[:cloud]
|
963
|
+
#return network_types_for_cloud(options[:cloud], options)
|
964
|
+
zone = find_zone_by_name_or_id(nil, options[:cloud])
|
965
|
+
#params["zoneTypeId"] = zone['zoneTypeId']
|
966
|
+
params["zoneId"] = zone['id']
|
967
|
+
params["creatable"] = true
|
968
|
+
end
|
969
|
+
@network_types_interface.setopts(options)
|
970
|
+
if options[:dry_run]
|
971
|
+
print_dry_run @network_types_interface.dry.list(params)
|
972
|
+
return
|
973
|
+
end
|
974
|
+
json_response = @network_types_interface.list(params)
|
975
|
+
|
976
|
+
render_result = render_with_format(json_response, options, 'networkTypes')
|
977
|
+
return 0 if render_result
|
978
|
+
|
979
|
+
network_types = json_response['networkTypes']
|
980
|
+
|
981
|
+
title = "Morpheus network Types"
|
982
|
+
subtitles = []
|
983
|
+
subtitles += parse_list_subtitles(options)
|
984
|
+
if options[:cloud]
|
985
|
+
subtitles << "Cloud: #{options[:cloud]}"
|
986
|
+
end
|
987
|
+
print_h1 title, subtitles
|
988
|
+
if network_types.empty?
|
989
|
+
print cyan,"No network types found.",reset,"\n"
|
990
|
+
else
|
991
|
+
rows = network_types.collect do |network_type|
|
992
|
+
{
|
993
|
+
id: network_type['id'],
|
994
|
+
code: network_type['code'],
|
995
|
+
name: network_type['name']
|
996
|
+
}
|
997
|
+
end
|
998
|
+
columns = [:id, :name, :code]
|
999
|
+
print cyan
|
1000
|
+
print as_pretty_table(rows, columns, options)
|
1001
|
+
print reset
|
1002
|
+
print_results_pagination(json_response)
|
1003
|
+
end
|
1004
|
+
print reset,"\n"
|
1005
|
+
return 0
|
1006
|
+
|
1007
|
+
rescue RestClient::Exception => e
|
1008
|
+
print_rest_exception(e, options)
|
1009
|
+
exit 1
|
1010
|
+
end
|
1011
|
+
end
|
1012
|
+
|
912
1013
|
private
|
913
1014
|
|
914
1015
|
|
915
|
-
|
1016
|
+
def find_network_by_name_or_id(val)
|
916
1017
|
if val.to_s =~ /\A\d{1,}\Z/
|
917
1018
|
return find_network_by_id(val)
|
918
1019
|
else
|
@@ -56,9 +56,13 @@ module Morpheus
|
|
56
56
|
# end
|
57
57
|
# end
|
58
58
|
|
59
|
-
|
59
|
+
field_key = [option_type['fieldContext'], option_type['fieldName']].select {|it| it && it != '' }.join('.')
|
60
|
+
namespaces = field_key.split(".")
|
61
|
+
field_name = namespaces.pop
|
62
|
+
|
63
|
+
if field_key.include?(".")
|
60
64
|
cur_namespace = options
|
61
|
-
|
65
|
+
|
62
66
|
namespaces.each do |ns|
|
63
67
|
next if ns.empty?
|
64
68
|
cur_namespace[ns.to_s] ||= {}
|
@@ -67,13 +71,13 @@ module Morpheus
|
|
67
71
|
context_map = context_map[ns.to_s]
|
68
72
|
end
|
69
73
|
# use the value passed in the options map
|
70
|
-
if cur_namespace.key?(
|
71
|
-
value = cur_namespace[
|
74
|
+
if cur_namespace.key?(field_name)
|
75
|
+
value = cur_namespace[field_name]
|
72
76
|
if option_type['type'] == 'number'
|
73
77
|
value = value.to_s.include?('.') ? value.to_f : value.to_i
|
74
78
|
elsif option_type['type'] == 'select'
|
75
79
|
# this should just fall down through below, with the extra params no_prompt, use_value
|
76
|
-
value = select_prompt(option_type, api_client, api_params, true, value)
|
80
|
+
value = select_prompt(option_type, api_client, (api_params || {}).merge(results), true, value)
|
77
81
|
end
|
78
82
|
if options[:always_prompt] != true
|
79
83
|
value_found = true
|
@@ -81,8 +85,8 @@ module Morpheus
|
|
81
85
|
end
|
82
86
|
else
|
83
87
|
# no fieldContext
|
84
|
-
if value_found == false && options.key?(
|
85
|
-
value = options[
|
88
|
+
if value_found == false && options.key?(field_key)
|
89
|
+
value = options[field_key]
|
86
90
|
if option_type['type'] == 'number'
|
87
91
|
value = value.to_s.include?('.') ? value.to_f : value.to_i
|
88
92
|
end
|
@@ -113,13 +117,13 @@ module Morpheus
|
|
113
117
|
# select type is special because it supports skipSingleOption
|
114
118
|
# and prints the available options on error
|
115
119
|
if option_type['type'] == 'select'
|
116
|
-
value = select_prompt(option_type, api_client, api_params, true)
|
120
|
+
value = select_prompt(option_type, api_client, (api_params || {}).merge(results), true)
|
117
121
|
value_found = !!value
|
118
122
|
end
|
119
123
|
if !value_found
|
120
124
|
if option_type['required']
|
121
125
|
print Term::ANSIColor.red, "\nMissing Required Option\n\n", Term::ANSIColor.reset
|
122
|
-
print Term::ANSIColor.red, " * #{option_type['fieldLabel']} [-O #{
|
126
|
+
print Term::ANSIColor.red, " * #{option_type['fieldLabel']} [-O #{field_key}=] - #{option_type['description']}\n", Term::ANSIColor.reset
|
123
127
|
print "\n"
|
124
128
|
exit 1
|
125
129
|
else
|
@@ -150,10 +154,7 @@ module Morpheus
|
|
150
154
|
# I suppose the entered value should take precedence
|
151
155
|
# api_params = api_params.merge(options) # this might be good enough
|
152
156
|
# dup it
|
153
|
-
|
154
|
-
grails_select_api_params = grails_params(select_api_params)
|
155
|
-
|
156
|
-
value = select_prompt(option_type,api_client, grails_select_api_params)
|
157
|
+
value = select_prompt(option_type,api_client, (api_params || {}).merge(results))
|
157
158
|
elsif option_type['type'] == 'hidden'
|
158
159
|
value = option_type['defaultValue']
|
159
160
|
input = value
|
@@ -163,7 +164,7 @@ module Morpheus
|
|
163
164
|
value = generic_prompt(option_type)
|
164
165
|
end
|
165
166
|
end
|
166
|
-
context_map[
|
167
|
+
context_map[field_name] = value
|
167
168
|
end
|
168
169
|
|
169
170
|
return results
|
@@ -248,7 +249,7 @@ module Morpheus
|
|
248
249
|
if option_type['optionSource'] == 'list'
|
249
250
|
select_options = load_source_options(option_type['optionSource'], api_client, {'optionTypeId' => option_type['id']})
|
250
251
|
else
|
251
|
-
select_options = load_source_options(option_type['optionSource'], api_client, api_params)
|
252
|
+
select_options = load_source_options(option_type['optionSource'], api_client, grails_params(api_params || {}))
|
252
253
|
end
|
253
254
|
else
|
254
255
|
raise "select_prompt() requires selectOptions or optionSource!"
|