morpheus-cli 5.3.4 → 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 +14 -1
- data/lib/morpheus/api/health_interface.rb +37 -3
- 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_servers_interface.rb +68 -12
- data/lib/morpheus/api/roles_interface.rb +7 -0
- data/lib/morpheus/cli/cli_command.rb +7 -8
- data/lib/morpheus/cli/cli_registry.rb +1 -0
- 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} +0 -9
- 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} +0 -4
- data/lib/morpheus/cli/{clouds.rb → commands/clouds.rb} +0 -7
- data/lib/morpheus/cli/{clusters.rb → commands/clusters.rb} +0 -6
- 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 -9
- 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} +0 -4
- data/lib/morpheus/cli/{integrations_command.rb → commands/integrations_command.rb} +0 -0
- 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} +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} +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/{load_balancer_pools.rb → commands/load_balancer_pools.rb} +0 -0
- data/lib/morpheus/cli/{load_balancer_types.rb → commands/load_balancer_types.rb} +0 -4
- data/lib/morpheus/cli/{load_balancer_virtual_servers.rb → commands/load_balancer_virtual_servers.rb} +0 -0
- data/lib/morpheus/cli/{load_balancers.rb → commands/load_balancers.rb} +0 -1
- 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 +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} +0 -5
- data/lib/morpheus/cli/{network_services_command.rb → commands/network_services_command.rb} +0 -4
- 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} +18 -18
- 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} +0 -4
- data/lib/morpheus/cli/{tasks.rb → commands/tasks.rb} +0 -4
- 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} +0 -0
- 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} +0 -4
- data/lib/morpheus/cli/{whitelabel_settings_command.rb → commands/whitelabel_settings_command.rb} +0 -1
- data/lib/morpheus/cli/{whoami.rb → commands/whoami.rb} +0 -4
- data/lib/morpheus/cli/{wiki_command.rb → commands/wiki_command.rb} +0 -5
- data/lib/morpheus/cli/{workflows.rb → commands/workflows.rb} +0 -3
- data/lib/morpheus/cli/mixins/logs_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +1 -0
- data/lib/morpheus/cli/mixins/rest_command.rb +103 -17
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +105 -18
- data/lib/morpheus/cli/option_types.rb +56 -19
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +4 -135
- data/lib/morpheus/terminal.rb +5 -6
- metadata +150 -144
- data/lib/morpheus/cli/change_password_command.rb +0 -147
- data/lib/morpheus/cli/library.rb +0 -1
- data/lib/morpheus/cli/logout.rb +0 -81
@@ -0,0 +1,329 @@
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
2
|
+
|
3
|
+
class Morpheus::Cli::NetworkEdgeClustersCommand
|
4
|
+
include Morpheus::Cli::CliCommand
|
5
|
+
include Morpheus::Cli::ProvisioningHelper
|
6
|
+
include Morpheus::Cli::WhoamiHelper
|
7
|
+
|
8
|
+
set_command_name :'network-edge-clusters'
|
9
|
+
register_subcommands :list, :get, :update
|
10
|
+
|
11
|
+
def connect(opts)
|
12
|
+
@api_client = establish_remote_appliance_connection(opts)
|
13
|
+
@account_interface = @api_client.accounts
|
14
|
+
@network_edge_clusters_interface = @api_client.network_edge_clusters
|
15
|
+
@network_servers_interface = @api_client.network_servers
|
16
|
+
@options_interface = @api_client.options
|
17
|
+
end
|
18
|
+
|
19
|
+
def handle(args)
|
20
|
+
handle_subcommand(args)
|
21
|
+
end
|
22
|
+
|
23
|
+
def list(args)
|
24
|
+
options = {}
|
25
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
26
|
+
opts.banner = subcommand_usage("[server]")
|
27
|
+
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
28
|
+
opts.footer = "List network edge clusters." + "\n" +
|
29
|
+
"[server] is required. This is the name or id of a network server."
|
30
|
+
end
|
31
|
+
|
32
|
+
optparse.parse!(args)
|
33
|
+
connect(options)
|
34
|
+
|
35
|
+
if args.count < 1
|
36
|
+
puts optparse
|
37
|
+
return 1
|
38
|
+
end
|
39
|
+
|
40
|
+
server = find_network_server(args[0])
|
41
|
+
if server.nil?
|
42
|
+
return 1
|
43
|
+
end
|
44
|
+
|
45
|
+
_list(server, options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def _list(server, options)
|
49
|
+
@network_edge_clusters_interface.setopts(options)
|
50
|
+
|
51
|
+
if options[:dry_run]
|
52
|
+
print_dry_run @network_edge_clusters_interface.dry.list_edge_clusters(server['id'])
|
53
|
+
return
|
54
|
+
end
|
55
|
+
|
56
|
+
if server['type']['hasEdgeClusters']
|
57
|
+
json_response = @network_edge_clusters_interface.list_edge_clusters(server['id'])
|
58
|
+
render_response(json_response, options, 'networkEdgeClusters') do
|
59
|
+
print_h1 "Network Edge Clusters For: #{server['name']}"
|
60
|
+
print cyan
|
61
|
+
print_edge_clusters(server, json_response['networkEdgeClusters'])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
print_red_alert "Edge Clusters not supported for #{server['type']['name']}"
|
65
|
+
end
|
66
|
+
print reset
|
67
|
+
end
|
68
|
+
|
69
|
+
def get(args)
|
70
|
+
options = {}
|
71
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
72
|
+
opts.banner = subcommand_usage("[server] [edge_cluster]")
|
73
|
+
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
74
|
+
opts.footer = "Display details on a network edge cluster." + "\n" +
|
75
|
+
"[server] is required. This is the name or id of a network server.\n" +
|
76
|
+
"[edge_cluster] is required. This is the id of a network edge cluster.\n"
|
77
|
+
end
|
78
|
+
|
79
|
+
optparse.parse!(args)
|
80
|
+
connect(options)
|
81
|
+
|
82
|
+
if args.count < 2
|
83
|
+
puts optparse
|
84
|
+
return 1
|
85
|
+
end
|
86
|
+
|
87
|
+
server = find_network_server(args[0])
|
88
|
+
if server.nil?
|
89
|
+
return 1
|
90
|
+
end
|
91
|
+
|
92
|
+
_get(server, args[1], options)
|
93
|
+
end
|
94
|
+
|
95
|
+
def _get(server, edge_cluster_id, options)
|
96
|
+
@network_edge_clusters_interface.setopts(options)
|
97
|
+
|
98
|
+
if options[:dry_run]
|
99
|
+
if edge_cluster_id.to_s =~ /\A\d{1,}\Z/
|
100
|
+
print_dry_run @network_edge_clusters_interface.dry.get_edge_cluster(server['id'], edge_cluster_id.to_i)
|
101
|
+
else
|
102
|
+
print_dry_run @network_edge_clusters_interface.dry.list_edge_clusters(server['id'], {name: edge_cluster_id})
|
103
|
+
end
|
104
|
+
return
|
105
|
+
end
|
106
|
+
|
107
|
+
if server['type']['hasEdgeClusters']
|
108
|
+
edgeCluster = find_edge_cluster(server['id'], edge_cluster_id)
|
109
|
+
|
110
|
+
return 1 if edgeCluster.nil?
|
111
|
+
|
112
|
+
render_response({networkEdgeCluster: edgeCluster}, options, 'networkEdgeCluster') do
|
113
|
+
print_h1 "Network Edge Cluster Details"
|
114
|
+
print cyan
|
115
|
+
|
116
|
+
description_cols = {
|
117
|
+
"ID" => lambda {|it| it['id']},
|
118
|
+
"Name" => lambda {|it| it['name']},
|
119
|
+
"Description" => lambda {|it| it['description']},
|
120
|
+
"Status" => lambda {|it| it['status']}
|
121
|
+
}
|
122
|
+
|
123
|
+
if is_master_account
|
124
|
+
description_cols["Visibility"] = lambda {|it| it['visibility']}
|
125
|
+
description_cols["Tenants"] = lambda {|it| it['tenants'].collect {|tenant| tenant['name']}.join(', ')}
|
126
|
+
end
|
127
|
+
|
128
|
+
server['type']['edgeClusterOptionTypes'].sort_by {|it| it['displayOrder']}.each do |option_type|
|
129
|
+
description_cols[option_type['fieldLabel']] = lambda {|it| Morpheus::Cli::OptionTypes.get_option_value(it, option_type, true)}
|
130
|
+
end
|
131
|
+
print_description_list(description_cols, edgeCluster)
|
132
|
+
end
|
133
|
+
else
|
134
|
+
print_red_alert "Edge Clusters not supported for #{server['type']['name']}"
|
135
|
+
end
|
136
|
+
println reset
|
137
|
+
end
|
138
|
+
|
139
|
+
def update(args)
|
140
|
+
options = {:options=>{}}
|
141
|
+
params = {}
|
142
|
+
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
143
|
+
opts.banner = subcommand_usage("[server] [edge_cluster]")
|
144
|
+
opts.on( '--name NAME', "Name" ) do |val|
|
145
|
+
params['name'] = val.to_s
|
146
|
+
end
|
147
|
+
opts.on("--description [TEXT]", String, "Description") do |val|
|
148
|
+
params['description'] = val.to_s
|
149
|
+
end
|
150
|
+
add_perms_options(opts, options, ['plans', 'groups'])
|
151
|
+
build_common_options(opts, options, [:options, :payload, :json, :dry_run, :remote])
|
152
|
+
opts.footer = "Update a network edge cluster.\n" +
|
153
|
+
"[server] is required. This is the name or id of an existing network server.\n" +
|
154
|
+
"[edge_cluster] is required. This is the name or id of an existing network edge cluster."
|
155
|
+
end
|
156
|
+
optparse.parse!(args)
|
157
|
+
if args.count != 2
|
158
|
+
raise_command_error "wrong number of arguments, expected 2 and got (#{args.count}) #{args}\n#{optparse}"
|
159
|
+
end
|
160
|
+
connect(options)
|
161
|
+
|
162
|
+
server = find_network_server(args[0])
|
163
|
+
if server.nil?
|
164
|
+
return 1
|
165
|
+
end
|
166
|
+
|
167
|
+
if !server['type']['hasEdgeClusters']
|
168
|
+
print_red_alert "Edge Clusters not supported for #{server['type']['name']}"
|
169
|
+
return 1
|
170
|
+
end
|
171
|
+
|
172
|
+
edgeCluster = find_edge_cluster(server['id'], args[1])
|
173
|
+
return 1 if edgeCluster.nil?
|
174
|
+
|
175
|
+
payload = parse_payload(options) || {'networkEdgeCluster' => params}
|
176
|
+
payload['networkEdgeCluster'].deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options] && !payload['networkEdgeCluster'].nil?
|
177
|
+
|
178
|
+
if !options[:visibility].nil?
|
179
|
+
payload['networkEdgeCluster']['visibility'] = options[:visibility]
|
180
|
+
end
|
181
|
+
if !options[:tenants].nil?
|
182
|
+
payload['networkEdgeCluster']['tenants'] = options[:tenants].collect {|id| {id: id.to_i}}
|
183
|
+
end
|
184
|
+
|
185
|
+
if payload['networkEdgeCluster'].empty?
|
186
|
+
option_types = server['type']['edgeClusterOptionTypes'].sort_by {|it| it['displayOrder']}
|
187
|
+
print_green_success "Nothing to update"
|
188
|
+
println cyan
|
189
|
+
print Morpheus::Cli::OptionTypes.display_option_types_help(
|
190
|
+
option_types,
|
191
|
+
{:include_context => true, :context_map => {'edgeCluster' => ''}, :color => cyan, :title => "Available Edge Cluster Options"}
|
192
|
+
)
|
193
|
+
exit 1
|
194
|
+
end
|
195
|
+
|
196
|
+
#payload = {'networkEdgeCluster' => edgeCluster.deep_merge(payload['networkEdgeCluster'])}
|
197
|
+
|
198
|
+
@network_edge_clusters_interface.setopts(options)
|
199
|
+
|
200
|
+
if options[:dry_run]
|
201
|
+
print_dry_run @network_edge_clusters_interface.dry.update_edge_cluster(server['id'], edgeCluster['id'], payload)
|
202
|
+
return
|
203
|
+
end
|
204
|
+
|
205
|
+
json_response = @network_edge_clusters_interface.update_edge_cluster(server['id'], edgeCluster['id'], payload)
|
206
|
+
render_response(json_response, options, 'networkEdgeCluster') do
|
207
|
+
print_green_success "\nUpdated Network Edge Cluster #{edgeCluster['id']}\n"
|
208
|
+
_get(server, edgeCluster['id'], options)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
private
|
213
|
+
|
214
|
+
def print_edge_clusters(server, edgeClusters)
|
215
|
+
if edgeClusters.count > 0
|
216
|
+
cols = [:id, :name, :description, :status]
|
217
|
+
server['type']['edgeClusterOptionTypes'].sort_by {|it| it['displayOrder']}.each do |option_type|
|
218
|
+
cols << option_type['fieldLabel']
|
219
|
+
end
|
220
|
+
cols += [:visibility, :tenants] if is_master_account
|
221
|
+
rows = edgeClusters.collect do |it|
|
222
|
+
row = {
|
223
|
+
id: it['id'],
|
224
|
+
name: it['name'],
|
225
|
+
description: it['description'],
|
226
|
+
status: it['statusMessage'],
|
227
|
+
}
|
228
|
+
server['type']['edgeClusterOptionTypes'].sort_by {|it| it['displayOrder']}.each do |option_type|
|
229
|
+
row[option_type['fieldLabel']] = Morpheus::Cli::OptionTypes.get_option_value(it, option_type, true)
|
230
|
+
end
|
231
|
+
if is_master_account
|
232
|
+
row = row.merge({
|
233
|
+
visibility: it['visibility'],
|
234
|
+
tenants: it['tenants'].collect {|it| it['name']}.join(', ')
|
235
|
+
})
|
236
|
+
end
|
237
|
+
row
|
238
|
+
end
|
239
|
+
puts as_pretty_table(rows, cols)
|
240
|
+
else
|
241
|
+
println "No Edge Clusters\n"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def find_network_server(val)
|
246
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
247
|
+
return find_network_server_by_id(val)
|
248
|
+
else
|
249
|
+
if server = find_network_server_by_name(val)
|
250
|
+
return find_network_server_by_id(server['id'])
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def find_network_server_by_id(id)
|
256
|
+
begin
|
257
|
+
json_response = @network_servers_interface.get(id.to_i)
|
258
|
+
return json_response['networkServer']
|
259
|
+
rescue RestClient::Exception => e
|
260
|
+
if e.response && e.response.code == 404
|
261
|
+
print_red_alert "Network Server not found by id #{id}"
|
262
|
+
return nil
|
263
|
+
else
|
264
|
+
raise e
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def find_network_server_by_name(name)
|
270
|
+
json_response = @network_servers_interface.list({phrase: name.to_s})
|
271
|
+
servers = json_response['networkServers']
|
272
|
+
if servers.empty?
|
273
|
+
print_red_alert "Network Server not found by name #{name}"
|
274
|
+
return nil
|
275
|
+
elsif servers.size > 1
|
276
|
+
print_red_alert "#{servers.size} network servers found by name #{name}"
|
277
|
+
rows = servers.collect do |it|
|
278
|
+
{id: it['id'], name: it['name']}
|
279
|
+
end
|
280
|
+
puts as_pretty_table(rows, [:id, :name], {color:red})
|
281
|
+
return nil
|
282
|
+
else
|
283
|
+
return servers[0]
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
def find_edge_cluster(server_id, val)
|
288
|
+
if val.to_s =~ /\A\d{1,}\Z/
|
289
|
+
return find_edge_cluster_by_id(server_id, val)
|
290
|
+
else
|
291
|
+
if edgeCluster = find_edge_cluster_by_name(server_id, val)
|
292
|
+
return find_edge_cluster_by_id(server_id, edgeCluster['id'])
|
293
|
+
end
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def find_edge_cluster_by_id(server_id, edge_cluster_id)
|
298
|
+
begin
|
299
|
+
json_response = @network_edge_clusters_interface.get_edge_cluster(server_id, edge_cluster_id.to_i)
|
300
|
+
return json_response['networkEdgeCluster']
|
301
|
+
rescue RestClient::Exception => e
|
302
|
+
if e.response && e.response.code == 404
|
303
|
+
print_red_alert "Network Edge Cluster not found by id #{id}"
|
304
|
+
return nil
|
305
|
+
else
|
306
|
+
raise e
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def find_edge_cluster_by_name(server_id, name)
|
312
|
+
json_response = @network_edge_clusters_interface.list_edge_clusters(server_id, {phrase: name.to_s})
|
313
|
+
edgeClusters = json_response['networkEdgeClusters']
|
314
|
+
if edgeClusters.empty?
|
315
|
+
print_red_alert "Network Edge Cluster not found by name #{name}"
|
316
|
+
return nil
|
317
|
+
elsif edgeClusters.size > 1
|
318
|
+
print_red_alert "#{edgeClusters.size} network edge clusters found by name #{name}"
|
319
|
+
rows = edgeClusters.collect do |it|
|
320
|
+
{id: it['id'], name: it['name']}
|
321
|
+
end
|
322
|
+
puts as_pretty_table(rows, [:id, :name], {color:red})
|
323
|
+
return nil
|
324
|
+
else
|
325
|
+
return edgeClusters[0]
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
end
|