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
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class Morpheus::Cli::Audit
|
|
4
|
+
include Morpheus::Cli::CliCommand
|
|
5
|
+
include Morpheus::Cli::LogsHelper
|
|
6
|
+
include Morpheus::Cli::RestCommand
|
|
7
|
+
include Morpheus::Cli::OptionSourceHelper
|
|
8
|
+
|
|
9
|
+
set_command_description "View audit log records."
|
|
10
|
+
set_command_name :'audit'
|
|
11
|
+
register_subcommands :list, :get
|
|
12
|
+
|
|
13
|
+
# audit is not published yet
|
|
14
|
+
set_command_hidden
|
|
15
|
+
|
|
16
|
+
# RestCommand settings
|
|
17
|
+
|
|
18
|
+
# interfaces
|
|
19
|
+
register_interfaces :audit
|
|
20
|
+
set_rest_interface_name :audit
|
|
21
|
+
|
|
22
|
+
# resource name is "Audit Log"
|
|
23
|
+
set_rest_name :audit_log
|
|
24
|
+
|
|
25
|
+
# display argument as [id] instead of [audit log]
|
|
26
|
+
set_rest_has_name false
|
|
27
|
+
set_rest_arg "id"
|
|
28
|
+
|
|
29
|
+
# def connect(opts)
|
|
30
|
+
# @api_client = establish_remote_appliance_connection(opts)
|
|
31
|
+
# @audit_interface = @api_client.audit # @api_client.rest("audit")
|
|
32
|
+
# end
|
|
33
|
+
|
|
34
|
+
# def handle(args)
|
|
35
|
+
# handle_subcommand(args)
|
|
36
|
+
# end
|
|
37
|
+
|
|
38
|
+
def list(args)
|
|
39
|
+
options = {}
|
|
40
|
+
params = {}
|
|
41
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
42
|
+
opts.banner = subcommand_usage("[search]")
|
|
43
|
+
opts.on('--user USER', String, "Filter by User Username or ID") do |val|
|
|
44
|
+
params['user'] = params['user'] ? [params['user'], val].flatten : [val]
|
|
45
|
+
end
|
|
46
|
+
opts.on('--level VALUE', String, "Log Level. DEBUG|INFO|WARN|ERROR") do |val|
|
|
47
|
+
params['level'] = params['level'] ? [params['level'], val].flatten : [val]
|
|
48
|
+
end
|
|
49
|
+
opts.on('--start TIMESTAMP','--start TIMESTAMP', "Start date timestamp in standard iso8601 format.") do |val|
|
|
50
|
+
params['startDate'] = val # parse_time(val).utc.iso8601
|
|
51
|
+
end
|
|
52
|
+
opts.on('--end TIMESTAMP','--end TIMESTAMP', "End date timestamp in standard iso8601 format.") do |val|
|
|
53
|
+
params['endDate'] = val # parse_time(val).utc.iso8601
|
|
54
|
+
end
|
|
55
|
+
build_standard_list_options(opts, options)
|
|
56
|
+
opts.footer = "List audit logs records."
|
|
57
|
+
end
|
|
58
|
+
optparse.parse!(args)
|
|
59
|
+
if args.count > 0
|
|
60
|
+
options[:phrase] = args.join(" ")
|
|
61
|
+
end
|
|
62
|
+
connect(options)
|
|
63
|
+
params.merge!(parse_list_options(options))
|
|
64
|
+
# parse --user id,name
|
|
65
|
+
if params['user']
|
|
66
|
+
user_ids = parse_user_id_list(params['user'])
|
|
67
|
+
return 1 if user_ids.nil?
|
|
68
|
+
params['user'] = user_ids
|
|
69
|
+
end
|
|
70
|
+
# api works with level=INFO|WARN
|
|
71
|
+
if params['level']
|
|
72
|
+
params['level'] = [params['level']].flatten.collect {|it| it.to_s.upcase }.join('|')
|
|
73
|
+
end
|
|
74
|
+
# could find_by_name_or_id for params['servers'] and params['containers']
|
|
75
|
+
@audit_interface.setopts(options)
|
|
76
|
+
if options[:dry_run]
|
|
77
|
+
print_dry_run @audit_interface.dry.list(params)
|
|
78
|
+
return
|
|
79
|
+
end
|
|
80
|
+
json_response = @audit_interface.list(params)
|
|
81
|
+
|
|
82
|
+
render_response(json_response, options, rest_list_key) do
|
|
83
|
+
records = json_response[rest_list_key]
|
|
84
|
+
print_h1 "Morpheus Audit Log", parse_list_subtitles(options), options
|
|
85
|
+
if records.nil? || records.empty?
|
|
86
|
+
print cyan,"No #{rest_label_plural.downcase} found.",reset,"\n"
|
|
87
|
+
else
|
|
88
|
+
print as_pretty_table(records, rest_list_column_definitions(options).upcase_keys!, options)
|
|
89
|
+
print_results_pagination(json_response) if json_response['meta']
|
|
90
|
+
end
|
|
91
|
+
print reset,"\n"
|
|
92
|
+
end
|
|
93
|
+
return 0, nil
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
protected
|
|
97
|
+
|
|
98
|
+
# custom rendering to print Message below description list
|
|
99
|
+
def render_response_for_get(json_response, options)
|
|
100
|
+
render_response(json_response, options, rest_object_key) do
|
|
101
|
+
record = json_response[rest_object_key]
|
|
102
|
+
print_h1 rest_label, [], options
|
|
103
|
+
print cyan
|
|
104
|
+
print_description_list(rest_column_definitions(options), record, options)
|
|
105
|
+
# show log message settings...
|
|
106
|
+
print_h2 "Message", options
|
|
107
|
+
print cyan
|
|
108
|
+
puts record['message']
|
|
109
|
+
print reset,"\n"
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def audit_log_object_key
|
|
114
|
+
"auditLog"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def audit_log_list_key
|
|
118
|
+
"auditLogs"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def audit_log_list_column_definitions(options={})
|
|
122
|
+
{
|
|
123
|
+
"ID" => 'id',
|
|
124
|
+
"Level" => lambda {|it| format_log_level(it['level']) },
|
|
125
|
+
"Message" => {display_method:'message', max_width: (options[:wrap] ? nil : 75)},
|
|
126
|
+
"Event Type" => 'eventType',
|
|
127
|
+
"Object" => lambda {|it| "#{it['objectClass']} #{it['objectId']}".strip },
|
|
128
|
+
# "Object Type" => 'objectClass',
|
|
129
|
+
# "Object ID" => 'objectId',
|
|
130
|
+
"User" => lambda {|it|
|
|
131
|
+
if it['actualUser'] && it['user'] && it['actualUser']['username'] != it['user']['username']
|
|
132
|
+
it['user']['username'] + '(' + it['actualUser']['username'].to_s + ')'
|
|
133
|
+
elsif it['user']
|
|
134
|
+
it['user']['username']
|
|
135
|
+
else
|
|
136
|
+
# system or deleted user maybe?
|
|
137
|
+
end
|
|
138
|
+
},
|
|
139
|
+
# "Tenant" => lambda {|it| it['account'] ? it['account']['name'] : '' },
|
|
140
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
141
|
+
}
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def audit_log_column_definitions(options={})
|
|
145
|
+
{
|
|
146
|
+
"ID" => 'id',
|
|
147
|
+
"Level" => lambda {|it| format_log_level(it['level']) },
|
|
148
|
+
#"Message" => 'message',
|
|
149
|
+
"Event Type" => 'eventType',
|
|
150
|
+
"Object Type" => 'objectClass',
|
|
151
|
+
"Object ID" => 'objectId',
|
|
152
|
+
"User" => lambda {|it|
|
|
153
|
+
if it['actualUser'] && it['user'] && it['actualUser']['username'] != it['user']['username']
|
|
154
|
+
it['user']['username'] + '(' + it['actualUser']['username'].to_s + ')'
|
|
155
|
+
elsif it['user']
|
|
156
|
+
it['user']['username']
|
|
157
|
+
else
|
|
158
|
+
# system or deleted user maybe?
|
|
159
|
+
end
|
|
160
|
+
},
|
|
161
|
+
# "Tenant" => lambda {|it| it['account'] ? it['account']['name'] : '' },
|
|
162
|
+
"Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
163
|
+
}
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def find_audit_log_by_name_or_id(val)
|
|
167
|
+
return find_audit_log_by_id(val)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def find_audit_log_by_id(id)
|
|
171
|
+
begin
|
|
172
|
+
json_response = @audit_interface.get(id)
|
|
173
|
+
return json_response[audit_log_object_key]
|
|
174
|
+
rescue RestClient::Exception => e
|
|
175
|
+
if e.response && e.response.code == 404
|
|
176
|
+
print_red_alert "Audit Log not found by id #{id}"
|
|
177
|
+
return nil
|
|
178
|
+
else
|
|
179
|
+
raise e
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def find_audit_log_by_name(name)
|
|
185
|
+
raise_command_error "finding audit log by name not supported"
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -36,7 +36,7 @@ class Morpheus::Cli::BlueprintsCommand
|
|
|
36
36
|
@options_interface = @api_client.options
|
|
37
37
|
@active_group_id = Morpheus::Cli::Groups.active_groups[@appliance_name]
|
|
38
38
|
@clouds_interface = @api_client.clouds
|
|
39
|
-
@
|
|
39
|
+
@account_users_interface = @api_client.account_users
|
|
40
40
|
@library_layouts_interface = @api_client.library_layouts
|
|
41
41
|
end
|
|
42
42
|
|
|
File without changes
|
|
File without changes
|
data/lib/morpheus/cli/{catalog_item_types_command.rb → commands/catalog_item_types_command.rb}
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require 'morpheus/cli/cli_command'
|
|
2
|
+
|
|
3
|
+
class Morpheus::Cli::ChangePasswordCommand
|
|
4
|
+
include Morpheus::Cli::CliCommand
|
|
5
|
+
include Morpheus::Cli::AccountsHelper
|
|
6
|
+
|
|
7
|
+
set_command_name :passwd
|
|
8
|
+
|
|
9
|
+
def connect(opts)
|
|
10
|
+
@api_client = establish_remote_appliance_connection(opts)
|
|
11
|
+
@whoami_interface = @api_client.whoami
|
|
12
|
+
@account_users_interface = @api_client.account_users
|
|
13
|
+
@accounts_interface = @api_client.accounts
|
|
14
|
+
@roles_interface = @api_client.roles
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def handle(args)
|
|
18
|
+
change_password(args)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def change_password(args)
|
|
22
|
+
options = {}
|
|
23
|
+
username = nil
|
|
24
|
+
new_password = nil
|
|
25
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
26
|
+
opts.banner = subcommand_usage("[username] [options]")
|
|
27
|
+
opts.on('--username USERNAME', String, "Username. Default is your own.") do |val|
|
|
28
|
+
username = val
|
|
29
|
+
end
|
|
30
|
+
opts.on('--password VALUE', String, "New password") do |val|
|
|
31
|
+
new_password = val
|
|
32
|
+
end
|
|
33
|
+
build_common_options(opts, options, [:account, :options, :json, :dry_run, :remote, :quiet, :auto_confirm], [:username,:password])
|
|
34
|
+
opts.footer = "Change your password or the password of another user.\n" +
|
|
35
|
+
"[username] is optional. This is the username of the user to update. Default is your own.\n" +
|
|
36
|
+
"Be careful with this command, the default behavior is to update your own password."
|
|
37
|
+
end
|
|
38
|
+
optparse.parse!(args)
|
|
39
|
+
|
|
40
|
+
if args.count > 1
|
|
41
|
+
print_error Morpheus::Terminal.angry_prompt
|
|
42
|
+
puts_error "wrong number of arguments, expected 0-1 and got #{args.count} #{args}\n#{optparse}"
|
|
43
|
+
return 1
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
connect(options)
|
|
47
|
+
@current_remote = @appliance_name ? ::Morpheus::Cli::Remote.load_remote(@appliance_name) : ::Morpheus::Cli::Remote.load_active_remote()
|
|
48
|
+
|
|
49
|
+
if args[0]
|
|
50
|
+
username = args[0]
|
|
51
|
+
end
|
|
52
|
+
if username.nil?
|
|
53
|
+
if !@current_remote
|
|
54
|
+
raise_command_error "No current appliance, see `remote use`."
|
|
55
|
+
end
|
|
56
|
+
if !@current_remote[:username]
|
|
57
|
+
raise_command_error "You are not currently logged in to #{display_appliance(@current_remote[:name], @current_remote[:url])}"
|
|
58
|
+
end
|
|
59
|
+
username = @current_remote[:username]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
account = find_account_from_options(options)
|
|
63
|
+
account_id = account ? account['id'] : nil
|
|
64
|
+
|
|
65
|
+
user = find_user_by_username_or_id(account_id, username)
|
|
66
|
+
return 1 if user.nil?
|
|
67
|
+
|
|
68
|
+
if @current_remote && @current_remote[:username] == username
|
|
69
|
+
if !options[:quiet]
|
|
70
|
+
if options[:dry_run]
|
|
71
|
+
print cyan,bold, "DRY RUN. This is just a dry run, the password is not being updated.",reset,"\n"
|
|
72
|
+
else
|
|
73
|
+
print cyan,bold, "WARNING! You are about to update your own password!",reset,"\n"
|
|
74
|
+
print yellow,bold,"WARNING! You are about to update your own password!",reset,"\n"
|
|
75
|
+
print reset,bold, "WARNING! You are about to update your own password!",reset,"\n"
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
if !options[:quiet]
|
|
81
|
+
print cyan, "Changing password for #{user['username']}", reset, "\n"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
if new_password.nil? && options[:options]['password']
|
|
85
|
+
new_password = options[:options]['password']
|
|
86
|
+
end
|
|
87
|
+
if new_password.nil?
|
|
88
|
+
password_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'password', 'fieldLabel' => 'New Password', 'type' => 'password', 'required' => true}], options[:options], @api_client)
|
|
89
|
+
new_password = password_prompt['password']
|
|
90
|
+
confirm_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'passwordConfirmation', 'fieldLabel' => 'Confirm Password', 'type' => 'password', 'required' => true}], options[:options], @api_client)
|
|
91
|
+
confirm_password = confirm_prompt['passwordConfirmation']
|
|
92
|
+
if confirm_password != new_password
|
|
93
|
+
print_red_alert "Confirm password did not match."
|
|
94
|
+
return 1
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
if new_password.nil? || new_password.empty?
|
|
99
|
+
print_red_alert "A new password is required"
|
|
100
|
+
return 1
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
payload = {
|
|
104
|
+
'user' => {
|
|
105
|
+
'password' => new_password
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
@account_users_interface.setopts(options)
|
|
109
|
+
if options[:dry_run]
|
|
110
|
+
print_dry_run @account_users_interface.dry.update(account_id, user['id'], payload)
|
|
111
|
+
return 0
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
unless options[:yes]
|
|
115
|
+
unless ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to update the password for user #{user['username']}?", options)
|
|
116
|
+
return 9, "aborted command"
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
json_response = @account_users_interface.update(account_id, user['id'], payload)
|
|
121
|
+
if options[:json]
|
|
122
|
+
puts as_json(json_response)
|
|
123
|
+
elsif !options[:quiet]
|
|
124
|
+
print_green_success "Updated password for user #{user['username']}"
|
|
125
|
+
end
|
|
126
|
+
return 0
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
private
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
end
|