morpheus-cli 5.3.2.3 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/account_users_interface.rb +68 -0
- data/lib/morpheus/api/api_client.rb +75 -8
- data/lib/morpheus/api/audit_interface.rb +9 -0
- data/lib/morpheus/api/clouds_interface.rb +4 -11
- data/lib/morpheus/api/health_interface.rb +37 -3
- data/lib/morpheus/api/instances_interface.rb +39 -5
- data/lib/morpheus/api/load_balancer_monitors_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +9 -0
- data/lib/morpheus/api/load_balancers_interface.rb +5 -0
- data/lib/morpheus/api/network_dhcp_relays_interface.rb +36 -0
- data/lib/morpheus/api/network_dhcp_servers_interface.rb +36 -0
- data/lib/morpheus/api/network_edge_clusters_interface.rb +26 -0
- data/lib/morpheus/api/network_routers_interface.rb +30 -0
- data/lib/morpheus/api/network_servers_interface.rb +98 -0
- data/lib/morpheus/api/network_static_routes_interface.rb +36 -0
- data/lib/morpheus/api/read_interface.rb +4 -3
- data/lib/morpheus/api/rest_interface.rb +5 -4
- data/lib/morpheus/api/roles_interface.rb +7 -0
- data/lib/morpheus/api/secondary_read_interface.rb +1 -1
- data/lib/morpheus/api/secondary_rest_interface.rb +19 -19
- data/lib/morpheus/api/storage_server_types_interface.rb +14 -0
- data/lib/morpheus/api/storage_servers_interface.rb +9 -0
- data/lib/morpheus/api/storage_volume_types_interface.rb +9 -0
- data/lib/morpheus/api/storage_volumes_interface.rb +9 -0
- data/lib/morpheus/api/users_interface.rb +16 -63
- data/lib/morpheus/api/virtual_images_interface.rb +23 -2
- data/lib/morpheus/api/virtual_servers_interface.rb +9 -0
- data/lib/morpheus/cli/cli_command.rb +274 -19
- data/lib/morpheus/cli/cli_registry.rb +56 -2
- data/lib/morpheus/cli/{access_token_command.rb → commands/access_token_command.rb} +1 -1
- data/lib/morpheus/cli/{account_groups_command.rb → commands/account_groups_command.rb} +0 -8
- data/lib/morpheus/cli/{activity_command.rb → commands/activity_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/alias_command.rb → alias_command.rb} +1 -4
- data/lib/morpheus/cli/{appliance_settings_command.rb → commands/appliance_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{approvals_command.rb → commands/approvals_command.rb} +0 -0
- data/lib/morpheus/cli/{apps.rb → commands/apps.rb} +17 -89
- data/lib/morpheus/cli/{archives_command.rb → commands/archives_command.rb} +0 -6
- data/lib/morpheus/cli/commands/audit.rb +188 -0
- data/lib/morpheus/cli/{backup_jobs_command.rb → commands/backup_jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{backup_settings_command.rb → commands/backup_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{backups_command.rb → commands/backups_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/benchmark_command.rb → benchmark_command.rb} +0 -3
- data/lib/morpheus/cli/{blueprints_command.rb → commands/blueprints_command.rb} +1 -1
- data/lib/morpheus/cli/{boot_scripts_command.rb → commands/boot_scripts_command.rb} +0 -3
- data/lib/morpheus/cli/{budgets_command.rb → commands/budgets_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/cat_command.rb → cat_command.rb} +0 -0
- data/lib/morpheus/cli/{catalog_item_types_command.rb → commands/catalog_item_types_command.rb} +0 -0
- data/lib/morpheus/cli/{certificates_command.rb → commands/certificates_command.rb} +0 -0
- data/lib/morpheus/cli/commands/change_password_command.rb +132 -0
- data/lib/morpheus/cli/{cloud_datastores_command.rb → commands/cloud_datastores_command.rb} +0 -4
- data/lib/morpheus/cli/{cloud_folders_command.rb → commands/cloud_folders_command.rb} +0 -4
- data/lib/morpheus/cli/{cloud_resource_pools_command.rb → commands/cloud_resource_pools_command.rb} +170 -138
- data/lib/morpheus/cli/{clouds.rb → commands/clouds.rb} +22 -47
- data/lib/morpheus/cli/{clusters.rb → commands/clusters.rb} +86 -49
- data/lib/morpheus/cli/commands/{standard/coloring_command.rb → coloring_command.rb} +0 -2
- data/lib/morpheus/cli/{containers_command.rb → commands/containers_command.rb} +0 -7
- data/lib/morpheus/cli/commands/{standard/curl_command.rb → curl_command.rb} +0 -3
- data/lib/morpheus/cli/{cypher_command.rb → commands/cypher_command.rb} +0 -1
- data/lib/morpheus/cli/{dashboard_command.rb → commands/dashboard_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/debug_command.rb → debug_command.rb} +0 -1
- data/lib/morpheus/cli/{deploy.rb → commands/deploy.rb} +0 -1
- data/lib/morpheus/cli/{deployments.rb → commands/deployments.rb} +0 -0
- data/lib/morpheus/cli/{deploys.rb → commands/deploys.rb} +0 -1
- data/lib/morpheus/cli/{doc.rb → commands/doc.rb} +1 -1
- data/lib/morpheus/cli/commands/{standard/echo_command.rb → echo_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/edit_profile_command.rb → edit_profile_command.rb} +15 -4
- data/lib/morpheus/cli/commands/{standard/edit_rc_command.rb → edit_rc_command.rb} +19 -3
- data/lib/morpheus/cli/{environments_command.rb → commands/environments_command.rb} +0 -5
- data/lib/morpheus/cli/{execute_schedules_command.rb → commands/execute_schedules_command.rb} +0 -0
- data/lib/morpheus/cli/{execution_request_command.rb → commands/execution_request_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/exit_command.rb → exit_command.rb} +0 -2
- data/lib/morpheus/cli/{file_copy_request_command.rb → commands/file_copy_request_command.rb} +0 -4
- data/lib/morpheus/cli/{forgot_password.rb → commands/forgot_password.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/get_prompt_command.rb → get_prompt_command.rb} +0 -3
- data/lib/morpheus/cli/{groups.rb → commands/groups.rb} +0 -7
- data/lib/morpheus/cli/{guidance_command.rb → commands/guidance_command.rb} +1 -1
- data/lib/morpheus/cli/{health_command.rb → commands/health_command.rb} +104 -19
- data/lib/morpheus/cli/commands/{standard/history_command.rb → history_command.rb} +0 -3
- data/lib/morpheus/cli/{hosts.rb → commands/hosts.rb} +15 -25
- data/lib/morpheus/cli/{image_builder_command.rb → commands/image_builder_command.rb} +2 -8
- data/lib/morpheus/cli/{instance_types.rb → commands/instance_types.rb} +0 -3
- data/lib/morpheus/cli/{instances.rb → commands/instances.rb} +473 -150
- data/lib/morpheus/cli/{integrations_command.rb → commands/integrations_command.rb} +0 -0
- data/lib/morpheus/cli/{invoices_command.rb → commands/invoices_command.rb} +118 -134
- data/lib/morpheus/cli/{jobs_command.rb → commands/jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{key_pairs.rb → commands/key_pairs.rb} +0 -6
- data/lib/morpheus/cli/{library_cluster_layouts_command.rb → commands/library_cluster_layouts_command.rb} +20 -4
- data/lib/morpheus/cli/{library_container_scripts_command.rb → commands/library_container_scripts_command.rb} +0 -0
- data/lib/morpheus/cli/{library_container_templates_command.rb → commands/library_container_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_container_types_command.rb → commands/library_container_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_instance_types_command.rb → commands/library_instance_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_layouts_command.rb → commands/library_layouts_command.rb} +0 -4
- data/lib/morpheus/cli/{library_option_lists_command.rb → commands/library_option_lists_command.rb} +3 -7
- data/lib/morpheus/cli/{library_option_types_command.rb → commands/library_option_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_spec_templates_command.rb → commands/library_spec_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_upgrades_command.rb → commands/library_upgrades_command.rb} +0 -4
- data/lib/morpheus/cli/{license.rb → commands/license.rb} +0 -3
- data/lib/morpheus/cli/commands/load_balancer_monitors.rb +71 -0
- data/lib/morpheus/cli/commands/load_balancer_pools.rb +91 -0
- data/lib/morpheus/cli/commands/load_balancer_profiles.rb +65 -0
- data/lib/morpheus/cli/{load_balancer_types.rb → commands/load_balancer_types.rb} +9 -8
- data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +156 -0
- data/lib/morpheus/cli/commands/load_balancers.rb +176 -0
- data/lib/morpheus/cli/commands/{standard/log_level_command.rb → log_level_command.rb} +0 -3
- data/lib/morpheus/cli/{log_settings_command.rb → commands/log_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{login.rb → commands/login.rb} +0 -5
- data/lib/morpheus/cli/commands/logout.rb +63 -0
- data/lib/morpheus/cli/{logs_command.rb → commands/logs_command.rb} +0 -3
- data/lib/morpheus/cli/commands/{standard/man_command.rb → man_command.rb} +0 -2
- data/lib/morpheus/cli/{monitoring_alerts_command.rb → commands/monitoring_alerts_command.rb} +0 -7
- data/lib/morpheus/cli/{monitoring_apps_command.rb → commands/monitoring_apps_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_checks_command.rb → commands/monitoring_checks_command.rb} +2 -1
- data/lib/morpheus/cli/{monitoring_contacts_command.rb → commands/monitoring_contacts_command.rb} +0 -7
- data/lib/morpheus/cli/{monitoring_groups_command.rb → commands/monitoring_groups_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_incidents_command.rb → commands/monitoring_incidents_command.rb} +0 -1
- data/lib/morpheus/cli/commands/network_dhcp_relays_command.rb +416 -0
- data/lib/morpheus/cli/commands/network_dhcp_servers_command.rb +407 -0
- data/lib/morpheus/cli/{network_domains_command.rb → commands/network_domains_command.rb} +0 -4
- data/lib/morpheus/cli/commands/network_edge_clusters_command.rb +329 -0
- data/lib/morpheus/cli/commands/network_firewalls_command.rb +823 -0
- data/lib/morpheus/cli/{network_groups_command.rb → commands/network_groups_command.rb} +0 -4
- data/lib/morpheus/cli/{network_pool_servers_command.rb → commands/network_pool_servers_command.rb} +0 -4
- data/lib/morpheus/cli/{network_pools_command.rb → commands/network_pools_command.rb} +0 -4
- data/lib/morpheus/cli/{network_proxies_command.rb → commands/network_proxies_command.rb} +0 -4
- data/lib/morpheus/cli/{network_routers_command.rb → commands/network_routers_command.rb} +387 -57
- data/lib/morpheus/cli/{network_services_command.rb → commands/network_services_command.rb} +0 -4
- data/lib/morpheus/cli/commands/network_static_routes_command.rb +446 -0
- data/lib/morpheus/cli/commands/network_transport_zones_command.rb +452 -0
- data/lib/morpheus/cli/{networks_command.rb → commands/networks_command.rb} +21 -21
- data/lib/morpheus/cli/commands/open_command.rb +30 -0
- data/lib/morpheus/cli/commands/options.rb +98 -0
- data/lib/morpheus/cli/{packages_command.rb → commands/packages_command.rb} +0 -2
- data/lib/morpheus/cli/{ping.rb → commands/ping.rb} +0 -7
- data/lib/morpheus/cli/{policies_command.rb → commands/policies_command.rb} +1 -8
- data/lib/morpheus/cli/{power_schedules_command.rb → commands/power_schedules_command.rb} +0 -0
- data/lib/morpheus/cli/{preseed_scripts_command.rb → commands/preseed_scripts_command.rb} +0 -3
- data/lib/morpheus/cli/{price_sets_command.rb → commands/price_sets_command.rb} +0 -0
- data/lib/morpheus/cli/{prices_command.rb → commands/prices_command.rb} +7 -7
- data/lib/morpheus/cli/{processes_command.rb → commands/processes_command.rb} +0 -1
- data/lib/morpheus/cli/{projects_command.rb → commands/projects_command.rb} +0 -0
- data/lib/morpheus/cli/{provisioning_licenses_command.rb → commands/provisioning_licenses_command.rb} +0 -0
- data/lib/morpheus/cli/{provisioning_settings_command.rb → commands/provisioning_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{recent_activity_command.rb → commands/recent_activity_command.rb} +0 -0
- data/lib/morpheus/cli/{remote.rb → commands/remote.rb} +5 -9
- data/lib/morpheus/cli/{reports_command.rb → commands/reports_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/rm_command.rb → rm_command.rb} +0 -0
- data/lib/morpheus/cli/{roles.rb → commands/roles.rb} +245 -40
- data/lib/morpheus/cli/{search_command.rb → commands/search_command.rb} +0 -0
- data/lib/morpheus/cli/{security_group_rules.rb → commands/security_group_rules.rb} +0 -5
- data/lib/morpheus/cli/{security_groups.rb → commands/security_groups.rb} +0 -6
- data/lib/morpheus/cli/{service_catalog_command.rb → commands/service_catalog_command.rb} +0 -0
- data/lib/morpheus/cli/{service_plans_command.rb → commands/service_plans_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/set_prompt_command.rb → set_prompt_command.rb} +0 -3
- data/lib/morpheus/cli/{setup.rb → commands/setup.rb} +0 -0
- data/lib/morpheus/cli/{shell.rb → commands/shell.rb} +4 -105
- data/lib/morpheus/cli/commands/{standard/sleep_command.rb → sleep_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/source_command.rb → source_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/ssl_verification_command.rb → ssl_verification_command.rb} +0 -3
- data/lib/morpheus/cli/{storage_providers_command.rb → commands/storage_providers_command.rb} +0 -4
- data/lib/morpheus/cli/commands/storage_server_types.rb +50 -0
- data/lib/morpheus/cli/commands/storage_servers.rb +122 -0
- data/lib/morpheus/cli/commands/storage_volume_types.rb +50 -0
- data/lib/morpheus/cli/commands/storage_volumes.rb +103 -0
- data/lib/morpheus/cli/{subnets_command.rb → commands/subnets_command.rb} +7 -6
- data/lib/morpheus/cli/{tasks.rb → commands/tasks.rb} +25 -6
- data/lib/morpheus/cli/commands/{standard/tee_command.rb → tee_command.rb} +0 -0
- data/lib/morpheus/cli/{tenants_command.rb → commands/tenants_command.rb} +1 -8
- data/lib/morpheus/cli/commands/{standard/update_command.rb → update_command.rb} +0 -1
- data/lib/morpheus/cli/{usage_command.rb → commands/usage_command.rb} +0 -0
- data/lib/morpheus/cli/{user_groups_command.rb → commands/user_groups_command.rb} +1 -2
- data/lib/morpheus/cli/{user_settings_command.rb → commands/user_settings_command.rb} +2 -1
- data/lib/morpheus/cli/{user_sources_command.rb → commands/user_sources_command.rb} +1 -2
- data/lib/morpheus/cli/{users.rb → commands/users.rb} +28 -35
- data/lib/morpheus/cli/{vdi_allocations_command.rb → commands/vdi_allocations_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_apps_command.rb → commands/vdi_apps_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_command.rb → commands/vdi_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_gateways_command.rb → commands/vdi_gateways_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_pools_command.rb → commands/vdi_pools_command.rb} +4 -1
- data/lib/morpheus/cli/commands/{standard/version_command.rb → version_command.rb} +0 -0
- data/lib/morpheus/cli/commands/view.rb +102 -0
- data/lib/morpheus/cli/{virtual_images.rb → commands/virtual_images.rb} +251 -33
- data/lib/morpheus/cli/{whitelabel_settings_command.rb → commands/whitelabel_settings_command.rb} +0 -1
- data/lib/morpheus/cli/{whoami.rb → commands/whoami.rb} +0 -4
- data/lib/morpheus/cli/{wiki_command.rb → commands/wiki_command.rb} +0 -5
- data/lib/morpheus/cli/{workflows.rb → commands/workflows.rb} +0 -3
- data/lib/morpheus/cli/mixins/accounts_helper.rb +5 -5
- data/lib/morpheus/cli/mixins/load_balancers_helper.rb +26 -6
- data/lib/morpheus/cli/mixins/logs_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +51 -18
- data/lib/morpheus/cli/mixins/processes_helper.rb +1 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +167 -110
- data/lib/morpheus/cli/mixins/rest_command.rb +268 -94
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +668 -0
- data/lib/morpheus/cli/mixins/storage_servers_helper.rb +156 -0
- data/lib/morpheus/cli/mixins/storage_volumes_helper.rb +119 -0
- data/lib/morpheus/cli/option_parser.rb +25 -17
- data/lib/morpheus/cli/option_types.rb +137 -52
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +6 -128
- data/lib/morpheus/ext/string.rb +29 -6
- data/lib/morpheus/routes.rb +238 -0
- data/lib/morpheus/terminal.rb +5 -6
- data/lib/morpheus/util.rb +6 -1
- data/morpheus-cli.gemspec +1 -1
- metadata +183 -149
- data/lib/morpheus/cli/change_password_command.rb +0 -147
- data/lib/morpheus/cli/library.rb +0 -1
- data/lib/morpheus/cli/load_balancers.rb +0 -245
- data/lib/morpheus/cli/logout.rb +0 -81
|
@@ -1,26 +1,26 @@
|
|
|
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 'morpheus/cli/mixins/provisioning_helper'
|
|
9
|
-
require 'json'
|
|
10
2
|
|
|
11
3
|
class Morpheus::Cli::Roles
|
|
12
4
|
include Morpheus::Cli::CliCommand
|
|
13
5
|
include Morpheus::Cli::AccountsHelper
|
|
14
6
|
include Morpheus::Cli::ProvisioningHelper
|
|
15
7
|
include Morpheus::Cli::WhoamiHelper
|
|
16
|
-
register_subcommands :list, :get, :add, :update, :remove,
|
|
8
|
+
register_subcommands :list, :get, :add, :update, :remove,
|
|
9
|
+
:'list-permissions', :'update-feature-access', :'update-global-group-access',
|
|
10
|
+
:'update-group-access', :'update-global-cloud-access', :'update-cloud-access',
|
|
11
|
+
:'update-global-instance-type-access', :'update-instance-type-access',
|
|
12
|
+
:'update-global-blueprint-access', :'update-blueprint-access',
|
|
13
|
+
:'update-global-catalog-item-type-access', :'update-catalog-item-type-access',
|
|
14
|
+
:'update-persona-access',
|
|
15
|
+
:'update-global-vdi-pool-access', :'update-vdi-pool-access',
|
|
16
|
+
:'update-global-report-type-access', :'update-report-type-access'
|
|
17
17
|
alias_subcommand :details, :get
|
|
18
18
|
set_default_subcommand :list
|
|
19
19
|
|
|
20
20
|
def connect(opts)
|
|
21
21
|
@api_client = establish_remote_appliance_connection(opts)
|
|
22
22
|
@whoami_interface = @api_client.whoami
|
|
23
|
-
@
|
|
23
|
+
@account_users_interface = @api_client.account_users
|
|
24
24
|
@accounts_interface = @api_client.accounts
|
|
25
25
|
@roles_interface = @api_client.roles
|
|
26
26
|
@groups_interface = @api_client.groups
|
|
@@ -110,6 +110,9 @@ class Morpheus::Cli::Roles
|
|
|
110
110
|
opts.on(nil,'--vdi-pool-access', "Display VDI Pool Access") do
|
|
111
111
|
options[:include_vdi_pool_access] = true
|
|
112
112
|
end
|
|
113
|
+
opts.on(nil,'--report-type-access', "Display Report Type Access") do
|
|
114
|
+
options[:include_report_type_access] = true
|
|
115
|
+
end
|
|
113
116
|
opts.on('-a','--all', "Display All Access Lists") do
|
|
114
117
|
options[:include_feature_access] = true
|
|
115
118
|
options[:include_group_access] = true
|
|
@@ -119,6 +122,7 @@ class Morpheus::Cli::Roles
|
|
|
119
122
|
options[:include_catalog_item_type_access] = true
|
|
120
123
|
options[:include_personas_access] = true
|
|
121
124
|
options[:include_vdi_pool_access] = true
|
|
125
|
+
options[:include_report_type_access] = true
|
|
122
126
|
end
|
|
123
127
|
build_standard_get_options(opts, options)
|
|
124
128
|
opts.footer = <<-EOT
|
|
@@ -225,6 +229,7 @@ EOT
|
|
|
225
229
|
"Blueprints" => lambda {|it| get_access_string(it['globalAppTemplateAccess'] || it['globalBlueprintAccess']) },
|
|
226
230
|
"Catalog Item Types" => lambda {|it| get_access_string(it['globalCatalogItemTypeAccess']) },
|
|
227
231
|
"VDI Pools" => lambda {|it| get_access_string(it['globalVdiPoolAccess']) },
|
|
232
|
+
"Report Types" => lambda {|it| get_access_string(it['globalReportTypeAccess']) },
|
|
228
233
|
}
|
|
229
234
|
if role['roleType'].to_s.downcase == 'account'
|
|
230
235
|
global_access_columns.delete("Groups")
|
|
@@ -378,7 +383,7 @@ EOT
|
|
|
378
383
|
rows = vdi_pool_permissions.collect do |it|
|
|
379
384
|
{
|
|
380
385
|
name: it['name'],
|
|
381
|
-
access: format_access_string(it['access'], ["none","
|
|
386
|
+
access: format_access_string(it['access'], ["none","full"]),
|
|
382
387
|
}
|
|
383
388
|
end
|
|
384
389
|
print as_pretty_table(rows, [:name, :access], options)
|
|
@@ -390,6 +395,27 @@ EOT
|
|
|
390
395
|
# print cyan,bold,"VDI Pool Access: #{get_access_string(json_response['globalVdiPoolAccess'])}",reset,"\n"
|
|
391
396
|
end
|
|
392
397
|
|
|
398
|
+
report_type_global_access = json_response['globalReportTypeAccess']
|
|
399
|
+
report_type_permissions = json_response['reportTypePermissions'] || []
|
|
400
|
+
print cyan
|
|
401
|
+
if report_type_global_access == 'custom'
|
|
402
|
+
print_h2 "Report Type Access", options
|
|
403
|
+
if options[:include_report_type_access]
|
|
404
|
+
rows = report_type_permissions.collect do |it|
|
|
405
|
+
{
|
|
406
|
+
name: it['name'],
|
|
407
|
+
access: format_access_string(it['access'], ["none","full"]),
|
|
408
|
+
}
|
|
409
|
+
end
|
|
410
|
+
print as_pretty_table(rows, [:name, :access], options)
|
|
411
|
+
else
|
|
412
|
+
print cyan,"Use --report-type-access to list custom access","\n"
|
|
413
|
+
end
|
|
414
|
+
else
|
|
415
|
+
# print "\n"
|
|
416
|
+
# print cyan,bold,"Report Type Access: #{get_access_string(json_response['globalReportTypeAccess'])}",reset,"\n"
|
|
417
|
+
end
|
|
418
|
+
|
|
393
419
|
end
|
|
394
420
|
print reset,"\n"
|
|
395
421
|
|
|
@@ -765,6 +791,11 @@ EOT
|
|
|
765
791
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
766
792
|
opts.banner = subcommand_usage("[name] [full|read|custom|none]")
|
|
767
793
|
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
794
|
+
opts.footer = <<-EOT
|
|
795
|
+
Update global group access for a role.
|
|
796
|
+
[role] is required. This is the name (authority) or id of a role.
|
|
797
|
+
[access] is required. This is the access level to assign: full, read, custom or none.
|
|
798
|
+
EOT
|
|
768
799
|
end
|
|
769
800
|
optparse.parse!(args)
|
|
770
801
|
|
|
@@ -844,16 +875,14 @@ EOT
|
|
|
844
875
|
access_value = args[2] if args[2]
|
|
845
876
|
end
|
|
846
877
|
if !group_id && !do_all
|
|
847
|
-
raise_command_error("missing required argument: [group] or --all", optparse)
|
|
878
|
+
raise_command_error("missing required argument: [group] or --all", args, optparse)
|
|
848
879
|
end
|
|
849
880
|
if !access_value
|
|
850
|
-
raise_command_error("missing required argument: [access]", optparse)
|
|
881
|
+
raise_command_error("missing required argument: [access]", args, optparse)
|
|
851
882
|
end
|
|
852
883
|
access_value = access_value.to_s.downcase
|
|
853
884
|
if !allowed_access_values.include?(access_value)
|
|
854
|
-
raise_command_error("invalid access value: #{access_value}", optparse)
|
|
855
|
-
puts optparse
|
|
856
|
-
return 1
|
|
885
|
+
raise_command_error("invalid access value: #{access_value}", args, optparse)
|
|
857
886
|
end
|
|
858
887
|
|
|
859
888
|
connect(options)
|
|
@@ -915,6 +944,11 @@ EOT
|
|
|
915
944
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
916
945
|
opts.banner = subcommand_usage("[name] [full|custom|none]")
|
|
917
946
|
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
947
|
+
opts.footer = <<-EOT
|
|
948
|
+
Update global cloud access for a role.
|
|
949
|
+
[role] is required. This is the name (authority) or id of a role.
|
|
950
|
+
[access] is required. This is the access level to assign: full, custom or none.
|
|
951
|
+
EOT
|
|
918
952
|
end
|
|
919
953
|
optparse.parse!(args)
|
|
920
954
|
|
|
@@ -993,16 +1027,14 @@ EOT
|
|
|
993
1027
|
access_value = args[2] if args[2]
|
|
994
1028
|
end
|
|
995
1029
|
if !cloud_id && !do_all
|
|
996
|
-
raise_command_error("missing required argument: [cloud] or --all", optparse)
|
|
1030
|
+
raise_command_error("missing required argument: [cloud] or --all", args, optparse)
|
|
997
1031
|
end
|
|
998
1032
|
if !access_value
|
|
999
|
-
raise_command_error("missing required argument: [access]", optparse)
|
|
1033
|
+
raise_command_error("missing required argument: [access]", args, optparse)
|
|
1000
1034
|
end
|
|
1001
1035
|
access_value = access_value.to_s.downcase
|
|
1002
1036
|
if !allowed_access_values.include?(access_value)
|
|
1003
|
-
raise_command_error("invalid access value: #{access_value}", optparse)
|
|
1004
|
-
puts optparse
|
|
1005
|
-
return 1
|
|
1037
|
+
raise_command_error("invalid access value: #{access_value}", args, optparse)
|
|
1006
1038
|
end
|
|
1007
1039
|
|
|
1008
1040
|
connect(options)
|
|
@@ -1063,6 +1095,11 @@ EOT
|
|
|
1063
1095
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1064
1096
|
opts.banner = subcommand_usage("[role] [full|custom|none]")
|
|
1065
1097
|
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
1098
|
+
opts.footer = <<-EOT
|
|
1099
|
+
Update global instance type access for a role.
|
|
1100
|
+
[role] is required. This is the name (authority) or id of a role.
|
|
1101
|
+
[access] is required. This is the access level to assign: full, custom or none.
|
|
1102
|
+
EOT
|
|
1066
1103
|
end
|
|
1067
1104
|
optparse.parse!(args)
|
|
1068
1105
|
|
|
@@ -1209,6 +1246,11 @@ EOT
|
|
|
1209
1246
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1210
1247
|
opts.banner = subcommand_usage("[role] [full|custom|none]")
|
|
1211
1248
|
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
1249
|
+
opts.footer = <<-EOT
|
|
1250
|
+
Update global blueprint access for a role.
|
|
1251
|
+
[role] is required. This is the name (authority) or id of a role.
|
|
1252
|
+
[access] is required. This is the access level to assign: full, custom or none.
|
|
1253
|
+
EOT
|
|
1212
1254
|
end
|
|
1213
1255
|
optparse.parse!(args)
|
|
1214
1256
|
|
|
@@ -1288,16 +1330,14 @@ EOT
|
|
|
1288
1330
|
access_value = args[2] if args[2]
|
|
1289
1331
|
end
|
|
1290
1332
|
if !blueprint_id && !do_all
|
|
1291
|
-
raise_command_error("missing required argument: [blueprint] or --all", optparse)
|
|
1333
|
+
raise_command_error("missing required argument: [blueprint] or --all", args, optparse)
|
|
1292
1334
|
end
|
|
1293
1335
|
if !access_value
|
|
1294
|
-
raise_command_error("missing required argument: [access]", optparse)
|
|
1336
|
+
raise_command_error("missing required argument: [access]", args, optparse)
|
|
1295
1337
|
end
|
|
1296
1338
|
access_value = access_value.to_s.downcase
|
|
1297
1339
|
if !allowed_access_values.include?(access_value)
|
|
1298
|
-
raise_command_error("invalid access value: #{access_value}", optparse)
|
|
1299
|
-
puts optparse
|
|
1300
|
-
return 1
|
|
1340
|
+
raise_command_error("invalid access value: #{access_value}", args, optparse)
|
|
1301
1341
|
end
|
|
1302
1342
|
|
|
1303
1343
|
connect(options)
|
|
@@ -1370,6 +1410,11 @@ EOT
|
|
|
1370
1410
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1371
1411
|
opts.banner = subcommand_usage("[role] [full|custom|none]")
|
|
1372
1412
|
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
1413
|
+
opts.footer = <<-EOT
|
|
1414
|
+
Update global catalog item type access for a role.
|
|
1415
|
+
[role] is required. This is the name (authority) or id of a role.
|
|
1416
|
+
[access] is required. This is the access level to assign: full, custom or none.
|
|
1417
|
+
EOT
|
|
1373
1418
|
end
|
|
1374
1419
|
optparse.parse!(args)
|
|
1375
1420
|
|
|
@@ -1449,16 +1494,14 @@ EOT
|
|
|
1449
1494
|
access_value = args[2] if args[2]
|
|
1450
1495
|
end
|
|
1451
1496
|
if !catalog_item_type_id && !do_all
|
|
1452
|
-
raise_command_error("missing required argument: [catalog-item-type] or --all", optparse)
|
|
1497
|
+
raise_command_error("missing required argument: [catalog-item-type] or --all", args, optparse)
|
|
1453
1498
|
end
|
|
1454
1499
|
if !access_value
|
|
1455
|
-
raise_command_error("missing required argument: [access]", optparse)
|
|
1500
|
+
raise_command_error("missing required argument: [access]", args, optparse)
|
|
1456
1501
|
end
|
|
1457
1502
|
access_value = access_value.to_s.downcase
|
|
1458
1503
|
if !allowed_access_values.include?(access_value)
|
|
1459
|
-
raise_command_error("invalid access value: #{access_value}", optparse)
|
|
1460
|
-
puts optparse
|
|
1461
|
-
return 1
|
|
1504
|
+
raise_command_error("invalid access value: #{access_value}", args, optparse)
|
|
1462
1505
|
end
|
|
1463
1506
|
|
|
1464
1507
|
connect(options)
|
|
@@ -1561,16 +1604,14 @@ EOT
|
|
|
1561
1604
|
access_value = args[2] if args[2]
|
|
1562
1605
|
end
|
|
1563
1606
|
if !persona_id && !do_all
|
|
1564
|
-
raise_command_error("missing required argument: [persona] or --all", optparse)
|
|
1607
|
+
raise_command_error("missing required argument: [persona] or --all", args, optparse)
|
|
1565
1608
|
end
|
|
1566
1609
|
if !access_value
|
|
1567
|
-
raise_command_error("missing required argument: [access]", optparse)
|
|
1610
|
+
raise_command_error("missing required argument: [access]", args, optparse)
|
|
1568
1611
|
end
|
|
1569
1612
|
access_value = access_value.to_s.downcase
|
|
1570
1613
|
if !allowed_access_values.include?(access_value)
|
|
1571
|
-
raise_command_error("invalid access value: #{access_value}", optparse)
|
|
1572
|
-
puts optparse
|
|
1573
|
-
return 1
|
|
1614
|
+
raise_command_error("invalid access value: #{access_value}", args, optparse)
|
|
1574
1615
|
end
|
|
1575
1616
|
|
|
1576
1617
|
connect(options)
|
|
@@ -1622,13 +1663,18 @@ EOT
|
|
|
1622
1663
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1623
1664
|
opts.banner = subcommand_usage("[role] [full|custom|none]")
|
|
1624
1665
|
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
1666
|
+
opts.footer = <<-EOT
|
|
1667
|
+
Update global VDI pool access for a role.
|
|
1668
|
+
[role] is required. This is the name (authority) or id of a role.
|
|
1669
|
+
[access] is required. This is the access level to assign: full, custom or none.
|
|
1670
|
+
EOT
|
|
1625
1671
|
end
|
|
1626
1672
|
optparse.parse!(args)
|
|
1627
1673
|
verify_args!(args:args, optparse:optparse, count: 2)
|
|
1628
1674
|
name = args[0]
|
|
1629
1675
|
access_value = args[1].to_s.downcase
|
|
1630
1676
|
if !['full', 'custom', 'none'].include?(access_value)
|
|
1631
|
-
raise_command_error("invalid access value: #{args[1]}", optparse)
|
|
1677
|
+
raise_command_error("invalid access value: #{args[1]}", args, optparse)
|
|
1632
1678
|
end
|
|
1633
1679
|
|
|
1634
1680
|
|
|
@@ -1696,14 +1742,14 @@ EOT
|
|
|
1696
1742
|
access_value = args[2] if args[2]
|
|
1697
1743
|
end
|
|
1698
1744
|
if !vdi_pool_id && !do_all
|
|
1699
|
-
raise_command_error("missing required argument: [vdi-pool] or --all", optparse)
|
|
1745
|
+
raise_command_error("missing required argument: [vdi-pool] or --all", args, optparse)
|
|
1700
1746
|
end
|
|
1701
1747
|
if !access_value
|
|
1702
|
-
raise_command_error("missing required argument: [access]", optparse)
|
|
1748
|
+
raise_command_error("missing required argument: [access]", args, optparse)
|
|
1703
1749
|
end
|
|
1704
1750
|
access_value = access_value.to_s.downcase
|
|
1705
1751
|
if !allowed_access_values.include?(access_value)
|
|
1706
|
-
raise_command_error("invalid access value: #{access_value}", optparse)
|
|
1752
|
+
raise_command_error("invalid access value: #{access_value}", args, optparse)
|
|
1707
1753
|
puts optparse
|
|
1708
1754
|
return 1
|
|
1709
1755
|
end
|
|
@@ -1770,6 +1816,165 @@ EOT
|
|
|
1770
1816
|
end
|
|
1771
1817
|
end
|
|
1772
1818
|
|
|
1819
|
+
def update_global_report_type_access(args)
|
|
1820
|
+
usage = "Usage: morpheus roles update-global-report-type-access [role] [full|custom|none]"
|
|
1821
|
+
options = {}
|
|
1822
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1823
|
+
opts.banner = subcommand_usage("[role] [full|custom|none]")
|
|
1824
|
+
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
1825
|
+
opts.footer = <<-EOT
|
|
1826
|
+
Update global report type access for a role.
|
|
1827
|
+
[role] is required. This is the name (authority) or id of a role.
|
|
1828
|
+
[access] is required. This is the access level to assign: full, custom or none.
|
|
1829
|
+
EOT
|
|
1830
|
+
end
|
|
1831
|
+
optparse.parse!(args)
|
|
1832
|
+
verify_args!(args:args, optparse:optparse, count: 2)
|
|
1833
|
+
name = args[0]
|
|
1834
|
+
access_value = args[1].to_s.downcase
|
|
1835
|
+
if !['full', 'custom', 'none'].include?(access_value)
|
|
1836
|
+
raise_command_error("invalid access value: #{args[1]}", args, optparse)
|
|
1837
|
+
end
|
|
1838
|
+
|
|
1839
|
+
|
|
1840
|
+
connect(options)
|
|
1841
|
+
begin
|
|
1842
|
+
account = find_account_from_options(options)
|
|
1843
|
+
account_id = account ? account['id'] : nil
|
|
1844
|
+
role = find_role_by_name_or_id(account_id, name)
|
|
1845
|
+
exit 1 if role.nil?
|
|
1846
|
+
# note: ReportTypes being plural is odd, the others are singular
|
|
1847
|
+
params = {permissionCode: 'ReportTypes', access: access_value}
|
|
1848
|
+
@roles_interface.setopts(options)
|
|
1849
|
+
if options[:dry_run]
|
|
1850
|
+
print_dry_run @roles_interface.dry.update_permission(account_id, role['id'], params)
|
|
1851
|
+
return
|
|
1852
|
+
end
|
|
1853
|
+
json_response = @roles_interface.update_permission(account_id, role['id'], params)
|
|
1854
|
+
|
|
1855
|
+
if options[:json]
|
|
1856
|
+
print JSON.pretty_generate(json_response)
|
|
1857
|
+
print "\n"
|
|
1858
|
+
else
|
|
1859
|
+
print_green_success "Role #{role['authority']} global report type access updated"
|
|
1860
|
+
end
|
|
1861
|
+
rescue RestClient::Exception => e
|
|
1862
|
+
print_rest_exception(e, options)
|
|
1863
|
+
exit 1
|
|
1864
|
+
end
|
|
1865
|
+
end
|
|
1866
|
+
|
|
1867
|
+
def update_report_type_access(args)
|
|
1868
|
+
options = {}
|
|
1869
|
+
report_type_id = nil
|
|
1870
|
+
access_value = nil
|
|
1871
|
+
do_all = false
|
|
1872
|
+
allowed_access_values = ['full', 'none']
|
|
1873
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1874
|
+
opts.banner = subcommand_usage("[role] [report-type] [access]")
|
|
1875
|
+
opts.on( '--report-type ID', String, "Report Type ID or Name" ) do |val|
|
|
1876
|
+
report_type_id = val
|
|
1877
|
+
end
|
|
1878
|
+
opts.on( nil, '--all', "Update all report types at once." ) do
|
|
1879
|
+
do_all = true
|
|
1880
|
+
end
|
|
1881
|
+
opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val|
|
|
1882
|
+
access_value = val
|
|
1883
|
+
end
|
|
1884
|
+
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
1885
|
+
opts.footer = "Update role access for a report type or all report types.\n" +
|
|
1886
|
+
"[role] is required. This is the name or id of a role.\n" +
|
|
1887
|
+
"--report-type or --all is required. This is the name or id of a report type.\n" +
|
|
1888
|
+
"--access is required. This is the new access value. #{anded_list(allowed_access_values)}"
|
|
1889
|
+
end
|
|
1890
|
+
optparse.parse!(args)
|
|
1891
|
+
|
|
1892
|
+
# usage: update-report-type-access [role] [access] --all
|
|
1893
|
+
# update-report-type-access [role] [report-type] [access]
|
|
1894
|
+
name = args[0]
|
|
1895
|
+
if do_all
|
|
1896
|
+
verify_args!(args:args, optparse:optparse, min:1, max:2)
|
|
1897
|
+
access_value = args[1] if args[1]
|
|
1898
|
+
else
|
|
1899
|
+
verify_args!(args:args, optparse:optparse, min:1, max:3)
|
|
1900
|
+
report_type_id = args[1] if args[1]
|
|
1901
|
+
access_value = args[2] if args[2]
|
|
1902
|
+
end
|
|
1903
|
+
if !report_type_id && !do_all
|
|
1904
|
+
raise_command_error("missing required argument: [report-type] or --all", args, optparse)
|
|
1905
|
+
end
|
|
1906
|
+
if !access_value
|
|
1907
|
+
raise_command_error("missing required argument: [access]", args, optparse)
|
|
1908
|
+
end
|
|
1909
|
+
access_value = access_value.to_s.downcase
|
|
1910
|
+
if !allowed_access_values.include?(access_value)
|
|
1911
|
+
raise_command_error("invalid access value: #{access_value}", args, optparse)
|
|
1912
|
+
puts optparse
|
|
1913
|
+
return 1
|
|
1914
|
+
end
|
|
1915
|
+
|
|
1916
|
+
connect(options)
|
|
1917
|
+
begin
|
|
1918
|
+
account = find_account_from_options(options)
|
|
1919
|
+
account_id = account ? account['id'] : nil
|
|
1920
|
+
role = find_role_by_name_or_id(account_id, name)
|
|
1921
|
+
return 1 if role.nil?
|
|
1922
|
+
|
|
1923
|
+
role_json = @roles_interface.get(account_id, role['id'])
|
|
1924
|
+
report_type_global_access = role_json['globalReportTypeAccess']
|
|
1925
|
+
report_type_permissions = role_json['reportTypePermissions'] || []
|
|
1926
|
+
if report_type_global_access != 'custom'
|
|
1927
|
+
print "\n", red, "Global Report Type Access is currently: #{report_type_global_access.to_s.capitalize}"
|
|
1928
|
+
print "\n", "You must first set it to Custom via `morpheus roles update-global-report-type-access \"#{name}\" custom`"
|
|
1929
|
+
print "\n\n", reset
|
|
1930
|
+
return 1
|
|
1931
|
+
end
|
|
1932
|
+
|
|
1933
|
+
# hacky, but support name or code lookup via the list returned in the show payload
|
|
1934
|
+
report_type = nil
|
|
1935
|
+
if !do_all
|
|
1936
|
+
if report_type_id.to_s =~ /\A\d{1,}\Z/
|
|
1937
|
+
report_type = report_type_permissions.find {|b| b['id'] == report_type_id.to_i }
|
|
1938
|
+
else
|
|
1939
|
+
report_type = report_type_permissions.find {|b| b['name'] == report_type_id }
|
|
1940
|
+
end
|
|
1941
|
+
if report_type.nil?
|
|
1942
|
+
print_red_alert "Report Type not found: '#{report_type_id}'"
|
|
1943
|
+
return 1
|
|
1944
|
+
end
|
|
1945
|
+
end
|
|
1946
|
+
|
|
1947
|
+
params = {}
|
|
1948
|
+
if do_all
|
|
1949
|
+
params['allReportTypes'] = true
|
|
1950
|
+
else
|
|
1951
|
+
params['reportTypeId'] = report_type['id']
|
|
1952
|
+
end
|
|
1953
|
+
params['access'] = access_value
|
|
1954
|
+
@roles_interface.setopts(options)
|
|
1955
|
+
if options[:dry_run]
|
|
1956
|
+
print_dry_run @roles_interface.dry.update_report_type(account_id, role['id'], params)
|
|
1957
|
+
return
|
|
1958
|
+
end
|
|
1959
|
+
json_response = @roles_interface.update_report_type(account_id, role['id'], params)
|
|
1960
|
+
|
|
1961
|
+
if options[:json]
|
|
1962
|
+
print JSON.pretty_generate(json_response)
|
|
1963
|
+
print "\n"
|
|
1964
|
+
else
|
|
1965
|
+
if do_all
|
|
1966
|
+
print_green_success "Role #{role['authority']} access updated for all report types"
|
|
1967
|
+
else
|
|
1968
|
+
print_green_success "Role #{role['authority']} access updated for report type #{report_type['name']}"
|
|
1969
|
+
end
|
|
1970
|
+
end
|
|
1971
|
+
return 0
|
|
1972
|
+
rescue RestClient::Exception => e
|
|
1973
|
+
print_rest_exception(e, options)
|
|
1974
|
+
exit 1
|
|
1975
|
+
end
|
|
1976
|
+
end
|
|
1977
|
+
|
|
1773
1978
|
private
|
|
1774
1979
|
|
|
1775
1980
|
def add_role_option_types
|
|
File without changes
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
# require 'yaml'
|
|
2
|
-
require 'io/console'
|
|
3
|
-
require 'rest_client'
|
|
4
|
-
require 'optparse'
|
|
5
|
-
require 'filesize'
|
|
6
1
|
require 'morpheus/cli/cli_command'
|
|
7
|
-
require 'morpheus/cli/mixins/infrastructure_helper'
|
|
8
2
|
|
|
9
3
|
class Morpheus::Cli::SecurityGroups
|
|
10
4
|
include Morpheus::Cli::CliCommand
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
# require 'yaml'
|
|
2
|
-
require 'io/console'
|
|
3
|
-
require 'rest_client'
|
|
4
|
-
require 'optparse'
|
|
5
|
-
require "shellwords"
|
|
6
|
-
require 'readline'
|
|
7
|
-
require 'logger'
|
|
8
|
-
require 'fileutils'
|
|
9
|
-
require 'morpheus/cli/cli_registry'
|
|
10
1
|
require 'morpheus/cli/cli_command'
|
|
11
|
-
require
|
|
12
|
-
require
|
|
13
|
-
require 'morpheus/terminal'
|
|
14
|
-
require 'morpheus/logging'
|
|
15
|
-
require 'morpheus/benchmarking'
|
|
2
|
+
require "shellwords"
|
|
3
|
+
require "readline"
|
|
16
4
|
|
|
17
5
|
#class Morpheus::Cli::Shell < Morpheus::Terminal
|
|
18
6
|
class Morpheus::Cli::Shell
|
|
@@ -391,102 +379,14 @@ class Morpheus::Cli::Shell
|
|
|
391
379
|
elsif input =~ /^\s*#/
|
|
392
380
|
Morpheus::Logging::DarkPrinter.puts "ignored comment: #{input}" if Morpheus::Logging.debug?
|
|
393
381
|
return 0
|
|
394
|
-
# this is a full blown command now
|
|
395
|
-
# elsif input =~ /^sleep/
|
|
396
|
-
# sleep_sec = input.sub("sleep ", "").to_f
|
|
397
|
-
# if (!(sleep_sec > 0))
|
|
398
|
-
# # raise_command_error "sleep requires the argument [seconds]. eg. sleep 3.14"
|
|
399
|
-
# puts_error "sleep requires argument [seconds]. eg. sleep 3.14"
|
|
400
|
-
# return false
|
|
401
|
-
# end
|
|
402
|
-
# log_history_command(input)
|
|
403
|
-
# Morpheus::Logging::DarkPrinter.puts "sleeping for #{sleep_sec}s ... zzzZzzzZ" if Morpheus::Logging.debug?
|
|
404
|
-
# begin
|
|
405
|
-
# sleep(sleep_sec)
|
|
406
|
-
# rescue Interrupt
|
|
407
|
-
# Morpheus::Logging::DarkPrinter.puts "\nInterrupt. waking up from sleep early"
|
|
408
|
-
# end
|
|
409
|
-
# return 0
|
|
410
|
-
# elsif input =~ /^history/
|
|
411
|
-
# n_commands = input.sub(/^history\s?/, '').sub(/\-n\s?/, '')
|
|
412
|
-
# n_commands = n_commands.empty? ? 25 : n_commands.to_i
|
|
413
|
-
# cmd_numbers = @history.keys.last(n_commands)
|
|
414
|
-
# if cmd_numbers.size == 1
|
|
415
|
-
# puts "Last command"
|
|
416
|
-
# else
|
|
417
|
-
# puts "Last #{cmd_numbers.size} commands"
|
|
418
|
-
# end
|
|
419
|
-
# cmd_numbers.each do |cmd_number|
|
|
420
|
-
# cmd = @history[cmd_number]
|
|
421
|
-
# puts "#{cmd_number.to_s.rjust(3, ' ')} #{cmd}"
|
|
422
|
-
# end
|
|
423
|
-
# last_cmd = cmd_numbers.last ? @history[cmd_numbers.last] : nil
|
|
424
|
-
# if input != last_cmd # no consecutive
|
|
425
|
-
# log_history_command(input)
|
|
426
|
-
# end
|
|
427
|
-
# return 0
|
|
428
382
|
elsif input == 'clear'
|
|
429
383
|
print "\e[H\e[2J"
|
|
430
384
|
return 0
|
|
431
|
-
# elsif input == 'flush-history' || input == 'flush_history'
|
|
432
|
-
# file_path = history_file_path
|
|
433
|
-
# if File.exists?(file_path)
|
|
434
|
-
# File.truncate(file_path, 0)
|
|
435
|
-
# end
|
|
436
|
-
# @history = {}
|
|
437
|
-
# @last_command_number = 0
|
|
438
|
-
# @history_logger = load_history_logger
|
|
439
|
-
# puts "history cleared!"
|
|
440
|
-
# return 0
|
|
441
|
-
# elsif input == "edit rc"
|
|
442
|
-
# fn = Morpheus::Cli::DotFile.morpheusrc_filename
|
|
443
|
-
# editor = ENV['EDITOR'] # || 'nano'
|
|
444
|
-
# if !editor
|
|
445
|
-
# puts "You have no EDITOR defined. Use 'export EDITOR=emacs'"
|
|
446
|
-
# #puts "Trying nano..."
|
|
447
|
-
# #editor = "nano"
|
|
448
|
-
# end
|
|
449
|
-
# system("which #{editor} > /dev/null 2>&1")
|
|
450
|
-
# has_editor = $?.success?
|
|
451
|
-
# if has_editor
|
|
452
|
-
# puts "opening #{fn} for editing with #{editor} ..."
|
|
453
|
-
# system("#{editor} #{fn}")
|
|
454
|
-
# puts "Use 'reload' to re-execute your startup script #{File.basename(fn)}"
|
|
455
|
-
# else
|
|
456
|
-
# puts_error2 Morpheus::Terminal.angry_prompt
|
|
457
|
-
# puts_error "The defined EDITOR '#{editor}' was not found on your system."
|
|
458
|
-
# end
|
|
459
|
-
# return 0 # $?
|
|
460
|
-
# elsif input == "edit profile"
|
|
461
|
-
# fn = Morpheus::Cli::DotFile.morpheus_profile_filename
|
|
462
|
-
# editor = ENV['EDITOR'] # || 'nano'
|
|
463
|
-
# if !editor
|
|
464
|
-
# puts "You have no EDITOR defined. Use 'export EDITOR=emacs'."
|
|
465
|
-
# #puts "Trying nano..."
|
|
466
|
-
# #editor = "nano"
|
|
467
|
-
# end
|
|
468
|
-
# system("which #{editor} > /dev/null 2>&1")
|
|
469
|
-
# has_editor = $?.success?
|
|
470
|
-
# if has_editor
|
|
471
|
-
# puts "opening #{fn} for editing with #{editor} ..."
|
|
472
|
-
# `#{editor} #{fn}`
|
|
473
|
-
# puts "Use 'reload' to re-execute your startup script #{File.basename(fn)}"
|
|
474
|
-
# else
|
|
475
|
-
# puts_error Morpheus::Terminal.angry_prompt
|
|
476
|
-
# puts_error "The defined EDITOR '#{editor}' was not found on your system."
|
|
477
|
-
# end
|
|
478
|
-
# return 0 # $?
|
|
479
385
|
elsif input == 'reload' || input == 'reload!'
|
|
480
|
-
# raise RestartShellPlease
|
|
481
|
-
#log_history_command(input)
|
|
482
|
-
# could just fork instead?
|
|
483
386
|
# clear registry
|
|
484
387
|
Morpheus::Cli::CliRegistry.instance.flush
|
|
485
388
|
# reload code
|
|
486
389
|
Morpheus::Cli.load!
|
|
487
|
-
|
|
488
|
-
# raise RestartShellPlease
|
|
489
|
-
|
|
490
390
|
# execute startup scripts
|
|
491
391
|
if File.exists?(Morpheus::Cli::DotFile.morpheus_profile_filename)
|
|
492
392
|
Morpheus::Cli::DotFile.new(Morpheus::Cli::DotFile.morpheus_profile_filename).execute()
|
|
@@ -494,7 +394,6 @@ class Morpheus::Cli::Shell
|
|
|
494
394
|
if File.exists?(Morpheus::Cli::DotFile.morpheusrc_filename)
|
|
495
395
|
Morpheus::Cli::DotFile.new(Morpheus::Cli::DotFile.morpheusrc_filename).execute()
|
|
496
396
|
end
|
|
497
|
-
|
|
498
397
|
# recalculate shell environment
|
|
499
398
|
reinitialize()
|
|
500
399
|
|
|
@@ -824,10 +723,10 @@ class Morpheus::Cli::Shell
|
|
|
824
723
|
end
|
|
825
724
|
if options[:show_pagination]
|
|
826
725
|
if options[:phrase] || options[:sort] || options[:direction] || options[:offset]
|
|
827
|
-
print_results_pagination(
|
|
726
|
+
print_results_pagination(history_result[:meta])
|
|
828
727
|
else
|
|
829
728
|
# default order is weird, it's the last page of results, 1-25 is misleading and showing the indexes is stranger
|
|
830
|
-
print_results_pagination(
|
|
729
|
+
print_results_pagination(history_result[:meta], {:message =>"Viewing most recent %{size} of %{total} %{label}"})
|
|
831
730
|
end
|
|
832
731
|
print reset, "\n"
|
|
833
732
|
else
|