morpheus-cli 5.3.2.2 → 5.4.0
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/api_client.rb +26 -1
- 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 +18 -5
- data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +10 -0
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +4 -4
- 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 +21 -0
- data/lib/morpheus/api/network_servers_interface.rb +98 -0
- data/lib/morpheus/api/rest_interface.rb +2 -1
- data/lib/morpheus/api/roles_interface.rb +7 -0
- 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 +21 -14
- 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} +0 -3
- 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} +3 -11
- data/lib/morpheus/cli/{archives_command.rb → commands/archives_command.rb} +0 -6
- 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} +0 -0
- 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} +51 -39
- 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} +0 -10
- 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} +364 -148
- 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_pools.rb +111 -0
- data/lib/morpheus/cli/{load_balancer_types.rb → commands/load_balancer_types.rb} +0 -4
- data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +136 -0
- data/lib/morpheus/cli/commands/load_balancers.rb +89 -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 +806 -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} +291 -12
- data/lib/morpheus/cli/{network_services_command.rb → commands/network_services_command.rb} +0 -4
- 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/{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} +0 -7
- 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} +0 -0
- 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} +1 -7
- 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} +244 -39
- 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} +2 -103
- 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/{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} +0 -7
- 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} +0 -1
- data/lib/morpheus/cli/{user_settings_command.rb → commands/user_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{user_sources_command.rb → commands/user_sources_command.rb} +0 -1
- data/lib/morpheus/cli/{users.rb → commands/users.rb} +0 -7
- 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/{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/load_balancers_helper.rb +2 -2
- data/lib/morpheus/cli/mixins/logs_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +1 -0
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +155 -112
- data/lib/morpheus/cli/mixins/rest_command.rb +154 -52
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +575 -0
- data/lib/morpheus/cli/option_parser.rb +25 -17
- data/lib/morpheus/cli/option_types.rb +96 -32
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +5 -128
- data/lib/morpheus/terminal.rb +5 -6
- data/morpheus-cli.gemspec +1 -1
- metadata +156 -143
- 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
@@ -0,0 +1,111 @@
|
|
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::LoadBalancersHelper
|
7
|
+
|
8
|
+
set_command_hidden # hide until ready
|
9
|
+
set_command_name :'load-balancer-pools'
|
10
|
+
register_subcommands :list, :get, :add, :update, :remove
|
11
|
+
|
12
|
+
register_interfaces :load_balancer_pools,
|
13
|
+
:load_balancers, :load_balancer_pools
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def load_balancer_pool_list_column_definitions()
|
18
|
+
{
|
19
|
+
"ID" => 'id',
|
20
|
+
"Name" => 'name',
|
21
|
+
"Balancer Mode" => lambda {|it| it['vipBalance'] },
|
22
|
+
"LB" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def load_balancer_pool_column_definitions()
|
27
|
+
{
|
28
|
+
"ID" => 'id',
|
29
|
+
"Name" => 'name',
|
30
|
+
"Description" => 'description',
|
31
|
+
"Balancer Mode" => lambda {|it| it['vipBalance'] },
|
32
|
+
"LB" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
33
|
+
# todo: more properties to show here
|
34
|
+
"Status" => lambda {|it| format_load_balancer_pool_status(it) },
|
35
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
36
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def load_balancer_pool_object_key
|
41
|
+
'loadBalancerPool'
|
42
|
+
end
|
43
|
+
|
44
|
+
def load_balancer_pool_list_key
|
45
|
+
'loadBalancerPools'
|
46
|
+
end
|
47
|
+
|
48
|
+
def load_balancer_pool_label
|
49
|
+
'Load Balancer Pool'
|
50
|
+
end
|
51
|
+
|
52
|
+
def load_balancer_pool_label_plural
|
53
|
+
'Load Balancer Pools'
|
54
|
+
end
|
55
|
+
|
56
|
+
def find_load_balancer_pool_by_name_or_id(val)
|
57
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
58
|
+
return find_load_balancer_pool_by_id(val)
|
59
|
+
else
|
60
|
+
return find_load_balancer_pool_by_name(val)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def find_load_balancer_pool_by_id(id)
|
65
|
+
begin
|
66
|
+
json_response = load_balancer_pools_interface.get(id.to_i)
|
67
|
+
return json_response[load_balancer_pool_object_key]
|
68
|
+
rescue RestClient::Exception => e
|
69
|
+
if e.response && e.response.code == 404
|
70
|
+
print_red_alert "#{load_balancer_pool_label} not found by id #{id}"
|
71
|
+
return nil
|
72
|
+
else
|
73
|
+
raise e
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def find_load_balancer_pool_by_name(name)
|
79
|
+
json_response = load_balancer_pools_interface.list({name: name.to_s})
|
80
|
+
load_balancer_pools = json_response[load_balancer_pool_list_key]
|
81
|
+
if load_balancer_pools.empty?
|
82
|
+
print_red_alert "#{load_balancer_pool_label_plural} not found by name #{name}"
|
83
|
+
return load_balancer_pools
|
84
|
+
elsif load_balancer_pools.size > 1
|
85
|
+
print_red_alert "#{load_balancer_pools.size} #{load_balancer_pool_label_plural.downcase} found by name #{name}"
|
86
|
+
rows = load_balancer_pools.collect do |it|
|
87
|
+
{id: it['id'], name: it['name']}
|
88
|
+
end
|
89
|
+
puts as_pretty_table(rows, [:id, :name], {color:red})
|
90
|
+
return nil
|
91
|
+
else
|
92
|
+
return load_balancer_pools[0]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def format_load_balancer_pool_status(pool, return_color=cyan)
|
97
|
+
out = ""
|
98
|
+
status_string = pool['vipStatus'] || pool['status']
|
99
|
+
if status_string.nil? || status_string.empty? || status_string == "unknown"
|
100
|
+
out << "#{white}UNKNOWN#{return_color}"
|
101
|
+
elsif status_string == 'ok'
|
102
|
+
out << "#{green}#{status_string.upcase}#{return_color}"
|
103
|
+
elsif status_string == 'syncing'
|
104
|
+
out << "#{yellow}#{status_string.upcase}#{return_color}"
|
105
|
+
else
|
106
|
+
out << "#{red}#{status_string ? status_string.upcase : 'N/A'}#{pool['statusMessage'] ? "#{return_color} - #{pool['statusMessage']}" : ''}#{return_color}"
|
107
|
+
end
|
108
|
+
out
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
2
|
+
|
3
|
+
class Morpheus::Cli::LoadBalancerVirtualServers
|
4
|
+
include Morpheus::Cli::CliCommand
|
5
|
+
include Morpheus::Cli::RestCommand
|
6
|
+
# include Morpheus::Cli::SecondaryRestCommand
|
7
|
+
include Morpheus::Cli::LoadBalancersHelper
|
8
|
+
|
9
|
+
set_command_hidden # hide until ready
|
10
|
+
set_command_name :'load-balancer-virtual-servers'
|
11
|
+
register_subcommands :list, :get, :add, :update, :remove
|
12
|
+
|
13
|
+
register_interfaces :load_balancer_virtual_servers,
|
14
|
+
:load_balancers, :load_balancer_types
|
15
|
+
|
16
|
+
# set_rest_parent_name :load_balancers
|
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
|
+
|
26
|
+
set_rest_arg 'vipName'
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def load_balancer_virtual_server_list_column_definitions()
|
31
|
+
{
|
32
|
+
"ID" => 'id',
|
33
|
+
"Name" => 'vipName',
|
34
|
+
"LB" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
35
|
+
# "Description" => 'description',
|
36
|
+
"Instance" => lambda {|it| it['instance'] ? it['instance']['name'] : '(Unassigned)' },
|
37
|
+
"Hostname" => lambda {|it| it['vipHostname'] },
|
38
|
+
"VIP" => lambda {|it| it['vipAddress'] },
|
39
|
+
"Protocol" => lambda {|it| it['vipProtocol'] },
|
40
|
+
"Port" => lambda {|it| it['vipPort'] },
|
41
|
+
"SSL" => lambda {|it| format_boolean(it['sslEnabled']) },
|
42
|
+
"Status" => lambda {|it| format_virtual_server_status(it) },
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def load_balancer_virtual_server_column_definitions()
|
47
|
+
{
|
48
|
+
"ID" => 'id',
|
49
|
+
"Name" => 'vipName',
|
50
|
+
"Description" => 'description',
|
51
|
+
"LB" => lambda {|it| it['loadBalancer'] ? it['loadBalancer']['name'] : '' },
|
52
|
+
"Instance" => lambda {|it| it['instance'] ? it['instance']['name'] : '(Unassigned)' },
|
53
|
+
"Hostname" => lambda {|it| it['vipHostname'] },
|
54
|
+
"VIP" => lambda {|it| it['vipAddress'] },
|
55
|
+
"Protocol" => lambda {|it| it['vipProtocol'] },
|
56
|
+
"Port" => lambda {|it| it['vipPort'] },
|
57
|
+
"SSL" => lambda {|it| format_boolean(it['sslEnabled']) },
|
58
|
+
# todo: more properties to show here
|
59
|
+
"Status" => lambda {|it| format_virtual_server_status(it) },
|
60
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
61
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def load_balancer_virtual_server_object_key
|
66
|
+
'virtualServer'
|
67
|
+
end
|
68
|
+
|
69
|
+
def load_balancer_virtual_server_list_key
|
70
|
+
'virtualServers'
|
71
|
+
end
|
72
|
+
|
73
|
+
def load_balancer_virtual_server_label
|
74
|
+
'Virtual Server'
|
75
|
+
end
|
76
|
+
|
77
|
+
def load_balancer_virtual_server_label_plural
|
78
|
+
'Virtual Servers'
|
79
|
+
end
|
80
|
+
|
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
|
+
def format_virtual_server_status(virtual_server, return_color=cyan)
|
122
|
+
out = ""
|
123
|
+
status_string = virtual_server['vipStatus'] || virtual_server['status']
|
124
|
+
if status_string.nil? || status_string.empty? || status_string == "unknown"
|
125
|
+
out << "#{white}UNKNOWN#{return_color}"
|
126
|
+
elsif status_string == 'ok'
|
127
|
+
out << "#{green}#{status_string.upcase}#{return_color}"
|
128
|
+
elsif status_string == 'syncing'
|
129
|
+
out << "#{yellow}#{status_string.upcase}#{return_color}"
|
130
|
+
else
|
131
|
+
out << "#{red}#{status_string ? status_string.upcase : 'N/A'}#{virtual_server['statusMessage'] ? "#{return_color} - #{virtual_server['statusMessage']}" : ''}#{return_color}"
|
132
|
+
end
|
133
|
+
out
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
@@ -0,0 +1,89 @@
|
|
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_name :'load-balancers'
|
9
|
+
register_subcommands :list, :get, :add, :update, :remove
|
10
|
+
|
11
|
+
# deprecated the `load-balancers types` command in 5.3.2, it moved to `load-balancer-types list`
|
12
|
+
register_subcommands :types
|
13
|
+
set_subcommands_hidden :types
|
14
|
+
|
15
|
+
# RestCommand settings
|
16
|
+
register_interfaces :load_balancers, :load_balancer_types
|
17
|
+
set_rest_has_type true
|
18
|
+
# set_rest_type :load_balancer_types
|
19
|
+
|
20
|
+
def render_response_for_get(json_response, options)
|
21
|
+
render_response(json_response, options, rest_object_key) do
|
22
|
+
record = json_response[rest_object_key]
|
23
|
+
print_h1 rest_label, [], options
|
24
|
+
print cyan
|
25
|
+
print_description_list(rest_column_definitions, record, options)
|
26
|
+
# show LB Ports
|
27
|
+
ports = record['ports']
|
28
|
+
if ports && ports.size > 0
|
29
|
+
print_h2 "LB Ports", options
|
30
|
+
columns = [
|
31
|
+
{"ID" => 'id'},
|
32
|
+
{"Name" => 'name'},
|
33
|
+
#{"Description" => 'description'},
|
34
|
+
{"Port" => lambda {|it| it['port'] } },
|
35
|
+
{"Protocol" => lambda {|it| it['proxyProtocol'] } },
|
36
|
+
{"SSL" => lambda {|it| it['sslEnabled'] ? "Yes (#{it['sslCert'] ? it['sslCert']['name'] : 'none'})" : "No" } },
|
37
|
+
]
|
38
|
+
print as_pretty_table(ports, columns, options)
|
39
|
+
end
|
40
|
+
print reset,"\n"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# deprecated, to be removed in the future.
|
45
|
+
def types(args)
|
46
|
+
print_error yellow,"[DEPRECATED] The command `load-balancers types` is deprecated and replaced by `load-balancer-types list`.",reset,"\n"
|
47
|
+
my_terminal.execute("load-balancer-types list #{args.join(' ')}")
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
def load_balancer_list_column_definitions()
|
53
|
+
{
|
54
|
+
"ID" => 'id',
|
55
|
+
"Name" => 'name',
|
56
|
+
"Type" => lambda {|it| it['type'] ? it['type']['name'] : '' },
|
57
|
+
"Cloud" => lambda {|it| it['cloud'] ? it['cloud']['name'] : '' },
|
58
|
+
"Host" => lambda {|it| it['host'] }
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
def load_balancer_column_definitions()
|
63
|
+
{
|
64
|
+
"ID" => 'id',
|
65
|
+
"Name" => 'name',
|
66
|
+
"Description" => 'description',
|
67
|
+
"Type" => lambda {|it| it['type'] ? it['type']['name'] : '' },
|
68
|
+
"Cloud" => lambda {|it| it['cloud'] ? it['cloud']['name'] : '' },
|
69
|
+
"Visibility" => 'visibility',
|
70
|
+
"IP" => 'ip',
|
71
|
+
"Host" => 'host',
|
72
|
+
"Port" => 'port',
|
73
|
+
"Username" => 'username',
|
74
|
+
# "SSL Enabled" => lambda {|it| format_boolean it['sslEnabled'] },
|
75
|
+
# "SSL Cert" => lambda {|it| it['sslCert'] ? it['sslCert']['name'] : '' },
|
76
|
+
# "SSL" => lambda {|it| it['sslEnabled'] ? "Yes (#{it['sslCert'] ? it['sslCert']['name'] : 'none'})" : "No" },
|
77
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
78
|
+
"Updated" => lambda {|it| format_local_dt(it['lastUpdated']) }
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
# overridden to work with name or code
|
83
|
+
def find_load_balancer_type_by_name_or_id(name)
|
84
|
+
load_balancer_type_for_name_or_id(name)
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
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
|
data/lib/morpheus/cli/{monitoring_checks_command.rb → commands/monitoring_checks_command.rb}
RENAMED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'morpheus/cli/cli_command'
|
2
|
-
require 'morpheus/cli/mixins/monitoring_helper'
|
3
2
|
|
4
3
|
class Morpheus::Cli::MonitoringChecksCommand
|
5
4
|
include Morpheus::Cli::CliCommand
|
@@ -158,11 +157,13 @@ class Morpheus::Cli::MonitoringChecksCommand
|
|
158
157
|
end
|
159
158
|
},
|
160
159
|
"Type" => lambda {|it| format_monitoring_check_type(it) },
|
160
|
+
"API Key" => lambda {|it| it['apiKey'] },
|
161
161
|
"Created By" => lambda {|it| it['createdBy'] ? it['createdBy']['username'] : "System" },
|
162
162
|
"Date Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
163
163
|
"Last Updated" => lambda {|it| format_local_dt(it['lastUpdated']) },
|
164
164
|
# "Last Error" => lambda {|it| format_local_dt(it['lastErrorDate']) },
|
165
165
|
}
|
166
|
+
description_cols.delete("API Key") if !['pushCheck'].include?(check['checkType']['code']) || check['apiKey'].nil?
|
166
167
|
print_description_list(description_cols, check)
|
167
168
|
|
168
169
|
# Last Error
|
data/lib/morpheus/cli/{monitoring_contacts_command.rb → commands/monitoring_contacts_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::MonitoringContactsCommand
|
11
4
|
include Morpheus::Cli::CliCommand
|