morpheus-cli 5.3.4 → 5.4.3
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 +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
|
@@ -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
|
@@ -13,6 +13,7 @@ class Morpheus::Cli::CatalogItemTypesCommand
|
|
|
13
13
|
set_command_description "Self Service: View and manage catalog item types"
|
|
14
14
|
|
|
15
15
|
register_subcommands :list, :get, :add, :update, :remove
|
|
16
|
+
register_subcommands({:'update-logo' => :update_logo})
|
|
16
17
|
|
|
17
18
|
def connect(opts)
|
|
18
19
|
@api_client = establish_remote_appliance_connection(opts)
|
|
@@ -222,6 +223,7 @@ EOT
|
|
|
222
223
|
def add(args)
|
|
223
224
|
options = {}
|
|
224
225
|
params = {}
|
|
226
|
+
logo_file = nil
|
|
225
227
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
226
228
|
opts.banner = subcommand_usage("[name] [options]")
|
|
227
229
|
# opts.on('-t', '--type [instance|blueprint|workflow]', "Item Type, default is instance.") do |val|
|
|
@@ -229,6 +231,19 @@ EOT
|
|
|
229
231
|
# options[:options]['type'] = val.to_s.downcase
|
|
230
232
|
# end
|
|
231
233
|
build_option_type_options(opts, options, add_catalog_item_type_option_types)
|
|
234
|
+
opts.on('--logo FILE', String, "Upload a custom logo icon") do |val|
|
|
235
|
+
filename = val
|
|
236
|
+
logo_file = nil
|
|
237
|
+
if filename == 'null'
|
|
238
|
+
filename = 'null' # clear it
|
|
239
|
+
else
|
|
240
|
+
filename = File.expand_path(filename)
|
|
241
|
+
if !File.exists?(filename)
|
|
242
|
+
raise_command_error "File not found: #{filename}"
|
|
243
|
+
end
|
|
244
|
+
logo_file = File.new(filename, 'rb')
|
|
245
|
+
end
|
|
246
|
+
end
|
|
232
247
|
opts.on('--config-file FILE', String, "Config from a local JSON or YAML file") do |val|
|
|
233
248
|
options[:config_file] = val.to_s
|
|
234
249
|
file_content = nil
|
|
@@ -330,6 +345,16 @@ EOT
|
|
|
330
345
|
return 0, nil
|
|
331
346
|
end
|
|
332
347
|
json_response = @catalog_item_types_interface.create(payload)
|
|
348
|
+
if json_response['success']
|
|
349
|
+
if logo_file
|
|
350
|
+
begin
|
|
351
|
+
@catalog_item_types_interface.update_logo(json_response['catalogItemType']['id'], logo_file)
|
|
352
|
+
rescue RestClient::Exception => e
|
|
353
|
+
print_red_alert "Failed to save logo!"
|
|
354
|
+
print_rest_exception(e, options)
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
end
|
|
333
358
|
catalog_item_type = json_response[catalog_item_type_object_key]
|
|
334
359
|
render_response(json_response, options, catalog_item_type_object_key) do
|
|
335
360
|
print_green_success "Added catalog item type #{catalog_item_type['name']}"
|
|
@@ -342,9 +367,23 @@ EOT
|
|
|
342
367
|
options = {}
|
|
343
368
|
params = {}
|
|
344
369
|
payload = {}
|
|
370
|
+
logo_file = nil
|
|
345
371
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
346
372
|
opts.banner = subcommand_usage("[type] [options]")
|
|
347
373
|
build_option_type_options(opts, options, update_catalog_item_type_option_types)
|
|
374
|
+
opts.on('--logo FILE', String, "Upload a custom logo icon") do |val|
|
|
375
|
+
filename = val
|
|
376
|
+
logo_file = nil
|
|
377
|
+
if filename == 'null'
|
|
378
|
+
filename = 'null' # clear it
|
|
379
|
+
else
|
|
380
|
+
filename = File.expand_path(filename)
|
|
381
|
+
if !File.exists?(filename)
|
|
382
|
+
raise_command_error "File not found: #{filename}"
|
|
383
|
+
end
|
|
384
|
+
logo_file = File.new(filename, 'rb')
|
|
385
|
+
end
|
|
386
|
+
end
|
|
348
387
|
opts.on('--config-file FILE', String, "Config from a local JSON or YAML file") do |val|
|
|
349
388
|
options[:config_file] = val.to_s
|
|
350
389
|
file_content = nil
|
|
@@ -445,6 +484,16 @@ EOT
|
|
|
445
484
|
return
|
|
446
485
|
end
|
|
447
486
|
json_response = @catalog_item_types_interface.update(catalog_item_type['id'], payload)
|
|
487
|
+
if json_response['success']
|
|
488
|
+
if logo_file
|
|
489
|
+
begin
|
|
490
|
+
@catalog_item_types_interface.update_logo(json_response['catalogItemType']['id'], logo_file)
|
|
491
|
+
rescue RestClient::Exception => e
|
|
492
|
+
print_red_alert "Failed to save logo!"
|
|
493
|
+
print_rest_exception(e, options)
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
end
|
|
448
497
|
catalog_item_type = json_response[catalog_item_type_object_key]
|
|
449
498
|
render_response(json_response, options, catalog_item_type_object_key) do
|
|
450
499
|
print_green_success "Updated catalog item type #{catalog_item_type['name']}"
|
|
@@ -453,6 +502,45 @@ EOT
|
|
|
453
502
|
return 0, nil
|
|
454
503
|
end
|
|
455
504
|
|
|
505
|
+
def update_logo(args)
|
|
506
|
+
options = {}
|
|
507
|
+
params = {}
|
|
508
|
+
filename = nil
|
|
509
|
+
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
510
|
+
opts.banner = subcommand_usage("[type] [file]")
|
|
511
|
+
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
512
|
+
opts.footer = "Update the logo for a catalog item type." + "\n" +
|
|
513
|
+
"[type] is required. This is the name or id of a catalog item type." + "\n" +
|
|
514
|
+
"[file] is required. This is the path of the logo file"
|
|
515
|
+
end
|
|
516
|
+
optparse.parse!(args)
|
|
517
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
|
518
|
+
connect(options)
|
|
519
|
+
catalog_item_type = find_catalog_item_type_by_name_or_id(args[0])
|
|
520
|
+
return 1 if catalog_item_type.nil?
|
|
521
|
+
filename = args[1]
|
|
522
|
+
logo_file = nil
|
|
523
|
+
if filename == 'null'
|
|
524
|
+
filename = 'null' # clear it
|
|
525
|
+
else
|
|
526
|
+
filename = File.expand_path(filename)
|
|
527
|
+
if !File.exists?(filename)
|
|
528
|
+
raise_command_error "File not found: #{filename}"
|
|
529
|
+
end
|
|
530
|
+
logo_file = File.new(filename, 'rb')
|
|
531
|
+
end
|
|
532
|
+
@catalog_item_types_interface.setopts(options)
|
|
533
|
+
if options[:dry_run]
|
|
534
|
+
print_dry_run @catalog_item_types_interface.dry.update_logo(catalog_item_type['id'], logo_file)
|
|
535
|
+
return
|
|
536
|
+
end
|
|
537
|
+
json_response = @catalog_item_types_interface.update_logo(catalog_item_type['id'], logo_file)
|
|
538
|
+
render_response(json_response, options, catalog_item_type_object_key) do
|
|
539
|
+
print_green_success "Updated catalog item type #{catalog_item_type['name']} logo"
|
|
540
|
+
return _get(catalog_item_type["id"], {}, options)
|
|
541
|
+
end
|
|
542
|
+
end
|
|
543
|
+
|
|
456
544
|
def remove(args)
|
|
457
545
|
options = {}
|
|
458
546
|
params = {}
|
|
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
|
|
@@ -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/mixins/infrastructure_helper'
|
|
7
|
-
require 'morpheus/cli/mixins/provisioning_helper'
|
|
8
|
-
require 'morpheus/cli/option_types'
|
|
9
2
|
|
|
10
3
|
class Morpheus::Cli::Clouds
|
|
11
4
|
include Morpheus::Cli::CliCommand
|