morpheus-cli 5.3.3 → 5.4.2
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 +21 -0
- 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_servers_interface.rb +9 -0
- data/lib/morpheus/cli/cli_command.rb +262 -14
- 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} +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} +1 -5
- data/lib/morpheus/cli/{clouds.rb → commands/clouds.rb} +22 -47
- data/lib/morpheus/cli/{clusters.rb → commands/clusters.rb} +38 -19
- 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} +6 -16
- data/lib/morpheus/cli/{instance_types.rb → commands/instance_types.rb} +0 -3
- data/lib/morpheus/cli/{instances.rb → commands/instances.rb} +220 -13
- data/lib/morpheus/cli/{integrations_command.rb → commands/integrations_command.rb} +1 -12
- data/lib/morpheus/cli/{invoices_command.rb → commands/invoices_command.rb} +43 -39
- data/lib/morpheus/cli/{jobs_command.rb → commands/jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{key_pairs.rb → commands/key_pairs.rb} +0 -6
- data/lib/morpheus/cli/{library_cluster_layouts_command.rb → commands/library_cluster_layouts_command.rb} +0 -4
- data/lib/morpheus/cli/{library_container_scripts_command.rb → commands/library_container_scripts_command.rb} +0 -0
- data/lib/morpheus/cli/{library_container_templates_command.rb → commands/library_container_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_container_types_command.rb → commands/library_container_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_instance_types_command.rb → commands/library_instance_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_layouts_command.rb → commands/library_layouts_command.rb} +0 -4
- data/lib/morpheus/cli/{library_option_lists_command.rb → commands/library_option_lists_command.rb} +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 +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/commands/load_balancer_virtual_servers.rb +147 -0
- 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} +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} +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} +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} +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} +2 -4
- data/lib/morpheus/cli/{whitelabel_settings_command.rb → commands/whitelabel_settings_command.rb} +0 -1
- data/lib/morpheus/cli/{whoami.rb → commands/whoami.rb} +0 -4
- data/lib/morpheus/cli/{wiki_command.rb → commands/wiki_command.rb} +0 -5
- data/lib/morpheus/cli/{workflows.rb → commands/workflows.rb} +0 -3
- data/lib/morpheus/cli/mixins/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 +48 -17
- data/lib/morpheus/cli/mixins/rest_command.rb +270 -94
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +667 -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_types.rb +149 -40
- 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
- metadata +176 -141
- 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,16 +1,10 @@
|
|
|
1
|
-
require 'io/console'
|
|
2
|
-
require 'rest_client'
|
|
3
|
-
require 'optparse'
|
|
4
1
|
require 'morpheus/cli/cli_command'
|
|
5
|
-
require 'morpheus/cli/mixins/logs_helper'
|
|
6
|
-
require 'morpheus/cli/option_types'
|
|
7
|
-
require 'json'
|
|
8
2
|
|
|
9
3
|
class Morpheus::Cli::HealthCommand
|
|
10
4
|
include Morpheus::Cli::CliCommand
|
|
11
5
|
include Morpheus::Cli::LogsHelper
|
|
12
6
|
set_command_name :health
|
|
13
|
-
register_subcommands :get, :alarms, :'get-alarm', :'acknowledge-alarms', :'unacknowledge-alarms', :logs
|
|
7
|
+
register_subcommands :get, :alarms, :'get-alarm', :'acknowledge-alarms', :'unacknowledge-alarms', :logs, :'export-logs'
|
|
14
8
|
|
|
15
9
|
def connect(opts)
|
|
16
10
|
@api_client = establish_remote_appliance_connection(opts)
|
|
@@ -510,17 +504,16 @@ class Morpheus::Cli::HealthCommand
|
|
|
510
504
|
def logs(args)
|
|
511
505
|
options = {}
|
|
512
506
|
params = {}
|
|
513
|
-
start_date, end_date = nil, nil
|
|
514
507
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
515
508
|
opts.banner = subcommand_usage()
|
|
516
509
|
opts.on('--level VALUE', String, "Log Level. DEBUG,INFO,WARN,ERROR") do |val|
|
|
517
510
|
params['level'] = params['level'] ? [params['level'], val].flatten : [val]
|
|
518
511
|
end
|
|
519
|
-
opts.on('--start TIMESTAMP','--start TIMESTAMP', "Start timestamp. Default is
|
|
520
|
-
|
|
512
|
+
opts.on('--start TIMESTAMP','--start TIMESTAMP', "Start date timestamp in standard iso8601 format. Default is 24 hours ago.") do |val|
|
|
513
|
+
params['startDate'] = val # parse_time(val).utc.iso8601
|
|
521
514
|
end
|
|
522
|
-
opts.on('--end TIMESTAMP','--end TIMESTAMP', "End timestamp. Default is now.") do |val|
|
|
523
|
-
|
|
515
|
+
opts.on('--end TIMESTAMP','--end TIMESTAMP', "End date timestamp in standard iso8601 format. Default is now.") do |val|
|
|
516
|
+
params['endDate'] = val # parse_time(val).utc.iso8601
|
|
524
517
|
end
|
|
525
518
|
opts.on('-t', '--table', "Format output as a table.") do
|
|
526
519
|
options[:table] = true
|
|
@@ -539,8 +532,8 @@ class Morpheus::Cli::HealthCommand
|
|
|
539
532
|
begin
|
|
540
533
|
# params['startDate'] = start_date.utc.iso8601 if start_date
|
|
541
534
|
# params['endDate'] = end_date.utc.iso8601 if end_date
|
|
542
|
-
params['startMs'] = (start_date.to_i * 1000) if start_date
|
|
543
|
-
params['endMs'] = (end_date.to_i * 1000) if end_date
|
|
535
|
+
# params['startMs'] = (start_date.to_i * 1000) if start_date
|
|
536
|
+
# params['endMs'] = (end_date.to_i * 1000) if end_date
|
|
544
537
|
params['level'] = params['level'].collect {|it| it.to_s.upcase }.join('|') if params['level'] # api works with INFO|WARN
|
|
545
538
|
params.merge!(parse_list_options(options))
|
|
546
539
|
@health_interface.setopts(options)
|
|
@@ -557,11 +550,11 @@ class Morpheus::Cli::HealthCommand
|
|
|
557
550
|
if params['level']
|
|
558
551
|
subtitles << "Level: #{[params['level']].flatten.join(',')}"
|
|
559
552
|
end
|
|
560
|
-
if
|
|
561
|
-
subtitles << "Start: #{
|
|
553
|
+
if params['startDate']
|
|
554
|
+
subtitles << "Start: #{params['startDate']}"
|
|
562
555
|
end
|
|
563
|
-
if
|
|
564
|
-
subtitles << "End: #{
|
|
556
|
+
if params['endDate']
|
|
557
|
+
subtitles << "End: #{params['endDate']}"
|
|
565
558
|
end
|
|
566
559
|
subtitles += parse_list_subtitles(options)
|
|
567
560
|
print_h1 title, subtitles
|
|
@@ -580,6 +573,98 @@ class Morpheus::Cli::HealthCommand
|
|
|
580
573
|
end
|
|
581
574
|
end
|
|
582
575
|
|
|
576
|
+
def export_logs(args)
|
|
577
|
+
params = {}
|
|
578
|
+
options = {}
|
|
579
|
+
outfile = nil
|
|
580
|
+
do_overwrite = false
|
|
581
|
+
do_mkdir = false
|
|
582
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
583
|
+
opts.banner = subcommand_usage("[file]")
|
|
584
|
+
opts.on('--level VALUE', String, "Log Level. DEBUG,INFO,WARN,ERROR") do |val|
|
|
585
|
+
params['level'] = params['level'] ? [params['level'], val].flatten : [val]
|
|
586
|
+
end
|
|
587
|
+
opts.on('--start TIMESTAMP','--start TIMESTAMP', "Start date timestamp in standard iso8601 format. Default is 24 hours ago.") do |val|
|
|
588
|
+
params['startDate'] = val # parse_time(val).utc.iso8601
|
|
589
|
+
end
|
|
590
|
+
opts.on('--end TIMESTAMP','--end TIMESTAMP', "End date timestamp in standard iso8601 format. Default is now.") do |val|
|
|
591
|
+
params['endDate'] = val # parse_time(val).utc.iso8601
|
|
592
|
+
end
|
|
593
|
+
opts.on( '-f', '--force', "Overwrite existing [file] if it exists." ) do
|
|
594
|
+
do_overwrite = true
|
|
595
|
+
# do_mkdir = true
|
|
596
|
+
end
|
|
597
|
+
opts.on( '-p', '--mkdir', "Create missing directories for [file] if they do not exist." ) do
|
|
598
|
+
do_mkdir = true
|
|
599
|
+
end
|
|
600
|
+
build_common_options(opts, options, [:list, :query, :dry_run, :remote])
|
|
601
|
+
opts.footer = "Export morpheus appliance log." + "\n" +
|
|
602
|
+
"[file] is required. This is local destination for the downloaded file. Example: morpheus.log"
|
|
603
|
+
end
|
|
604
|
+
optparse.parse!(args)
|
|
605
|
+
verify_args!(args:args, optparse:optparse, count: 1)
|
|
606
|
+
connect(options)
|
|
607
|
+
params['level'] = params['level'].collect {|it| it.to_s.upcase }.join('|') if params['level'] # api works with INFO|WARN
|
|
608
|
+
params.merge!(parse_list_options(options))
|
|
609
|
+
|
|
610
|
+
outfile = args[0]
|
|
611
|
+
outfile = File.expand_path(outfile)
|
|
612
|
+
|
|
613
|
+
if Dir.exists?(outfile)
|
|
614
|
+
raise_command_error("[file] is invalid. It is the name of an existing directory: #{outfile}", args, optparse)
|
|
615
|
+
end
|
|
616
|
+
destination_dir = File.dirname(outfile)
|
|
617
|
+
if !Dir.exists?(destination_dir)
|
|
618
|
+
if do_mkdir
|
|
619
|
+
print cyan,"Creating local directory #{destination_dir}",reset,"\n"
|
|
620
|
+
FileUtils.mkdir_p(destination_dir)
|
|
621
|
+
else
|
|
622
|
+
raise_command_error("[file] is invalid. Directory not found: #{destination_dir}", args, optparse)
|
|
623
|
+
end
|
|
624
|
+
end
|
|
625
|
+
if File.exists?(outfile)
|
|
626
|
+
if do_overwrite
|
|
627
|
+
# uhh need to be careful wih the passed filepath here..
|
|
628
|
+
# don't delete, just overwrite.
|
|
629
|
+
# File.delete(outfile)
|
|
630
|
+
else
|
|
631
|
+
raise_command_error("[file] is invalid. File already exists: #{outfile}\nUse -f to overwrite the existing file.", args, optparse)
|
|
632
|
+
end
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
@health_interface.setopts(options)
|
|
636
|
+
if options[:dry_run]
|
|
637
|
+
print_dry_run @health_interface.dry.export_logs(outfile, params)
|
|
638
|
+
return 0
|
|
639
|
+
end
|
|
640
|
+
if !options[:quiet]
|
|
641
|
+
print cyan + "Downloading file #{outfile} ... "
|
|
642
|
+
end
|
|
643
|
+
http_response, bad_body = @health_interface.export_logs(outfile, params)
|
|
644
|
+
# FileUtils.chmod(0600, outfile)
|
|
645
|
+
success = http_response.code.to_i == 200
|
|
646
|
+
if success
|
|
647
|
+
if !options[:quiet]
|
|
648
|
+
print green + "SUCCESS" + reset + " (" + format_bytes(http_response["Content-Length"].to_i).to_s + ")" + "\n"
|
|
649
|
+
end
|
|
650
|
+
# todo: parse default outfile from http_response["Content-Type"]
|
|
651
|
+
return 0
|
|
652
|
+
else
|
|
653
|
+
if !options[:quiet]
|
|
654
|
+
print red + "ERROR" + reset + " HTTP #{http_response.code}" + "\n"
|
|
655
|
+
end
|
|
656
|
+
# F it, just remove a bad result
|
|
657
|
+
if File.exists?(outfile) && File.file?(outfile)
|
|
658
|
+
Morpheus::Logging::DarkPrinter.puts "Deleting bad file download: #{outfile}" if Morpheus::Logging.debug?
|
|
659
|
+
File.delete(outfile)
|
|
660
|
+
end
|
|
661
|
+
if options[:debug]
|
|
662
|
+
puts_error http_response.inspect
|
|
663
|
+
end
|
|
664
|
+
return 1, "download failed"
|
|
665
|
+
end
|
|
666
|
+
end
|
|
667
|
+
|
|
583
668
|
def alarms(args)
|
|
584
669
|
options = {}
|
|
585
670
|
params = {}
|
|
@@ -595,7 +680,7 @@ class Morpheus::Cli::HealthCommand
|
|
|
595
680
|
opts.on('--acknowledged', '--acknowledged', "Filter by acknowledged. By default only open alarms are returned.") do
|
|
596
681
|
params['alarmStatus'] = 'acknowledged'
|
|
597
682
|
end
|
|
598
|
-
opts.on('--start TIMESTAMP','--start TIMESTAMP', "Start timestamp. Default is
|
|
683
|
+
opts.on('--start TIMESTAMP','--start TIMESTAMP', "Start timestamp. Default is 24 hours ago.") do |val|
|
|
599
684
|
start_date = parse_time(val) #.utc.iso8601
|
|
600
685
|
end
|
|
601
686
|
opts.on('--end TIMESTAMP','--end TIMESTAMP', "End timestamp. Default is now.") do |val|
|
|
@@ -1,13 +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/accounts_helper'
|
|
7
|
-
require 'morpheus/cli/mixins/provisioning_helper'
|
|
8
|
-
require 'morpheus/cli/mixins/logs_helper'
|
|
9
|
-
require 'morpheus/cli/option_types'
|
|
10
|
-
require 'json'
|
|
11
2
|
|
|
12
3
|
class Morpheus::Cli::Hosts
|
|
13
4
|
include Morpheus::Cli::CliCommand
|
|
@@ -31,7 +22,7 @@ class Morpheus::Cli::Hosts
|
|
|
31
22
|
def connect(opts)
|
|
32
23
|
@api_client = establish_remote_appliance_connection(opts)
|
|
33
24
|
@accounts_interface = @api_client.accounts
|
|
34
|
-
@
|
|
25
|
+
@account_users_interface = @api_client.account_users
|
|
35
26
|
@clouds_interface = @api_client.clouds
|
|
36
27
|
@options_interface = @api_client.options
|
|
37
28
|
@tasks_interface = @api_client.tasks
|
|
@@ -90,25 +81,25 @@ class Morpheus::Cli::Hosts
|
|
|
90
81
|
opts.on( '--plan-code CODE', String, "Filter by Plan code(s)" ) do |val|
|
|
91
82
|
params['planCode'] = parse_id_list(val)
|
|
92
83
|
end
|
|
93
|
-
opts.on(
|
|
84
|
+
opts.on('--vm', "Show only virtual machines" ) do
|
|
94
85
|
params[:vm] = true
|
|
95
86
|
end
|
|
96
|
-
opts.on(
|
|
87
|
+
opts.on('--hypervisor', "Show only VM Hypervisors" ) do
|
|
97
88
|
params[:vmHypervisor] = true
|
|
98
89
|
end
|
|
99
|
-
opts.on(
|
|
90
|
+
opts.on('--container', "Show only Container Hypervisors" ) do
|
|
100
91
|
params[:containerHypervisor] = true
|
|
101
92
|
end
|
|
102
|
-
opts.on(
|
|
93
|
+
opts.on('--baremetal', "Show only Baremetal Servers" ) do
|
|
103
94
|
params[:bareMetalHost] = true
|
|
104
95
|
end
|
|
105
|
-
opts.on(
|
|
96
|
+
opts.on('--status STATUS', String, "Filter by Status" ) do |val|
|
|
106
97
|
params[:status] = val
|
|
107
98
|
end
|
|
108
|
-
opts.on(
|
|
99
|
+
opts.on('--agent', "Show only Servers with the agent installed" ) do
|
|
109
100
|
params[:agentInstalled] = true
|
|
110
101
|
end
|
|
111
|
-
opts.on(
|
|
102
|
+
opts.on('--noagent', "Show only Servers with No agent" ) do
|
|
112
103
|
params[:agentInstalled] = false
|
|
113
104
|
end
|
|
114
105
|
opts.on( '--created-by USER', "Created By User Username or ID" ) do |val|
|
|
@@ -383,25 +374,25 @@ class Morpheus::Cli::Hosts
|
|
|
383
374
|
opts.on( '-i', '--ip IPADDRESS', "Filter by IP Address" ) do |val|
|
|
384
375
|
params[:ip] = val
|
|
385
376
|
end
|
|
386
|
-
opts.on(
|
|
377
|
+
opts.on('--vm', "Show only virtual machines" ) do
|
|
387
378
|
params[:vm] = true
|
|
388
379
|
end
|
|
389
|
-
opts.on(
|
|
380
|
+
opts.on('--hypervisor', "Show only VM Hypervisors" ) do
|
|
390
381
|
params[:vmHypervisor] = true
|
|
391
382
|
end
|
|
392
|
-
opts.on(
|
|
383
|
+
opts.on('--container', "Show only Container Hypervisors" ) do
|
|
393
384
|
params[:containerHypervisor] = true
|
|
394
385
|
end
|
|
395
|
-
opts.on(
|
|
386
|
+
opts.on('--baremetal', "Show only Baremetal Servers" ) do
|
|
396
387
|
params[:bareMetalHost] = true
|
|
397
388
|
end
|
|
398
|
-
opts.on(
|
|
389
|
+
opts.on('--status STATUS', "Filter by Status" ) do |val|
|
|
399
390
|
params[:status] = val
|
|
400
391
|
end
|
|
401
|
-
opts.on(
|
|
392
|
+
opts.on('--agent', "Show only Servers with the agent installed" ) do
|
|
402
393
|
params[:agentInstalled] = true
|
|
403
394
|
end
|
|
404
|
-
opts.on(
|
|
395
|
+
opts.on('--noagent', "Show only Servers with No agent" ) do
|
|
405
396
|
params[:agentInstalled] = false
|
|
406
397
|
end
|
|
407
398
|
opts.on( '--created-by USER', "Created By User Username or ID" ) do |val|
|
|
@@ -553,7 +544,6 @@ class Morpheus::Cli::Hosts
|
|
|
553
544
|
server_columns.delete("Cost") if server['hourlyCost'].to_f == 0
|
|
554
545
|
server_columns.delete("Price") if server['hourlyPrice'].to_f == 0 || server['hourlyPrice'] == server['hourlyCost']
|
|
555
546
|
server_columns.delete("Labels") if server['labels'].nil? || server['labels'].empty?
|
|
556
|
-
server_columns.delete("Tags") if tags.nil? || tags.empty?
|
|
557
547
|
|
|
558
548
|
print_description_list(server_columns, server)
|
|
559
549
|
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
require 'json'
|
|
2
|
-
require 'yaml'
|
|
3
|
-
require 'rest_client'
|
|
4
|
-
require 'optparse'
|
|
5
|
-
require 'filesize'
|
|
6
1
|
require 'morpheus/cli/cli_command'
|
|
7
|
-
require 'morpheus/cli/
|
|
8
|
-
require 'morpheus/cli/
|
|
9
|
-
require 'morpheus/cli/preseed_scripts_command'
|
|
2
|
+
# require 'morpheus/cli/commands/boot_scripts_command'
|
|
3
|
+
# require 'morpheus/cli/commands/preseed_scripts_command'
|
|
10
4
|
|
|
11
5
|
class Morpheus::Cli::ImageBuilderCommand
|
|
12
6
|
include Morpheus::Cli::CliCommand
|
|
@@ -1071,20 +1065,16 @@ class Morpheus::Cli::ImageBuilderCommand
|
|
|
1071
1065
|
preseed_script_id = nil
|
|
1072
1066
|
if options['preseedScript']
|
|
1073
1067
|
preseed_script = find_preseed_script(options['preseedScript'])
|
|
1074
|
-
if
|
|
1075
|
-
|
|
1076
|
-
return false
|
|
1068
|
+
if preseed_script
|
|
1069
|
+
preseed_script_id = preseed_script['id']
|
|
1077
1070
|
end
|
|
1078
|
-
preseed_script_id = preseed_script['id']
|
|
1079
1071
|
else
|
|
1080
1072
|
preseed_script_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'preseedScript', 'type' => 'select', 'fieldLabel' => 'Preseed Script', 'selectOptions' => get_available_preseed_scripts(), 'required' => false, 'description' => 'Select Preseed Script.', 'defaultValue' => default_values['preseedScript'], :fmt=>:natural}],options,api_client,{})
|
|
1081
1073
|
# preseed_script_id = preseed_script_prompt['preseedScript']
|
|
1082
1074
|
preseed_script = find_preseed_script(preseed_script_prompt['preseedScript'])
|
|
1083
|
-
if
|
|
1084
|
-
|
|
1085
|
-
return false
|
|
1075
|
+
if preseed_script
|
|
1076
|
+
preseed_script_id = preseed_script['id']
|
|
1086
1077
|
end
|
|
1087
|
-
preseed_script_id = preseed_script['id']
|
|
1088
1078
|
end
|
|
1089
1079
|
if preseed_script_id
|
|
1090
1080
|
# payload['preseedScript'] = preseed_script_id
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
require 'io/console'
|
|
2
|
-
require 'rest_client'
|
|
3
|
-
require 'optparse'
|
|
4
|
-
require 'filesize'
|
|
5
1
|
require 'morpheus/cli/cli_command'
|
|
6
2
|
|
|
7
3
|
class Morpheus::Cli::Instances
|
|
@@ -26,7 +22,8 @@ class Morpheus::Cli::Instances
|
|
|
26
22
|
:scaling, {:'scaling-update' => :scaling_update},
|
|
27
23
|
:wiki, :update_wiki,
|
|
28
24
|
{:exec => :execution_request},
|
|
29
|
-
:deploys
|
|
25
|
+
:deploys,
|
|
26
|
+
:refresh, :apply
|
|
30
27
|
#register_subcommands :firewall_disable, :firewall_enable
|
|
31
28
|
# register_subcommands {:'lb-update' => :load_balancer_update}
|
|
32
29
|
alias_subcommand :details, :get
|
|
@@ -39,7 +36,7 @@ class Morpheus::Cli::Instances
|
|
|
39
36
|
def connect(opts)
|
|
40
37
|
@api_client = establish_remote_appliance_connection(opts)
|
|
41
38
|
@accounts_interface = @api_client.accounts
|
|
42
|
-
@
|
|
39
|
+
@account_users_interface = @api_client.account_users
|
|
43
40
|
@instances_interface = @api_client.instances
|
|
44
41
|
@task_sets_interface = @api_client.task_sets
|
|
45
42
|
@logs_interface = @api_client.logs
|
|
@@ -81,6 +78,12 @@ class Morpheus::Cli::Instances
|
|
|
81
78
|
opts.on( '--created-by USER', "Alias for --owner" ) do |val|
|
|
82
79
|
options[:owner] = val
|
|
83
80
|
end
|
|
81
|
+
opts.on('--agent', "Show only Instances with the agent installed" ) do
|
|
82
|
+
params[:agentInstalled] = true
|
|
83
|
+
end
|
|
84
|
+
opts.on('--noagent', "Show only Instances with No agent" ) do
|
|
85
|
+
params[:agentInstalled] = false
|
|
86
|
+
end
|
|
84
87
|
opts.add_hidden_option('--created-by')
|
|
85
88
|
opts.on('--status STATUS', "Filter by status i.e. provisioning,running,starting,stopping") do |val|
|
|
86
89
|
params['status'] = (params['status'] || []) + val.to_s.split(',').collect {|s| s.strip }.select {|s| s != "" }
|
|
@@ -1365,7 +1368,6 @@ class Morpheus::Cli::Instances
|
|
|
1365
1368
|
"Status" => lambda {|it| format_instance_status(it) }
|
|
1366
1369
|
}
|
|
1367
1370
|
description_cols.delete("Labels") if labels.nil? || labels.empty?
|
|
1368
|
-
description_cols.delete("Tags") if tags.nil? || tags.empty?
|
|
1369
1371
|
description_cols.delete("Apps") if instance['apps'].nil? || instance['apps'].empty?
|
|
1370
1372
|
description_cols.delete("Power Schedule") if instance['powerSchedule'].nil?
|
|
1371
1373
|
description_cols.delete("Expire Date") if instance['expireDate'].nil?
|
|
@@ -1694,19 +1696,77 @@ class Morpheus::Cli::Instances
|
|
|
1694
1696
|
options = {:options => {}}
|
|
1695
1697
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1696
1698
|
opts.banner = subcommand_usage("[instance] -g GROUP")
|
|
1697
|
-
opts.on('--name VALUE', String, "Name") do |val|
|
|
1698
|
-
options[:options]['name'] = val
|
|
1699
|
-
end
|
|
1700
1699
|
opts.on( '-g', '--group GROUP', "Group Name or ID for the new instance" ) do |val|
|
|
1701
1700
|
options[:group] = val
|
|
1702
1701
|
end
|
|
1703
1702
|
opts.on( '-c', '--cloud CLOUD', "Cloud Name or ID for the new instance" ) do |val|
|
|
1704
1703
|
options[:cloud] = val
|
|
1705
1704
|
end
|
|
1705
|
+
opts.on('--name VALUE', String, "Name") do |val|
|
|
1706
|
+
options[:options]['name'] = val
|
|
1707
|
+
end
|
|
1708
|
+
opts.on("--description [TEXT]", String, "Description") do |val|
|
|
1709
|
+
options[:description] = val.to_s
|
|
1710
|
+
end
|
|
1711
|
+
opts.on("--environment ENV", String, "Environment code") do |val|
|
|
1712
|
+
options[:environment] = val.to_s
|
|
1713
|
+
end
|
|
1714
|
+
opts.on('--tags LIST', String, "Metadata tags in the format 'ping=pong,flash=bang'") do |val|
|
|
1715
|
+
options[:metadata] = val
|
|
1716
|
+
end
|
|
1717
|
+
opts.on('--metadata LIST', String, "Metadata tags in the format 'ping=pong,flash=bang'") do |val|
|
|
1718
|
+
options[:metadata] = val
|
|
1719
|
+
end
|
|
1720
|
+
opts.add_hidden_option('--metadata')
|
|
1721
|
+
opts.on('--labels LIST', String, "Labels (keywords) in the format 'foo, bar'") do |val|
|
|
1722
|
+
options[:labels] = val.split(',').collect {|it| it.to_s.strip }.compact.uniq.join(',')
|
|
1723
|
+
end
|
|
1724
|
+
# opts.on("--copies NUMBER", Integer, "Number of copies to provision") do |val|
|
|
1725
|
+
# options[:copies] = val.to_i
|
|
1726
|
+
# end
|
|
1727
|
+
# opts.on("--layout-size NUMBER", Integer, "Apply a multiply factor of containers/vms within the instance") do |val|
|
|
1728
|
+
# options[:layout_size] = val.to_i
|
|
1729
|
+
# end
|
|
1730
|
+
# opts.on( '-l', '--layout LAYOUT', "Layout ID" ) do |val|
|
|
1731
|
+
# options[:layout] = val
|
|
1732
|
+
# end
|
|
1733
|
+
opts.on( '-p', '--plan PLAN', "Service plan ID") do |val|
|
|
1734
|
+
options[:service_plan] = val
|
|
1735
|
+
end
|
|
1736
|
+
opts.on( '--resource-pool ID', String, "Resource pool ID" ) do |val|
|
|
1737
|
+
options[:resource_pool] = val
|
|
1738
|
+
end
|
|
1739
|
+
opts.on("--workflow ID", String, "Automation: Workflow ID") do |val|
|
|
1740
|
+
options[:workflow_id] = val
|
|
1741
|
+
end
|
|
1742
|
+
opts.on("--ports ARRAY", String, "Exposed Ports, JSON formatted list of objects containing name and port") do |val|
|
|
1743
|
+
# expects format like --ports '[{"name":"web","port":8080}]'
|
|
1744
|
+
ports_array = JSON.parse(val)
|
|
1745
|
+
options[:ports] = ports_array
|
|
1746
|
+
options[:options]['ports'] = ports_array
|
|
1747
|
+
end
|
|
1748
|
+
# opts.on('-L', "--lb", "Enable Load Balancer") do
|
|
1749
|
+
# options[:enable_load_balancer] = true
|
|
1750
|
+
# end
|
|
1706
1751
|
opts.on("--create-user on|off", String, "User Config: Create Your User. Default is on") do |val|
|
|
1707
1752
|
options[:create_user] = !['false','off','0'].include?(val.to_s)
|
|
1708
1753
|
end
|
|
1709
|
-
|
|
1754
|
+
opts.on("--user-group USERGROUP", String, "User Config: User Group") do |val|
|
|
1755
|
+
options[:user_group_id] = val
|
|
1756
|
+
end
|
|
1757
|
+
opts.on("--shutdown-days DAYS", Integer, "Automation: Shutdown Days") do |val|
|
|
1758
|
+
options[:shutdown_days] = val.to_i
|
|
1759
|
+
end
|
|
1760
|
+
opts.on("--expire-days DAYS", Integer, "Automation: Expiration Days") do |val|
|
|
1761
|
+
options[:expire_days] = val.to_i
|
|
1762
|
+
end
|
|
1763
|
+
opts.on("--create-backup [on|off]", String, "Automation: Create Backups.") do |val|
|
|
1764
|
+
options[:create_backup] = ['on','true','1',''].include?(val.to_s.downcase) ? 'on' : 'off'
|
|
1765
|
+
end
|
|
1766
|
+
opts.on("--security-groups LIST", String, "Security Groups, comma separated list of security group IDs") do |val|
|
|
1767
|
+
options[:security_groups] = val.split(",").collect {|s| s.strip }.select {|s| !s.to_s.empty? }
|
|
1768
|
+
end
|
|
1769
|
+
build_standard_post_options(opts, options, [:auto_confirm])
|
|
1710
1770
|
end
|
|
1711
1771
|
optparse.parse!(args)
|
|
1712
1772
|
if args.count < 1 || args.count > 2
|
|
@@ -1724,12 +1784,20 @@ class Morpheus::Cli::Instances
|
|
|
1724
1784
|
|
|
1725
1785
|
# defaults derived from clone
|
|
1726
1786
|
options[:default_name] = instance['name'] + '-clone' if instance['name']
|
|
1787
|
+
options[:default_description] = instance['description'] if !instance['description'].to_s.empty?
|
|
1788
|
+
options[:default_environment] = instance['environment'] if instance['environment']
|
|
1727
1789
|
options[:default_group] = instance['group']['id'] if instance['group']
|
|
1728
1790
|
options[:default_cloud] = instance['cloud']['name'] if instance['cloud']
|
|
1729
1791
|
options[:default_plan] = instance['plan']['name'] if instance['plan']
|
|
1730
1792
|
options[:default_resource_pool] = instance['config']['resourcePoolId'] if instance['config']
|
|
1731
1793
|
options[:default_config] = instance['config']
|
|
1732
1794
|
options[:default_security_group] = instance['config']['securityGroups'][0]['id'] if instance['config'] && (instance['config']['securityGroups'] || []).count > 0
|
|
1795
|
+
if instance['labels'] && !instance['labels'].empty?
|
|
1796
|
+
options[:default_labels] = (instance['labels'] || []).join(',')
|
|
1797
|
+
end
|
|
1798
|
+
if instance['tags'] && !instance['tags'].empty?
|
|
1799
|
+
options[:current_tags] = instance['tags']
|
|
1800
|
+
end
|
|
1733
1801
|
|
|
1734
1802
|
# immutable derived from clone
|
|
1735
1803
|
options[:instance_type_code] = instance['instanceType']['code'] if instance['instanceType']
|
|
@@ -1767,13 +1835,52 @@ class Morpheus::Cli::Instances
|
|
|
1767
1835
|
payload.deep_merge!(passed_options)
|
|
1768
1836
|
end
|
|
1769
1837
|
|
|
1838
|
+
#payload['instance'] ||= {}
|
|
1839
|
+
# if options[:instance_name]
|
|
1840
|
+
# payload['instance']['name'] = options[:instance_name]
|
|
1841
|
+
# end
|
|
1842
|
+
# if options[:description] && !payload['instance']['description']
|
|
1843
|
+
# payload['instance']['description'] = options[:description]
|
|
1844
|
+
# end
|
|
1845
|
+
# if options[:environment] && !payload['instance']['instanceContext']
|
|
1846
|
+
# payload['instance']['instanceContext'] = options[:environment]
|
|
1847
|
+
# end
|
|
1848
|
+
|
|
1849
|
+
#payload[:copies] = options[:copies] if options[:copies] && options[:copies] > 0
|
|
1850
|
+
if options[:layout_size] && options[:layout_size] > 0 # aka Scale Factor
|
|
1851
|
+
payload[:layoutSize] = options[:layout_size]
|
|
1852
|
+
end
|
|
1853
|
+
if !options[:create_backup].nil?
|
|
1854
|
+
payload[:createBackup] = options[:create_backup]
|
|
1855
|
+
end
|
|
1856
|
+
if options[:expire_days]
|
|
1857
|
+
payload['instance'] ||= {}
|
|
1858
|
+
payload['instance']['expireDays'] = options[:expire_days]
|
|
1859
|
+
end
|
|
1860
|
+
if options[:shutdown_days]
|
|
1861
|
+
payload['instance'] ||= {}
|
|
1862
|
+
payload['shutdownDays'] = options[:shutdown_days]
|
|
1863
|
+
end
|
|
1770
1864
|
# JD: this actually fixed a customer problem
|
|
1771
1865
|
# It appears to be important to pass this... not sure if config.createUser is necessary...
|
|
1772
1866
|
if options[:create_user].nil?
|
|
1773
1867
|
options[:create_user] = true
|
|
1774
1868
|
end
|
|
1775
|
-
if options
|
|
1776
|
-
payload
|
|
1869
|
+
if options.key?(:create_user)
|
|
1870
|
+
payload['config'] ||= {}
|
|
1871
|
+
payload['config']['createUser'] = options[:create_user]
|
|
1872
|
+
payload['createUser'] = options[:create_user]
|
|
1873
|
+
end
|
|
1874
|
+
if options[:user_group_id]
|
|
1875
|
+
payload['instance'] ||= {}
|
|
1876
|
+
payload['instance']['userGroup'] = {'id' => options[:user_group_id] }
|
|
1877
|
+
end
|
|
1878
|
+
if options[:workflow_id]
|
|
1879
|
+
if options[:workflow_id].to_s =~ /\A\d{1,}\Z/
|
|
1880
|
+
payload['taskSetId'] = options[:workflow_id].to_i
|
|
1881
|
+
else
|
|
1882
|
+
payload['taskSetName'] = options[:workflow_id]
|
|
1883
|
+
end
|
|
1777
1884
|
end
|
|
1778
1885
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to clone the instance #{instance['name']} as '#{payload['name']}'?", options)
|
|
1779
1886
|
return 9, "aborted command"
|
|
@@ -4130,6 +4237,106 @@ EOT
|
|
|
4130
4237
|
return 0, nil
|
|
4131
4238
|
end
|
|
4132
4239
|
|
|
4240
|
+
def refresh(args)
|
|
4241
|
+
params, payload, options = {}, {}, {}
|
|
4242
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
4243
|
+
opts.banner = subcommand_usage("[instance] [options]")
|
|
4244
|
+
build_standard_update_options(opts, options, [:auto_confirm])
|
|
4245
|
+
opts.footer = <<-EOT
|
|
4246
|
+
Refresh an instance.
|
|
4247
|
+
[instance] is required. This is the name or id of an instance.
|
|
4248
|
+
This is only supported by certain types of instances such as terraform.
|
|
4249
|
+
EOT
|
|
4250
|
+
end
|
|
4251
|
+
optparse.parse!(args)
|
|
4252
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
4253
|
+
connect(options)
|
|
4254
|
+
|
|
4255
|
+
begin
|
|
4256
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
4257
|
+
return 1 if instance.nil?
|
|
4258
|
+
# construct request
|
|
4259
|
+
params.merge!(parse_query_options(options))
|
|
4260
|
+
payload = {}
|
|
4261
|
+
if options[:payload]
|
|
4262
|
+
payload = options[:payload]
|
|
4263
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
4264
|
+
else
|
|
4265
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
4266
|
+
# raise_command_error "Specify at least one option to update.\n#{optparse}" if payload.empty?
|
|
4267
|
+
end
|
|
4268
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to refresh this instance: #{instance['name']}?")
|
|
4269
|
+
return 9, "aborted command"
|
|
4270
|
+
end
|
|
4271
|
+
@instances_interface.setopts(options)
|
|
4272
|
+
if options[:dry_run]
|
|
4273
|
+
print_dry_run @instances_interface.dry.refresh(instance["id"], params, payload)
|
|
4274
|
+
return
|
|
4275
|
+
end
|
|
4276
|
+
json_response = @instances_interface.refresh(instance["id"], params, payload)
|
|
4277
|
+
render_response(json_response, options) do
|
|
4278
|
+
print_green_success "Refreshing instance #{instance['name']}"
|
|
4279
|
+
# return _get(instance['id'], options)
|
|
4280
|
+
end
|
|
4281
|
+
return 0, nil
|
|
4282
|
+
rescue RestClient::Exception => e
|
|
4283
|
+
print_rest_exception(e, options)
|
|
4284
|
+
exit 1
|
|
4285
|
+
end
|
|
4286
|
+
end
|
|
4287
|
+
|
|
4288
|
+
def apply(args)
|
|
4289
|
+
params, payload, options = {}, {}, {}
|
|
4290
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
4291
|
+
opts.banner = subcommand_usage("[instance] [options]")
|
|
4292
|
+
build_standard_update_options(opts, options, [:auto_confirm])
|
|
4293
|
+
opts.footer = <<-EOT
|
|
4294
|
+
Apply an instance.
|
|
4295
|
+
[instance] is required. This is the name or id of an instance.
|
|
4296
|
+
This is only supported by certain types of instances such as terraform.
|
|
4297
|
+
EOT
|
|
4298
|
+
end
|
|
4299
|
+
optparse.parse!(args)
|
|
4300
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
4301
|
+
connect(options)
|
|
4302
|
+
|
|
4303
|
+
begin
|
|
4304
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
4305
|
+
return 1 if instance.nil?
|
|
4306
|
+
# construct request
|
|
4307
|
+
params.merge!(parse_query_options(options))
|
|
4308
|
+
payload = {}
|
|
4309
|
+
if options[:payload]
|
|
4310
|
+
payload = options[:payload]
|
|
4311
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
4312
|
+
else
|
|
4313
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
4314
|
+
# raise_command_error "Specify at least one option to update.\n#{optparse}" if payload.empty?
|
|
4315
|
+
end
|
|
4316
|
+
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to apply this instance: #{instance['name']}?")
|
|
4317
|
+
return 9, "aborted command"
|
|
4318
|
+
end
|
|
4319
|
+
@instances_interface.setopts(options)
|
|
4320
|
+
if options[:dry_run]
|
|
4321
|
+
print_dry_run @instances_interface.dry.apply(instance["id"], params, payload)
|
|
4322
|
+
return
|
|
4323
|
+
end
|
|
4324
|
+
json_response = @instances_interface.apply(instance["id"], params, payload)
|
|
4325
|
+
render_response(json_response, options) do
|
|
4326
|
+
print_green_success "Applying instance #{instance['name']}"
|
|
4327
|
+
# return _get(instance['id'], options)
|
|
4328
|
+
end
|
|
4329
|
+
return 0, nil
|
|
4330
|
+
rescue RestClient::Exception => e
|
|
4331
|
+
print_rest_exception(e, options)
|
|
4332
|
+
exit 1
|
|
4333
|
+
end
|
|
4334
|
+
end
|
|
4335
|
+
|
|
4336
|
+
# todo: print state summary
|
|
4337
|
+
def state_summary(args)
|
|
4338
|
+
end
|
|
4339
|
+
|
|
4133
4340
|
private
|
|
4134
4341
|
|
|
4135
4342
|
def find_zone_by_name_or_id(group_id, val)
|