morpheus-cli 5.3.4 → 5.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/account_users_interface.rb +68 -0
- data/lib/morpheus/api/api_client.rb +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
@@ -1,11 +1,4 @@
|
|
1
|
-
# require 'yaml'
|
2
|
-
require 'io/console'
|
3
|
-
require 'rest_client'
|
4
|
-
require 'optparse'
|
5
1
|
require 'morpheus/cli/cli_command'
|
6
|
-
require 'morpheus/cli/option_types'
|
7
|
-
require 'morpheus/cli/mixins/accounts_helper'
|
8
|
-
require 'json'
|
9
2
|
|
10
3
|
class Morpheus::Cli::Users
|
11
4
|
include Morpheus::Cli::CliCommand
|
@@ -22,7 +15,7 @@ class Morpheus::Cli::Users
|
|
22
15
|
|
23
16
|
def connect(opts)
|
24
17
|
@api_client = establish_remote_appliance_connection(opts)
|
25
|
-
@
|
18
|
+
@account_users_interface = @api_client.account_users
|
26
19
|
@accounts_interface = @api_client.accounts
|
27
20
|
@roles_interface = @api_client.roles
|
28
21
|
end
|
@@ -62,12 +55,12 @@ class Morpheus::Cli::Users
|
|
62
55
|
account_id = account ? account['id'] : nil
|
63
56
|
params['global'] = true if options[:global]
|
64
57
|
params.merge!(parse_list_options(options))
|
65
|
-
@
|
58
|
+
@account_users_interface.setopts(options)
|
66
59
|
if options[:dry_run]
|
67
|
-
print_dry_run @
|
60
|
+
print_dry_run @account_users_interface.dry.list(account_id, params)
|
68
61
|
return 0, nil
|
69
62
|
end
|
70
|
-
json_response = @
|
63
|
+
json_response = @account_users_interface.list(account_id, params)
|
71
64
|
render_response(json_response, options, "users") do
|
72
65
|
users = json_response['users']
|
73
66
|
title = "Morpheus Users"
|
@@ -110,12 +103,12 @@ class Morpheus::Cli::Users
|
|
110
103
|
account_id = account ? account['id'] : nil
|
111
104
|
params['global'] = true if options[:global]
|
112
105
|
params.merge!(parse_list_options(options))
|
113
|
-
@
|
106
|
+
@account_users_interface.setopts(options)
|
114
107
|
if options[:dry_run]
|
115
|
-
print_dry_run @
|
108
|
+
print_dry_run @account_users_interface.dry.list(account_id, params)
|
116
109
|
return
|
117
110
|
end
|
118
|
-
json_response = @
|
111
|
+
json_response = @account_users_interface.list(account_id, params)
|
119
112
|
# print number only
|
120
113
|
if json_response['meta'] && json_response['meta']['total']
|
121
114
|
print cyan, json_response['meta']['total'], reset, "\n"
|
@@ -202,12 +195,12 @@ EOT
|
|
202
195
|
account = find_account_from_options(options)
|
203
196
|
account_id = account ? account['id'] : nil
|
204
197
|
params['global'] = true if options[:global]
|
205
|
-
@
|
198
|
+
@account_users_interface.setopts(options)
|
206
199
|
if options[:dry_run]
|
207
200
|
if args[0].to_s =~ /\A\d{1,}\Z/
|
208
|
-
print_dry_run @
|
201
|
+
print_dry_run @account_users_interface.dry.get(account_id, args[0].to_i, params)
|
209
202
|
else
|
210
|
-
print_dry_run @
|
203
|
+
print_dry_run @account_users_interface.dry.list(account_id, params.merge({username: args[0]}))
|
211
204
|
end
|
212
205
|
return
|
213
206
|
end
|
@@ -220,7 +213,7 @@ EOT
|
|
220
213
|
user_id = user['id']
|
221
214
|
end
|
222
215
|
# always get by id, index does not return 'access'
|
223
|
-
json_response = @
|
216
|
+
json_response = @account_users_interface.get(account_id, user_id, params)
|
224
217
|
user = json_response['user']
|
225
218
|
render_response(json_response, options, "user") do
|
226
219
|
is_tenant_account = current_account['id'] != user['account']['id']
|
@@ -230,7 +223,7 @@ EOT
|
|
230
223
|
|
231
224
|
# backward compatibility
|
232
225
|
if user['access'].nil? && options[:include_features_access]
|
233
|
-
user_feature_permissions_json = @
|
226
|
+
user_feature_permissions_json = @account_users_interface.feature_permissions(account_id, user['id'])
|
234
227
|
user_feature_permissions = user_feature_permissions_json['permissions'] || user_feature_permissions_json['featurePermissions']
|
235
228
|
|
236
229
|
if user_feature_permissions
|
@@ -315,15 +308,15 @@ EOT
|
|
315
308
|
params['global'] = true if options[:global]
|
316
309
|
user = find_user_by_username_or_id(account_id, args[0], params)
|
317
310
|
return 1 if user.nil?
|
318
|
-
@
|
311
|
+
@account_users_interface.setopts(options)
|
319
312
|
if options[:dry_run]
|
320
|
-
print_dry_run @
|
313
|
+
print_dry_run @account_users_interface.dry.permissions(account_id, user['id'])
|
321
314
|
return
|
322
315
|
end
|
323
316
|
|
324
317
|
is_tenant_account = current_account['id'] != user['account']['id']
|
325
318
|
|
326
|
-
json_response = @
|
319
|
+
json_response = @account_users_interface.permissions(account_id, user['id'])
|
327
320
|
|
328
321
|
# backward compatibility
|
329
322
|
if !json_response['permissions'].nil?
|
@@ -467,12 +460,12 @@ EOT
|
|
467
460
|
puts as_json(payload, options)
|
468
461
|
return 0
|
469
462
|
end
|
470
|
-
@
|
463
|
+
@account_users_interface.setopts(options)
|
471
464
|
if options[:dry_run]
|
472
|
-
print_dry_run @
|
465
|
+
print_dry_run @account_users_interface.dry.create(account_id, payload)
|
473
466
|
return
|
474
467
|
end
|
475
|
-
json_response = @
|
468
|
+
json_response = @account_users_interface.create(account_id, payload)
|
476
469
|
if options[:json]
|
477
470
|
print JSON.pretty_generate(json_response)
|
478
471
|
print "\n"
|
@@ -552,12 +545,12 @@ EOT
|
|
552
545
|
end
|
553
546
|
end
|
554
547
|
|
555
|
-
@
|
548
|
+
@account_users_interface.setopts(options)
|
556
549
|
if options[:dry_run]
|
557
|
-
print_dry_run @
|
550
|
+
print_dry_run @account_users_interface.dry.update(account_id, user['id'], payload)
|
558
551
|
return
|
559
552
|
end
|
560
|
-
json_response = @
|
553
|
+
json_response = @account_users_interface.update(account_id, user['id'], payload)
|
561
554
|
user = json_response['user']
|
562
555
|
if options[:json]
|
563
556
|
print JSON.pretty_generate(json_response)
|
@@ -652,12 +645,12 @@ EOT
|
|
652
645
|
}
|
653
646
|
|
654
647
|
end
|
655
|
-
@
|
648
|
+
@account_users_interface.setopts(options)
|
656
649
|
if options[:dry_run]
|
657
|
-
print_dry_run @
|
650
|
+
print_dry_run @account_users_interface.dry.update(account_id, user['id'], payload)
|
658
651
|
return
|
659
652
|
end
|
660
|
-
json_response = @
|
653
|
+
json_response = @account_users_interface.update(account_id, user['id'], payload)
|
661
654
|
render_response(json_response, optparse, "user") do
|
662
655
|
print_green_success "Updated password for user #{user['username']}"
|
663
656
|
end
|
@@ -691,12 +684,12 @@ EOT
|
|
691
684
|
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the user #{user['username']}?")
|
692
685
|
exit 9, "arborted"
|
693
686
|
end
|
694
|
-
@
|
687
|
+
@account_users_interface.setopts(options)
|
695
688
|
if options[:dry_run]
|
696
|
-
print_dry_run @
|
689
|
+
print_dry_run @account_users_interface.dry.destroy(account_id, user['id'])
|
697
690
|
return 0
|
698
691
|
end
|
699
|
-
json_response = @
|
692
|
+
json_response = @account_users_interface.destroy(account_id, user['id'])
|
700
693
|
|
701
694
|
if options[:json]
|
702
695
|
print JSON.pretty_generate(json_response)
|
@@ -766,7 +759,7 @@ EOT
|
|
766
759
|
end
|
767
760
|
end
|
768
761
|
|
769
|
-
available_roles = @
|
762
|
+
available_roles = @account_users_interface.available_roles(account_id, user_id)['roles']
|
770
763
|
|
771
764
|
if available_roles.empty?
|
772
765
|
print_red_alert "No available roles found."
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
2
|
+
# require 'morpheus/routes'
|
3
|
+
|
4
|
+
class Morpheus::Cli::View
|
5
|
+
include Morpheus::Cli::CliCommand
|
6
|
+
|
7
|
+
set_command_description "Open the remote appliance in a web browser"
|
8
|
+
set_command_name :'view'
|
9
|
+
|
10
|
+
def connect(opts)
|
11
|
+
@api_client = establish_remote_appliance_connection(opts)
|
12
|
+
end
|
13
|
+
|
14
|
+
def handle(args)
|
15
|
+
params = {}
|
16
|
+
options = {}
|
17
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
18
|
+
opts.banner = subcommand_usage("[path] [id]")
|
19
|
+
# debate: should login using /login/ouath-redirect
|
20
|
+
opts.on('-L', '--login', "Login with the CLI access token before loading the path." ) do
|
21
|
+
options[:login] = true
|
22
|
+
end
|
23
|
+
opts.on('--absolute', "Absolute path, do not search for a matching route to use") do
|
24
|
+
options[:absolute_path] = true
|
25
|
+
end
|
26
|
+
build_common_options(opts, options, [:dry_run, :remote])
|
27
|
+
opts.footer = <<-EOT
|
28
|
+
View the remote appliance in a web browser.
|
29
|
+
[path] is optional. This the path or resource type to load. The default is the index page "/".
|
30
|
+
[id] is optional. This is the resource name or id to be append to the path to load details of a specific object.
|
31
|
+
The [path] is matched against the #{prog_name} UI site map to find the best matching route.
|
32
|
+
Route matching is skipped if the path begins with a "/" or --absolute is used.
|
33
|
+
By default no authentication is not done and the existing web browser session used.
|
34
|
+
The --login option will authenticate via the CLI access token and create a new browser session.
|
35
|
+
|
36
|
+
Examples:
|
37
|
+
view --login
|
38
|
+
view monitoring
|
39
|
+
view user 1
|
40
|
+
view user administrator
|
41
|
+
view /infrastructure/clouds/2
|
42
|
+
EOT
|
43
|
+
end
|
44
|
+
optparse.parse!(args)
|
45
|
+
# verify_args!(args:args, optparse:optparse, min: 0, max: 2)
|
46
|
+
connect(options)
|
47
|
+
# todo: it would actually be cool to use the params and include them on the path..
|
48
|
+
# params.merge!(parse_query_options(options))
|
49
|
+
path, *ids = args
|
50
|
+
# default to index page "/"
|
51
|
+
path = path || "/"
|
52
|
+
if options[:absolute_path] != true
|
53
|
+
if path.start_with?("/")
|
54
|
+
# treat like absolute path, no lookup
|
55
|
+
else
|
56
|
+
# lookup best matching route from sitemap
|
57
|
+
# lookup plural routes first, so 'app' finds apps and not approvals
|
58
|
+
found_route = Morpheus::Routes.lookup(path)
|
59
|
+
if found_route
|
60
|
+
# Morpheus::Logging::DarkPrinter.puts "Found matching route: '#{path}' => '#{found_route}'" if Morpheus::Logging.debug?
|
61
|
+
path = found_route
|
62
|
+
else
|
63
|
+
# just use specified path
|
64
|
+
end
|
65
|
+
end
|
66
|
+
# always add a leading slash
|
67
|
+
path = path.start_with?("/") ? path : "/#{path}"
|
68
|
+
# append id(s) to path if passed
|
69
|
+
if ids.size > 0
|
70
|
+
# convert names to ids
|
71
|
+
# assume the last part of path is the type and use generic finder
|
72
|
+
# only lookup names, and allow any id
|
73
|
+
ids = ids.collect do |id|
|
74
|
+
if id.to_s !~ /\A\d{1,}\Z/
|
75
|
+
# assume the last part of path is the type
|
76
|
+
record_type = path.split("/").last
|
77
|
+
record = find_by_name(record_type, id)
|
78
|
+
if record.nil?
|
79
|
+
raise_command_error("[id] is invalid. No #{record_type} found for '#{id}'", args, optparse)
|
80
|
+
end
|
81
|
+
record['id'].to_s
|
82
|
+
else
|
83
|
+
id
|
84
|
+
end
|
85
|
+
end
|
86
|
+
path = "#{path}/" + ids.join("/")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
# build the link to use, either our path or oauth-redirect to that path
|
90
|
+
link = "#{@appliance_url}#{path}"
|
91
|
+
if options[:login]
|
92
|
+
# uh, this should need CGI::escape(path)
|
93
|
+
link = "#{@appliance_url}/login/oauth-redirect?access_token=#{@access_token}\\&redirectUri=#{path}"
|
94
|
+
end
|
95
|
+
if options[:dry_run]
|
96
|
+
print_system_command_dry_run(Morpheus::Util.open_url_command(link), options)
|
97
|
+
return 0, nil
|
98
|
+
end
|
99
|
+
return Morpheus::Util.open_url(link)
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -1,7 +1,3 @@
|
|
1
|
-
# require 'yaml'
|
2
|
-
require 'io/console'
|
3
|
-
require 'rest_client'
|
4
|
-
require 'optparse'
|
5
1
|
require 'morpheus/cli/cli_command'
|
6
2
|
|
7
3
|
# JD: I don't think a lot of this has ever worked, fix it up.
|
@@ -42,6 +38,9 @@ class Morpheus::Cli::VirtualImages
|
|
42
38
|
end
|
43
39
|
opts.on('--system', "System Images" ) do
|
44
40
|
options[:filterType] = 'System'
|
41
|
+
end
|
42
|
+
opts.on('--synced', "Synced Images" ) do
|
43
|
+
options[:filterType] = 'Synced'
|
45
44
|
end
|
46
45
|
opts.on('--tags Name=Value',String, "Filter by tags (metadata name value pairs).") do |val|
|
47
46
|
val.split(",").each do |value_pair|
|
@@ -55,7 +54,7 @@ class Morpheus::Cli::VirtualImages
|
|
55
54
|
options[:details] = true
|
56
55
|
end
|
57
56
|
build_standard_list_options(opts, options)
|
58
|
-
opts.footer = "List virtual images."
|
57
|
+
opts.footer = "List virtual images. Default list applies User filter"
|
59
58
|
end
|
60
59
|
optparse.parse!(args)
|
61
60
|
connect(options)
|
@@ -15,10 +15,10 @@ module Morpheus::Cli::AccountsHelper
|
|
15
15
|
@accounts_interface
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def account_users_interface
|
19
19
|
# @api_client.users
|
20
|
-
raise "#{self.class} has not defined @
|
21
|
-
@
|
20
|
+
raise "#{self.class} has not defined @account_users_interface" if @account_users_interface.nil?
|
21
|
+
@account_users_interface
|
22
22
|
end
|
23
23
|
|
24
24
|
def user_groups_interface
|
@@ -244,7 +244,7 @@ module Morpheus::Cli::AccountsHelper
|
|
244
244
|
|
245
245
|
def find_user_by_id(account_id, id, params={})
|
246
246
|
begin
|
247
|
-
json_response =
|
247
|
+
json_response = account_users_interface.get(account_id, id.to_i, params)
|
248
248
|
return json_response['user']
|
249
249
|
rescue RestClient::Exception => e
|
250
250
|
if e.response && e.response.code == 404
|
@@ -256,7 +256,7 @@ module Morpheus::Cli::AccountsHelper
|
|
256
256
|
end
|
257
257
|
|
258
258
|
def find_user_by_username(account_id, username, params={})
|
259
|
-
users =
|
259
|
+
users = account_users_interface.list(account_id, params.merge({username: username.to_s}))['users']
|
260
260
|
if users.empty?
|
261
261
|
print_red_alert "User not found by username #{username}"
|
262
262
|
return nil
|
@@ -105,12 +105,32 @@ module Morpheus::Cli::LoadBalancersHelper
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
108
|
-
def load_balancer_type_for_id(
|
109
|
-
|
108
|
+
def load_balancer_type_for_id(val)
|
109
|
+
record = get_available_load_balancer_types().find { |z| z['id'].to_i == val.to_i}
|
110
|
+
label = "Load Balancer Type"
|
111
|
+
if record.nil?
|
112
|
+
print_red_alert "#{label.downcase} not found by id #{val}"
|
113
|
+
return nil
|
114
|
+
end
|
115
|
+
return record
|
110
116
|
end
|
111
117
|
|
112
|
-
def load_balancer_type_for_name(
|
113
|
-
|
118
|
+
def load_balancer_type_for_name(val)
|
119
|
+
records = get_available_load_balancer_types().select { |z| z['name'].downcase == val.downcase || z['code'].downcase == val.downcase}
|
120
|
+
label = "Load Balancer Type"
|
121
|
+
if records.empty?
|
122
|
+
print_red_alert "#{label} not found by name '#{val}'"
|
123
|
+
return nil
|
124
|
+
elsif records.size > 1
|
125
|
+
print_red_alert "More than one #{label.downcase} found by name '#{val}'"
|
126
|
+
print_error "\n"
|
127
|
+
puts_error as_pretty_table(records, [:id, :name], {color:red})
|
128
|
+
print_red_alert "Try using ID instead"
|
129
|
+
print_error reset,"\n"
|
130
|
+
return nil
|
131
|
+
else
|
132
|
+
return records[0]
|
133
|
+
end
|
114
134
|
end
|
115
135
|
|
116
136
|
def find_load_balancer_type_by_name_or_id(val)
|
@@ -6,6 +6,7 @@ require 'ostruct'
|
|
6
6
|
require 'io/console'
|
7
7
|
require 'morpheus/logging'
|
8
8
|
require 'fileutils'
|
9
|
+
require 'filesize'
|
9
10
|
|
10
11
|
module Morpheus::Cli::PrintHelper
|
11
12
|
|
@@ -201,7 +202,7 @@ module Morpheus::Cli::PrintHelper
|
|
201
202
|
if options[:outfile]
|
202
203
|
print_result = print_to_file(output, options[:outfile], options[:overwrite])
|
203
204
|
# with_stdout_to_file(options[:outfile], options[:overwrite]) { print output }
|
204
|
-
print "#{cyan}Wrote output to file #{options[:outfile]} (#{format_bytes
|
205
|
+
print "#{cyan}Wrote output to file #{options[:outfile]} (#{format_bytes(File.size(options[:outfile]))})\n" unless options[:quiet]
|
205
206
|
#return print_result
|
206
207
|
return
|
207
208
|
end
|
@@ -219,6 +220,14 @@ module Morpheus::Cli::PrintHelper
|
|
219
220
|
return
|
220
221
|
end
|
221
222
|
|
223
|
+
def print_system_command_dry_run(cmd, options={})
|
224
|
+
print "\n"
|
225
|
+
print "#{cyan}#{bold}#{dark}SYSTEM COMMAND#{reset}\n"
|
226
|
+
print cmd
|
227
|
+
print reset, "\n"
|
228
|
+
return
|
229
|
+
end
|
230
|
+
|
222
231
|
def format_api_request(http_method, url, headers, payload=nil, options={})
|
223
232
|
out = ""
|
224
233
|
# out << "\n"
|
@@ -384,33 +393,57 @@ module Morpheus::Cli::PrintHelper
|
|
384
393
|
if json_response.nil? || json_response.empty?
|
385
394
|
return ""
|
386
395
|
end
|
387
|
-
|
388
|
-
# options = OpenStruct.new(options) # laff, let's do this instead
|
389
396
|
color = options.key?(:color) ? options[:color] : cyan
|
390
397
|
label = options[:label]
|
391
|
-
n_label = options[:n_label]
|
392
|
-
# label = n_label if !label && n_label
|
398
|
+
n_label = options[:n_label] || (label ? label.to_s.pluralize : nil)
|
393
399
|
message = options[:message] || "Viewing %{start_index}-%{end_index} of %{total} %{label}"
|
394
400
|
blank_message = options[:blank_message] || nil # "No %{label} found"
|
395
401
|
|
396
|
-
# support lazy passing of common json_response {"meta": {"size":
|
397
|
-
#
|
398
|
-
meta
|
399
|
-
if
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
#
|
404
|
-
|
405
|
-
|
406
|
-
|
402
|
+
# support lazy passing of common list json_response {"meta": {"size": 25, "total": 56} }
|
403
|
+
# priority is:
|
404
|
+
# 1. "meta" that api response contains for list endpoints
|
405
|
+
# 2. "total" and "size" values if passed explicitely by the cli (pretty sure symbols are no longer used)
|
406
|
+
# 3. examine the first array found in the response
|
407
|
+
meta = nil
|
408
|
+
records = nil
|
409
|
+
# assume records is the first array in the response
|
410
|
+
records_key = json_response.keys.find { |k| json_response[k].is_a?(Array) }
|
411
|
+
if records_key
|
412
|
+
records = json_response[records_key]
|
413
|
+
meta = {'offset' => 0, 'size' => records.size, 'total' => records.size}
|
414
|
+
end
|
415
|
+
if json_response[:meta] || json_response["meta"]
|
416
|
+
meta = json_response[:meta] || json_response["meta"]
|
417
|
+
elsif json_response.key?('size') || json_response.key?('total')
|
418
|
+
meta = json_response
|
419
|
+
elsif json_response.key?(:size) || json_response.key?(:total)
|
420
|
+
meta = {'size' => json_response[:size], 'total' => json_response[:total], 'offset' => json_response[:offset]}
|
421
|
+
elsif records
|
422
|
+
# just use the first key in the response
|
423
|
+
meta = {'size' => records.size, 'total' => records.size}
|
424
|
+
end
|
425
|
+
# did not find pagination meta info?
|
426
|
+
if meta.nil?
|
427
|
+
return ""
|
428
|
+
end
|
429
|
+
# api should not need to return the size, just use records.size
|
430
|
+
if meta["size"].nil? && records
|
431
|
+
meta["size"] = records.size
|
432
|
+
end
|
433
|
+
offset = meta['offset'].to_i
|
434
|
+
size = meta['size'].to_i
|
435
|
+
total = meta['total'].to_i
|
436
|
+
# perhaps no total count returned, let total be equal to size of list
|
437
|
+
if total == 0 && size > 0
|
407
438
|
total = size
|
408
439
|
end
|
440
|
+
# plural label?
|
409
441
|
if total != 1
|
410
|
-
label = n_label
|
442
|
+
label = n_label
|
411
443
|
end
|
412
444
|
out_str = ""
|
413
|
-
string_key_values = {start_index: format_number(offset + 1), end_index: format_number(offset + size),
|
445
|
+
string_key_values = {start_index: format_number(offset + 1), end_index: format_number(offset + size),
|
446
|
+
total: format_number(total), size: format_number(size), offset: format_number(offset), label: label}
|
414
447
|
if size > 0
|
415
448
|
if message
|
416
449
|
out_str << message % string_key_values
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'morpheus/cli/mixins/print_helper'
|
2
2
|
|
3
3
|
# Mixin for Morpheus::Cli command classes
|
4
|
-
# Provides common methods for
|
5
|
-
# The including class must establish @accounts_interface, @roles_interface, @users_interface
|
4
|
+
# Provides common methods for viewing process history
|
6
5
|
module Morpheus::Cli::ProcessesHelper
|
7
6
|
|
8
7
|
def self.included(klass)
|