morpheus-cli 5.3.3 → 5.4.2
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/Dockerfile +1 -1
- data/lib/morpheus/api/account_users_interface.rb +68 -0
- data/lib/morpheus/api/api_client.rb +75 -8
- data/lib/morpheus/api/audit_interface.rb +9 -0
- data/lib/morpheus/api/clouds_interface.rb +4 -11
- data/lib/morpheus/api/health_interface.rb +37 -3
- data/lib/morpheus/api/instances_interface.rb +21 -0
- data/lib/morpheus/api/load_balancer_monitors_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +9 -0
- data/lib/morpheus/api/load_balancers_interface.rb +5 -0
- data/lib/morpheus/api/network_dhcp_relays_interface.rb +36 -0
- data/lib/morpheus/api/network_dhcp_servers_interface.rb +36 -0
- data/lib/morpheus/api/network_edge_clusters_interface.rb +26 -0
- data/lib/morpheus/api/network_routers_interface.rb +30 -0
- data/lib/morpheus/api/network_servers_interface.rb +98 -0
- data/lib/morpheus/api/network_static_routes_interface.rb +36 -0
- data/lib/morpheus/api/read_interface.rb +4 -3
- data/lib/morpheus/api/rest_interface.rb +5 -4
- data/lib/morpheus/api/roles_interface.rb +7 -0
- data/lib/morpheus/api/secondary_read_interface.rb +1 -1
- data/lib/morpheus/api/secondary_rest_interface.rb +19 -19
- data/lib/morpheus/api/storage_server_types_interface.rb +14 -0
- data/lib/morpheus/api/storage_servers_interface.rb +9 -0
- data/lib/morpheus/api/storage_volume_types_interface.rb +9 -0
- data/lib/morpheus/api/storage_volumes_interface.rb +9 -0
- data/lib/morpheus/api/users_interface.rb +16 -63
- data/lib/morpheus/api/virtual_servers_interface.rb +9 -0
- data/lib/morpheus/cli/cli_command.rb +262 -14
- data/lib/morpheus/cli/cli_registry.rb +2 -1
- data/lib/morpheus/cli/{access_token_command.rb → commands/access_token_command.rb} +1 -1
- data/lib/morpheus/cli/{account_groups_command.rb → commands/account_groups_command.rb} +0 -8
- data/lib/morpheus/cli/{activity_command.rb → commands/activity_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/alias_command.rb → alias_command.rb} +1 -4
- data/lib/morpheus/cli/{appliance_settings_command.rb → commands/appliance_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{approvals_command.rb → commands/approvals_command.rb} +0 -0
- data/lib/morpheus/cli/{apps.rb → commands/apps.rb} +14 -87
- data/lib/morpheus/cli/{archives_command.rb → commands/archives_command.rb} +0 -6
- data/lib/morpheus/cli/commands/audit.rb +188 -0
- data/lib/morpheus/cli/{backup_jobs_command.rb → commands/backup_jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{backup_settings_command.rb → commands/backup_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{backups_command.rb → commands/backups_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/benchmark_command.rb → benchmark_command.rb} +0 -3
- data/lib/morpheus/cli/{blueprints_command.rb → commands/blueprints_command.rb} +1 -1
- data/lib/morpheus/cli/{boot_scripts_command.rb → commands/boot_scripts_command.rb} +0 -3
- data/lib/morpheus/cli/{budgets_command.rb → commands/budgets_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/cat_command.rb → cat_command.rb} +0 -0
- data/lib/morpheus/cli/{catalog_item_types_command.rb → commands/catalog_item_types_command.rb} +0 -0
- data/lib/morpheus/cli/{certificates_command.rb → commands/certificates_command.rb} +0 -0
- data/lib/morpheus/cli/commands/change_password_command.rb +132 -0
- data/lib/morpheus/cli/{cloud_datastores_command.rb → commands/cloud_datastores_command.rb} +0 -4
- data/lib/morpheus/cli/{cloud_folders_command.rb → commands/cloud_folders_command.rb} +0 -4
- data/lib/morpheus/cli/{cloud_resource_pools_command.rb → commands/cloud_resource_pools_command.rb} +1 -5
- data/lib/morpheus/cli/{clouds.rb → commands/clouds.rb} +22 -47
- data/lib/morpheus/cli/{clusters.rb → commands/clusters.rb} +38 -19
- data/lib/morpheus/cli/commands/{standard/coloring_command.rb → coloring_command.rb} +0 -2
- data/lib/morpheus/cli/{containers_command.rb → commands/containers_command.rb} +0 -7
- data/lib/morpheus/cli/commands/{standard/curl_command.rb → curl_command.rb} +0 -3
- data/lib/morpheus/cli/{cypher_command.rb → commands/cypher_command.rb} +0 -1
- data/lib/morpheus/cli/{dashboard_command.rb → commands/dashboard_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/debug_command.rb → debug_command.rb} +0 -1
- data/lib/morpheus/cli/{deploy.rb → commands/deploy.rb} +0 -1
- data/lib/morpheus/cli/{deployments.rb → commands/deployments.rb} +0 -0
- data/lib/morpheus/cli/{deploys.rb → commands/deploys.rb} +0 -1
- data/lib/morpheus/cli/{doc.rb → commands/doc.rb} +1 -1
- data/lib/morpheus/cli/commands/{standard/echo_command.rb → echo_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/edit_profile_command.rb → edit_profile_command.rb} +15 -4
- data/lib/morpheus/cli/commands/{standard/edit_rc_command.rb → edit_rc_command.rb} +19 -3
- data/lib/morpheus/cli/{environments_command.rb → commands/environments_command.rb} +0 -5
- data/lib/morpheus/cli/{execute_schedules_command.rb → commands/execute_schedules_command.rb} +0 -0
- data/lib/morpheus/cli/{execution_request_command.rb → commands/execution_request_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/exit_command.rb → exit_command.rb} +0 -2
- data/lib/morpheus/cli/{file_copy_request_command.rb → commands/file_copy_request_command.rb} +0 -4
- data/lib/morpheus/cli/{forgot_password.rb → commands/forgot_password.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/get_prompt_command.rb → get_prompt_command.rb} +0 -3
- data/lib/morpheus/cli/{groups.rb → commands/groups.rb} +0 -7
- data/lib/morpheus/cli/{guidance_command.rb → commands/guidance_command.rb} +1 -1
- data/lib/morpheus/cli/{health_command.rb → commands/health_command.rb} +104 -19
- data/lib/morpheus/cli/commands/{standard/history_command.rb → history_command.rb} +0 -3
- data/lib/morpheus/cli/{hosts.rb → commands/hosts.rb} +15 -25
- data/lib/morpheus/cli/{image_builder_command.rb → commands/image_builder_command.rb} +6 -16
- data/lib/morpheus/cli/{instance_types.rb → commands/instance_types.rb} +0 -3
- data/lib/morpheus/cli/{instances.rb → commands/instances.rb} +220 -13
- data/lib/morpheus/cli/{integrations_command.rb → commands/integrations_command.rb} +1 -12
- data/lib/morpheus/cli/{invoices_command.rb → commands/invoices_command.rb} +43 -39
- data/lib/morpheus/cli/{jobs_command.rb → commands/jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{key_pairs.rb → commands/key_pairs.rb} +0 -6
- data/lib/morpheus/cli/{library_cluster_layouts_command.rb → commands/library_cluster_layouts_command.rb} +0 -4
- data/lib/morpheus/cli/{library_container_scripts_command.rb → commands/library_container_scripts_command.rb} +0 -0
- data/lib/morpheus/cli/{library_container_templates_command.rb → commands/library_container_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_container_types_command.rb → commands/library_container_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_instance_types_command.rb → commands/library_instance_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_layouts_command.rb → commands/library_layouts_command.rb} +0 -4
- data/lib/morpheus/cli/{library_option_lists_command.rb → commands/library_option_lists_command.rb} +3 -7
- data/lib/morpheus/cli/{library_option_types_command.rb → commands/library_option_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_spec_templates_command.rb → commands/library_spec_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_upgrades_command.rb → commands/library_upgrades_command.rb} +0 -4
- data/lib/morpheus/cli/{license.rb → commands/license.rb} +0 -3
- data/lib/morpheus/cli/commands/load_balancer_monitors.rb +70 -0
- data/lib/morpheus/cli/commands/load_balancer_pools.rb +90 -0
- data/lib/morpheus/cli/commands/load_balancer_profiles.rb +64 -0
- data/lib/morpheus/cli/{load_balancer_types.rb → commands/load_balancer_types.rb} +9 -8
- data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +147 -0
- data/lib/morpheus/cli/commands/load_balancers.rb +192 -0
- data/lib/morpheus/cli/commands/{standard/log_level_command.rb → log_level_command.rb} +0 -3
- data/lib/morpheus/cli/{log_settings_command.rb → commands/log_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{login.rb → commands/login.rb} +0 -5
- data/lib/morpheus/cli/commands/logout.rb +63 -0
- data/lib/morpheus/cli/{logs_command.rb → commands/logs_command.rb} +0 -3
- data/lib/morpheus/cli/commands/{standard/man_command.rb → man_command.rb} +0 -2
- data/lib/morpheus/cli/{monitoring_alerts_command.rb → commands/monitoring_alerts_command.rb} +0 -7
- data/lib/morpheus/cli/{monitoring_apps_command.rb → commands/monitoring_apps_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_checks_command.rb → commands/monitoring_checks_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_contacts_command.rb → commands/monitoring_contacts_command.rb} +0 -7
- data/lib/morpheus/cli/{monitoring_groups_command.rb → commands/monitoring_groups_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_incidents_command.rb → commands/monitoring_incidents_command.rb} +0 -1
- data/lib/morpheus/cli/commands/network_dhcp_relays_command.rb +416 -0
- data/lib/morpheus/cli/commands/network_dhcp_servers_command.rb +407 -0
- data/lib/morpheus/cli/{network_domains_command.rb → commands/network_domains_command.rb} +0 -4
- data/lib/morpheus/cli/commands/network_edge_clusters_command.rb +329 -0
- data/lib/morpheus/cli/commands/network_firewalls_command.rb +823 -0
- data/lib/morpheus/cli/{network_groups_command.rb → commands/network_groups_command.rb} +0 -4
- data/lib/morpheus/cli/{network_pool_servers_command.rb → commands/network_pool_servers_command.rb} +0 -4
- data/lib/morpheus/cli/{network_pools_command.rb → commands/network_pools_command.rb} +0 -4
- data/lib/morpheus/cli/{network_proxies_command.rb → commands/network_proxies_command.rb} +0 -4
- data/lib/morpheus/cli/{network_routers_command.rb → commands/network_routers_command.rb} +387 -57
- data/lib/morpheus/cli/{network_services_command.rb → commands/network_services_command.rb} +0 -4
- data/lib/morpheus/cli/commands/network_static_routes_command.rb +446 -0
- data/lib/morpheus/cli/commands/network_transport_zones_command.rb +452 -0
- data/lib/morpheus/cli/{networks_command.rb → commands/networks_command.rb} +20 -20
- data/lib/morpheus/cli/commands/open_command.rb +30 -0
- data/lib/morpheus/cli/commands/options.rb +98 -0
- data/lib/morpheus/cli/{packages_command.rb → commands/packages_command.rb} +0 -2
- data/lib/morpheus/cli/{ping.rb → commands/ping.rb} +0 -7
- data/lib/morpheus/cli/{policies_command.rb → commands/policies_command.rb} +1 -8
- data/lib/morpheus/cli/{power_schedules_command.rb → commands/power_schedules_command.rb} +0 -0
- data/lib/morpheus/cli/{preseed_scripts_command.rb → commands/preseed_scripts_command.rb} +0 -3
- data/lib/morpheus/cli/{price_sets_command.rb → commands/price_sets_command.rb} +0 -0
- data/lib/morpheus/cli/{prices_command.rb → commands/prices_command.rb} +7 -7
- data/lib/morpheus/cli/{processes_command.rb → commands/processes_command.rb} +0 -1
- data/lib/morpheus/cli/{projects_command.rb → commands/projects_command.rb} +0 -0
- data/lib/morpheus/cli/{provisioning_licenses_command.rb → commands/provisioning_licenses_command.rb} +0 -0
- data/lib/morpheus/cli/{provisioning_settings_command.rb → commands/provisioning_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{recent_activity_command.rb → commands/recent_activity_command.rb} +0 -0
- data/lib/morpheus/cli/{remote.rb → commands/remote.rb} +5 -9
- data/lib/morpheus/cli/{reports_command.rb → commands/reports_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/rm_command.rb → rm_command.rb} +0 -0
- data/lib/morpheus/cli/{roles.rb → commands/roles.rb} +245 -40
- data/lib/morpheus/cli/{search_command.rb → commands/search_command.rb} +0 -0
- data/lib/morpheus/cli/{security_group_rules.rb → commands/security_group_rules.rb} +0 -5
- data/lib/morpheus/cli/{security_groups.rb → commands/security_groups.rb} +0 -6
- data/lib/morpheus/cli/{service_catalog_command.rb → commands/service_catalog_command.rb} +0 -0
- data/lib/morpheus/cli/{service_plans_command.rb → commands/service_plans_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/set_prompt_command.rb → set_prompt_command.rb} +0 -3
- data/lib/morpheus/cli/{setup.rb → commands/setup.rb} +0 -0
- data/lib/morpheus/cli/{shell.rb → commands/shell.rb} +4 -105
- data/lib/morpheus/cli/commands/{standard/sleep_command.rb → sleep_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/source_command.rb → source_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/ssl_verification_command.rb → ssl_verification_command.rb} +0 -3
- data/lib/morpheus/cli/{storage_providers_command.rb → commands/storage_providers_command.rb} +0 -4
- data/lib/morpheus/cli/commands/storage_server_types.rb +50 -0
- data/lib/morpheus/cli/commands/storage_servers.rb +122 -0
- data/lib/morpheus/cli/commands/storage_volume_types.rb +50 -0
- data/lib/morpheus/cli/commands/storage_volumes.rb +103 -0
- data/lib/morpheus/cli/{subnets_command.rb → commands/subnets_command.rb} +7 -6
- data/lib/morpheus/cli/{tasks.rb → commands/tasks.rb} +25 -6
- data/lib/morpheus/cli/commands/{standard/tee_command.rb → tee_command.rb} +0 -0
- data/lib/morpheus/cli/{tenants_command.rb → commands/tenants_command.rb} +1 -8
- data/lib/morpheus/cli/commands/{standard/update_command.rb → update_command.rb} +0 -1
- data/lib/morpheus/cli/{usage_command.rb → commands/usage_command.rb} +0 -0
- data/lib/morpheus/cli/{user_groups_command.rb → commands/user_groups_command.rb} +1 -2
- data/lib/morpheus/cli/{user_settings_command.rb → commands/user_settings_command.rb} +2 -1
- data/lib/morpheus/cli/{user_sources_command.rb → commands/user_sources_command.rb} +1 -2
- data/lib/morpheus/cli/{users.rb → commands/users.rb} +28 -35
- data/lib/morpheus/cli/{vdi_allocations_command.rb → commands/vdi_allocations_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_apps_command.rb → commands/vdi_apps_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_command.rb → commands/vdi_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_gateways_command.rb → commands/vdi_gateways_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_pools_command.rb → commands/vdi_pools_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/version_command.rb → version_command.rb} +0 -0
- data/lib/morpheus/cli/commands/view.rb +102 -0
- data/lib/morpheus/cli/{virtual_images.rb → commands/virtual_images.rb} +2 -4
- data/lib/morpheus/cli/{whitelabel_settings_command.rb → commands/whitelabel_settings_command.rb} +0 -1
- data/lib/morpheus/cli/{whoami.rb → commands/whoami.rb} +0 -4
- data/lib/morpheus/cli/{wiki_command.rb → commands/wiki_command.rb} +0 -5
- data/lib/morpheus/cli/{workflows.rb → commands/workflows.rb} +0 -3
- data/lib/morpheus/cli/mixins/accounts_helper.rb +5 -5
- data/lib/morpheus/cli/mixins/load_balancers_helper.rb +26 -6
- data/lib/morpheus/cli/mixins/logs_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +51 -18
- data/lib/morpheus/cli/mixins/processes_helper.rb +1 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +48 -17
- data/lib/morpheus/cli/mixins/rest_command.rb +270 -94
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +667 -0
- data/lib/morpheus/cli/mixins/storage_servers_helper.rb +156 -0
- data/lib/morpheus/cli/mixins/storage_volumes_helper.rb +119 -0
- data/lib/morpheus/cli/option_types.rb +149 -40
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +6 -128
- data/lib/morpheus/ext/string.rb +29 -6
- data/lib/morpheus/routes.rb +238 -0
- data/lib/morpheus/terminal.rb +5 -6
- data/lib/morpheus/util.rb +6 -1
- metadata +176 -141
- data/lib/morpheus/cli/change_password_command.rb +0 -147
- data/lib/morpheus/cli/library.rb +0 -1
- data/lib/morpheus/cli/load_balancers.rb +0 -245
- data/lib/morpheus/cli/logout.rb +0 -81
|
@@ -33,14 +33,21 @@ module Morpheus
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
# supresses prompting unless --prompt has been passed
|
|
36
37
|
def self.no_prompt(option_types, options={}, api_client=nil,api_params={})
|
|
37
|
-
|
|
38
|
+
if options[:always_prompt]
|
|
39
|
+
prompt(option_types, options, api_client, api_params)
|
|
40
|
+
else
|
|
41
|
+
prompt(option_types, options, api_client, api_params, true)
|
|
42
|
+
end
|
|
38
43
|
end
|
|
39
44
|
|
|
40
45
|
def self.prompt(option_types, options={}, api_client=nil, api_params={}, no_prompt=false, paging_enabled=false)
|
|
41
46
|
paging_enabled = false if Morpheus::Cli.windows?
|
|
47
|
+
no_prompt = no_prompt || options[:no_prompt]
|
|
42
48
|
results = {}
|
|
43
49
|
options = options || {}
|
|
50
|
+
|
|
44
51
|
# inject cli only stuff into option_types (should clone() here)
|
|
45
52
|
option_types.each do |option_type|
|
|
46
53
|
if options[:help_field_prefix]
|
|
@@ -54,11 +61,7 @@ module Morpheus
|
|
|
54
61
|
# puts "Options Prompt #{options}"
|
|
55
62
|
# Sort options by default, group, advanced
|
|
56
63
|
cur_field_group = 'default'
|
|
57
|
-
(
|
|
58
|
-
option_types.reject {|it| (it['fieldGroup'] || 'default') != 'default'}.sort {|a,b| a['displayOrder'].to_i <=> b['displayOrder'].to_i} +
|
|
59
|
-
option_types.reject {|it| ['default', 'advanced'].include?(it['fieldGroup'] || 'default')}.sort{|a,b| a['displayOrder'] <=> b['displayOrder']}.group_by{|it| it['fieldGroup']}.values.collect { |it| it.sort{|a,b| a['displayOrder'].to_i <=> b['displayOrder'].to_i}}.flatten +
|
|
60
|
-
option_types.reject {|it| it['fieldGroup'] != 'advanced'}.sort {|a,b| a['displayOrder'].to_i <=> b['displayOrder'].to_i}
|
|
61
|
-
).each do |option_type|
|
|
64
|
+
self.sorted_option_types(option_types).each do |option_type|
|
|
62
65
|
context_map = results
|
|
63
66
|
value = nil
|
|
64
67
|
value_found = false
|
|
@@ -66,7 +69,9 @@ module Morpheus
|
|
|
66
69
|
|
|
67
70
|
if cur_field_group != field_group
|
|
68
71
|
cur_field_group = field_group
|
|
69
|
-
|
|
72
|
+
if !no_prompt
|
|
73
|
+
print "\n#{cur_field_group.upcase} OPTIONS\n#{"=" * ("#{cur_field_group} OPTIONS".length)}\n\n"
|
|
74
|
+
end
|
|
70
75
|
end
|
|
71
76
|
|
|
72
77
|
# How about this instead?
|
|
@@ -123,7 +128,11 @@ module Morpheus
|
|
|
123
128
|
get_object_value(options, depends_on_field_key) ||
|
|
124
129
|
get_object_value(api_params, depends_on_field_key)
|
|
125
130
|
|
|
126
|
-
if
|
|
131
|
+
if field_value.nil? && !options['_object_key'].nil?
|
|
132
|
+
field_value = get_object_value({options['_object_key'] => results}, depends_on_field_key)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
if !field_value.nil? && (depends_on_value.nil? || depends_on_value.empty? || field_value.to_s.match?(depends_on_value))
|
|
127
136
|
found_dep_value = true if match_type != 'all'
|
|
128
137
|
else
|
|
129
138
|
found_dep_value = false if match_type == 'all'
|
|
@@ -146,6 +155,10 @@ module Morpheus
|
|
|
146
155
|
context_map = context_map[ns.to_s]
|
|
147
156
|
end
|
|
148
157
|
|
|
158
|
+
# build parameters for option source api request
|
|
159
|
+
option_params = (option_type['noParams'] ? {} : (api_params || {}).merge(results))
|
|
160
|
+
option_params.merge!(option_type['optionParams']) if option_type['optionParams']
|
|
161
|
+
|
|
149
162
|
# use the value passed in the options map
|
|
150
163
|
if cur_namespace.respond_to?('key?') && cur_namespace.key?(field_name)
|
|
151
164
|
value = cur_namespace[field_name]
|
|
@@ -156,25 +169,25 @@ module Morpheus
|
|
|
156
169
|
end
|
|
157
170
|
# these select prompts should just fall down through below, with the extra params no_prompt, use_value
|
|
158
171
|
elsif option_type['type'] == 'select'
|
|
159
|
-
value = select_prompt(option_type.merge({'defaultValue' => value, 'defaultInputValue' => input_value}), api_client,
|
|
172
|
+
value = select_prompt(option_type.merge({'defaultValue' => value, 'defaultInputValue' => input_value}), api_client, option_params, true)
|
|
160
173
|
elsif option_type['type'] == 'multiSelect'
|
|
161
174
|
# support value as csv like "thing1, thing2"
|
|
162
175
|
value_list = value.is_a?(String) ? value.parse_csv.collect {|v| v ? v.to_s.strip : v } : [value].flatten
|
|
163
176
|
input_value_list = input_value.is_a?(String) ? input_value.parse_csv.collect {|v| v ? v.to_s.strip : v } : [input_value].flatten
|
|
164
177
|
select_value_list = []
|
|
165
178
|
value_list.each_with_index do |v, i|
|
|
166
|
-
select_value_list << select_prompt(option_type.merge({'defaultValue' => v, 'defaultInputValue' => input_value_list[i]}), api_client,
|
|
179
|
+
select_value_list << select_prompt(option_type.merge({'defaultValue' => v, 'defaultInputValue' => input_value_list[i]}), api_client, option_params, true)
|
|
167
180
|
end
|
|
168
181
|
value = select_value_list
|
|
169
182
|
elsif option_type['type'] == 'typeahead'
|
|
170
|
-
value = typeahead_prompt(option_type.merge({'defaultValue' => value, 'defaultInputValue' => input_value}), api_client,
|
|
183
|
+
value = typeahead_prompt(option_type.merge({'defaultValue' => value, 'defaultInputValue' => input_value}), api_client, option_params, true)
|
|
171
184
|
elsif option_type['type'] == 'multiTypeahead'
|
|
172
185
|
# support value as csv like "thing1, thing2"
|
|
173
186
|
value_list = value.is_a?(String) ? value.parse_csv.collect {|v| v ? v.to_s.strip : v } : [value].flatten
|
|
174
187
|
input_value_list = input_value.is_a?(String) ? input_value.parse_csv.collect {|v| v ? v.to_s.strip : v } : [input_value].flatten
|
|
175
188
|
select_value_list = []
|
|
176
189
|
value_list.each_with_index do |v, i|
|
|
177
|
-
select_value_list << typeahead_prompt(option_type.merge({'defaultValue' => v, 'defaultInputValue' => input_value_list[i]}), api_client,
|
|
190
|
+
select_value_list << typeahead_prompt(option_type.merge({'defaultValue' => v, 'defaultInputValue' => input_value_list[i]}), api_client, option_params, true)
|
|
178
191
|
end
|
|
179
192
|
value = select_value_list
|
|
180
193
|
end
|
|
@@ -190,7 +203,6 @@ module Morpheus
|
|
|
190
203
|
end
|
|
191
204
|
# no_prompt means skip prompting and instead
|
|
192
205
|
# use default value or error if a required option is not present
|
|
193
|
-
no_prompt = no_prompt || options[:no_prompt]
|
|
194
206
|
if no_prompt
|
|
195
207
|
if !value_found
|
|
196
208
|
if option_type['defaultValue'] != nil && !['select', 'multiSelect','typeahead','multiTypeahead'].include?(option_type['type'])
|
|
@@ -201,11 +213,11 @@ module Morpheus
|
|
|
201
213
|
# select type is special because it supports skipSingleOption
|
|
202
214
|
# and prints the available options on error
|
|
203
215
|
if ['select', 'multiSelect'].include?(option_type['type'])
|
|
204
|
-
value = select_prompt(option_type, api_client,
|
|
216
|
+
value = select_prompt(option_type, api_client, option_params, true)
|
|
205
217
|
value_found = !!value
|
|
206
218
|
end
|
|
207
219
|
if ['typeahead', 'multiTypeahead'].include?(option_type['type'])
|
|
208
|
-
value = typeahead_prompt(option_type, api_client,
|
|
220
|
+
value = typeahead_prompt(option_type, api_client, option_params, true)
|
|
209
221
|
value_found = !!value
|
|
210
222
|
end
|
|
211
223
|
if !value_found
|
|
@@ -242,11 +254,11 @@ module Morpheus
|
|
|
242
254
|
# I suppose the entered value should take precedence
|
|
243
255
|
# api_params = api_params.merge(options) # this might be good enough
|
|
244
256
|
# dup it
|
|
245
|
-
value = select_prompt(option_type, api_client,
|
|
257
|
+
value = select_prompt(option_type, api_client, option_params, options[:no_prompt], nil, paging_enabled)
|
|
246
258
|
if value && option_type['type'] == 'multiSelect'
|
|
247
259
|
value = [value]
|
|
248
260
|
while self.confirm("Add another #{option_type['fieldLabel']}?", {:default => false}) do
|
|
249
|
-
if addn_value = select_prompt(option_type, api_client,
|
|
261
|
+
if addn_value = select_prompt(option_type, api_client, option_params, options[:no_prompt], nil, paging_enabled)
|
|
250
262
|
value << addn_value
|
|
251
263
|
else
|
|
252
264
|
break
|
|
@@ -254,11 +266,11 @@ module Morpheus
|
|
|
254
266
|
end
|
|
255
267
|
end
|
|
256
268
|
elsif ['typeahead', 'multiTypeahead'].include?(option_type['type'])
|
|
257
|
-
value = typeahead_prompt(option_type, api_client,
|
|
269
|
+
value = typeahead_prompt(option_type, api_client, option_params, options[:no_prompt], nil, paging_enabled)
|
|
258
270
|
if value && option_type['type'] == 'multiTypeahead'
|
|
259
271
|
value = [value]
|
|
260
272
|
while self.confirm("Add another #{option_type['fieldLabel']}?", {:default => false}) do
|
|
261
|
-
if addn_value = typeahead_prompt(option_type, api_client,
|
|
273
|
+
if addn_value = typeahead_prompt(option_type, api_client, option_params, options[:no_prompt], nil, paging_enabled)
|
|
262
274
|
value << addn_value
|
|
263
275
|
else
|
|
264
276
|
break
|
|
@@ -266,12 +278,17 @@ module Morpheus
|
|
|
266
278
|
end
|
|
267
279
|
end
|
|
268
280
|
elsif option_type['type'] == 'hidden'
|
|
269
|
-
|
|
270
|
-
|
|
281
|
+
if option_type['optionSource'].nil?
|
|
282
|
+
value = option_type['defaultValue']
|
|
283
|
+
else
|
|
284
|
+
value = load_source_options(option_type['optionSource'], option_type['optionSourceType'], api_client, api_params || {})
|
|
285
|
+
end
|
|
271
286
|
elsif option_type['type'] == 'file'
|
|
272
287
|
value = file_prompt(option_type)
|
|
273
288
|
elsif option_type['type'] == 'file-content'
|
|
274
289
|
value = file_content_prompt(option_type, options, api_client, {})
|
|
290
|
+
elsif option_type['type'] == 'multiText'
|
|
291
|
+
value = multitext_prompt(option_type)
|
|
275
292
|
else
|
|
276
293
|
value = generic_prompt(option_type)
|
|
277
294
|
end
|
|
@@ -279,7 +296,11 @@ module Morpheus
|
|
|
279
296
|
|
|
280
297
|
if option_type['type'] == 'multiSelect'
|
|
281
298
|
value = [value] if !value.nil? && !value.is_a?(Array)
|
|
282
|
-
|
|
299
|
+
elsif option_type['type'] == 'multiText'
|
|
300
|
+
# multiText expects csv value
|
|
301
|
+
if value && value.is_a?(String)
|
|
302
|
+
value = value.split(",").collect {|it| it.strip }
|
|
303
|
+
end
|
|
283
304
|
end
|
|
284
305
|
context_map[field_name] = value if !(value.nil? || (value.is_a?(Hash) && value.empty?))
|
|
285
306
|
parent_context_map.reject! {|k,v| k == parent_ns && (v.nil? || (v.is_a?(Hash) && v.empty?))}
|
|
@@ -298,7 +319,7 @@ module Morpheus
|
|
|
298
319
|
end
|
|
299
320
|
optionString = options.collect{ |b| b[:checked] ? "(#{b[:key]})" : b[:key]}.join(', ')
|
|
300
321
|
while !value_found do
|
|
301
|
-
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }[#{optionString}]: "
|
|
322
|
+
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }[#{optionString}]: "
|
|
302
323
|
input = $stdin.gets.chomp!
|
|
303
324
|
if input == '?'
|
|
304
325
|
help_prompt(option_type)
|
|
@@ -325,7 +346,7 @@ module Morpheus
|
|
|
325
346
|
value_found = false
|
|
326
347
|
value = nil
|
|
327
348
|
while !value_found do
|
|
328
|
-
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}#{!option_type['defaultValue'].to_s.empty? ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
|
|
349
|
+
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}#{!option_type['defaultValue'].to_s.empty? ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
|
|
329
350
|
input = $stdin.gets.chomp!
|
|
330
351
|
value = input.empty? ? option_type['defaultValue'] : input
|
|
331
352
|
if !value.to_s.empty?
|
|
@@ -349,7 +370,7 @@ module Morpheus
|
|
|
349
370
|
Thread.current[:_last_select]
|
|
350
371
|
end
|
|
351
372
|
|
|
352
|
-
def self.select_prompt(option_type,api_client, api_params={}, no_prompt=false, use_value=nil, paging_enabled=false)
|
|
373
|
+
def self.select_prompt(option_type, api_client, api_params={}, no_prompt=false, use_value=nil, paging_enabled=false)
|
|
353
374
|
paging_enabled = false if Morpheus::Cli.windows?
|
|
354
375
|
field_key = [option_type['fieldContext'], option_type['fieldName']].select {|it| it && it != '' }.join('.')
|
|
355
376
|
help_field_key = option_type[:help_field_prefix] ? "#{option_type[:help_field_prefix]}.#{field_key}" : field_key
|
|
@@ -358,7 +379,12 @@ module Morpheus
|
|
|
358
379
|
value_field = (option_type['config'] ? option_type['config']['valueField'] : nil) || 'value'
|
|
359
380
|
default_value = option_type['defaultValue']
|
|
360
381
|
default_value = default_value['id'] if default_value && default_value.is_a?(Hash) && !default_value['id'].nil?
|
|
361
|
-
|
|
382
|
+
|
|
383
|
+
if !option_type['params'].nil?
|
|
384
|
+
api_params = (api_params || {}).select {|k,v| option_type['params'].key?(k) || option_type['params'].key?(k.to_s)}
|
|
385
|
+
option_type['params'].select {|k,v| !v.empty?}.each {|k,v| api_params[k] = v}
|
|
386
|
+
end
|
|
387
|
+
|
|
362
388
|
# local array of options
|
|
363
389
|
if option_type['selectOptions']
|
|
364
390
|
# calculate from inline lambda
|
|
@@ -417,7 +443,8 @@ module Morpheus
|
|
|
417
443
|
default_value = found_default_option['name'] # name is prettier than value
|
|
418
444
|
end
|
|
419
445
|
else
|
|
420
|
-
found_default_option
|
|
446
|
+
found_default_option = select_options.find {|opt| opt[value_field].to_s == default_value.to_s || opt['name'] == default_value.to_s}
|
|
447
|
+
found_default_option = select_options.find {|opt| opt[value_field].to_s.start_with?(default_value.to_s) || opt['name'].to_s.start_with?(default_value.to_s)} if !found_default_option
|
|
421
448
|
if found_default_option
|
|
422
449
|
default_value = found_default_option['name'] # name is prettier than value
|
|
423
450
|
end
|
|
@@ -476,7 +503,7 @@ module Morpheus
|
|
|
476
503
|
}
|
|
477
504
|
|
|
478
505
|
has_more_pages = paging && (paging[:cur_page] * paging[:page_size]) < paging[:total]
|
|
479
|
-
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
|
|
506
|
+
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
|
|
480
507
|
input = input.chomp.strip
|
|
481
508
|
if input.empty? && default_value
|
|
482
509
|
input = default_value.to_s
|
|
@@ -504,13 +531,19 @@ module Morpheus
|
|
|
504
531
|
if value && !option_type['fieldInput'].nil?
|
|
505
532
|
value = {option_type['fieldName'].split('.').last => value, option_type['fieldInput'] => (no_prompt ? option_type['defaultInputValue'] : field_input_prompt(option_type))}
|
|
506
533
|
end
|
|
534
|
+
|
|
535
|
+
if value && !option_type['resultValueField'].nil?
|
|
536
|
+
value = {option_type['resultValueField'] => value}
|
|
537
|
+
end
|
|
507
538
|
value
|
|
508
539
|
end
|
|
509
540
|
|
|
510
541
|
# this works like select_prompt, but refreshes options with ?query=value between inputs
|
|
511
542
|
# paging_enabled is ignored right now
|
|
512
543
|
def self.typeahead_prompt(option_type,api_client, api_params={}, no_prompt=false, use_value=nil, paging_enabled=false)
|
|
513
|
-
|
|
544
|
+
paging_enabled = false if Morpheus::Cli.windows?
|
|
545
|
+
paging = nil
|
|
546
|
+
select_options = nil
|
|
514
547
|
field_key = [option_type['fieldContext'], option_type['fieldName']].select {|it| it && it != '' }.join('.')
|
|
515
548
|
help_field_key = option_type[:help_field_prefix] ? "#{option_type[:help_field_prefix]}.#{field_key}" : field_key
|
|
516
549
|
input = ""
|
|
@@ -544,7 +577,8 @@ module Morpheus
|
|
|
544
577
|
matches
|
|
545
578
|
}
|
|
546
579
|
# prompt for typeahead input value
|
|
547
|
-
|
|
580
|
+
has_more_pages = paging && ((paging[:cur_page] + 1) * paging[:page_size]) < paging[:total]
|
|
581
|
+
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 ? ' more ' : ' '}options]: ", false).to_s
|
|
548
582
|
input = input.chomp.strip
|
|
549
583
|
end
|
|
550
584
|
|
|
@@ -571,8 +605,22 @@ module Morpheus
|
|
|
571
605
|
# looking for help with this input
|
|
572
606
|
if input == '?'
|
|
573
607
|
help_prompt(option_type)
|
|
574
|
-
select_options = load_options(option_type, api_client, api_params)
|
|
575
|
-
|
|
608
|
+
select_options = select_options || load_options(option_type, api_client, api_params)
|
|
609
|
+
|
|
610
|
+
if !select_options.empty?
|
|
611
|
+
if paging_enabled
|
|
612
|
+
if paging.nil?
|
|
613
|
+
option_count = select_options ? select_options.count : 0
|
|
614
|
+
page_size = Readline.get_screen_size[0] - 6
|
|
615
|
+
if page_size < option_count
|
|
616
|
+
paging = {:cur_page => 0, :page_size => page_size, :total => option_count}
|
|
617
|
+
end
|
|
618
|
+
else
|
|
619
|
+
paging[:cur_page] = (paging[:cur_page] + 1) * paging[:page_size] < paging[:total] ? paging[:cur_page] + 1 : 0
|
|
620
|
+
end
|
|
621
|
+
end
|
|
622
|
+
display_select_options(option_type, select_options, paging)
|
|
623
|
+
end
|
|
576
624
|
next
|
|
577
625
|
end
|
|
578
626
|
|
|
@@ -719,7 +767,7 @@ module Morpheus
|
|
|
719
767
|
value_found = false
|
|
720
768
|
value = nil
|
|
721
769
|
while !value_found do
|
|
722
|
-
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}#{!option_type['defaultValue'].to_s.empty? ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
|
|
770
|
+
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }#{!option_type['required'] ? ' (optional)' : ''}#{!option_type['defaultValue'].to_s.empty? ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
|
|
723
771
|
input = $stdin.gets.chomp!
|
|
724
772
|
value = input.empty? ? option_type['defaultValue'] : input
|
|
725
773
|
if input == '?'
|
|
@@ -736,7 +784,7 @@ module Morpheus
|
|
|
736
784
|
value = nil
|
|
737
785
|
while !value_found do
|
|
738
786
|
if value.nil?
|
|
739
|
-
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{optional_label(option_type)} [Type 'EOF' to stop input]: \n"
|
|
787
|
+
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }#{optional_label(option_type)} [Type 'EOF' to stop input]: \n"
|
|
740
788
|
end
|
|
741
789
|
input = $stdin.gets.chomp!
|
|
742
790
|
# value = input.empty? ? option_type['defaultValue'] : input
|
|
@@ -760,7 +808,7 @@ module Morpheus
|
|
|
760
808
|
def self.password_prompt(option_type)
|
|
761
809
|
value_found = false
|
|
762
810
|
while !value_found do
|
|
763
|
-
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{optional_label(option_type)}#{option_type['defaultValue'] ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
|
|
811
|
+
print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }#{optional_label(option_type)}#{option_type['defaultValue'] ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
|
|
764
812
|
input = $stdin.noecho(&:gets).chomp!
|
|
765
813
|
value = input
|
|
766
814
|
print "\n"
|
|
@@ -780,11 +828,11 @@ module Morpheus
|
|
|
780
828
|
value_found = false
|
|
781
829
|
value = nil
|
|
782
830
|
while !value_found do
|
|
783
|
-
#print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{optional_label(option_type)}#{option_type['defaultValue'] ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
|
|
831
|
+
#print "#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }#{optional_label(option_type)}#{option_type['defaultValue'] ? ' ['+option_type['defaultValue'].to_s+']' : ''}: "
|
|
784
832
|
Readline.completion_append_character = ""
|
|
785
833
|
Readline.basic_word_break_characters = ''
|
|
786
834
|
Readline.completion_proc = proc {|s| Readline::FILENAME_COMPLETION_PROC.call(s) }
|
|
787
|
-
input = Readline.readline("#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? ('(' + option_type['fieldAddOn'] + ') ') : '' }#{optional_label(option_type)}#{option_type['defaultValue'] ? ' ['+option_type['defaultValue'].to_s+']' : ''}: ", false).to_s
|
|
835
|
+
input = Readline.readline("#{option_type['fieldLabel']}#{option_type['fieldAddOn'] ? (' (' + option_type['fieldAddOn'] + ') ') : '' }#{optional_label(option_type)}#{option_type['defaultValue'] ? ' ['+option_type['defaultValue'].to_s+']' : ''}: ", false).to_s
|
|
788
836
|
input = input.chomp.strip
|
|
789
837
|
#input = $stdin.gets.chomp!
|
|
790
838
|
value = input.empty? ? option_type['defaultValue'] : input.to_s
|
|
@@ -883,6 +931,32 @@ module Morpheus
|
|
|
883
931
|
return file_params
|
|
884
932
|
end
|
|
885
933
|
|
|
934
|
+
def self.multitext_prompt(option_type)
|
|
935
|
+
rtn = nil
|
|
936
|
+
|
|
937
|
+
# supports multi-part fields via config.fields
|
|
938
|
+
# {"fields": [{"name":"tag", "required":true, "label": "Tag"}, {"name":"value", "required":false, "label": "Scope"}]}
|
|
939
|
+
if option_type['config']['fields']
|
|
940
|
+
while (option_type['required'] && rtn.empty?) || self.confirm("Add#{rtn.empty? ? '': ' more'} #{option_type['fieldLabel']}?", {:default => false})
|
|
941
|
+
rtn ||= []
|
|
942
|
+
value = {}
|
|
943
|
+
option_type['config']['fields'].each do |field|
|
|
944
|
+
field_label = field['label'] || field['name'].capitalize
|
|
945
|
+
value[field['name']] = generic_prompt(option_type.merge({'fieldLabel' => field_label, 'required' => field['required'], 'description' => "#{option_type['fieldLabel']} #{field_label}"}))
|
|
946
|
+
end
|
|
947
|
+
rtn << value
|
|
948
|
+
end
|
|
949
|
+
else
|
|
950
|
+
if rtn = generic_prompt(option_type)
|
|
951
|
+
rtn = [rtn]
|
|
952
|
+
while self.confirm("Add more #{option_type['fieldLabel']}?", {:default => false}) do
|
|
953
|
+
rtn << generic_prompt(option_type)
|
|
954
|
+
end
|
|
955
|
+
end
|
|
956
|
+
end
|
|
957
|
+
rtn
|
|
958
|
+
end
|
|
959
|
+
|
|
886
960
|
def self.load_options(option_type, api_client, api_params, query_value=nil)
|
|
887
961
|
select_options = []
|
|
888
962
|
# local array of options
|
|
@@ -902,6 +976,8 @@ module Morpheus
|
|
|
902
976
|
select_options = filtered_options
|
|
903
977
|
end
|
|
904
978
|
elsif option_type['optionSource']
|
|
979
|
+
api_params = api_params.select {|k,v| option_type['params'].include(k)} if !option_type['params'].nil? && api_params
|
|
980
|
+
|
|
905
981
|
# calculate from inline lambda
|
|
906
982
|
if option_type['optionSource'].is_a?(Proc)
|
|
907
983
|
select_options = option_type['optionSource'].call(api_client, api_params || {})
|
|
@@ -960,21 +1036,29 @@ module Morpheus
|
|
|
960
1036
|
return out
|
|
961
1037
|
end
|
|
962
1038
|
|
|
1039
|
+
def self.sorted_option_types(option_types)
|
|
1040
|
+
option_types.reject {|it| (it['fieldGroup'] || 'default') != 'default'}.sort {|a,b| a['displayOrder'].to_i <=> b['displayOrder'].to_i} +
|
|
1041
|
+
option_types.reject {|it| ['default', 'advanced'].include?(it['fieldGroup'] || 'default')}.sort{|a,b| a['displayOrder'] <=> b['displayOrder']}.group_by{|it| it['fieldGroup']}.values.collect { |it| it.sort{|a,b| a['displayOrder'].to_i <=> b['displayOrder'].to_i}}.flatten +
|
|
1042
|
+
option_types.reject {|it| it['fieldGroup'] != 'advanced'}.sort {|a,b| a['displayOrder'].to_i <=> b['displayOrder'].to_i}
|
|
1043
|
+
end
|
|
1044
|
+
|
|
963
1045
|
def self.display_select_options(opt, select_options = [], paging = nil)
|
|
964
|
-
puts format_select_options_help(opt, select_options, paging)
|
|
1046
|
+
puts self.format_select_options_help(opt, select_options, paging)
|
|
965
1047
|
end
|
|
966
1048
|
|
|
967
1049
|
def self.format_option_types_help(option_types, opts={})
|
|
1050
|
+
option_types = self.sorted_option_types(option_types).reject {|it| it['hidden']}
|
|
1051
|
+
|
|
968
1052
|
if option_types.empty?
|
|
969
1053
|
"#{opts[:color]}#{opts[:title] || "Available Options:"}\nNone\n\n"
|
|
970
1054
|
else
|
|
971
1055
|
if opts[:include_context]
|
|
972
|
-
option_lines = option_types.
|
|
1056
|
+
option_lines = option_types.collect {|it|
|
|
973
1057
|
field_context = (opts[:context_map] || {})[it['fieldContext']] || it['fieldContext']
|
|
974
1058
|
" -O #{field_context && field_context != '' ? "#{field_context}." : ''}#{it['fieldName']}=\"value\""
|
|
975
1059
|
}
|
|
976
1060
|
else
|
|
977
|
-
option_lines = option_types.
|
|
1061
|
+
option_lines = option_types.collect {|it| " -O #{it['fieldName']}=\"value\"" }
|
|
978
1062
|
end
|
|
979
1063
|
"#{opts[:color]}#{opts[:title] || "Available Options:"}\n#{option_lines.join("\n")}\n\n"
|
|
980
1064
|
end
|
|
@@ -992,6 +1076,31 @@ module Morpheus
|
|
|
992
1076
|
return option_type['required'] ? '' : ' (optional)'
|
|
993
1077
|
end
|
|
994
1078
|
end
|
|
1079
|
+
|
|
1080
|
+
def self.get_option_value(obj, option_type, format=false)
|
|
1081
|
+
context = option_type['fieldContext'] == 'config' ? obj['config'] : obj
|
|
1082
|
+
name = option_type['fieldName']
|
|
1083
|
+
tokens = name.split('.')
|
|
1084
|
+
|
|
1085
|
+
if tokens.length > 1
|
|
1086
|
+
tokens.slice(0, tokens.length - 1).each do |token|
|
|
1087
|
+
context = context[token]
|
|
1088
|
+
end
|
|
1089
|
+
name = tokens.last
|
|
1090
|
+
end
|
|
1091
|
+
|
|
1092
|
+
if context.kind_of?(Array)
|
|
1093
|
+
rtn = context.collect {|it| it['name'] || it[name]}.join ', '
|
|
1094
|
+
else
|
|
1095
|
+
rtn = context[name]
|
|
1096
|
+
end
|
|
1097
|
+
|
|
1098
|
+
if format
|
|
1099
|
+
rtn = (rtn ? 'On' : 'Off') if option_type['type'] == 'checkbox'
|
|
1100
|
+
rtn = rtn.join(', ') if rtn.is_a?(Array)
|
|
1101
|
+
end
|
|
1102
|
+
rtn
|
|
1103
|
+
end
|
|
995
1104
|
end
|
|
996
1105
|
end
|
|
997
1106
|
end
|
data/lib/morpheus/cli/version.rb
CHANGED
data/lib/morpheus/cli.rb
CHANGED
|
@@ -4,6 +4,7 @@ require 'morpheus/rest_client'
|
|
|
4
4
|
require 'morpheus/formatters'
|
|
5
5
|
require 'morpheus/logging'
|
|
6
6
|
require 'morpheus/util'
|
|
7
|
+
require 'morpheus/routes'
|
|
7
8
|
require 'term/ansicolor'
|
|
8
9
|
|
|
9
10
|
Dir[File.dirname(__FILE__) + "/ext/*.rb"].each {|file| require file }
|
|
@@ -11,12 +12,12 @@ Dir[File.dirname(__FILE__) + "/ext/*.rb"].each {|file| require file }
|
|
|
11
12
|
module Morpheus
|
|
12
13
|
module Cli
|
|
13
14
|
|
|
14
|
-
# get the home directory, where morpheus-cli stores things
|
|
15
15
|
# The default is $MORPHEUS_CLI_HOME or $HOME/.morpheus
|
|
16
16
|
unless defined?(@@home_directory)
|
|
17
17
|
@@home_directory = ENV['MORPHEUS_CLI_HOME'] || File.join(Dir.home, ".morpheus")
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
# get the home directory, where morpheus-cli stores things
|
|
20
21
|
def self.home_directory
|
|
21
22
|
@@home_directory
|
|
22
23
|
end
|
|
@@ -50,12 +51,9 @@ module Morpheus
|
|
|
50
51
|
Dir[File.dirname(__FILE__) + "/api/**/*.rb"].each {|file| load file }
|
|
51
52
|
|
|
52
53
|
# load mixins
|
|
53
|
-
Dir[File.dirname(__FILE__) + "/cli/mixins
|
|
54
|
+
Dir[File.dirname(__FILE__) + "/cli/mixins/**/*.rb"].each {|file| load file }
|
|
54
55
|
|
|
55
|
-
# load
|
|
56
|
-
# Dir[File.dirname(__FILE__) + "/cli/*.rb"].each {|file| load file }
|
|
57
|
-
|
|
58
|
-
# utilites
|
|
56
|
+
# load utilites
|
|
59
57
|
require 'morpheus/cli/cli_registry.rb'
|
|
60
58
|
require 'morpheus/cli/expression_parser.rb'
|
|
61
59
|
require 'morpheus/cli/dot_file.rb'
|
|
@@ -65,128 +63,8 @@ module Morpheus
|
|
|
65
63
|
load 'morpheus/cli/option_types.rb'
|
|
66
64
|
load 'morpheus/cli/credentials.rb'
|
|
67
65
|
|
|
68
|
-
# all
|
|
69
|
-
Dir[File.dirname(__FILE__) + "/cli/commands
|
|
70
|
-
|
|
71
|
-
# all the known commands
|
|
72
|
-
load 'morpheus/cli/remote.rb'
|
|
73
|
-
load 'morpheus/cli/doc.rb'
|
|
74
|
-
load 'morpheus/cli/ping.rb'
|
|
75
|
-
load 'morpheus/cli/setup.rb'
|
|
76
|
-
load 'morpheus/cli/login.rb'
|
|
77
|
-
load 'morpheus/cli/logout.rb'
|
|
78
|
-
load 'morpheus/cli/forgot_password.rb'
|
|
79
|
-
load 'morpheus/cli/whoami.rb'
|
|
80
|
-
load 'morpheus/cli/access_token_command.rb'
|
|
81
|
-
load 'morpheus/cli/user_settings_command.rb'
|
|
82
|
-
load 'morpheus/cli/search_command.rb'
|
|
83
|
-
load 'morpheus/cli/dashboard_command.rb'
|
|
84
|
-
load 'morpheus/cli/recent_activity_command.rb' # deprecated, removing soon
|
|
85
|
-
load 'morpheus/cli/activity_command.rb'
|
|
86
|
-
load 'morpheus/cli/appliance_settings_command.rb'
|
|
87
|
-
load 'morpheus/cli/power_schedules_command.rb'
|
|
88
|
-
load 'morpheus/cli/execute_schedules_command.rb'
|
|
89
|
-
load 'morpheus/cli/groups.rb'
|
|
90
|
-
load 'morpheus/cli/clouds.rb'
|
|
91
|
-
load 'morpheus/cli/cloud_datastores_command.rb'
|
|
92
|
-
load 'morpheus/cli/cloud_resource_pools_command.rb'
|
|
93
|
-
load 'morpheus/cli/cloud_folders_command.rb'
|
|
94
|
-
load 'morpheus/cli/hosts.rb'
|
|
95
|
-
load 'morpheus/cli/load_balancers.rb'
|
|
96
|
-
load 'morpheus/cli/load_balancer_types.rb'
|
|
97
|
-
load 'morpheus/cli/shell.rb'
|
|
98
|
-
load 'morpheus/cli/tasks.rb'
|
|
99
|
-
load 'morpheus/cli/workflows.rb'
|
|
100
|
-
load 'morpheus/cli/deployments.rb'
|
|
101
|
-
load 'morpheus/cli/deploy.rb'
|
|
102
|
-
load 'morpheus/cli/deploys.rb'
|
|
103
|
-
load 'morpheus/cli/instances.rb'
|
|
104
|
-
load 'morpheus/cli/containers_command.rb'
|
|
105
|
-
load 'morpheus/cli/apps.rb'
|
|
106
|
-
load 'morpheus/cli/blueprints_command.rb'
|
|
107
|
-
load 'morpheus/cli/license.rb'
|
|
108
|
-
load 'morpheus/cli/instance_types.rb'
|
|
109
|
-
load 'morpheus/cli/jobs_command.rb'
|
|
110
|
-
load 'morpheus/cli/integrations_command.rb'
|
|
111
|
-
load 'morpheus/cli/security_groups.rb'
|
|
112
|
-
load 'morpheus/cli/security_group_rules.rb'
|
|
113
|
-
load 'morpheus/cli/clusters.rb'
|
|
114
|
-
load 'morpheus/cli/tenants_command.rb'
|
|
115
|
-
load 'morpheus/cli/account_groups_command.rb'
|
|
116
|
-
load 'morpheus/cli/users.rb'
|
|
117
|
-
load 'morpheus/cli/change_password_command.rb'
|
|
118
|
-
load 'morpheus/cli/user_groups_command.rb'
|
|
119
|
-
load 'morpheus/cli/user_sources_command.rb'
|
|
120
|
-
load 'morpheus/cli/roles.rb'
|
|
121
|
-
load 'morpheus/cli/key_pairs.rb'
|
|
122
|
-
load 'morpheus/cli/virtual_images.rb'
|
|
123
|
-
# load 'morpheus/cli/library.rb' # gone until we collapse these again
|
|
124
|
-
load 'morpheus/cli/library_instance_types_command.rb'
|
|
125
|
-
load 'morpheus/cli/library_cluster_layouts_command.rb'
|
|
126
|
-
load 'morpheus/cli/library_layouts_command.rb'
|
|
127
|
-
load 'morpheus/cli/library_upgrades_command.rb'
|
|
128
|
-
load 'morpheus/cli/library_container_types_command.rb'
|
|
129
|
-
load 'morpheus/cli/library_container_scripts_command.rb'
|
|
130
|
-
load 'morpheus/cli/library_container_templates_command.rb'
|
|
131
|
-
load 'morpheus/cli/library_option_types_command.rb'
|
|
132
|
-
load 'morpheus/cli/library_option_lists_command.rb'
|
|
133
|
-
load 'morpheus/cli/library_spec_templates_command.rb'
|
|
134
|
-
load 'morpheus/cli/monitoring_incidents_command.rb'
|
|
135
|
-
load 'morpheus/cli/monitoring_checks_command.rb'
|
|
136
|
-
load 'morpheus/cli/monitoring_contacts_command.rb'
|
|
137
|
-
load 'morpheus/cli/monitoring_alerts_command.rb'
|
|
138
|
-
load 'morpheus/cli/monitoring_groups_command.rb'
|
|
139
|
-
load 'morpheus/cli/monitoring_apps_command.rb'
|
|
140
|
-
load 'morpheus/cli/logs_command.rb'
|
|
141
|
-
load 'morpheus/cli/policies_command.rb'
|
|
142
|
-
load 'morpheus/cli/networks_command.rb'
|
|
143
|
-
load 'morpheus/cli/subnets_command.rb'
|
|
144
|
-
load 'morpheus/cli/network_groups_command.rb'
|
|
145
|
-
load 'morpheus/cli/network_pools_command.rb'
|
|
146
|
-
load 'morpheus/cli/network_services_command.rb'
|
|
147
|
-
load 'morpheus/cli/network_pool_servers_command.rb'
|
|
148
|
-
load 'morpheus/cli/network_domains_command.rb'
|
|
149
|
-
load 'morpheus/cli/network_proxies_command.rb'
|
|
150
|
-
load 'morpheus/cli/network_routers_command.rb'
|
|
151
|
-
load 'morpheus/cli/cypher_command.rb'
|
|
152
|
-
load 'morpheus/cli/image_builder_command.rb'
|
|
153
|
-
load 'morpheus/cli/preseed_scripts_command.rb'
|
|
154
|
-
load 'morpheus/cli/boot_scripts_command.rb'
|
|
155
|
-
load 'morpheus/cli/archives_command.rb'
|
|
156
|
-
load 'morpheus/cli/storage_providers_command.rb'
|
|
157
|
-
load 'morpheus/cli/execution_request_command.rb'
|
|
158
|
-
load 'morpheus/cli/file_copy_request_command.rb'
|
|
159
|
-
load 'morpheus/cli/processes_command.rb'
|
|
160
|
-
load 'morpheus/cli/packages_command.rb'
|
|
161
|
-
load 'morpheus/cli/reports_command.rb'
|
|
162
|
-
load 'morpheus/cli/environments_command.rb'
|
|
163
|
-
load 'morpheus/cli/backup_settings_command.rb'
|
|
164
|
-
load 'morpheus/cli/log_settings_command.rb'
|
|
165
|
-
load 'morpheus/cli/whitelabel_settings_command.rb'
|
|
166
|
-
load 'morpheus/cli/wiki_command.rb'
|
|
167
|
-
load 'morpheus/cli/approvals_command.rb'
|
|
168
|
-
load 'morpheus/cli/service_plans_command.rb'
|
|
169
|
-
load 'morpheus/cli/price_sets_command.rb'
|
|
170
|
-
load 'morpheus/cli/prices_command.rb'
|
|
171
|
-
load 'morpheus/cli/provisioning_settings_command.rb'
|
|
172
|
-
load 'morpheus/cli/provisioning_licenses_command.rb'
|
|
173
|
-
load 'morpheus/cli/budgets_command.rb'
|
|
174
|
-
load 'morpheus/cli/health_command.rb'
|
|
175
|
-
load 'morpheus/cli/invoices_command.rb'
|
|
176
|
-
load 'morpheus/cli/guidance_command.rb'
|
|
177
|
-
load 'morpheus/cli/projects_command.rb'
|
|
178
|
-
load 'morpheus/cli/backups_command.rb'
|
|
179
|
-
load 'morpheus/cli/backup_jobs_command.rb'
|
|
180
|
-
load 'morpheus/cli/catalog_item_types_command.rb' # self-service
|
|
181
|
-
load 'morpheus/cli/service_catalog_command.rb' # catalog (Service Catalog persona)
|
|
182
|
-
load 'morpheus/cli/usage_command.rb'
|
|
183
|
-
load 'morpheus/cli/vdi_pools_command.rb'
|
|
184
|
-
load 'morpheus/cli/vdi_allocations_command.rb'
|
|
185
|
-
load 'morpheus/cli/vdi_apps_command.rb'
|
|
186
|
-
load 'morpheus/cli/vdi_gateways_command.rb'
|
|
187
|
-
load 'morpheus/cli/vdi_command.rb' # (VDI persona)
|
|
188
|
-
load 'morpheus/cli/certificates_command.rb' # (VDI persona)
|
|
189
|
-
# add new commands here...
|
|
66
|
+
# load all commands
|
|
67
|
+
Dir[File.dirname(__FILE__) + "/cli/commands/**/*.rb"].each {|file| load file }
|
|
190
68
|
|
|
191
69
|
end
|
|
192
70
|
|