morpheus-cli 5.3.2.3 → 5.4.1
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/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 +39 -5
- 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_images_interface.rb +23 -2
- data/lib/morpheus/api/virtual_servers_interface.rb +9 -0
- data/lib/morpheus/cli/cli_command.rb +274 -19
- data/lib/morpheus/cli/cli_registry.rb +56 -2
- 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} +17 -89
- 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} +170 -138
- data/lib/morpheus/cli/{clouds.rb → commands/clouds.rb} +22 -47
- data/lib/morpheus/cli/{clusters.rb → commands/clusters.rb} +86 -49
- 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} +2 -8
- data/lib/morpheus/cli/{instance_types.rb → commands/instance_types.rb} +0 -3
- data/lib/morpheus/cli/{instances.rb → commands/instances.rb} +473 -150
- data/lib/morpheus/cli/{integrations_command.rb → commands/integrations_command.rb} +0 -0
- data/lib/morpheus/cli/{invoices_command.rb → commands/invoices_command.rb} +118 -134
- 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} +20 -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 +71 -0
- data/lib/morpheus/cli/commands/load_balancer_pools.rb +91 -0
- data/lib/morpheus/cli/commands/load_balancer_profiles.rb +65 -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 +156 -0
- data/lib/morpheus/cli/commands/load_balancers.rb +176 -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} +2 -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} +21 -21
- 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} +4 -1
- 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} +251 -33
- 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 +167 -110
- data/lib/morpheus/cli/mixins/rest_command.rb +268 -94
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +668 -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_parser.rb +25 -17
- data/lib/morpheus/cli/option_types.rb +137 -52
- 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
- data/morpheus-cli.gemspec +1 -1
- metadata +183 -149
- 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
@@ -6,6 +6,7 @@ require 'ostruct'
|
|
6
6
|
require 'io/console'
|
7
7
|
require 'morpheus/logging'
|
8
8
|
require 'fileutils'
|
9
|
+
require 'filesize'
|
9
10
|
|
10
11
|
module Morpheus::Cli::PrintHelper
|
11
12
|
|
@@ -201,7 +202,7 @@ module Morpheus::Cli::PrintHelper
|
|
201
202
|
if options[:outfile]
|
202
203
|
print_result = print_to_file(output, options[:outfile], options[:overwrite])
|
203
204
|
# with_stdout_to_file(options[:outfile], options[:overwrite]) { print output }
|
204
|
-
print "#{cyan}Wrote output to file #{options[:outfile]} (#{format_bytes
|
205
|
+
print "#{cyan}Wrote output to file #{options[:outfile]} (#{format_bytes(File.size(options[:outfile]))})\n" unless options[:quiet]
|
205
206
|
#return print_result
|
206
207
|
return
|
207
208
|
end
|
@@ -219,6 +220,14 @@ module Morpheus::Cli::PrintHelper
|
|
219
220
|
return
|
220
221
|
end
|
221
222
|
|
223
|
+
def print_system_command_dry_run(cmd, options={})
|
224
|
+
print "\n"
|
225
|
+
print "#{cyan}#{bold}#{dark}SYSTEM COMMAND#{reset}\n"
|
226
|
+
print cmd
|
227
|
+
print reset, "\n"
|
228
|
+
return
|
229
|
+
end
|
230
|
+
|
222
231
|
def format_api_request(http_method, url, headers, payload=nil, options={})
|
223
232
|
out = ""
|
224
233
|
# out << "\n"
|
@@ -384,33 +393,57 @@ module Morpheus::Cli::PrintHelper
|
|
384
393
|
if json_response.nil? || json_response.empty?
|
385
394
|
return ""
|
386
395
|
end
|
387
|
-
|
388
|
-
# options = OpenStruct.new(options) # laff, let's do this instead
|
389
396
|
color = options.key?(:color) ? options[:color] : cyan
|
390
397
|
label = options[:label]
|
391
|
-
n_label = options[:n_label]
|
392
|
-
# label = n_label if !label && n_label
|
398
|
+
n_label = options[:n_label] || (label ? label.to_s.pluralize : nil)
|
393
399
|
message = options[:message] || "Viewing %{start_index}-%{end_index} of %{total} %{label}"
|
394
400
|
blank_message = options[:blank_message] || nil # "No %{label} found"
|
395
401
|
|
396
|
-
# support lazy passing of common json_response {"meta": {"size":
|
397
|
-
#
|
398
|
-
meta
|
399
|
-
if
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
#
|
404
|
-
|
405
|
-
|
406
|
-
|
402
|
+
# support lazy passing of common list json_response {"meta": {"size": 25, "total": 56} }
|
403
|
+
# priority is:
|
404
|
+
# 1. "meta" that api response contains for list endpoints
|
405
|
+
# 2. "total" and "size" values if passed explicitely by the cli (pretty sure symbols are no longer used)
|
406
|
+
# 3. examine the first array found in the response
|
407
|
+
meta = nil
|
408
|
+
records = nil
|
409
|
+
# assume records is the first array in the response
|
410
|
+
records_key = json_response.keys.find { |k| json_response[k].is_a?(Array) }
|
411
|
+
if records_key
|
412
|
+
records = json_response[records_key]
|
413
|
+
meta = {'offset' => 0, 'size' => records.size, 'total' => records.size}
|
414
|
+
end
|
415
|
+
if json_response[:meta] || json_response["meta"]
|
416
|
+
meta = json_response[:meta] || json_response["meta"]
|
417
|
+
elsif json_response.key?('size') || json_response.key?('total')
|
418
|
+
meta = json_response
|
419
|
+
elsif json_response.key?(:size) || json_response.key?(:total)
|
420
|
+
meta = {'size' => json_response[:size], 'total' => json_response[:total], 'offset' => json_response[:offset]}
|
421
|
+
elsif records
|
422
|
+
# just use the first key in the response
|
423
|
+
meta = {'size' => records.size, 'total' => records.size}
|
424
|
+
end
|
425
|
+
# did not find pagination meta info?
|
426
|
+
if meta.nil?
|
427
|
+
return ""
|
428
|
+
end
|
429
|
+
# api should not need to return the size, just use records.size
|
430
|
+
if meta["size"].nil? && records
|
431
|
+
meta["size"] = records.size
|
432
|
+
end
|
433
|
+
offset = meta['offset'].to_i
|
434
|
+
size = meta['size'].to_i
|
435
|
+
total = meta['total'].to_i
|
436
|
+
# perhaps no total count returned, let total be equal to size of list
|
437
|
+
if total == 0 && size > 0
|
407
438
|
total = size
|
408
439
|
end
|
440
|
+
# plural label?
|
409
441
|
if total != 1
|
410
|
-
label = n_label
|
442
|
+
label = n_label
|
411
443
|
end
|
412
444
|
out_str = ""
|
413
|
-
string_key_values = {start_index: format_number(offset + 1), end_index: format_number(offset + size),
|
445
|
+
string_key_values = {start_index: format_number(offset + 1), end_index: format_number(offset + size),
|
446
|
+
total: format_number(total), size: format_number(size), offset: format_number(offset), label: label}
|
414
447
|
if size > 0
|
415
448
|
if message
|
416
449
|
out_str << message % string_key_values
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'morpheus/cli/mixins/print_helper'
|
2
2
|
|
3
3
|
# Mixin for Morpheus::Cli command classes
|
4
|
-
# Provides common methods for
|
5
|
-
# The including class must establish @accounts_interface, @roles_interface, @users_interface
|
4
|
+
# Provides common methods for viewing process history
|
6
5
|
module Morpheus::Cli::ProcessesHelper
|
7
6
|
|
8
7
|
def self.included(klass)
|
@@ -57,9 +57,9 @@ module Morpheus::Cli::ProvisioningHelper
|
|
57
57
|
@api_client.accounts
|
58
58
|
end
|
59
59
|
|
60
|
-
def get_available_groups(refresh=false)
|
60
|
+
def get_available_groups(params = {}, refresh=false)
|
61
61
|
if !@available_groups || refresh
|
62
|
-
option_results = options_interface.options_for_source('groups',
|
62
|
+
option_results = options_interface.options_for_source('groups', params)
|
63
63
|
@available_groups = option_results['data'].collect {|it|
|
64
64
|
{"id" => it["value"], "name" => it["name"], "value" => it["value"]}
|
65
65
|
}
|
@@ -68,9 +68,9 @@ module Morpheus::Cli::ProvisioningHelper
|
|
68
68
|
return @available_groups
|
69
69
|
end
|
70
70
|
|
71
|
-
def get_available_clouds(group_id, refresh=false)
|
71
|
+
def get_available_clouds(group_id, params = {}, refresh=false)
|
72
72
|
if !group_id
|
73
|
-
option_results = options_interface.options_for_source('clouds', {'default' => 'false'})
|
73
|
+
option_results = options_interface.options_for_source('clouds', params.merge({'default' => 'false'}))
|
74
74
|
return option_results['data'].collect {|it|
|
75
75
|
{"id" => it["value"], "name" => it["name"], "value" => it["value"], "zoneTypeId" => it["zoneTypeId"]}
|
76
76
|
}
|
@@ -80,7 +80,7 @@ module Morpheus::Cli::ProvisioningHelper
|
|
80
80
|
return []
|
81
81
|
end
|
82
82
|
if !group["clouds"] || refresh
|
83
|
-
option_results = options_interface.options_for_source('clouds', {groupId: group_id})
|
83
|
+
option_results = options_interface.options_for_source('clouds', params.merge({groupId: group_id}))
|
84
84
|
group["clouds"] = option_results['data'].collect {|it|
|
85
85
|
{"id" => it["value"], "name" => it["name"], "value" => it["value"], "zoneTypeId" => it["zoneTypeId"]}
|
86
86
|
}
|
@@ -484,7 +484,7 @@ module Morpheus::Cli::ProvisioningHelper
|
|
484
484
|
if options[:instance_type_code]
|
485
485
|
instance_type_code = options[:instance_type_code]
|
486
486
|
else
|
487
|
-
instance_type_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'type', 'type' => 'select', 'fieldLabel' => 'Type', 'optionSource' => 'instanceTypes', 'required' => true, 'description' => 'Select Instance Type.'}],options[:options],api_client,{groupId: group_id})
|
487
|
+
instance_type_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'type', 'type' => 'select', 'fieldLabel' => 'Type', 'optionSource' => 'instanceTypes', 'required' => true, 'description' => 'Select Instance Type.'}],options[:options],api_client,{groupId: group_id}, no_prompt, true)
|
488
488
|
instance_type_code = instance_type_prompt['type']
|
489
489
|
end
|
490
490
|
if instance_type_code.to_s =~ /\A\d{1,}\Z/
|
@@ -584,7 +584,7 @@ module Morpheus::Cli::ProvisioningHelper
|
|
584
584
|
if options[:description]
|
585
585
|
options[:options]['description'] = options[:description]
|
586
586
|
end
|
587
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false}], options[:options])
|
587
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false, 'defaultValue' => options[:default_description]}], options[:options])
|
588
588
|
payload['instance']['description'] = v_prompt['description'] if !v_prompt['description'].empty?
|
589
589
|
|
590
590
|
# Environment
|
@@ -593,14 +593,14 @@ module Morpheus::Cli::ProvisioningHelper
|
|
593
593
|
elsif options[:options]['instanceContext'] && !options[:options]['environment']
|
594
594
|
options[:options]['environment'] = options[:options]['instanceContext']
|
595
595
|
end
|
596
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'environment', 'fieldLabel' => 'Environment', 'type' => 'select', 'required' => false, 'selectOptions' => get_available_environments()}], options[:options])
|
596
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'environment', 'fieldLabel' => 'Environment', 'type' => 'select', 'required' => false, 'selectOptions' => get_available_environments(), 'defaultValue' => options[:default_environment]}], options[:options])
|
597
597
|
payload['instance']['instanceContext'] = v_prompt['environment'] if !v_prompt['environment'].empty?
|
598
598
|
|
599
599
|
# Labels (used to be called tags)
|
600
600
|
if options[:labels]
|
601
601
|
payload['instance']['labels'] = options[:labels].is_a?(Array) ? options[:labels] : options[:labels].to_s.split(',').collect {|it| it.to_s.strip }.compact.uniq
|
602
602
|
else
|
603
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'labels', 'fieldLabel' => 'Labels', 'type' => 'text', 'required' => false}], options[:options])
|
603
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'labels', 'fieldLabel' => 'Labels', 'type' => 'text', 'required' => false, 'defaultValue' => options[:default_labels]}], options[:options])
|
604
604
|
payload['instance']['labels'] = v_prompt['labels'].split(',').collect {|it| it.to_s.strip }.compact.uniq if !v_prompt['labels'].empty?
|
605
605
|
end
|
606
606
|
|
@@ -657,13 +657,11 @@ module Morpheus::Cli::ProvisioningHelper
|
|
657
657
|
version_value = default_version_value
|
658
658
|
version_is_required = default_layout_value.nil?
|
659
659
|
if default_layout_value.nil? && options[:options]["layout"].nil? && options[:always_prompt] != true
|
660
|
-
#version_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'version', 'type' => 'select', 'fieldLabel' => 'Version', 'optionSource' => 'instanceVersions', 'required' => true, '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']})
|
661
660
|
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']})
|
662
661
|
version_value = version_prompt['version']
|
663
662
|
end
|
664
663
|
end
|
665
|
-
|
666
|
-
layout_id = 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, creatable: true})['layout']
|
664
|
+
layout_id = 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, creatable: true}, no_prompt, true)['layout']
|
667
665
|
end
|
668
666
|
end
|
669
667
|
|
@@ -679,7 +677,7 @@ module Morpheus::Cli::ProvisioningHelper
|
|
679
677
|
end
|
680
678
|
layout_id = layout['id']
|
681
679
|
payload['instance']['layout'] = {'id' => layout['id'], 'code' => layout['code']}
|
682
|
-
|
680
|
+
|
683
681
|
# need to GET provision type for optionTypes, and other settings...
|
684
682
|
provision_type_code = layout['provisionTypeCode'] || layout['provisionType']['code']
|
685
683
|
provision_type = nil
|
@@ -693,50 +691,6 @@ module Morpheus::Cli::ProvisioningHelper
|
|
693
691
|
provision_type = get_provision_type_for_zone_type(cloud['zoneType']['id'])
|
694
692
|
end
|
695
693
|
|
696
|
-
# prompt for service plan
|
697
|
-
plan_id = nil
|
698
|
-
service_plan = nil
|
699
|
-
service_plans_json = instances_interface.service_plans({zoneId: cloud_id, layoutId: layout['id'], siteId: group_id})
|
700
|
-
service_plans = service_plans_json["plans"]
|
701
|
-
if locked_fields.include?('plan.id')
|
702
|
-
plan_id = options[:options]['plan']['id'] rescue nil
|
703
|
-
if plan_id.nil?
|
704
|
-
plan_id = options[:options]['instance']['plan']['id'] rescue nil
|
705
|
-
end
|
706
|
-
service_plan = service_plans.find {|sp| sp['id'] == plan_id }
|
707
|
-
else
|
708
|
-
service_plan = service_plans.find {|sp| sp['id'] == options[:service_plan].to_i} if options[:service_plan]
|
709
|
-
|
710
|
-
if !service_plan
|
711
|
-
service_plans_dropdown = service_plans.collect {|sp| {'name' => sp["name"], 'value' => sp["id"], 'code' => sp['code']} } # already sorted
|
712
|
-
default_plan = nil
|
713
|
-
if payload['plan']
|
714
|
-
default_plan = payload['plan']
|
715
|
-
elsif payload['instance'] && payload['instance']['plan']
|
716
|
-
default_plan = payload['instance']['plan']
|
717
|
-
end
|
718
|
-
|
719
|
-
if options[:default_plan] && service_plans_dropdown.find {|sp| [sp["name"], sp["value"].to_s, sp["code"]].include?(options[:default_plan].to_s)}
|
720
|
-
default_plan_value = options[:default_plan]
|
721
|
-
else
|
722
|
-
default_plan_value = options[:default_plan] || (default_plan.is_a?(Hash) ? default_plan['id'] : default_plan)
|
723
|
-
end
|
724
|
-
plan_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'servicePlan', 'type' => 'select', 'fieldLabel' => 'Plan', 'selectOptions' => service_plans_dropdown, 'required' => true, 'description' => 'Choose the appropriately sized plan for this instance', 'defaultValue' => default_plan_value}],options[:options])
|
725
|
-
plan_id = plan_prompt['servicePlan']
|
726
|
-
service_plan = service_plans.find {|sp| sp["id"] == plan_id.to_i }
|
727
|
-
if !service_plan
|
728
|
-
print_red_alert "Plan not found by id #{plan_id}"
|
729
|
-
exit 1
|
730
|
-
end
|
731
|
-
end
|
732
|
-
#todo: consolidate these, instances api looks for instance.plan.id and apps looks for plan.id
|
733
|
-
if options[:for_app]
|
734
|
-
payload['plan'] = {'id' => service_plan["id"], 'code' => service_plan["code"], 'name' => service_plan["name"]}
|
735
|
-
else
|
736
|
-
payload['instance']['plan'] = {'id' => service_plan["id"], 'code' => service_plan["code"], 'name' => service_plan["name"]}
|
737
|
-
end
|
738
|
-
end
|
739
|
-
|
740
694
|
# build config option types
|
741
695
|
option_type_list = []
|
742
696
|
if !layout['optionTypes'].nil? && !layout['optionTypes'].empty?
|
@@ -745,47 +699,112 @@ module Morpheus::Cli::ProvisioningHelper
|
|
745
699
|
if !instance_type['optionTypes'].nil? && !instance_type['optionTypes'].empty?
|
746
700
|
option_type_list += instance_type['optionTypes']
|
747
701
|
end
|
748
|
-
if !provision_type.nil? && !provision_type['optionTypes'].nil? && !provision_type['optionTypes'].empty?
|
749
|
-
option_type_list += provision_type['optionTypes']
|
750
|
-
end
|
751
702
|
|
752
|
-
|
703
|
+
api_params = {groupId: group_id, cloudId: cloud_id, zoneId: cloud_id, instanceTypeId: instance_type['id'], version: version_value}
|
704
|
+
|
753
705
|
pool_id = nil
|
754
706
|
resource_pool = nil
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
707
|
+
service_plan = nil
|
708
|
+
|
709
|
+
prompt_service_plan = -> {
|
710
|
+
service_plans_json = instances_interface.service_plans({zoneId: cloud_id, layoutId: layout['id'], siteId: group_id}.merge(resource_pool.nil? ? {} : {'resourcePoolId' => resource_pool['id']}))
|
711
|
+
service_plans = service_plans_json["plans"]
|
712
|
+
if locked_fields.include?('plan.id')
|
713
|
+
plan_id = options[:options]['plan']['id'] rescue nil
|
714
|
+
if plan_id.nil?
|
715
|
+
plan_id = options[:options]['instance']['plan']['id'] rescue nil
|
716
|
+
end
|
717
|
+
service_plan = service_plans.find {|sp| sp['id'] == plan_id }
|
718
|
+
else
|
719
|
+
service_plan = service_plans.find {|sp| sp['id'] == options[:service_plan].to_i} if options[:service_plan]
|
720
|
+
|
721
|
+
if !service_plan
|
722
|
+
service_plans_dropdown = service_plans.collect {|sp| {'name' => sp["name"], 'value' => sp["id"], 'code' => sp['code']} } # already sorted
|
723
|
+
default_plan = nil
|
724
|
+
if payload['plan']
|
725
|
+
default_plan = payload['plan']
|
726
|
+
elsif payload['instance'] && payload['instance']['plan']
|
727
|
+
default_plan = payload['instance']['plan']
|
775
728
|
end
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
729
|
+
|
730
|
+
if options[:default_plan] && service_plans_dropdown.find {|sp| [sp["name"], sp["value"].to_s, sp["code"]].include?(options[:default_plan].to_s)}
|
731
|
+
default_plan_value = options[:default_plan]
|
732
|
+
else
|
733
|
+
default_plan_value = options[:default_plan] || (default_plan.is_a?(Hash) ? default_plan['id'] : default_plan)
|
734
|
+
end
|
735
|
+
plan_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'servicePlan', 'type' => 'select', 'fieldLabel' => 'Plan', 'selectOptions' => service_plans_dropdown, 'required' => true, 'description' => 'Choose the appropriately sized plan for this instance', 'defaultValue' => default_plan_value}],options[:options], api_client, {}, no_prompt, true)
|
736
|
+
plan_id = plan_prompt['servicePlan']
|
737
|
+
service_plan = service_plans.find {|sp| sp["id"] == plan_id.to_i }
|
738
|
+
if !service_plan
|
739
|
+
print_red_alert "Plan not found by id #{plan_id}"
|
740
|
+
exit 1
|
785
741
|
end
|
786
|
-
|
742
|
+
end
|
743
|
+
#todo: consolidate these, instances api looks for instance.plan.id and apps looks for plan.id
|
744
|
+
if options[:for_app]
|
745
|
+
payload['plan'] = {'id' => service_plan["id"], 'code' => service_plan["code"], 'name' => service_plan["name"]}
|
746
|
+
else
|
747
|
+
payload['instance']['plan'] = {'id' => service_plan["id"], 'code' => service_plan["code"], 'name' => service_plan["name"]}
|
787
748
|
end
|
788
749
|
end
|
750
|
+
}
|
751
|
+
|
752
|
+
prompt_resource_pool = -> {
|
753
|
+
# prompt for resource pool
|
754
|
+
if locked_fields.include?('config.resourcePoolId')
|
755
|
+
pool_id = payload['config']['resourcePoolId'] rescue nil
|
756
|
+
elsif locked_fields.include?('config.resourcePool')
|
757
|
+
pool_id = payload['config']['resourcePool'] rescue nil
|
758
|
+
elsif locked_fields.include?('config.azureResourceGroupId')
|
759
|
+
pool_id = payload['config']['azureResourceGroupId'] rescue nil
|
760
|
+
else
|
761
|
+
has_zone_pools = provision_type && provision_type["id"] && provision_type["hasZonePools"]
|
762
|
+
if has_zone_pools
|
763
|
+
# pluck out the resourcePoolId option type to prompt for
|
764
|
+
resource_pool_option_type = option_type_list.find {|opt| ['resourcePool','resourcePoolId','azureResourceGroupId'].include?(opt['fieldName']) }
|
765
|
+
option_type_list = option_type_list.reject {|opt| ['resourcePool','resourcePoolId','azureResourceGroupId'].include?(opt['fieldName']) }
|
766
|
+
|
767
|
+
resource_pool_options = options_interface.options_for_source('zonePools', {groupId: group_id, siteId: group_id, zoneId: cloud_id, cloudId: cloud_id, instanceTypeId: instance_type['id'], layoutId: layout["id"]}.merge(service_plan.nil? ? {} : {planId: service_plan["id"]}))['data']
|
768
|
+
resource_pool = resource_pool_options.find {|opt| opt['id'] == options[:resource_pool].to_i} if options[:resource_pool]
|
769
|
+
|
770
|
+
if resource_pool
|
771
|
+
pool_id = resource_pool['id']
|
772
|
+
else
|
773
|
+
if options[:default_resource_pool]
|
774
|
+
default_resource_pool = resource_pool_options.find {|rp| rp['id'] == options[:default_resource_pool]}
|
775
|
+
end
|
776
|
+
resource_pool_option_type ||= {'fieldContext' => 'config', 'fieldName' => 'resourcePoolId', 'type' => 'select', 'fieldLabel' => 'Resource Pool', 'selectOptions' => resource_pool_options, 'required' => true, 'skipSingleOption' => true, 'description' => 'Select resource pool.', 'defaultValue' => default_resource_pool ? default_resource_pool['name'] : nil}
|
777
|
+
resource_pool_prompt = Morpheus::Cli::OptionTypes.prompt([resource_pool_option_type],options[:options],api_client,{}, no_prompt, true)
|
778
|
+
resource_pool_prompt.deep_compact!
|
779
|
+
payload.deep_merge!(resource_pool_prompt)
|
780
|
+
resource_pool = Morpheus::Cli::OptionTypes.get_last_select()
|
781
|
+
if resource_pool_option_type['fieldContext'] && resource_pool_prompt[resource_pool_option_type['fieldContext']]
|
782
|
+
pool_id = resource_pool_prompt[resource_pool_option_type['fieldContext']][resource_pool_option_type['fieldName']]
|
783
|
+
elsif resource_pool_prompt[resource_pool_option_type['fieldName']]
|
784
|
+
pool_id = resource_pool_prompt[resource_pool_option_type['fieldName']]
|
785
|
+
end
|
786
|
+
resource_pool ||= resource_pool_options.find {|it| it['id'] == pool_id}
|
787
|
+
end
|
788
|
+
end
|
789
|
+
end
|
790
|
+
}
|
791
|
+
|
792
|
+
prompt_provision_options = -> {
|
793
|
+
if !provision_type.nil? && !provision_type['optionTypes'].nil? && !provision_type['optionTypes'].empty?
|
794
|
+
option_type_list += provision_type['optionTypes'].reject {|it| (it['fieldGroup'] || '').downcase == 'provisiontype'}
|
795
|
+
provision_config_payload = Morpheus::Cli::OptionTypes.prompt(provision_type['optionTypes'].reject {|it| (it['fieldGroup'] || '').downcase != 'provisiontype'}, options[:options], @api_client, api_params, no_prompt, true)
|
796
|
+
payload.deep_merge!(provision_config_payload)
|
797
|
+
end
|
798
|
+
}
|
799
|
+
|
800
|
+
if ['openstack', 'huawei', 'opentelekom'].include?(cloud_type['zoneType']['code'])
|
801
|
+
prompt_resource_pool.call
|
802
|
+
prompt_provision_options.call
|
803
|
+
prompt_service_plan.call
|
804
|
+
else
|
805
|
+
prompt_service_plan.call
|
806
|
+
prompt_provision_options.call
|
807
|
+
prompt_resource_pool.call
|
789
808
|
end
|
790
809
|
|
791
810
|
# remove host selection for kubernetes
|
@@ -858,7 +877,7 @@ module Morpheus::Cli::ProvisioningHelper
|
|
858
877
|
if provision_type && provision_type["hasNetworks"]
|
859
878
|
# prompt for network interfaces (if supported)
|
860
879
|
begin
|
861
|
-
network_interfaces = prompt_network_interfaces(cloud_id, provision_type["id"], pool_id, options)
|
880
|
+
network_interfaces = prompt_network_interfaces(cloud_id, provision_type["id"], pool_id, options.merge({:api_params => payload['config']}))
|
862
881
|
if !network_interfaces.empty?
|
863
882
|
payload['networkInterfaces'] = network_interfaces
|
864
883
|
end
|
@@ -921,9 +940,9 @@ module Morpheus::Cli::ProvisioningHelper
|
|
921
940
|
end
|
922
941
|
|
923
942
|
# prompt for option types
|
924
|
-
api_params = {groupId: group_id, cloudId: cloud_id, zoneId: cloud_id, instanceTypeId: instance_type['id'], version: version_value}
|
925
943
|
api_params['config'] = payload['config'] if payload['config']
|
926
944
|
api_params['poolId'] = payload['config']['resourcePoolId'] if payload['config'] && payload['config']['resourcePoolId']
|
945
|
+
api_params['resourcePoolId'] = api_params['poolId']
|
927
946
|
|
928
947
|
# set option type defaults from config
|
929
948
|
if options[:default_config]
|
@@ -935,10 +954,21 @@ module Morpheus::Cli::ProvisioningHelper
|
|
935
954
|
end
|
936
955
|
end
|
937
956
|
|
938
|
-
|
939
|
-
|
957
|
+
option_type_list += [
|
958
|
+
{'fieldName' => 'userGroup.id', 'fieldLabel' => 'User Group', 'fieldGroup' => 'User Config', 'type' => 'select', 'optionSource' => 'userGroups', 'displayOrder' => 0, 'fieldContext' => 'instance'},
|
959
|
+
{'fieldName' => 'hostName', 'fieldLabel' => 'Hostname', 'fieldGroup' => 'Advanced', 'type' => 'string', 'displayOrder' => 1},
|
960
|
+
{'fieldName' => 'networkDomain.id', 'fieldLabel' => 'Domain', 'fieldGroup' => 'Advanced', 'type' => 'select', 'optionSource' => 'networkDomains', 'displayOrder' => 2, 'fieldContext' => 'instance'},
|
961
|
+
{'fieldName' => 'timezone', 'fieldLabel' => 'Time Zone', 'fieldGroup' => 'Advanced', 'type' => 'select', 'optionSource' => 'timezones', 'displayOrder' => 3, 'fieldContext' => 'config'}
|
962
|
+
]
|
940
963
|
|
941
|
-
|
964
|
+
if instance_type['hasAutoScale']
|
965
|
+
option_type_list += [
|
966
|
+
{'fieldName' => 'layoutSize', 'fieldLabel' => 'Scale Factor', 'fieldGroup' => 'Advanced', 'type' => 'number', 'defaultValue' => 1, 'displayOrder' => 0},
|
967
|
+
]
|
968
|
+
end
|
969
|
+
|
970
|
+
instance_config_payload = Morpheus::Cli::OptionTypes.prompt(option_type_list.reject {|ot| ot['type'] == 'exposedPorts'}, options[:options], @api_client, api_params, no_prompt, true)
|
971
|
+
payload.deep_merge!(instance_config_payload)
|
942
972
|
|
943
973
|
# prompt for exposed ports
|
944
974
|
if payload['ports'].nil?
|
@@ -950,10 +980,6 @@ module Morpheus::Cli::ProvisioningHelper
|
|
950
980
|
end
|
951
981
|
end
|
952
982
|
|
953
|
-
## Advanced Options
|
954
|
-
|
955
|
-
# scale factor
|
956
|
-
|
957
983
|
# prompt for environment variables
|
958
984
|
evars = prompt_evars(options)
|
959
985
|
if !evars.empty?
|
@@ -961,20 +987,28 @@ module Morpheus::Cli::ProvisioningHelper
|
|
961
987
|
end
|
962
988
|
|
963
989
|
# metadata tags
|
964
|
-
|
965
|
-
|
990
|
+
# metadata_tag_key = 'metadata'
|
991
|
+
metadata_tag_key = 'tags'
|
992
|
+
if !options[:metadata]
|
993
|
+
if options[:options]['metadata'].is_a?(Array)
|
994
|
+
options[:metadata] = options[:options]['metadata']
|
995
|
+
end
|
996
|
+
if options[:options]['tags'].is_a?(Array)
|
997
|
+
options[:metadata] = options[:options]['tags']
|
998
|
+
end
|
966
999
|
end
|
967
1000
|
if options[:metadata]
|
1001
|
+
metadata = []
|
968
1002
|
if options[:metadata] == "[]" || options[:metadata] == "null"
|
969
|
-
|
1003
|
+
metadata = []
|
970
1004
|
elsif options[:metadata].is_a?(Array)
|
971
|
-
|
1005
|
+
metadata = options[:metadata]
|
972
1006
|
else
|
973
1007
|
# parse string into format name:value, name:value
|
974
1008
|
# merge IDs from current metadata
|
975
1009
|
# todo: should allow quoted semicolons..
|
976
|
-
|
977
|
-
|
1010
|
+
metadata = options[:metadata].split(",").select {|it| !it.to_s.empty? }
|
1011
|
+
metadata = metadata.collect do |it|
|
978
1012
|
metadata_pair = it.split(":")
|
979
1013
|
if metadata_pair.size < 2 && it.include?("=")
|
980
1014
|
metadata_pair = it.split("=")
|
@@ -984,13 +1018,13 @@ module Morpheus::Cli::ProvisioningHelper
|
|
984
1018
|
row['value'] = metadata_pair[1].to_s.strip
|
985
1019
|
row
|
986
1020
|
end
|
987
|
-
payload['metadata'] = metadata_list
|
988
1021
|
end
|
1022
|
+
payload[metadata_tag_key] = metadata
|
989
1023
|
else
|
990
1024
|
# prompt for metadata tags
|
991
1025
|
metadata = prompt_metadata(options)
|
992
1026
|
if !metadata.empty?
|
993
|
-
payload[
|
1027
|
+
payload[metadata_tag_key] = metadata
|
994
1028
|
end
|
995
1029
|
end
|
996
1030
|
|
@@ -1486,10 +1520,11 @@ module Morpheus::Cli::ProvisioningHelper
|
|
1486
1520
|
#puts "Configure Networks:"
|
1487
1521
|
no_prompt = (options[:no_prompt] || (options[:options] && options[:options][:no_prompt]))
|
1488
1522
|
network_interfaces = []
|
1489
|
-
api_params = {zoneId: zone_id, provisionTypeId: provision_type_id}
|
1523
|
+
api_params = {zoneId: zone_id, provisionTypeId: provision_type_id}.merge(options[:api_params] || {})
|
1490
1524
|
if pool_id.to_s =~ /\A\d{1,}\Z/
|
1491
1525
|
api_params[:poolId] = pool_id
|
1492
1526
|
end
|
1527
|
+
|
1493
1528
|
zone_network_options_json = api_client.options.options_for_source('zoneNetworkOptions', api_params)
|
1494
1529
|
# puts "zoneNetworkOptions JSON"
|
1495
1530
|
# puts JSON.pretty_generate(zone_network_options_json)
|
@@ -1571,7 +1606,7 @@ module Morpheus::Cli::ProvisioningHelper
|
|
1571
1606
|
default_network_value = (network_options.find {|n| n['value'] == default_network_id} || {})['name']
|
1572
1607
|
|
1573
1608
|
# choose network
|
1574
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'networkId', 'type' => 'select', 'fieldLabel' => "Network", 'selectOptions' => network_options, 'required' => true, 'skipSingleOption' => false, 'description' => 'Choose a network for this interface.', 'defaultValue' => default_network_value}], options[:options])
|
1609
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldContext' => field_context, 'fieldName' => 'networkId', 'type' => 'select', 'fieldLabel' => "Network", 'selectOptions' => network_options, 'required' => true, 'skipSingleOption' => false, 'description' => 'Choose a network for this interface.', 'defaultValue' => default_network_value}], options[:options], api_client, {}, no_prompt, true)
|
1575
1610
|
network_interface['network'] = {}
|
1576
1611
|
network_interface['network']['id'] = v_prompt[field_context]['networkId'].to_s
|
1577
1612
|
selected_network = networks.find {|it| it["id"].to_s == network_interface['network']['id'] }
|
@@ -1711,6 +1746,19 @@ module Morpheus::Cli::ProvisioningHelper
|
|
1711
1746
|
no_prompt = (options[:no_prompt] || (options[:options] && options[:options][:no_prompt]))
|
1712
1747
|
metadata_array = []
|
1713
1748
|
metadata_index = 0
|
1749
|
+
# Keep Current Tags (foo:bar,hello:world)
|
1750
|
+
# this is used by clone()
|
1751
|
+
if options[:current_tags] && !options[:current_tags].empty?
|
1752
|
+
current_tags_string = options[:current_tags].collect { |tag| tag['name'].to_s + '=' + tag['value'].to_s }.join(', ')
|
1753
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'keepExistingTags', 'type' => 'checkbox', 'fieldLabel' => "Keep existing metadata tags (#{current_tags_string}) ?", 'required' => true, 'description' => 'Whether or not to keep existing metadata tags', 'defaultValue' => true}], options[:options])
|
1754
|
+
if ['on','true','1',''].include?(v_prompt['keepExistingTags'].to_s.downcase)
|
1755
|
+
options[:current_tags].each do |tag|
|
1756
|
+
current_tag = tag.clone
|
1757
|
+
current_tag.delete('id')
|
1758
|
+
metadata_array << current_tag
|
1759
|
+
end
|
1760
|
+
end
|
1761
|
+
end
|
1714
1762
|
has_another_metadata = options[:options] && options[:options]["metadata#{metadata_index}"]
|
1715
1763
|
add_another_metadata = has_another_metadata || (!no_prompt && Morpheus::Cli::OptionTypes.confirm("Add a metadata tag?", {default: false}))
|
1716
1764
|
while add_another_metadata do
|
@@ -2046,6 +2094,15 @@ module Morpheus::Cli::ProvisioningHelper
|
|
2046
2094
|
permissions
|
2047
2095
|
end
|
2048
2096
|
|
2097
|
+
def prompt_permissions_v2(options, excludes = [])
|
2098
|
+
perms = prompt_permissions(options, excludes)
|
2099
|
+
rtn = {}
|
2100
|
+
|
2101
|
+
rtn['visibility'] = perms['resourcePool']['visibility'] if !perms['resourcePool'].nil?
|
2102
|
+
rtn['tenants'] = ((perms['tenantPermissions'] || {})['accounts'] || []).collect {|it| {'id' => it}}
|
2103
|
+
rtn
|
2104
|
+
end
|
2105
|
+
|
2049
2106
|
def print_permissions(permissions, excludes = [])
|
2050
2107
|
if permissions.nil?
|
2051
2108
|
print_h2 "Permissions"
|