morpheus-cli 5.3.4 → 5.4.3
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 +69 -11
- data/lib/morpheus/api/audit_interface.rb +9 -0
- data/lib/morpheus/api/catalog_item_types_interface.rb +20 -0
- data/lib/morpheus/api/health_interface.rb +37 -3
- data/lib/morpheus/api/instances_interface.rb +49 -0
- data/lib/morpheus/api/load_balancer_monitors_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +4 -5
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +13 -4
- 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 +9 -0
- data/lib/morpheus/api/network_servers_interface.rb +68 -12
- data/lib/morpheus/api/network_static_routes_interface.rb +36 -0
- data/lib/morpheus/api/ping_interface.rb +2 -0
- data/lib/morpheus/api/read_interface.rb +4 -3
- data/lib/morpheus/api/rest_interface.rb +3 -3
- 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/setup_interface.rb +4 -0
- data/lib/morpheus/api/snapshots_interface.rb +19 -0
- 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/cli/cli_command.rb +260 -13
- 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} +88 -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} +0 -4
- data/lib/morpheus/cli/{clouds.rb → commands/clouds.rb} +0 -7
- data/lib/morpheus/cli/{clusters.rb → commands/clusters.rb} +96 -64
- 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} +27 -24
- 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} +359 -7
- data/lib/morpheus/cli/{integrations_command.rb → commands/integrations_command.rb} +1 -12
- data/lib/morpheus/cli/{invoices_command.rb → commands/invoices_command.rb} +1 -1
- 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} +3 -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} +0 -4
- 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/{load_balancer_virtual_servers.rb → commands/load_balancer_virtual_servers.rb} +69 -58
- 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} +96 -50
- 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 +451 -0
- data/lib/morpheus/cli/{network_scopes_command.rb → commands/network_transport_zones_command.rb} +102 -92
- 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} +3 -12
- data/lib/morpheus/cli/{policies_command.rb → commands/policies_command.rb} +2 -9
- 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} +1 -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} +21 -19
- 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} +2 -8
- 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} +1 -1
- 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} +1 -1
- 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/snapshots.rb +139 -0
- 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} +0 -4
- data/lib/morpheus/cli/{tasks.rb → commands/tasks.rb} +5 -9
- 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} +3 -2
- 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} +4 -5
- 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 +24 -4
- 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 +96 -6
- data/lib/morpheus/cli/mixins/rest_command.rb +222 -62
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +249 -70
- 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 +150 -46
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +5 -135
- 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 +174 -144
- data/lib/morpheus/cli/change_password_command.rb +0 -147
- data/lib/morpheus/cli/library.rb +0 -1
- data/lib/morpheus/cli/load_balancer_pools.rb +0 -111
- data/lib/morpheus/cli/load_balancers.rb +0 -90
- data/lib/morpheus/cli/logout.rb +0 -81
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class Morpheus::Cli::LoadBalancerPools
|
|
4
|
+
include Morpheus::Cli::CliCommand
|
|
5
|
+
include Morpheus::Cli::RestCommand
|
|
6
|
+
include Morpheus::Cli::SecondaryRestCommand
|
|
7
|
+
include Morpheus::Cli::LoadBalancersHelper
|
|
8
|
+
|
|
9
|
+
set_command_description "View and manage load balancer pools."
|
|
10
|
+
set_command_name :'load-balancer-pools'
|
|
11
|
+
register_subcommands :list, :get, :add, :update, :remove
|
|
12
|
+
register_interfaces :load_balancer_pools,
|
|
13
|
+
:load_balancers, :load_balancer_types
|
|
14
|
+
|
|
15
|
+
set_rest_parent_name :load_balancers
|
|
16
|
+
|
|
17
|
+
# set_rest_interface_name :load_balancer_pools
|
|
18
|
+
# set_parent_rest_interface_name :load_balancers
|
|
19
|
+
|
|
20
|
+
# todo: a configurable way to load the optionTypes
|
|
21
|
+
# option_types = loadBalancer['poolOptionTypes']
|
|
22
|
+
# set_rest_has_type true
|
|
23
|
+
# set_rest_type :load_balancer_virtual_server_types
|
|
24
|
+
|
|
25
|
+
protected
|
|
26
|
+
|
|
27
|
+
def load_balancer_pool_list_column_definitions(options)
|
|
28
|
+
{
|
|
29
|
+
"ID" => 'id',
|
|
30
|
+
"Name" => 'name',
|
|
31
|
+
#"Load Balancer" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
|
32
|
+
"Balancer Mode" => lambda {|it| it['vipBalance'] },
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def load_balancer_pool_column_definitions(options)
|
|
37
|
+
{
|
|
38
|
+
"ID" => 'id',
|
|
39
|
+
"Name" => 'name',
|
|
40
|
+
"Load Balancer" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
|
41
|
+
"Description" => 'description',
|
|
42
|
+
"Balancer Mode" => lambda {|it| it['vipBalance'] },
|
|
43
|
+
# todo: more properties to show here
|
|
44
|
+
"Status" => lambda {|it| format_load_balancer_pool_status(it) },
|
|
45
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
46
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
|
47
|
+
}
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def load_balancer_pool_object_key
|
|
51
|
+
'loadBalancerPool'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def load_balancer_pool_list_key
|
|
55
|
+
'loadBalancerPools'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def load_balancer_pool_label
|
|
59
|
+
'Load Balancer Pool'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def load_balancer_pool_label_plural
|
|
63
|
+
'Load Balancer Pools'
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def format_load_balancer_pool_status(record, return_color=cyan)
|
|
67
|
+
out = ""
|
|
68
|
+
status_string = record['status']
|
|
69
|
+
if status_string.nil? || status_string.empty? || status_string == "unknown"
|
|
70
|
+
out << "#{white}UNKNOWN#{return_color}"
|
|
71
|
+
elsif status_string == 'ok'
|
|
72
|
+
out << "#{green}#{status_string.upcase}#{return_color}"
|
|
73
|
+
elsif status_string == 'syncing'
|
|
74
|
+
out << "#{yellow}#{status_string.upcase}#{return_color}"
|
|
75
|
+
else
|
|
76
|
+
out << "#{red}#{status_string ? status_string.upcase : 'N/A'}#{record['statusMessage'] ? "#{return_color} - #{record['statusMessage']}" : ''}#{return_color}"
|
|
77
|
+
end
|
|
78
|
+
out
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def load_option_types_for_load_balancer_pool(type_record, parent_record)
|
|
82
|
+
load_balancer = parent_record
|
|
83
|
+
load_balancer_type_id = load_balancer['type']['id']
|
|
84
|
+
load_balancer_type = find_by_id(:load_balancer_type, load_balancer_type_id)
|
|
85
|
+
load_balancer_type['poolOptionTypes']
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
## using CliCommand's generic find_by methods
|
|
89
|
+
|
|
90
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class Morpheus::Cli::LoadBalancerProfiles
|
|
4
|
+
include Morpheus::Cli::CliCommand
|
|
5
|
+
include Morpheus::Cli::RestCommand
|
|
6
|
+
include Morpheus::Cli::SecondaryRestCommand
|
|
7
|
+
include Morpheus::Cli::LoadBalancersHelper
|
|
8
|
+
|
|
9
|
+
set_command_description "View and manage load balancer profiles."
|
|
10
|
+
set_command_name :'load-balancer-profiles'
|
|
11
|
+
register_subcommands :list, :get, :add, :update, :remove
|
|
12
|
+
register_interfaces :load_balancer_profiles,
|
|
13
|
+
:load_balancers, :load_balancer_types
|
|
14
|
+
|
|
15
|
+
set_rest_parent_name :load_balancers
|
|
16
|
+
|
|
17
|
+
protected
|
|
18
|
+
|
|
19
|
+
def load_balancer_profile_list_column_definitions(options)
|
|
20
|
+
{
|
|
21
|
+
"ID" => 'id',
|
|
22
|
+
"Name" => 'name',
|
|
23
|
+
# "Profile Type" => lambda {|it| it['config']['profileType'] rescue '' },
|
|
24
|
+
"Service Type" => lambda {|it| it['serviceTypeDisplay'] || it['serviceType'] },
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def load_balancer_profile_column_definitions(options)
|
|
29
|
+
{
|
|
30
|
+
"ID" => 'id',
|
|
31
|
+
"Name" => 'name',
|
|
32
|
+
"Load Balancer" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
|
33
|
+
"Description" => 'description',
|
|
34
|
+
# "Profile Type" => lambda {|it| it['config']['profileType'] rescue '' },
|
|
35
|
+
"Service Type" => lambda {|it| it['serviceTypeDisplay'] || it['serviceType'] },
|
|
36
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
37
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def load_balancer_profile_object_key
|
|
42
|
+
'loadBalancerProfile'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def load_balancer_profile_list_key
|
|
46
|
+
'loadBalancerProfiles'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def load_balancer_profile_label
|
|
50
|
+
'Load Balancer Profile'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def load_balancer_profile_label_plural
|
|
54
|
+
'Load Balancer Profiles'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def load_option_types_for_load_balancer_profile(type_record, parent_record)
|
|
58
|
+
load_balancer = parent_record
|
|
59
|
+
load_balancer_type_id = load_balancer['type']['id']
|
|
60
|
+
load_balancer_type = find_by_id(:load_balancer_type, load_balancer_type_id)
|
|
61
|
+
load_balancer_type['profileOptionTypes']
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
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
|
class Morpheus::Cli::LoadBalancerTypes
|
|
@@ -16,16 +12,21 @@ class Morpheus::Cli::LoadBalancerTypes
|
|
|
16
12
|
|
|
17
13
|
protected
|
|
18
14
|
|
|
19
|
-
def
|
|
15
|
+
def load_balancer_type_list_column_definitions(options)
|
|
20
16
|
{
|
|
21
17
|
"ID" => 'id',
|
|
22
18
|
"Name" => 'name',
|
|
23
|
-
"Code" => 'code'
|
|
19
|
+
"Code" => 'code',
|
|
24
20
|
}
|
|
25
21
|
end
|
|
26
22
|
|
|
27
|
-
def
|
|
28
|
-
|
|
23
|
+
def load_balancer_type_column_definitions(options)
|
|
24
|
+
{
|
|
25
|
+
"ID" => 'id',
|
|
26
|
+
"Name" => 'name',
|
|
27
|
+
"Code" => 'code',
|
|
28
|
+
"Creatable" => lambda {|it| format_boolean(it['creatable']) },
|
|
29
|
+
}
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
# overridden to support name or code
|
data/lib/morpheus/cli/{load_balancer_virtual_servers.rb → commands/load_balancer_virtual_servers.rb}
RENAMED
|
@@ -3,31 +3,73 @@ require 'morpheus/cli/cli_command'
|
|
|
3
3
|
class Morpheus::Cli::LoadBalancerVirtualServers
|
|
4
4
|
include Morpheus::Cli::CliCommand
|
|
5
5
|
include Morpheus::Cli::RestCommand
|
|
6
|
-
|
|
6
|
+
include Morpheus::Cli::SecondaryRestCommand
|
|
7
7
|
include Morpheus::Cli::LoadBalancersHelper
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
set_command_description "View and manage load balancer virtual servers."
|
|
10
10
|
set_command_name :'load-balancer-virtual-servers'
|
|
11
11
|
register_subcommands :list, :get, :add, :update, :remove
|
|
12
|
-
|
|
13
12
|
register_interfaces :load_balancer_virtual_servers,
|
|
14
13
|
:load_balancers, :load_balancer_types
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# set_rest_interface_name :load_balancer_virtual_servers
|
|
19
|
-
# set_parent_rest_interface_name :load_balancers
|
|
20
|
-
|
|
21
|
-
# todo: a configurable way to load the optionTypes
|
|
22
|
-
# option_types = loadBalancer['vipOptionTypes']
|
|
23
|
-
# set_rest_has_type true
|
|
24
|
-
# set_rest_type :load_balancer_virtual_server_types
|
|
25
|
-
|
|
15
|
+
set_rest_parent_name :load_balancers
|
|
26
16
|
set_rest_arg 'vipName'
|
|
27
17
|
|
|
18
|
+
# overridden to provide global list functionality without requiring parent argument
|
|
19
|
+
=begin
|
|
20
|
+
def list(args)
|
|
21
|
+
parent_id, parent_record = nil, nil
|
|
22
|
+
params = {}
|
|
23
|
+
options = {}
|
|
24
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
25
|
+
opts.banner = subcommand_usage("[#{rest_parent_arg}] [search]")
|
|
26
|
+
build_list_options(opts, options, params)
|
|
27
|
+
opts.footer = <<-EOT
|
|
28
|
+
List #{rest_label_plural.downcase}.
|
|
29
|
+
[#{rest_parent_arg}] is optional. This is the #{rest_parent_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_parent_label)} #{rest_parent_label.downcase}.
|
|
30
|
+
[search] is optional. This is a search phrase to filter the results.
|
|
31
|
+
EOT
|
|
32
|
+
end
|
|
33
|
+
optparse.parse!(args)
|
|
34
|
+
parent_id = args[0]
|
|
35
|
+
connect(options)
|
|
36
|
+
if parent_id
|
|
37
|
+
args = args[1..-1]
|
|
38
|
+
parent_record = rest_parent_find_by_name_or_id(parent_id)
|
|
39
|
+
if parent_record.nil?
|
|
40
|
+
return 1, "#{rest_parent_label} not found for '#{parent_id}"
|
|
41
|
+
end
|
|
42
|
+
parent_id = parent_record['id']
|
|
43
|
+
end
|
|
44
|
+
parse_list_options!(args, options, params)
|
|
45
|
+
rest_interface.setopts(options)
|
|
46
|
+
if options[:dry_run]
|
|
47
|
+
print_dry_run rest_interface.dry.list(parent_id, params)
|
|
48
|
+
return
|
|
49
|
+
end
|
|
50
|
+
json_response = rest_interface.list(parent_id, params)
|
|
51
|
+
render_response(json_response, options, rest_list_key) do
|
|
52
|
+
records = json_response[rest_list_key]
|
|
53
|
+
print_h1 "Morpheus #{rest_label_plural}"
|
|
54
|
+
if records.nil? || records.empty?
|
|
55
|
+
print cyan,"No #{rest_label_plural.downcase} found.",reset,"\n"
|
|
56
|
+
else
|
|
57
|
+
print as_pretty_table(records, rest_list_column_definitions(options).upcase_keys!, options)
|
|
58
|
+
print_results_pagination(json_response) if json_response['meta']
|
|
59
|
+
end
|
|
60
|
+
print reset,"\n"
|
|
61
|
+
end
|
|
62
|
+
return 0, nil
|
|
63
|
+
end
|
|
64
|
+
=end
|
|
28
65
|
protected
|
|
29
66
|
|
|
30
|
-
def
|
|
67
|
+
def parse_list_options!(args, options, params)
|
|
68
|
+
parse_parameter_as_resource_id!(:load_balancer, options, params)
|
|
69
|
+
super
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def load_balancer_virtual_server_list_column_definitions(options)
|
|
31
73
|
{
|
|
32
74
|
"ID" => 'id',
|
|
33
75
|
"Name" => 'vipName',
|
|
@@ -43,7 +85,7 @@ class Morpheus::Cli::LoadBalancerVirtualServers
|
|
|
43
85
|
}
|
|
44
86
|
end
|
|
45
87
|
|
|
46
|
-
def load_balancer_virtual_server_column_definitions()
|
|
88
|
+
def load_balancer_virtual_server_column_definitions(options)
|
|
47
89
|
{
|
|
48
90
|
"ID" => 'id',
|
|
49
91
|
"Name" => 'vipName',
|
|
@@ -63,11 +105,11 @@ class Morpheus::Cli::LoadBalancerVirtualServers
|
|
|
63
105
|
end
|
|
64
106
|
|
|
65
107
|
def load_balancer_virtual_server_object_key
|
|
66
|
-
'
|
|
108
|
+
'loadBalancerInstance'
|
|
67
109
|
end
|
|
68
110
|
|
|
69
111
|
def load_balancer_virtual_server_list_key
|
|
70
|
-
'
|
|
112
|
+
'loadBalancerInstances'
|
|
71
113
|
end
|
|
72
114
|
|
|
73
115
|
def load_balancer_virtual_server_label
|
|
@@ -78,52 +120,12 @@ class Morpheus::Cli::LoadBalancerVirtualServers
|
|
|
78
120
|
'Virtual Servers'
|
|
79
121
|
end
|
|
80
122
|
|
|
81
|
-
def find_load_balancer_virtual_server_by_name_or_id(val)
|
|
82
|
-
if val.to_s =~ /\A\d{1,}\Z/
|
|
83
|
-
return find_load_balancer_virtual_server_by_id(val)
|
|
84
|
-
else
|
|
85
|
-
return find_load_balancer_virtual_server_by_name(val)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def find_load_balancer_virtual_server_by_id(id)
|
|
90
|
-
begin
|
|
91
|
-
json_response = load_balancer_virtual_servers_interface.get(id.to_i)
|
|
92
|
-
return json_response[load_balancer_virtual_server_object_key]
|
|
93
|
-
rescue RestClient::Exception => e
|
|
94
|
-
if e.response && e.response.code == 404
|
|
95
|
-
print_red_alert "#{load_balancer_virtual_server_label} not found by id #{id}"
|
|
96
|
-
return nil
|
|
97
|
-
else
|
|
98
|
-
raise e
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def find_load_balancer_virtual_server_by_name(name)
|
|
104
|
-
json_response = load_balancer_virtual_servers_interface.list({name: name.to_s})
|
|
105
|
-
load_balancer_virtual_servers = json_response[load_balancer_virtual_server_list_key]
|
|
106
|
-
if load_balancer_virtual_servers.empty?
|
|
107
|
-
print_red_alert "#{load_balancer_virtual_server_label_plural} not found by name #{name}"
|
|
108
|
-
return load_balancer_virtual_servers
|
|
109
|
-
elsif load_balancer_virtual_servers.size > 1
|
|
110
|
-
print_red_alert "#{load_balancer_virtual_servers.size} #{load_balancer_virtual_server_label_plural.downcase} found by name #{name}"
|
|
111
|
-
rows = load_balancer_virtual_servers.collect do |it|
|
|
112
|
-
{id: it['id'], name: it['name']}
|
|
113
|
-
end
|
|
114
|
-
puts as_pretty_table(rows, [:id, :name], {color:red})
|
|
115
|
-
return nil
|
|
116
|
-
else
|
|
117
|
-
return load_balancer_virtual_servers[0]
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
123
|
def format_virtual_server_status(virtual_server, return_color=cyan)
|
|
122
124
|
out = ""
|
|
123
125
|
status_string = virtual_server['vipStatus'] || virtual_server['status']
|
|
124
126
|
if status_string.nil? || status_string.empty? || status_string == "unknown"
|
|
125
127
|
out << "#{white}UNKNOWN#{return_color}"
|
|
126
|
-
elsif status_string == '
|
|
128
|
+
elsif status_string == 'online'
|
|
127
129
|
out << "#{green}#{status_string.upcase}#{return_color}"
|
|
128
130
|
elsif status_string == 'syncing'
|
|
129
131
|
out << "#{yellow}#{status_string.upcase}#{return_color}"
|
|
@@ -133,4 +135,13 @@ class Morpheus::Cli::LoadBalancerVirtualServers
|
|
|
133
135
|
out
|
|
134
136
|
end
|
|
135
137
|
|
|
138
|
+
def load_option_types_for_load_balancer_virtual_server(type_record, parent_record)
|
|
139
|
+
load_balancer = parent_record
|
|
140
|
+
load_balancer_type_id = load_balancer['type']['id']
|
|
141
|
+
load_balancer_type = find_by_id(:load_balancer_type, load_balancer_type_id)
|
|
142
|
+
load_balancer_type['vipOptionTypes']
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
## using CliCommand's generic find_by methods
|
|
146
|
+
|
|
136
147
|
end
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class Morpheus::Cli::LoadBalancers
|
|
4
|
+
include Morpheus::Cli::CliCommand
|
|
5
|
+
include Morpheus::Cli::RestCommand
|
|
6
|
+
include Morpheus::Cli::LoadBalancersHelper
|
|
7
|
+
|
|
8
|
+
set_command_description "View and manage load balancers."
|
|
9
|
+
set_command_name :'load-balancers'
|
|
10
|
+
register_subcommands :list, :get, :add, :update, :remove, :refresh
|
|
11
|
+
|
|
12
|
+
# deprecated the `load-balancers types` command in 5.3.2, it moved to `load-balancer-types list`
|
|
13
|
+
register_subcommands :types
|
|
14
|
+
set_subcommands_hidden :types
|
|
15
|
+
|
|
16
|
+
# RestCommand settings
|
|
17
|
+
register_interfaces :load_balancers, :load_balancer_types
|
|
18
|
+
set_rest_has_type true
|
|
19
|
+
# set_rest_type :load_balancer_types
|
|
20
|
+
|
|
21
|
+
def render_response_for_get(json_response, options)
|
|
22
|
+
render_response(json_response, options, rest_object_key) do
|
|
23
|
+
record = json_response[rest_object_key]
|
|
24
|
+
print_h1 rest_label, [], options
|
|
25
|
+
print cyan
|
|
26
|
+
print_description_list(rest_column_definitions(options), record, options)
|
|
27
|
+
# show LB Ports
|
|
28
|
+
ports = record['ports']
|
|
29
|
+
if ports && ports.size > 0
|
|
30
|
+
print_h2 "LB Ports", options
|
|
31
|
+
columns = [
|
|
32
|
+
{"ID" => 'id'},
|
|
33
|
+
{"Name" => 'name'},
|
|
34
|
+
#{"Description" => 'description'},
|
|
35
|
+
{"Port" => lambda {|it| it['port'] } },
|
|
36
|
+
{"Protocol" => lambda {|it| it['proxyProtocol'] } },
|
|
37
|
+
{"SSL" => lambda {|it| it['sslEnabled'] ? "Yes (#{it['sslCert'] ? it['sslCert']['name'] : 'none'})" : "No" } },
|
|
38
|
+
]
|
|
39
|
+
print as_pretty_table(ports, columns, options)
|
|
40
|
+
end
|
|
41
|
+
print reset,"\n"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def refresh(args)
|
|
46
|
+
id = args[0]
|
|
47
|
+
record_type = nil
|
|
48
|
+
record_type_id = nil
|
|
49
|
+
options = {}
|
|
50
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
51
|
+
opts.banner = subcommand_usage("[#{rest_arg}] [options]")
|
|
52
|
+
build_standard_update_options(opts, options)
|
|
53
|
+
opts.footer = <<-EOT
|
|
54
|
+
Refresh an existing #{rest_label.downcase}.
|
|
55
|
+
[#{rest_arg}] is required. This is the #{rest_has_name ? 'name or id' : 'id'} of #{a_or_an(rest_label)} #{rest_label.downcase}.
|
|
56
|
+
EOT
|
|
57
|
+
end
|
|
58
|
+
optparse.parse!(args)
|
|
59
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
60
|
+
connect(options)
|
|
61
|
+
record = rest_find_by_name_or_id(id)
|
|
62
|
+
if record.nil?
|
|
63
|
+
return 1, "#{rest_name} not found for '#{id}'"
|
|
64
|
+
end
|
|
65
|
+
passed_options = parse_passed_options(options)
|
|
66
|
+
payload = {}
|
|
67
|
+
if options[:payload]
|
|
68
|
+
payload = options[:payload]
|
|
69
|
+
payload.deep_merge!({rest_object_key => passed_options}) unless passed_options.empty?
|
|
70
|
+
else
|
|
71
|
+
record_payload = passed_options
|
|
72
|
+
payload[rest_object_key] = record_payload
|
|
73
|
+
end
|
|
74
|
+
rest_interface.setopts(options)
|
|
75
|
+
if options[:dry_run]
|
|
76
|
+
print_dry_run rest_interface.dry.refresh(record['id'], payload)
|
|
77
|
+
return
|
|
78
|
+
end
|
|
79
|
+
json_response = rest_interface.refresh(record['id'], payload)
|
|
80
|
+
render_response(json_response, options, rest_object_key) do
|
|
81
|
+
print_green_success "Refreshing #{rest_label.downcase} #{record['name'] || record['id']}"
|
|
82
|
+
_get(record["id"], {}, options)
|
|
83
|
+
end
|
|
84
|
+
return 0, nil
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# deprecated, to be removed in the future.
|
|
88
|
+
def types(args)
|
|
89
|
+
print_error yellow,"[DEPRECATED] The command `load-balancers types` is deprecated and replaced by `load-balancer-types list`.",reset,"\n"
|
|
90
|
+
my_terminal.execute("load-balancer-types list #{args.join(' ')}")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
protected
|
|
94
|
+
|
|
95
|
+
# filtering for NSX-T only
|
|
96
|
+
def rest_list_types()
|
|
97
|
+
rest_type_interface.list({max:10000, creatable:true})[rest_type_list_key].reject {|it| it['code'] == 'nsx-t'}
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def load_balancer_type_list_to_options(type_list)
|
|
101
|
+
type_list.reject {|it| it['code'] != 'nsx-t'}.collect {|it| {'name' => it['name'], 'value' => it['code']} }
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def add_load_balancer_footer_addn
|
|
105
|
+
"#{bold}Available for NSX-T load balancers only#{reset}"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def update_load_balancer_footer_addn
|
|
109
|
+
"#{bold}Available for NSX-T load balancers only#{reset}"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def load_balancer_list_column_definitions(options)
|
|
113
|
+
{
|
|
114
|
+
"ID" => 'id',
|
|
115
|
+
"Name" => 'name',
|
|
116
|
+
"Type" => lambda {|it| it['type'] ? it['type']['name'] : '' },
|
|
117
|
+
"Cloud" => lambda {|it| it['cloud'] ? it['cloud']['name'] : '' },
|
|
118
|
+
"Host" => lambda {|it| it['host'] }
|
|
119
|
+
}
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def load_balancer_column_definitions(options)
|
|
123
|
+
{
|
|
124
|
+
"ID" => 'id',
|
|
125
|
+
"Name" => 'name',
|
|
126
|
+
"Description" => 'description',
|
|
127
|
+
"Type" => lambda {|it| it['type'] ? it['type']['name'] : '' },
|
|
128
|
+
"Cloud" => lambda {|it| it['cloud'] ? it['cloud']['name'] : '' },
|
|
129
|
+
"Visibility" => 'visibility',
|
|
130
|
+
"IP" => 'ip',
|
|
131
|
+
"Host" => 'host',
|
|
132
|
+
"Port" => 'port',
|
|
133
|
+
"Username" => 'username',
|
|
134
|
+
# "SSL Enabled" => lambda {|it| format_boolean it['sslEnabled'] },
|
|
135
|
+
# "SSL Cert" => lambda {|it| it['sslCert'] ? it['sslCert']['name'] : '' },
|
|
136
|
+
# "SSL" => lambda {|it| it['sslEnabled'] ? "Yes (#{it['sslCert'] ? it['sslCert']['name'] : 'none'})" : "No" },
|
|
137
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
138
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
|
139
|
+
}
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# overridden to work with name or code
|
|
143
|
+
# nope, api works with name=code now too
|
|
144
|
+
# def find_load_balancer_type_by_name_or_id(name)
|
|
145
|
+
# load_balancer_type_for_name_or_id(name)
|
|
146
|
+
# end
|
|
147
|
+
|
|
148
|
+
# def add_load_balancer_option_types()
|
|
149
|
+
# [
|
|
150
|
+
# {'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true},
|
|
151
|
+
# {'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'required' => false},
|
|
152
|
+
# {'fieldName' => 'enabled', 'fieldLabel' => 'Enabled', 'type' => 'checkbox', 'required' => false, 'defaultValue' => true},
|
|
153
|
+
# # {'fieldName' => 'type', 'fieldLabel' => 'Storage Server Type', 'type' => 'select', 'optionSource' => 'loadBalancerTypes', 'required' => true},
|
|
154
|
+
# ]
|
|
155
|
+
# end
|
|
156
|
+
|
|
157
|
+
def add_load_balancer_advanced_option_types()
|
|
158
|
+
[
|
|
159
|
+
{'fieldName' => 'visibility', 'fieldLabel' => 'Visibility', 'fieldGroup' => 'Advanced', 'type' => 'select', 'selectOptions' => [{'name' => 'Private', 'value' => 'private'},{'name' => 'Public', 'value' => 'public'}], 'required' => false, 'description' => 'Visibility', 'category' => 'permissions', 'defaultValue' => 'public'},
|
|
160
|
+
{'fieldName' => 'tenants', 'fieldLabel' => 'Tenants', 'fieldGroup' => 'Advanced', 'type' => 'multiSelect', 'resultValueField' => 'id', 'optionSource' => lambda { |api_client, api_params|
|
|
161
|
+
api_client.options.options_for_source("allTenants", {})['data']
|
|
162
|
+
}},
|
|
163
|
+
]
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# def update_load_balancer_option_types()
|
|
167
|
+
# [
|
|
168
|
+
# {'fieldName' => 'name', 'fieldLabel' => 'Name', 'type' => 'text'},
|
|
169
|
+
# {'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text'},
|
|
170
|
+
# {'fieldName' => 'enabled', 'fieldLabel' => 'Enabled', 'type' => 'checkbox'},
|
|
171
|
+
# ]
|
|
172
|
+
# end
|
|
173
|
+
|
|
174
|
+
def update_load_balancer_advanced_option_types()
|
|
175
|
+
add_load_balancer_advanced_option_types()
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def load_option_types_for_load_balancer(type_record, parent_record)
|
|
179
|
+
load_balancer_type = type_record
|
|
180
|
+
# reload it by id to get optionTypes
|
|
181
|
+
option_types = load_balancer_type['optionTypes']
|
|
182
|
+
if option_types.nil?
|
|
183
|
+
load_balancer_type = find_by_id(:load_balancer_type, load_balancer_type['id'])
|
|
184
|
+
if load_balancer_type.nil?
|
|
185
|
+
raise_command_error("Load balancer type not found for id '#{id}'")
|
|
186
|
+
end
|
|
187
|
+
option_types = load_balancer_type['optionTypes']
|
|
188
|
+
end
|
|
189
|
+
return option_types
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class Morpheus::Cli::Logout
|
|
4
|
+
include Morpheus::Cli::CliCommand
|
|
5
|
+
|
|
6
|
+
def connect(options)
|
|
7
|
+
@api_client = establish_remote_appliance_connection(options.merge({:no_prompt => true, :skip_verify_access_token => true, :skip_login => true}))
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def usage
|
|
11
|
+
"Usage: morpheus logout"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def handle(args)
|
|
15
|
+
logout(args)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def logout(args)
|
|
19
|
+
options = {}
|
|
20
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
21
|
+
opts.banner = usage
|
|
22
|
+
build_common_options(opts, options, [:remote, :quiet])
|
|
23
|
+
opts.footer = <<-EOT
|
|
24
|
+
Logout of a remote appliance.
|
|
25
|
+
This clears your credentials so that you will need to login again.
|
|
26
|
+
EOT
|
|
27
|
+
end
|
|
28
|
+
optparse.parse!(args)
|
|
29
|
+
verify_args!(args:args,count:0,optpare:optparse)
|
|
30
|
+
connect(options)
|
|
31
|
+
|
|
32
|
+
if !@appliance_name
|
|
33
|
+
print_error Morpheus::Terminal.angry_prompt
|
|
34
|
+
puts_error "Please specify a Morpheus Appliance to logout of with -r or see the command `remote use`"
|
|
35
|
+
return 1
|
|
36
|
+
end
|
|
37
|
+
wallet = Morpheus::Cli::Credentials.new(@appliance_name, @appliance_url).load_saved_credentials
|
|
38
|
+
token = wallet ? wallet['access_token'] : nil
|
|
39
|
+
if !token
|
|
40
|
+
if !options[:quiet]
|
|
41
|
+
puts "You are not currently logged in to #{display_appliance(@appliance_name, @appliance_url)}"
|
|
42
|
+
end
|
|
43
|
+
else
|
|
44
|
+
# todo: need to tell the server to delete the token too..
|
|
45
|
+
# delete token from credentials file
|
|
46
|
+
# note: this also handles updating appliance session info
|
|
47
|
+
Morpheus::Cli::Credentials.new(@appliance_name, @appliance_url).logout()
|
|
48
|
+
if !options[:quiet]
|
|
49
|
+
puts "#{cyan}Logged out of #{@appliance_name}. Goodbye #{wallet['username']}!#{reset}"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
# recalcuate echo vars
|
|
53
|
+
Morpheus::Cli::Echo.recalculate_variable_map()
|
|
54
|
+
# recalculate shell prompt after this change
|
|
55
|
+
if Morpheus::Cli::Shell.has_instance?
|
|
56
|
+
Morpheus::Cli::Shell.instance.reinitialize()
|
|
57
|
+
end
|
|
58
|
+
return 0
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
end
|
data/lib/morpheus/cli/{monitoring_alerts_command.rb → commands/monitoring_alerts_command.rb}
RENAMED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
# require 'yaml'
|
|
2
|
-
require 'time'
|
|
3
|
-
require 'io/console'
|
|
4
|
-
require 'rest_client'
|
|
5
|
-
require 'optparse'
|
|
6
|
-
require 'filesize'
|
|
7
1
|
require 'morpheus/cli/cli_command'
|
|
8
|
-
require 'morpheus/cli/mixins/provisioning_helper'
|
|
9
2
|
|
|
10
3
|
class Morpheus::Cli::MonitoringAlertsCommand
|
|
11
4
|
include Morpheus::Cli::CliCommand
|