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
File without changes
|
@@ -418,6 +418,7 @@ EOT
|
|
418
418
|
"Name" => 'name',
|
419
419
|
"Description" => 'description',
|
420
420
|
"Persistent" => lambda {|it| format_boolean(it['persistentUser']) },
|
421
|
+
"Recyclable" => lambda {|it| it['recyclable'].nil? ? nil : format_boolean(it['recyclable']) },
|
421
422
|
"Enabled" => lambda {|it| format_boolean(it['enabled']) },
|
422
423
|
"Pool Usage" => lambda {|it|
|
423
424
|
# todo: [== ] 2/8 would be neat generate_usage_bar(...)
|
@@ -447,12 +448,13 @@ EOT
|
|
447
448
|
"Max Size" => lambda {|it| format_number(it['maxPoolSize']) rescue '' },
|
448
449
|
"Lease Timeout" => lambda {|it| format_number(it['allocationTimeoutMinutes']) rescue '' },
|
449
450
|
"Persistent" => lambda {|it| format_boolean(it['persistentUser']) },
|
451
|
+
"Recyclable" => lambda {|it| it['recyclable'].nil? ? nil : format_boolean(it['recyclable']) },
|
452
|
+
"Enabled" => lambda {|it| format_boolean(it['enabled']) },
|
450
453
|
"Allow Copy" => lambda {|it| format_boolean(it['allowCopy']) },
|
451
454
|
"Allow Printer" => lambda {|it| format_boolean(it['allowPrinter']) },
|
452
455
|
"Allow File Share" => lambda {|it| format_boolean(it['allowFileshare']) },
|
453
456
|
"Allow Hypervisor Console" => lambda {|it| format_boolean(it['allowHypervisorConsole']) },
|
454
457
|
"Auto Create User" => lambda {|it| format_boolean(it['autoCreateLocalUserOnReservation']) },
|
455
|
-
"Enabled" => lambda {|it| format_boolean(it['enabled']) },
|
456
458
|
"Logo" => lambda {|it| it['logo'] || it['imagePath'] },
|
457
459
|
#"Config" => lambda {|it| it['config'] },
|
458
460
|
"Group" => lambda {|it| it['group'] ? it['group']['name'] : nil },
|
@@ -484,6 +486,7 @@ EOT
|
|
484
486
|
{'fieldName' => 'maxPoolSize', 'fieldLabel' => 'Max Size', 'type' => 'number', 'required' => true, 'description' => 'Max limit on number of allocations and instances within the pool.'},
|
485
487
|
{'fieldName' => 'allocationTimeoutMinutes', 'fieldLabel' => 'Lease Timeout', 'type' => 'number', 'description' => 'Time (in minutes) after a user disconnects before an allocation is recycled or shutdown depending on persistence.'},
|
486
488
|
{'fieldName' => 'persistentUser', 'fieldLabel' => 'Persistent', 'type' => 'checkbox', 'defaultValue' => false},
|
489
|
+
{'fieldName' => 'recyclable', 'fieldLabel' => 'Recyclable', 'type' => 'checkbox', 'defaultValue' => false, 'description' => 'Recyclable VDI Pools only work with cloud types that support snapshot management (i.e. Vmware, Nutanix, VCD)'},
|
487
490
|
{'fieldName' => 'allowCopy', 'fieldLabel' => 'Allow Copy', 'type' => 'checkbox', 'defaultValue' => false},
|
488
491
|
{'fieldName' => 'allowPrinter', 'fieldLabel' => 'Allow Printer', 'type' => 'checkbox', 'defaultValue' => false},
|
489
492
|
{'fieldName' => 'allowFileshare', 'fieldLabel' => 'Allow File Share', 'type' => 'checkbox', 'defaultValue' => false},
|
File without changes
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
2
|
+
# require 'morpheus/routes'
|
3
|
+
|
4
|
+
class Morpheus::Cli::View
|
5
|
+
include Morpheus::Cli::CliCommand
|
6
|
+
|
7
|
+
set_command_description "Open the remote appliance in a web browser"
|
8
|
+
set_command_name :'view'
|
9
|
+
|
10
|
+
def connect(opts)
|
11
|
+
@api_client = establish_remote_appliance_connection(opts)
|
12
|
+
end
|
13
|
+
|
14
|
+
def handle(args)
|
15
|
+
params = {}
|
16
|
+
options = {}
|
17
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
18
|
+
opts.banner = subcommand_usage("[path] [id]")
|
19
|
+
# debate: should login using /login/ouath-redirect
|
20
|
+
opts.on('-L', '--login', "Login with the CLI access token before loading the path." ) do
|
21
|
+
options[:login] = true
|
22
|
+
end
|
23
|
+
opts.on('--absolute', "Absolute path, do not search for a matching route to use") do
|
24
|
+
options[:absolute_path] = true
|
25
|
+
end
|
26
|
+
build_common_options(opts, options, [:dry_run, :remote])
|
27
|
+
opts.footer = <<-EOT
|
28
|
+
View the remote appliance in a web browser.
|
29
|
+
[path] is optional. This the path or resource type to load. The default is the index page "/".
|
30
|
+
[id] is optional. This is the resource name or id to be append to the path to load details of a specific object.
|
31
|
+
The [path] is matched against the #{prog_name} UI site map to find the best matching route.
|
32
|
+
Route matching is skipped if the path begins with a "/" or --absolute is used.
|
33
|
+
By default no authentication is not done and the existing web browser session used.
|
34
|
+
The --login option will authenticate via the CLI access token and create a new browser session.
|
35
|
+
|
36
|
+
Examples:
|
37
|
+
view --login
|
38
|
+
view monitoring
|
39
|
+
view user 1
|
40
|
+
view user administrator
|
41
|
+
view /infrastructure/clouds/2
|
42
|
+
EOT
|
43
|
+
end
|
44
|
+
optparse.parse!(args)
|
45
|
+
# verify_args!(args:args, optparse:optparse, min: 0, max: 2)
|
46
|
+
connect(options)
|
47
|
+
# todo: it would actually be cool to use the params and include them on the path..
|
48
|
+
# params.merge!(parse_query_options(options))
|
49
|
+
path, *ids = args
|
50
|
+
# default to index page "/"
|
51
|
+
path = path || "/"
|
52
|
+
if options[:absolute_path] != true
|
53
|
+
if path.start_with?("/")
|
54
|
+
# treat like absolute path, no lookup
|
55
|
+
else
|
56
|
+
# lookup best matching route from sitemap
|
57
|
+
# lookup plural routes first, so 'app' finds apps and not approvals
|
58
|
+
found_route = Morpheus::Routes.lookup(path)
|
59
|
+
if found_route
|
60
|
+
# Morpheus::Logging::DarkPrinter.puts "Found matching route: '#{path}' => '#{found_route}'" if Morpheus::Logging.debug?
|
61
|
+
path = found_route
|
62
|
+
else
|
63
|
+
# just use specified path
|
64
|
+
end
|
65
|
+
end
|
66
|
+
# always add a leading slash
|
67
|
+
path = path.start_with?("/") ? path : "/#{path}"
|
68
|
+
# append id(s) to path if passed
|
69
|
+
if ids.size > 0
|
70
|
+
# convert names to ids
|
71
|
+
# assume the last part of path is the type and use generic finder
|
72
|
+
# only lookup names, and allow any id
|
73
|
+
ids = ids.collect do |id|
|
74
|
+
if id.to_s !~ /\A\d{1,}\Z/
|
75
|
+
# assume the last part of path is the type
|
76
|
+
record_type = path.split("/").last
|
77
|
+
record = find_by_name(record_type, id)
|
78
|
+
if record.nil?
|
79
|
+
raise_command_error("[id] is invalid. No #{record_type} found for '#{id}'", args, optparse)
|
80
|
+
end
|
81
|
+
record['id'].to_s
|
82
|
+
else
|
83
|
+
id
|
84
|
+
end
|
85
|
+
end
|
86
|
+
path = "#{path}/" + ids.join("/")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
# build the link to use, either our path or oauth-redirect to that path
|
90
|
+
link = "#{@appliance_url}#{path}"
|
91
|
+
if options[:login]
|
92
|
+
# uh, this should need CGI::escape(path)
|
93
|
+
link = "#{@appliance_url}/login/oauth-redirect?access_token=#{@access_token}\\&redirectUri=#{path}"
|
94
|
+
end
|
95
|
+
if options[:dry_run]
|
96
|
+
print_system_command_dry_run(Morpheus::Util.open_url_command(link), options)
|
97
|
+
return 0, nil
|
98
|
+
end
|
99
|
+
return Morpheus::Util.open_url(link)
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -1,7 +1,3 @@
|
|
1
|
-
# require 'yaml'
|
2
|
-
require 'io/console'
|
3
|
-
require 'rest_client'
|
4
|
-
require 'optparse'
|
5
1
|
require 'morpheus/cli/cli_command'
|
6
2
|
|
7
3
|
# JD: I don't think a lot of this has ever worked, fix it up.
|
@@ -11,8 +7,7 @@ class Morpheus::Cli::VirtualImages
|
|
11
7
|
include Morpheus::Cli::ProvisioningHelper
|
12
8
|
|
13
9
|
register_subcommands :list, :get, :add, :add_file, :remove_file, :update, :remove, :types => :virtual_image_types
|
14
|
-
|
15
|
-
set_default_subcommand :list
|
10
|
+
register_subcommands :list_locations, :get_location, :remove_location
|
16
11
|
|
17
12
|
# def initialize()
|
18
13
|
# # @appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
@@ -84,6 +79,7 @@ class Morpheus::Cli::VirtualImages
|
|
84
79
|
json_response = @virtual_images_interface.list(params)
|
85
80
|
images = json_response['virtualImages']
|
86
81
|
render_response(json_response, options, 'virtualImages') do
|
82
|
+
get_available_virtual_image_types() # preload
|
87
83
|
title = "Morpheus Virtual Images"
|
88
84
|
subtitles = parse_list_subtitles(options)
|
89
85
|
if options[:imageType]
|
@@ -188,10 +184,12 @@ EOT
|
|
188
184
|
image = json_response['virtualImage']
|
189
185
|
image_config = image['config'] || {}
|
190
186
|
image_volumes = image['volumes'] || []
|
187
|
+
image_locations = image['locations'] || []
|
191
188
|
image_files = json_response['cloudFiles'] || json_response['files']
|
192
189
|
image_type = virtual_image_type_for_name_or_code(image['imageType'])
|
193
190
|
image_type_display = image_type ? "#{image_type['name']}" : image['imageType']
|
194
191
|
render_response(json_response, options, 'virtualImage') do
|
192
|
+
get_available_virtual_image_types() # preload
|
195
193
|
print_h1 "Virtual Image Details", [], options
|
196
194
|
description_cols = {
|
197
195
|
"ID" => 'id',
|
@@ -255,7 +253,7 @@ EOT
|
|
255
253
|
# print "\n", reset
|
256
254
|
end
|
257
255
|
|
258
|
-
if image_files
|
256
|
+
if image_files && !image_files.empty?
|
259
257
|
print_h2 "Files (#{image_files.size})"
|
260
258
|
# image_files.each {|image_file|
|
261
259
|
# pretty_filesize = Filesize.from("#{image_file['size']} B").pretty
|
@@ -270,6 +268,11 @@ EOT
|
|
270
268
|
print as_pretty_table(image_file_rows, [:filename, :size])
|
271
269
|
# print reset,"\n"
|
272
270
|
end
|
271
|
+
|
272
|
+
if image_locations && !image_locations.empty?
|
273
|
+
print_h2 "Locations", options
|
274
|
+
print as_pretty_table(image_locations, virtual_image_location_list_column_definitions.upcase_keys!, options)
|
275
|
+
end
|
273
276
|
|
274
277
|
if options[:details] && image_config && !image_config.empty?
|
275
278
|
print_h2 "Config", options
|
@@ -689,7 +692,7 @@ EOT
|
|
689
692
|
image = find_virtual_image_by_name_or_id(image_name)
|
690
693
|
return 1 if image.nil?
|
691
694
|
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the virtual image filename #{filename}?")
|
692
|
-
|
695
|
+
return 9, "aborted"
|
693
696
|
end
|
694
697
|
@virtual_images_interface.setopts(options)
|
695
698
|
if options[:dry_run]
|
@@ -709,44 +712,188 @@ EOT
|
|
709
712
|
end
|
710
713
|
|
711
714
|
def remove(args)
|
715
|
+
params = {}
|
712
716
|
options = {}
|
713
717
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
714
|
-
opts.banner = subcommand_usage("[
|
715
|
-
|
718
|
+
opts.banner = subcommand_usage("[image] [location]")
|
719
|
+
opts.on('--remove-from-cloud [true|false]', String, "Remove from all clouds. Default is true.") do |val|
|
720
|
+
options[:options]['removeFromCloud'] = ['','true','on'].include?(val.to_s)
|
721
|
+
end
|
722
|
+
build_standard_remove_options(opts, options)
|
723
|
+
opts.footer = <<-EOT
|
724
|
+
Delete a virtual image.
|
725
|
+
[image] is required. This is the name or id of a virtual image.
|
726
|
+
EOT
|
716
727
|
end
|
717
728
|
optparse.parse!(args)
|
718
|
-
|
719
|
-
|
720
|
-
|
729
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
730
|
+
connect(options)
|
731
|
+
image = find_virtual_image_by_name_or_id(args[0])
|
732
|
+
return 1, "virtual image not found for '#{args[0]}'" if image.nil?
|
733
|
+
params.merge!(parse_query_options(options))
|
734
|
+
# Delete prompt
|
735
|
+
# [ X ] Remove from all clouds
|
736
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'removeFromCloud', 'fieldLabel' => 'Remove from all clouds', 'type' => 'checkbox', 'defaultValue' => true, 'required' => true, 'description' => "Remove from all clouds"}], options[:options], @api_client)
|
737
|
+
remove_from_cloud = v_prompt['removeFromCloud'].to_s == 'true' || v_prompt['removeFromCloud'].to_s == 'on'
|
738
|
+
params['removeFromCloud'] = remove_from_cloud
|
739
|
+
|
740
|
+
# Delete confirmation
|
741
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the virtual image #{image['name']}?")
|
742
|
+
return 9, "aborted"
|
743
|
+
end
|
744
|
+
|
745
|
+
@virtual_images_interface.setopts(options)
|
746
|
+
if options[:dry_run]
|
747
|
+
print_dry_run @virtual_images_interface.dry.destroy(image['id'], params)
|
748
|
+
return
|
749
|
+
end
|
750
|
+
json_response = @virtual_images_interface.destroy(image['id'], params)
|
751
|
+
render_response(json_response, options) do
|
752
|
+
print_green_success "Removed virtual image #{image['name']}"
|
753
|
+
end
|
754
|
+
return 0, nil
|
755
|
+
end
|
756
|
+
|
757
|
+
def list_locations(args)
|
758
|
+
params = {}
|
759
|
+
options = {}
|
760
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
761
|
+
opts.banner = subcommand_usage("[image]")
|
762
|
+
build_standard_list_options(opts, options)
|
763
|
+
opts.footer = <<-EOT
|
764
|
+
List virtual image locations for a specific virtual image.
|
765
|
+
[image] is required. This is the name or id of a virtual image.
|
766
|
+
EOT
|
767
|
+
end
|
768
|
+
optparse.parse!(args)
|
769
|
+
verify_args!(args:args, optparse:optparse, min:1)
|
770
|
+
if args.count > 1
|
771
|
+
options[:phrase] = args[1..-1].join(" ")
|
721
772
|
end
|
722
|
-
image_name = args[0]
|
723
773
|
connect(options)
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
774
|
+
image = find_virtual_image_by_name_or_id(args[0])
|
775
|
+
return 1, "virtual image not found for '#{args[0]}'" if image.nil?
|
776
|
+
params.merge!(parse_list_options(options))
|
777
|
+
@virtual_images_interface.setopts(options)
|
778
|
+
if options[:dry_run]
|
779
|
+
print_dry_run @virtual_images_interface.dry.list_locations(image['id'], params)
|
780
|
+
return
|
781
|
+
end
|
782
|
+
json_response = @virtual_images_interface.list_locations(image['id'], params)
|
783
|
+
records = json_response['locations']
|
784
|
+
render_response(json_response, options, 'virtualImages') do
|
785
|
+
title = "Virtual Image Locations"
|
786
|
+
subtitles = parse_list_subtitles(options)
|
787
|
+
print_h1 title, subtitles
|
788
|
+
if records.empty?
|
789
|
+
print cyan,"No virtual image locations found.",reset,"\n"
|
738
790
|
else
|
739
|
-
print
|
791
|
+
print as_pretty_table(records, virtual_image_location_list_column_definitions.upcase_keys!, options)
|
792
|
+
print_results_pagination(json_response)
|
740
793
|
end
|
741
|
-
|
742
|
-
|
743
|
-
|
794
|
+
print reset,"\n"
|
795
|
+
end
|
796
|
+
return 0, nil
|
797
|
+
end
|
798
|
+
|
799
|
+
def get_location(args)
|
800
|
+
params = {}
|
801
|
+
options = {}
|
802
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
803
|
+
opts.banner = subcommand_usage("[image] [location]")
|
804
|
+
build_standard_remove_options(opts, options)
|
805
|
+
opts.footer = <<-EOT
|
806
|
+
Get details about a virtual image location.
|
807
|
+
[image] is required. This is the name or id of a virtual image.
|
808
|
+
[location] is required. This is the name or id of a virtual image location.
|
809
|
+
EOT
|
744
810
|
end
|
811
|
+
optparse.parse!(args)
|
812
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
813
|
+
connect(options)
|
814
|
+
image = find_virtual_image_by_name_or_id(args[0])
|
815
|
+
return 1, "virtual image not found for '#{args[0]}'" if image.nil?
|
816
|
+
location = find_virtual_image_location_by_name_or_id(image['id'], args[1])
|
817
|
+
return 1, "location not found for '#{args[1]}'" if location.nil?
|
818
|
+
params.merge!(parse_query_options(options))
|
819
|
+
@virtual_images_interface.setopts(options)
|
820
|
+
if options[:dry_run]
|
821
|
+
print_dry_run @virtual_images_interface.dry.get_location(image['id'], location['id'])
|
822
|
+
return 0, nil
|
823
|
+
end
|
824
|
+
# json_response = @virtual_images_interface.get(image['id'], location['id'])
|
825
|
+
json_response = {'location' => location} # skip redundant request
|
826
|
+
render_response(json_response, options, 'location') do
|
827
|
+
location = json_response['location']
|
828
|
+
volumes = location['volumes'] || []
|
829
|
+
print_h1 "Virtual Image Location Details", [], options
|
830
|
+
print_description_list(virtual_image_location_column_definitions, location, options)
|
831
|
+
if volumes && !volumes.empty?
|
832
|
+
print_h2 "Volumes", options
|
833
|
+
volume_rows = location_volumes.collect do |volume|
|
834
|
+
{name: volume['name'], size: Filesize.from("#{volume['rawSize']} B").pretty}
|
835
|
+
end
|
836
|
+
print cyan
|
837
|
+
print as_pretty_table(volume_rows, [:name, :size], options)
|
838
|
+
print cyan
|
839
|
+
# print "\n", reset
|
840
|
+
end
|
841
|
+
print reset,"\n"
|
842
|
+
end
|
843
|
+
return 0, nil
|
745
844
|
end
|
746
845
|
|
846
|
+
def remove_location(args)
|
847
|
+
params = {}
|
848
|
+
options = {}
|
849
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
850
|
+
opts.banner = subcommand_usage("[image] [location]")
|
851
|
+
opts.on('--remove-from-cloud [true|false]', String, "Remove from cloud. Default is true.") do |val|
|
852
|
+
options[:options]['removeFromCloud'] = ['','true','on'].include?(val.to_s)
|
853
|
+
end
|
854
|
+
build_standard_remove_options(opts, options)
|
855
|
+
opts.footer = <<-EOT
|
856
|
+
Delete a virtual image location.
|
857
|
+
[image] is required. This is the name or id of a virtual image.
|
858
|
+
[location] is required. This is the name or id of a virtual image location.
|
859
|
+
EOT
|
860
|
+
end
|
861
|
+
optparse.parse!(args)
|
862
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
863
|
+
connect(options)
|
864
|
+
image = find_virtual_image_by_name_or_id(args[0])
|
865
|
+
return 1, "virtual image not found for '#{args[0]}'" if image.nil?
|
866
|
+
location = find_virtual_image_location_by_name_or_id(image['id'], args[1])
|
867
|
+
return 1, "location not found for '#{args[1]}'" if location.nil?
|
868
|
+
|
869
|
+
params.merge!(parse_query_options(options))
|
870
|
+
|
871
|
+
# Delete prompt
|
872
|
+
# [ X ] Remove from cloud
|
873
|
+
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'removeFromCloud', 'fieldLabel' => 'Remove from cloud', 'type' => 'checkbox', 'defaultValue' => true, 'required' => true, 'description' => "Remove from cloud"}], options[:options], @api_client)
|
874
|
+
remove_from_cloud = v_prompt['removeFromCloud'].to_s == 'true' || v_prompt['removeFromCloud'].to_s == 'on'
|
875
|
+
params['removeFromCloud'] = remove_from_cloud
|
876
|
+
|
877
|
+
# Delete confirmation
|
878
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the virtual image location #{location['id']}?")
|
879
|
+
return 9, "aborted"
|
880
|
+
end
|
881
|
+
|
882
|
+
@virtual_images_interface.setopts(options)
|
883
|
+
if options[:dry_run]
|
884
|
+
print_dry_run @virtual_images_interface.dry.destroy_location(image['id'], location['id'], params)
|
885
|
+
return
|
886
|
+
end
|
887
|
+
json_response = @virtual_images_interface.destroy_location(image['id'], location['id'], params)
|
888
|
+
render_response(json_response, options) do
|
889
|
+
print_green_success "Removed virtual image location #{location['id']}"
|
890
|
+
end
|
891
|
+
return 0, nil
|
892
|
+
end
|
747
893
|
|
748
894
|
private
|
749
|
-
|
895
|
+
|
896
|
+
def find_virtual_image_by_name_or_id(val)
|
750
897
|
if val.to_s =~ /\A\d{1,}\Z/
|
751
898
|
return find_virtual_image_by_id(val)
|
752
899
|
else
|
@@ -911,4 +1058,75 @@ EOT
|
|
911
1058
|
out
|
912
1059
|
end
|
913
1060
|
|
1061
|
+
|
1062
|
+
## Virtual Image Locations
|
1063
|
+
|
1064
|
+
def virtual_image_location_object_key
|
1065
|
+
"location"
|
1066
|
+
end
|
1067
|
+
|
1068
|
+
def virtual_image_location_list_key
|
1069
|
+
"locations"
|
1070
|
+
end
|
1071
|
+
|
1072
|
+
def find_virtual_image_location_by_name_or_id(virtual_image_id, val)
|
1073
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
1074
|
+
return find_virtual_image_location_by_id(virtual_image_id, val)
|
1075
|
+
else
|
1076
|
+
return find_virtual_image_location_by_name(virtual_image_id, val)
|
1077
|
+
end
|
1078
|
+
end
|
1079
|
+
|
1080
|
+
def virtual_image_location_list_column_definitions
|
1081
|
+
virtual_image_location_column_definitions
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
def virtual_image_location_column_definitions
|
1085
|
+
{
|
1086
|
+
"ID" => 'id',
|
1087
|
+
"Name" => 'imageName',
|
1088
|
+
"Cloud" => lambda {|it| it['cloud']['name'] rescue '' },
|
1089
|
+
"Public" => lambda {|it| format_boolean(it['isPublic']) },
|
1090
|
+
"Region" => lambda {|it| it['imageRegion'] },
|
1091
|
+
"External ID" => lambda {|it| it['externalId'] },
|
1092
|
+
"Price Plan" => lambda {|it| it['pricePlan'] ? it['pricePlan']['name'] : nil },
|
1093
|
+
# "Virtual Image" => lambda {|it| it['virtualImage']['name'] rescue '' },
|
1094
|
+
# "Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
1095
|
+
# "Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
1096
|
+
}
|
1097
|
+
end
|
1098
|
+
|
1099
|
+
|
1100
|
+
def find_virtual_image_location_by_id(virtual_image_id, id)
|
1101
|
+
begin
|
1102
|
+
json_response = @virtual_images_interface.get_location(virtual_image_id, id.to_i)
|
1103
|
+
return json_response[virtual_image_location_object_key]
|
1104
|
+
rescue RestClient::Exception => e
|
1105
|
+
if e.response && e.response.code == 404
|
1106
|
+
print_red_alert "Virtual Image Location not found by id '#{id}'"
|
1107
|
+
else
|
1108
|
+
raise e
|
1109
|
+
end
|
1110
|
+
end
|
1111
|
+
end
|
1112
|
+
|
1113
|
+
def find_virtual_image_location_by_name(virtual_image_id, name)
|
1114
|
+
json_response = @virtual_images_interface.list_locations(virtual_image_id, {imageName: name.to_s})
|
1115
|
+
virtual_image_locations = json_response[virtual_image_location_list_key]
|
1116
|
+
if virtual_image_locations.empty?
|
1117
|
+
print_red_alert "Virtual Image Location not found by name '#{name}'"
|
1118
|
+
return nil
|
1119
|
+
elsif virtual_image_locations.size > 1
|
1120
|
+
print_red_alert "#{virtual_image_locations.size} Virtual Image Locations found by name '#{name}'"
|
1121
|
+
print_error "\n"
|
1122
|
+
puts_error as_pretty_table(virtual_image_locations, {"ID" => 'id', "NAME" => 'imageName'}, {color:red})
|
1123
|
+
print_red_alert "Try using ID instead"
|
1124
|
+
print_error reset,"\n"
|
1125
|
+
return nil
|
1126
|
+
else
|
1127
|
+
return virtual_image_locations[0]
|
1128
|
+
end
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
|
914
1132
|
end
|
@@ -15,10 +15,10 @@ module Morpheus::Cli::AccountsHelper
|
|
15
15
|
@accounts_interface
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def account_users_interface
|
19
19
|
# @api_client.users
|
20
|
-
raise "#{self.class} has not defined @
|
21
|
-
@
|
20
|
+
raise "#{self.class} has not defined @account_users_interface" if @account_users_interface.nil?
|
21
|
+
@account_users_interface
|
22
22
|
end
|
23
23
|
|
24
24
|
def user_groups_interface
|
@@ -244,7 +244,7 @@ module Morpheus::Cli::AccountsHelper
|
|
244
244
|
|
245
245
|
def find_user_by_id(account_id, id, params={})
|
246
246
|
begin
|
247
|
-
json_response =
|
247
|
+
json_response = account_users_interface.get(account_id, id.to_i, params)
|
248
248
|
return json_response['user']
|
249
249
|
rescue RestClient::Exception => e
|
250
250
|
if e.response && e.response.code == 404
|
@@ -256,7 +256,7 @@ module Morpheus::Cli::AccountsHelper
|
|
256
256
|
end
|
257
257
|
|
258
258
|
def find_user_by_username(account_id, username, params={})
|
259
|
-
users =
|
259
|
+
users = account_users_interface.list(account_id, params.merge({username: username.to_s}))['users']
|
260
260
|
if users.empty?
|
261
261
|
print_red_alert "User not found by username #{username}"
|
262
262
|
return nil
|
@@ -34,7 +34,7 @@ module Morpheus::Cli::LoadBalancersHelper
|
|
34
34
|
'Load Balancer'
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def load_balancer_label_plural
|
38
38
|
'Load Balancers'
|
39
39
|
end
|
40
40
|
|
@@ -50,7 +50,7 @@ module Morpheus::Cli::LoadBalancersHelper
|
|
50
50
|
'Load Balancer Type'
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
53
|
+
def load_balancer_type_label_plural
|
54
54
|
'Load Balancer Types'
|
55
55
|
end
|
56
56
|
|
@@ -105,12 +105,32 @@ module Morpheus::Cli::LoadBalancersHelper
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
def load_balancer_type_for_id(
|
109
|
-
|
108
|
+
def load_balancer_type_for_id(val)
|
109
|
+
record = get_available_load_balancer_types().find { |z| z['id'].to_i == val.to_i}
|
110
|
+
label = "Load Balancer Type"
|
111
|
+
if record.nil?
|
112
|
+
print_red_alert "#{label.downcase} not found by id #{val}"
|
113
|
+
return nil
|
114
|
+
end
|
115
|
+
return record
|
110
116
|
end
|
111
117
|
|
112
|
-
def load_balancer_type_for_name(
|
113
|
-
|
118
|
+
def load_balancer_type_for_name(val)
|
119
|
+
records = get_available_load_balancer_types().select { |z| z['name'].downcase == val.downcase || z['code'].downcase == val.downcase}
|
120
|
+
label = "Load Balancer Type"
|
121
|
+
if records.empty?
|
122
|
+
print_red_alert "#{label} not found by name '#{val}'"
|
123
|
+
return nil
|
124
|
+
elsif records.size > 1
|
125
|
+
print_red_alert "More than one #{label.downcase} found by name '#{val}'"
|
126
|
+
print_error "\n"
|
127
|
+
puts_error as_pretty_table(records, [:id, :name], {color:red})
|
128
|
+
print_red_alert "Try using ID instead"
|
129
|
+
print_error reset,"\n"
|
130
|
+
return nil
|
131
|
+
else
|
132
|
+
return records[0]
|
133
|
+
end
|
114
134
|
end
|
115
135
|
|
116
136
|
def find_load_balancer_type_by_name_or_id(val)
|