morpheus-cli 5.3.2.3 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/account_users_interface.rb +68 -0
- data/lib/morpheus/api/api_client.rb +75 -8
- data/lib/morpheus/api/audit_interface.rb +9 -0
- data/lib/morpheus/api/clouds_interface.rb +4 -11
- data/lib/morpheus/api/health_interface.rb +37 -3
- data/lib/morpheus/api/instances_interface.rb +39 -5
- data/lib/morpheus/api/load_balancer_monitors_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +9 -0
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +9 -0
- data/lib/morpheus/api/load_balancers_interface.rb +5 -0
- data/lib/morpheus/api/network_dhcp_relays_interface.rb +36 -0
- data/lib/morpheus/api/network_dhcp_servers_interface.rb +36 -0
- data/lib/morpheus/api/network_edge_clusters_interface.rb +26 -0
- data/lib/morpheus/api/network_routers_interface.rb +30 -0
- data/lib/morpheus/api/network_servers_interface.rb +98 -0
- data/lib/morpheus/api/network_static_routes_interface.rb +36 -0
- data/lib/morpheus/api/read_interface.rb +4 -3
- data/lib/morpheus/api/rest_interface.rb +5 -4
- data/lib/morpheus/api/roles_interface.rb +7 -0
- data/lib/morpheus/api/secondary_read_interface.rb +1 -1
- data/lib/morpheus/api/secondary_rest_interface.rb +19 -19
- data/lib/morpheus/api/storage_server_types_interface.rb +14 -0
- data/lib/morpheus/api/storage_servers_interface.rb +9 -0
- data/lib/morpheus/api/storage_volume_types_interface.rb +9 -0
- data/lib/morpheus/api/storage_volumes_interface.rb +9 -0
- data/lib/morpheus/api/users_interface.rb +16 -63
- data/lib/morpheus/api/virtual_images_interface.rb +23 -2
- data/lib/morpheus/api/virtual_servers_interface.rb +9 -0
- data/lib/morpheus/cli/cli_command.rb +274 -19
- data/lib/morpheus/cli/cli_registry.rb +56 -2
- data/lib/morpheus/cli/{access_token_command.rb → commands/access_token_command.rb} +1 -1
- data/lib/morpheus/cli/{account_groups_command.rb → commands/account_groups_command.rb} +0 -8
- data/lib/morpheus/cli/{activity_command.rb → commands/activity_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/alias_command.rb → alias_command.rb} +1 -4
- data/lib/morpheus/cli/{appliance_settings_command.rb → commands/appliance_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{approvals_command.rb → commands/approvals_command.rb} +0 -0
- data/lib/morpheus/cli/{apps.rb → commands/apps.rb} +17 -89
- data/lib/morpheus/cli/{archives_command.rb → commands/archives_command.rb} +0 -6
- data/lib/morpheus/cli/commands/audit.rb +188 -0
- data/lib/morpheus/cli/{backup_jobs_command.rb → commands/backup_jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{backup_settings_command.rb → commands/backup_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{backups_command.rb → commands/backups_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/benchmark_command.rb → benchmark_command.rb} +0 -3
- data/lib/morpheus/cli/{blueprints_command.rb → commands/blueprints_command.rb} +1 -1
- data/lib/morpheus/cli/{boot_scripts_command.rb → commands/boot_scripts_command.rb} +0 -3
- data/lib/morpheus/cli/{budgets_command.rb → commands/budgets_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/cat_command.rb → cat_command.rb} +0 -0
- data/lib/morpheus/cli/{catalog_item_types_command.rb → commands/catalog_item_types_command.rb} +0 -0
- data/lib/morpheus/cli/{certificates_command.rb → commands/certificates_command.rb} +0 -0
- data/lib/morpheus/cli/commands/change_password_command.rb +132 -0
- data/lib/morpheus/cli/{cloud_datastores_command.rb → commands/cloud_datastores_command.rb} +0 -4
- data/lib/morpheus/cli/{cloud_folders_command.rb → commands/cloud_folders_command.rb} +0 -4
- data/lib/morpheus/cli/{cloud_resource_pools_command.rb → commands/cloud_resource_pools_command.rb} +170 -138
- data/lib/morpheus/cli/{clouds.rb → commands/clouds.rb} +22 -47
- data/lib/morpheus/cli/{clusters.rb → commands/clusters.rb} +86 -49
- data/lib/morpheus/cli/commands/{standard/coloring_command.rb → coloring_command.rb} +0 -2
- data/lib/morpheus/cli/{containers_command.rb → commands/containers_command.rb} +0 -7
- data/lib/morpheus/cli/commands/{standard/curl_command.rb → curl_command.rb} +0 -3
- data/lib/morpheus/cli/{cypher_command.rb → commands/cypher_command.rb} +0 -1
- data/lib/morpheus/cli/{dashboard_command.rb → commands/dashboard_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/debug_command.rb → debug_command.rb} +0 -1
- data/lib/morpheus/cli/{deploy.rb → commands/deploy.rb} +0 -1
- data/lib/morpheus/cli/{deployments.rb → commands/deployments.rb} +0 -0
- data/lib/morpheus/cli/{deploys.rb → commands/deploys.rb} +0 -1
- data/lib/morpheus/cli/{doc.rb → commands/doc.rb} +1 -1
- data/lib/morpheus/cli/commands/{standard/echo_command.rb → echo_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/edit_profile_command.rb → edit_profile_command.rb} +15 -4
- data/lib/morpheus/cli/commands/{standard/edit_rc_command.rb → edit_rc_command.rb} +19 -3
- data/lib/morpheus/cli/{environments_command.rb → commands/environments_command.rb} +0 -5
- data/lib/morpheus/cli/{execute_schedules_command.rb → commands/execute_schedules_command.rb} +0 -0
- data/lib/morpheus/cli/{execution_request_command.rb → commands/execution_request_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/exit_command.rb → exit_command.rb} +0 -2
- data/lib/morpheus/cli/{file_copy_request_command.rb → commands/file_copy_request_command.rb} +0 -4
- data/lib/morpheus/cli/{forgot_password.rb → commands/forgot_password.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/get_prompt_command.rb → get_prompt_command.rb} +0 -3
- data/lib/morpheus/cli/{groups.rb → commands/groups.rb} +0 -7
- data/lib/morpheus/cli/{guidance_command.rb → commands/guidance_command.rb} +1 -1
- data/lib/morpheus/cli/{health_command.rb → commands/health_command.rb} +104 -19
- data/lib/morpheus/cli/commands/{standard/history_command.rb → history_command.rb} +0 -3
- data/lib/morpheus/cli/{hosts.rb → commands/hosts.rb} +15 -25
- data/lib/morpheus/cli/{image_builder_command.rb → commands/image_builder_command.rb} +2 -8
- data/lib/morpheus/cli/{instance_types.rb → commands/instance_types.rb} +0 -3
- data/lib/morpheus/cli/{instances.rb → commands/instances.rb} +473 -150
- data/lib/morpheus/cli/{integrations_command.rb → commands/integrations_command.rb} +0 -0
- data/lib/morpheus/cli/{invoices_command.rb → commands/invoices_command.rb} +118 -134
- data/lib/morpheus/cli/{jobs_command.rb → commands/jobs_command.rb} +0 -0
- data/lib/morpheus/cli/{key_pairs.rb → commands/key_pairs.rb} +0 -6
- data/lib/morpheus/cli/{library_cluster_layouts_command.rb → commands/library_cluster_layouts_command.rb} +20 -4
- data/lib/morpheus/cli/{library_container_scripts_command.rb → commands/library_container_scripts_command.rb} +0 -0
- data/lib/morpheus/cli/{library_container_templates_command.rb → commands/library_container_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_container_types_command.rb → commands/library_container_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_instance_types_command.rb → commands/library_instance_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_layouts_command.rb → commands/library_layouts_command.rb} +0 -4
- data/lib/morpheus/cli/{library_option_lists_command.rb → commands/library_option_lists_command.rb} +3 -7
- data/lib/morpheus/cli/{library_option_types_command.rb → commands/library_option_types_command.rb} +0 -4
- data/lib/morpheus/cli/{library_spec_templates_command.rb → commands/library_spec_templates_command.rb} +0 -1
- data/lib/morpheus/cli/{library_upgrades_command.rb → commands/library_upgrades_command.rb} +0 -4
- data/lib/morpheus/cli/{license.rb → commands/license.rb} +0 -3
- data/lib/morpheus/cli/commands/load_balancer_monitors.rb +71 -0
- data/lib/morpheus/cli/commands/load_balancer_pools.rb +91 -0
- data/lib/morpheus/cli/commands/load_balancer_profiles.rb +65 -0
- data/lib/morpheus/cli/{load_balancer_types.rb → commands/load_balancer_types.rb} +9 -8
- data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +156 -0
- data/lib/morpheus/cli/commands/load_balancers.rb +176 -0
- data/lib/morpheus/cli/commands/{standard/log_level_command.rb → log_level_command.rb} +0 -3
- data/lib/morpheus/cli/{log_settings_command.rb → commands/log_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{login.rb → commands/login.rb} +0 -5
- data/lib/morpheus/cli/commands/logout.rb +63 -0
- data/lib/morpheus/cli/{logs_command.rb → commands/logs_command.rb} +0 -3
- data/lib/morpheus/cli/commands/{standard/man_command.rb → man_command.rb} +0 -2
- data/lib/morpheus/cli/{monitoring_alerts_command.rb → commands/monitoring_alerts_command.rb} +0 -7
- data/lib/morpheus/cli/{monitoring_apps_command.rb → commands/monitoring_apps_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_checks_command.rb → commands/monitoring_checks_command.rb} +2 -1
- data/lib/morpheus/cli/{monitoring_contacts_command.rb → commands/monitoring_contacts_command.rb} +0 -7
- data/lib/morpheus/cli/{monitoring_groups_command.rb → commands/monitoring_groups_command.rb} +0 -1
- data/lib/morpheus/cli/{monitoring_incidents_command.rb → commands/monitoring_incidents_command.rb} +0 -1
- data/lib/morpheus/cli/commands/network_dhcp_relays_command.rb +416 -0
- data/lib/morpheus/cli/commands/network_dhcp_servers_command.rb +407 -0
- data/lib/morpheus/cli/{network_domains_command.rb → commands/network_domains_command.rb} +0 -4
- data/lib/morpheus/cli/commands/network_edge_clusters_command.rb +329 -0
- data/lib/morpheus/cli/commands/network_firewalls_command.rb +823 -0
- data/lib/morpheus/cli/{network_groups_command.rb → commands/network_groups_command.rb} +0 -4
- data/lib/morpheus/cli/{network_pool_servers_command.rb → commands/network_pool_servers_command.rb} +0 -4
- data/lib/morpheus/cli/{network_pools_command.rb → commands/network_pools_command.rb} +0 -4
- data/lib/morpheus/cli/{network_proxies_command.rb → commands/network_proxies_command.rb} +0 -4
- data/lib/morpheus/cli/{network_routers_command.rb → commands/network_routers_command.rb} +387 -57
- data/lib/morpheus/cli/{network_services_command.rb → commands/network_services_command.rb} +0 -4
- data/lib/morpheus/cli/commands/network_static_routes_command.rb +446 -0
- data/lib/morpheus/cli/commands/network_transport_zones_command.rb +452 -0
- data/lib/morpheus/cli/{networks_command.rb → commands/networks_command.rb} +21 -21
- data/lib/morpheus/cli/commands/open_command.rb +30 -0
- data/lib/morpheus/cli/commands/options.rb +98 -0
- data/lib/morpheus/cli/{packages_command.rb → commands/packages_command.rb} +0 -2
- data/lib/morpheus/cli/{ping.rb → commands/ping.rb} +0 -7
- data/lib/morpheus/cli/{policies_command.rb → commands/policies_command.rb} +1 -8
- data/lib/morpheus/cli/{power_schedules_command.rb → commands/power_schedules_command.rb} +0 -0
- data/lib/morpheus/cli/{preseed_scripts_command.rb → commands/preseed_scripts_command.rb} +0 -3
- data/lib/morpheus/cli/{price_sets_command.rb → commands/price_sets_command.rb} +0 -0
- data/lib/morpheus/cli/{prices_command.rb → commands/prices_command.rb} +7 -7
- data/lib/morpheus/cli/{processes_command.rb → commands/processes_command.rb} +0 -1
- data/lib/morpheus/cli/{projects_command.rb → commands/projects_command.rb} +0 -0
- data/lib/morpheus/cli/{provisioning_licenses_command.rb → commands/provisioning_licenses_command.rb} +0 -0
- data/lib/morpheus/cli/{provisioning_settings_command.rb → commands/provisioning_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{recent_activity_command.rb → commands/recent_activity_command.rb} +0 -0
- data/lib/morpheus/cli/{remote.rb → commands/remote.rb} +5 -9
- data/lib/morpheus/cli/{reports_command.rb → commands/reports_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/rm_command.rb → rm_command.rb} +0 -0
- data/lib/morpheus/cli/{roles.rb → commands/roles.rb} +245 -40
- data/lib/morpheus/cli/{search_command.rb → commands/search_command.rb} +0 -0
- data/lib/morpheus/cli/{security_group_rules.rb → commands/security_group_rules.rb} +0 -5
- data/lib/morpheus/cli/{security_groups.rb → commands/security_groups.rb} +0 -6
- data/lib/morpheus/cli/{service_catalog_command.rb → commands/service_catalog_command.rb} +0 -0
- data/lib/morpheus/cli/{service_plans_command.rb → commands/service_plans_command.rb} +0 -0
- data/lib/morpheus/cli/commands/{standard/set_prompt_command.rb → set_prompt_command.rb} +0 -3
- data/lib/morpheus/cli/{setup.rb → commands/setup.rb} +0 -0
- data/lib/morpheus/cli/{shell.rb → commands/shell.rb} +4 -105
- data/lib/morpheus/cli/commands/{standard/sleep_command.rb → sleep_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/source_command.rb → source_command.rb} +0 -2
- data/lib/morpheus/cli/commands/{standard/ssl_verification_command.rb → ssl_verification_command.rb} +0 -3
- data/lib/morpheus/cli/{storage_providers_command.rb → commands/storage_providers_command.rb} +0 -4
- data/lib/morpheus/cli/commands/storage_server_types.rb +50 -0
- data/lib/morpheus/cli/commands/storage_servers.rb +122 -0
- data/lib/morpheus/cli/commands/storage_volume_types.rb +50 -0
- data/lib/morpheus/cli/commands/storage_volumes.rb +103 -0
- data/lib/morpheus/cli/{subnets_command.rb → commands/subnets_command.rb} +7 -6
- data/lib/morpheus/cli/{tasks.rb → commands/tasks.rb} +25 -6
- data/lib/morpheus/cli/commands/{standard/tee_command.rb → tee_command.rb} +0 -0
- data/lib/morpheus/cli/{tenants_command.rb → commands/tenants_command.rb} +1 -8
- data/lib/morpheus/cli/commands/{standard/update_command.rb → update_command.rb} +0 -1
- data/lib/morpheus/cli/{usage_command.rb → commands/usage_command.rb} +0 -0
- data/lib/morpheus/cli/{user_groups_command.rb → commands/user_groups_command.rb} +1 -2
- data/lib/morpheus/cli/{user_settings_command.rb → commands/user_settings_command.rb} +2 -1
- data/lib/morpheus/cli/{user_sources_command.rb → commands/user_sources_command.rb} +1 -2
- data/lib/morpheus/cli/{users.rb → commands/users.rb} +28 -35
- data/lib/morpheus/cli/{vdi_allocations_command.rb → commands/vdi_allocations_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_apps_command.rb → commands/vdi_apps_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_command.rb → commands/vdi_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_gateways_command.rb → commands/vdi_gateways_command.rb} +0 -0
- data/lib/morpheus/cli/{vdi_pools_command.rb → commands/vdi_pools_command.rb} +4 -1
- data/lib/morpheus/cli/commands/{standard/version_command.rb → version_command.rb} +0 -0
- data/lib/morpheus/cli/commands/view.rb +102 -0
- data/lib/morpheus/cli/{virtual_images.rb → commands/virtual_images.rb} +251 -33
- data/lib/morpheus/cli/{whitelabel_settings_command.rb → commands/whitelabel_settings_command.rb} +0 -1
- data/lib/morpheus/cli/{whoami.rb → commands/whoami.rb} +0 -4
- data/lib/morpheus/cli/{wiki_command.rb → commands/wiki_command.rb} +0 -5
- data/lib/morpheus/cli/{workflows.rb → commands/workflows.rb} +0 -3
- data/lib/morpheus/cli/mixins/accounts_helper.rb +5 -5
- data/lib/morpheus/cli/mixins/load_balancers_helper.rb +26 -6
- data/lib/morpheus/cli/mixins/logs_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +51 -18
- data/lib/morpheus/cli/mixins/processes_helper.rb +1 -2
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +167 -110
- data/lib/morpheus/cli/mixins/rest_command.rb +268 -94
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +668 -0
- data/lib/morpheus/cli/mixins/storage_servers_helper.rb +156 -0
- data/lib/morpheus/cli/mixins/storage_volumes_helper.rb +119 -0
- data/lib/morpheus/cli/option_parser.rb +25 -17
- data/lib/morpheus/cli/option_types.rb +137 -52
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +6 -128
- data/lib/morpheus/ext/string.rb +29 -6
- data/lib/morpheus/routes.rb +238 -0
- data/lib/morpheus/terminal.rb +5 -6
- data/lib/morpheus/util.rb +6 -1
- data/morpheus-cli.gemspec +1 -1
- metadata +183 -149
- data/lib/morpheus/cli/change_password_command.rb +0 -147
- data/lib/morpheus/cli/library.rb +0 -1
- data/lib/morpheus/cli/load_balancers.rb +0 -245
- data/lib/morpheus/cli/logout.rb +0 -81
|
@@ -1,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
|
|
@@ -15,9 +11,10 @@ class Morpheus::Cli::Instances
|
|
|
15
11
|
|
|
16
12
|
set_command_name :instances
|
|
17
13
|
set_command_description "View and manage instances."
|
|
18
|
-
register_subcommands :list, :count, :get, :view, :add, :update, :remove,
|
|
14
|
+
register_subcommands :list, :count, :get, :view, :add, :update, :remove,
|
|
15
|
+
:cancel_removal, :cancel_expiration, :cancel_shutdown, :extend_expiration, :extend_shutdown,
|
|
19
16
|
:history, {:'history-details' => :history_details}, {:'history-event' => :history_event_details},
|
|
20
|
-
:stats, :stop, :start, :restart, :actions, :action, :suspend, :eject, :stop_service, :start_service, :restart_service,
|
|
17
|
+
:logs, :stats, :stop, :start, :restart, :actions, :action, :suspend, :eject, :stop_service, :start_service, :restart_service,
|
|
21
18
|
:backup, :backups, :resize, :clone, :envs, :setenv, :delenv,
|
|
22
19
|
:lock, :unlock, :clone_image,
|
|
23
20
|
:security_groups, :apply_security_groups, :run_workflow, :import_snapshot, :snapshot, :snapshots,
|
|
@@ -25,7 +22,8 @@ class Morpheus::Cli::Instances
|
|
|
25
22
|
:scaling, {:'scaling-update' => :scaling_update},
|
|
26
23
|
:wiki, :update_wiki,
|
|
27
24
|
{:exec => :execution_request},
|
|
28
|
-
:deploys
|
|
25
|
+
:deploys,
|
|
26
|
+
:refresh, :apply
|
|
29
27
|
#register_subcommands :firewall_disable, :firewall_enable
|
|
30
28
|
# register_subcommands {:'lb-update' => :load_balancer_update}
|
|
31
29
|
alias_subcommand :details, :get
|
|
@@ -38,7 +36,7 @@ class Morpheus::Cli::Instances
|
|
|
38
36
|
def connect(opts)
|
|
39
37
|
@api_client = establish_remote_appliance_connection(opts)
|
|
40
38
|
@accounts_interface = @api_client.accounts
|
|
41
|
-
@
|
|
39
|
+
@account_users_interface = @api_client.account_users
|
|
42
40
|
@instances_interface = @api_client.instances
|
|
43
41
|
@task_sets_interface = @api_client.task_sets
|
|
44
42
|
@logs_interface = @api_client.logs
|
|
@@ -80,6 +78,12 @@ class Morpheus::Cli::Instances
|
|
|
80
78
|
opts.on( '--created-by USER', "Alias for --owner" ) do |val|
|
|
81
79
|
options[:owner] = val
|
|
82
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
|
|
83
87
|
opts.add_hidden_option('--created-by')
|
|
84
88
|
opts.on('--status STATUS', "Filter by status i.e. provisioning,running,starting,stopping") do |val|
|
|
85
89
|
params['status'] = (params['status'] || []) + val.to_s.split(',').collect {|s| s.strip }.select {|s| s != "" }
|
|
@@ -444,7 +448,7 @@ class Morpheus::Cli::Instances
|
|
|
444
448
|
opts.on('--refresh [SECONDS]', String, "Refresh until status is running,failed. Default interval is #{default_refresh_interval} seconds.") do |val|
|
|
445
449
|
options[:refresh_interval] = val.to_s.empty? ? default_refresh_interval : val.to_f
|
|
446
450
|
end
|
|
447
|
-
|
|
451
|
+
build_standard_add_options(opts, options) #, [:options, :payload, :json, :dry_run, :remote, :quiet])
|
|
448
452
|
opts.footer = "Create a new instance." + "\n" +
|
|
449
453
|
"[name] is required. This is the new instance name." + "\n" +
|
|
450
454
|
"The available options vary by --type."
|
|
@@ -462,33 +466,30 @@ class Morpheus::Cli::Instances
|
|
|
462
466
|
options[:instance_name] = args[0]
|
|
463
467
|
end
|
|
464
468
|
|
|
465
|
-
|
|
466
|
-
payload =
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
group =
|
|
475
|
-
if
|
|
476
|
-
group
|
|
477
|
-
if group.nil?
|
|
478
|
-
return 1, "group not found by #{options[:group]}"
|
|
479
|
-
end
|
|
480
|
-
#payload["siteId"] = group["id"]
|
|
481
|
-
payload.deep_merge!({"instance" => {"site" => {"id" => group["id"]} } })
|
|
469
|
+
if options[:payload]
|
|
470
|
+
payload = options[:payload]
|
|
471
|
+
# support -O OPTION switch on top of --payload
|
|
472
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
|
473
|
+
# obviously should support every option that prompt supports on top of -- payload as well
|
|
474
|
+
# group, cloud and type for now
|
|
475
|
+
# todo: also support :layout, service_plan, :resource_pool, etc.
|
|
476
|
+
group = nil
|
|
477
|
+
if options[:group]
|
|
478
|
+
group = find_group_by_name_or_id_for_provisioning(options[:group])
|
|
479
|
+
if group.nil?
|
|
480
|
+
return 1, "group not found by #{options[:group]}"
|
|
482
481
|
end
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
payload.deep_merge!({"instance" => {"cloud" => cloud["name"] } })
|
|
482
|
+
payload.deep_merge!({"instance" => {"site" => {"id" => group["id"]} } })
|
|
483
|
+
end
|
|
484
|
+
if options[:cloud]
|
|
485
|
+
group_id = group ? group["id"] : ((payload["instance"] && payload["instance"]["site"].is_a?(Hash)) ? payload["instance"]["site"]["id"] : nil)
|
|
486
|
+
cloud = find_cloud_by_name_or_id_for_provisioning(group_id, options[:cloud])
|
|
487
|
+
if cloud.nil?
|
|
488
|
+
return 1, "cloud not found by #{options[:cloud]}"
|
|
491
489
|
end
|
|
490
|
+
payload["zoneId"] = cloud["id"]
|
|
491
|
+
payload.deep_merge!({"instance" => {"cloud" => cloud["name"] } })
|
|
492
|
+
end
|
|
492
493
|
if options[:cloud]
|
|
493
494
|
group_id = group ? group["id"] : ((payload["instance"] && payload["instance"]["site"].is_a?(Hash)) ? payload["instance"]["site"]["id"] : nil)
|
|
494
495
|
cloud = find_cloud_by_name_or_id_for_provisioning(group_id, options[:cloud])
|
|
@@ -498,96 +499,90 @@ class Morpheus::Cli::Instances
|
|
|
498
499
|
payload["zoneId"] = cloud["id"]
|
|
499
500
|
payload.deep_merge!({"instance" => {"cloud" => cloud["name"] } })
|
|
500
501
|
end
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
end
|
|
508
|
-
payload.deep_merge!({"instance" => {"type" => instance_type["code"] } })
|
|
509
|
-
payload.deep_merge!({"instance" => {"instanceType" => {"code" => instance_type["code"]} } })
|
|
510
|
-
end
|
|
511
|
-
|
|
512
|
-
else
|
|
513
|
-
# use active group by default
|
|
514
|
-
options[:group] ||= @active_group_id
|
|
515
|
-
options[:select_datastore] = true
|
|
516
|
-
options[:name_required] = true
|
|
517
|
-
# prompt for all the instance configuration options
|
|
518
|
-
# this provisioning helper method handles all (most) of the parsing and prompting
|
|
519
|
-
# and it relies on the method to exit non-zero on error, like a bad CLOUD or TYPE value
|
|
520
|
-
payload = prompt_new_instance(options)
|
|
521
|
-
# clean payload of empty objects
|
|
522
|
-
# note: this is temporary and should be fixed upstream in OptionTypes.prompt()
|
|
523
|
-
if payload['instance'].is_a?(Hash)
|
|
524
|
-
payload['instance'].keys.each do |k|
|
|
525
|
-
v = payload['instance'][k]
|
|
526
|
-
payload['instance'].delete(k) if v.is_a?(Hash) && v.empty?
|
|
527
|
-
end
|
|
502
|
+
if options[:instance_type_code]
|
|
503
|
+
# should just use find_instance_type_by_name_or_id
|
|
504
|
+
# note that the api actually will match name name or code
|
|
505
|
+
instance_type = (options[:instance_type_code].to_s =~ /\A\d{1,}\Z/) ? find_instance_type_by_id(options[:instance_type_code]) : find_instance_type_by_code(options[:instance_type_code])
|
|
506
|
+
if instance_type.nil?
|
|
507
|
+
return 1, "instance type not found by #{options[:cloud]}"
|
|
528
508
|
end
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
v = payload['config'][k]
|
|
532
|
-
payload['config'].delete(k) if v.is_a?(Hash) && v.empty?
|
|
533
|
-
end
|
|
534
|
-
end
|
|
535
|
-
end
|
|
536
|
-
payload['instance'] ||= {}
|
|
537
|
-
if options[:instance_name]
|
|
538
|
-
payload['instance']['name'] = options[:instance_name]
|
|
539
|
-
end
|
|
540
|
-
if options[:description] && !payload['instance']['description']
|
|
541
|
-
payload['instance']['description'] = options[:description]
|
|
509
|
+
payload.deep_merge!({"instance" => {"type" => instance_type["code"] } })
|
|
510
|
+
payload.deep_merge!({"instance" => {"instanceType" => {"code" => instance_type["code"]} } })
|
|
542
511
|
end
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
if options[:workflow_id]
|
|
559
|
-
if options[:workflow_id].to_s =~ /\A\d{1,}\Z/
|
|
560
|
-
payload['taskSetId'] = options[:workflow_id].to_i
|
|
561
|
-
else
|
|
562
|
-
payload['taskSetName'] = options[:workflow_id]
|
|
512
|
+
else
|
|
513
|
+
# use active group by default
|
|
514
|
+
options[:group] ||= @active_group_id
|
|
515
|
+
options[:select_datastore] = true
|
|
516
|
+
options[:name_required] = true
|
|
517
|
+
# prompt for all the instance configuration options
|
|
518
|
+
# this provisioning helper method handles all (most) of the parsing and prompting
|
|
519
|
+
# and it relies on the method to exit non-zero on error, like a bad CLOUD or TYPE value
|
|
520
|
+
payload = prompt_new_instance(options)
|
|
521
|
+
# clean payload of empty objects
|
|
522
|
+
# note: this is temporary and should be fixed upstream in OptionTypes.prompt()
|
|
523
|
+
if payload['instance'].is_a?(Hash)
|
|
524
|
+
payload['instance'].keys.each do |k|
|
|
525
|
+
v = payload['instance'][k]
|
|
526
|
+
payload['instance'].delete(k) if v.is_a?(Hash) && v.empty?
|
|
563
527
|
end
|
|
564
528
|
end
|
|
565
|
-
if
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
if options[:dry_run]
|
|
571
|
-
print_dry_run @instances_interface.dry.create(payload)
|
|
572
|
-
return 0
|
|
529
|
+
if payload['config'].is_a?(Hash)
|
|
530
|
+
payload['config'].keys.each do |k|
|
|
531
|
+
v = payload['config'][k]
|
|
532
|
+
payload['config'].delete(k) if v.is_a?(Hash) && v.empty?
|
|
533
|
+
end
|
|
573
534
|
end
|
|
535
|
+
end
|
|
574
536
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
537
|
+
payload['instance'] ||= {}
|
|
538
|
+
if options[:instance_name]
|
|
539
|
+
payload['instance']['name'] = options[:instance_name]
|
|
540
|
+
end
|
|
541
|
+
if options[:description] && !payload['instance']['description']
|
|
542
|
+
payload['instance']['description'] = options[:description]
|
|
543
|
+
end
|
|
544
|
+
if options[:environment] && !payload['instance']['instanceContext']
|
|
545
|
+
payload['instance']['instanceContext'] = options[:environment]
|
|
546
|
+
end
|
|
547
|
+
payload[:copies] = options[:copies] if options[:copies] && options[:copies] > 0
|
|
548
|
+
payload[:layoutSize] = options[:layout_size] if options[:layout_size] && options[:layout_size] > 0 # aka Scale Factor
|
|
549
|
+
payload[:createBackup] = options[:create_backup] if !options[:create_backup].nil?
|
|
550
|
+
payload['instance']['expireDays'] = options[:expire_days] if options[:expire_days]
|
|
551
|
+
payload['instance']['shutdownDays'] = options[:shutdown_days] if options[:shutdown_days]
|
|
552
|
+
if options.key?(:create_user)
|
|
553
|
+
payload['config'] ||= {}
|
|
554
|
+
payload['config']['createUser'] = options[:create_user]
|
|
555
|
+
end
|
|
556
|
+
if options[:user_group_id]
|
|
557
|
+
payload['instance']['userGroup'] = {'id' => options[:user_group_id] }
|
|
558
|
+
end
|
|
559
|
+
if options[:workflow_id]
|
|
560
|
+
if options[:workflow_id].to_s =~ /\A\d{1,}\Z/
|
|
561
|
+
payload['taskSetId'] = options[:workflow_id].to_i
|
|
562
|
+
else
|
|
563
|
+
payload['taskSetName'] = options[:workflow_id]
|
|
585
564
|
end
|
|
565
|
+
end
|
|
566
|
+
if options[:enable_load_balancer]
|
|
567
|
+
lb_payload = prompt_instance_load_balancer(payload['instance'], nil, options)
|
|
568
|
+
payload.deep_merge!(lb_payload)
|
|
569
|
+
end
|
|
570
|
+
@instances_interface.setopts(options)
|
|
571
|
+
if options[:dry_run]
|
|
572
|
+
print_dry_run @instances_interface.dry.create(payload)
|
|
586
573
|
return 0
|
|
587
|
-
rescue RestClient::Exception => e
|
|
588
|
-
print_rest_exception(e, options)
|
|
589
|
-
return 1
|
|
590
574
|
end
|
|
575
|
+
|
|
576
|
+
json_response = @instances_interface.create(payload)
|
|
577
|
+
render_response(json_response, options, "instance") do
|
|
578
|
+
instance_id = json_response["instance"]["id"]
|
|
579
|
+
instance_name = json_response["instance"]["name"]
|
|
580
|
+
print_green_success "Provisioning instance [#{instance_id}] #{instance_name}"
|
|
581
|
+
# print details
|
|
582
|
+
get_args = [instance_id] + (options[:remote] ? ["-r",options[:remote]] : []) + (options[:refresh_interval] ? ['--refresh', options[:refresh_interval].to_s] : [])
|
|
583
|
+
get(get_args)
|
|
584
|
+
end
|
|
585
|
+
return 0, nil
|
|
591
586
|
end
|
|
592
587
|
|
|
593
588
|
def update(args)
|
|
@@ -1373,7 +1368,6 @@ class Morpheus::Cli::Instances
|
|
|
1373
1368
|
"Status" => lambda {|it| format_instance_status(it) }
|
|
1374
1369
|
}
|
|
1375
1370
|
description_cols.delete("Labels") if labels.nil? || labels.empty?
|
|
1376
|
-
description_cols.delete("Tags") if tags.nil? || tags.empty?
|
|
1377
1371
|
description_cols.delete("Apps") if instance['apps'].nil? || instance['apps'].empty?
|
|
1378
1372
|
description_cols.delete("Power Schedule") if instance['powerSchedule'].nil?
|
|
1379
1373
|
description_cols.delete("Expire Date") if instance['expireDate'].nil?
|
|
@@ -1702,19 +1696,77 @@ class Morpheus::Cli::Instances
|
|
|
1702
1696
|
options = {:options => {}}
|
|
1703
1697
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1704
1698
|
opts.banner = subcommand_usage("[instance] -g GROUP")
|
|
1705
|
-
opts.on('--name VALUE', String, "Name") do |val|
|
|
1706
|
-
options[:options]['name'] = val
|
|
1707
|
-
end
|
|
1708
1699
|
opts.on( '-g', '--group GROUP', "Group Name or ID for the new instance" ) do |val|
|
|
1709
1700
|
options[:group] = val
|
|
1710
1701
|
end
|
|
1711
1702
|
opts.on( '-c', '--cloud CLOUD', "Cloud Name or ID for the new instance" ) do |val|
|
|
1712
1703
|
options[:cloud] = val
|
|
1713
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
|
|
1714
1751
|
opts.on("--create-user on|off", String, "User Config: Create Your User. Default is on") do |val|
|
|
1715
1752
|
options[:create_user] = !['false','off','0'].include?(val.to_s)
|
|
1716
1753
|
end
|
|
1717
|
-
|
|
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])
|
|
1718
1770
|
end
|
|
1719
1771
|
optparse.parse!(args)
|
|
1720
1772
|
if args.count < 1 || args.count > 2
|
|
@@ -1732,12 +1784,20 @@ class Morpheus::Cli::Instances
|
|
|
1732
1784
|
|
|
1733
1785
|
# defaults derived from clone
|
|
1734
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']
|
|
1735
1789
|
options[:default_group] = instance['group']['id'] if instance['group']
|
|
1736
1790
|
options[:default_cloud] = instance['cloud']['name'] if instance['cloud']
|
|
1737
1791
|
options[:default_plan] = instance['plan']['name'] if instance['plan']
|
|
1738
1792
|
options[:default_resource_pool] = instance['config']['resourcePoolId'] if instance['config']
|
|
1739
1793
|
options[:default_config] = instance['config']
|
|
1740
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
|
|
1741
1801
|
|
|
1742
1802
|
# immutable derived from clone
|
|
1743
1803
|
options[:instance_type_code] = instance['instanceType']['code'] if instance['instanceType']
|
|
@@ -1775,13 +1835,52 @@ class Morpheus::Cli::Instances
|
|
|
1775
1835
|
payload.deep_merge!(passed_options)
|
|
1776
1836
|
end
|
|
1777
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
|
|
1778
1864
|
# JD: this actually fixed a customer problem
|
|
1779
1865
|
# It appears to be important to pass this... not sure if config.createUser is necessary...
|
|
1780
1866
|
if options[:create_user].nil?
|
|
1781
1867
|
options[:create_user] = true
|
|
1782
1868
|
end
|
|
1783
|
-
if options
|
|
1784
|
-
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
|
|
1785
1884
|
end
|
|
1786
1885
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to clone the instance #{instance['name']} as '#{payload['name']}'?", options)
|
|
1787
1886
|
return 9, "aborted command"
|
|
@@ -1931,7 +2030,7 @@ class Morpheus::Cli::Instances
|
|
|
1931
2030
|
opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is off.") do |val|
|
|
1932
2031
|
params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
1933
2032
|
end
|
|
1934
|
-
opts.add_hidden_option('muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
2033
|
+
opts.add_hidden_option('--muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
1935
2034
|
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
|
1936
2035
|
opts.footer = "Stop an instance.\n" +
|
|
1937
2036
|
"[instance] is required. This is the name or id of an instance. Supports 1-N [instance] arguments."
|
|
@@ -2059,7 +2158,7 @@ class Morpheus::Cli::Instances
|
|
|
2059
2158
|
opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is on.") do |val|
|
|
2060
2159
|
params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
2061
2160
|
end
|
|
2062
|
-
opts.add_hidden_option('muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
2161
|
+
opts.add_hidden_option('--muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
2063
2162
|
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
|
2064
2163
|
opts.footer = "Restart an instance.\n" +
|
|
2065
2164
|
"[instance] is required. This is the name or id of an instance. Supports 1-N [instance] arguments."
|
|
@@ -2127,7 +2226,7 @@ class Morpheus::Cli::Instances
|
|
|
2127
2226
|
opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is on.") do |val|
|
|
2128
2227
|
params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
2129
2228
|
end
|
|
2130
|
-
opts.add_hidden_option('muteMonitoring')
|
|
2229
|
+
opts.add_hidden_option('--muteMonitoring')
|
|
2131
2230
|
opts.on('--server [on|off]', String, "Suspend instance server. Default is off.") do |val|
|
|
2132
2231
|
params['server'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
2133
2232
|
end
|
|
@@ -2233,7 +2332,7 @@ class Morpheus::Cli::Instances
|
|
|
2233
2332
|
opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is off.") do |val|
|
|
2234
2333
|
params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
2235
2334
|
end
|
|
2236
|
-
opts.add_hidden_option('muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
2335
|
+
opts.add_hidden_option('--muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
2237
2336
|
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
|
2238
2337
|
opts.footer = "Stop service on an instance.\n" +
|
|
2239
2338
|
"[instance] is required. This is the name or id of an instance. Supports 1-N [instance] arguments."
|
|
@@ -2361,7 +2460,7 @@ class Morpheus::Cli::Instances
|
|
|
2361
2460
|
opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is on.") do |val|
|
|
2362
2461
|
params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
2363
2462
|
end
|
|
2364
|
-
opts.add_hidden_option('muteMonitoring')
|
|
2463
|
+
opts.add_hidden_option('--muteMonitoring')
|
|
2365
2464
|
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
|
2366
2465
|
opts.footer = "Restart service on an instance.\n" +
|
|
2367
2466
|
"[instance] is required. This is the name or id of an instance. Supports 1-N [instance] arguments."
|
|
@@ -2785,34 +2884,158 @@ EOT
|
|
|
2785
2884
|
|
|
2786
2885
|
def cancel_removal(args)
|
|
2787
2886
|
options = {}
|
|
2887
|
+
params = {}
|
|
2788
2888
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
2789
2889
|
opts.banner = subcommand_usage("[instance]")
|
|
2790
|
-
|
|
2890
|
+
build_standard_update_options(opts, options)
|
|
2891
|
+
opts.footer = <<-EOT
|
|
2892
|
+
Cancel removal of an instance.
|
|
2893
|
+
This is a way to undo delete of an instance still pending removal.
|
|
2894
|
+
[instance] is required. This is the name or id of an instance
|
|
2895
|
+
EOT
|
|
2791
2896
|
end
|
|
2792
2897
|
optparse.parse!(args)
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2898
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
2899
|
+
connect(options)
|
|
2900
|
+
params.merge!(parse_query_options(options))
|
|
2901
|
+
payload = options[:payload] || {}
|
|
2902
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
2903
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
2904
|
+
@instances_interface.setopts(options)
|
|
2905
|
+
if options[:dry_run]
|
|
2906
|
+
print_dry_run @instances_interface.dry.cancel_removal(instance['id'], params, payload)
|
|
2907
|
+
return
|
|
2908
|
+
end
|
|
2909
|
+
json_response = @instances_interface.cancel_removal(instance['id'], params, payload)
|
|
2910
|
+
render_response(json_response, options) do
|
|
2911
|
+
print_green_success "Canceled removal for instance #{instance['name']} ..."
|
|
2912
|
+
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
2913
|
+
end
|
|
2914
|
+
return 0, nil
|
|
2915
|
+
end
|
|
2916
|
+
|
|
2917
|
+
def cancel_expiration(args)
|
|
2918
|
+
options = {}
|
|
2919
|
+
params = {}
|
|
2920
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
2921
|
+
opts.banner = subcommand_usage("[instance]")
|
|
2922
|
+
build_standard_update_options(opts, options, [:query]) # query params instead of p
|
|
2923
|
+
opts.footer = <<-EOT
|
|
2924
|
+
Cancel expiration of an instance.
|
|
2925
|
+
[instance] is required. This is the name or id of an instance
|
|
2926
|
+
EOT
|
|
2796
2927
|
end
|
|
2928
|
+
optparse.parse!(args)
|
|
2929
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
2797
2930
|
connect(options)
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2931
|
+
params.merge!(parse_query_options(options))
|
|
2932
|
+
payload = options[:payload] || {}
|
|
2933
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
2934
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
2935
|
+
@instances_interface.setopts(options)
|
|
2936
|
+
if options[:dry_run]
|
|
2937
|
+
print_dry_run @instances_interface.dry.cancel_expiration(instance['id'], params, payload)
|
|
2938
|
+
return
|
|
2939
|
+
end
|
|
2940
|
+
json_response = @instances_interface.cancel_expiration(instance['id'], params, payload)
|
|
2941
|
+
render_response(json_response, options) do
|
|
2942
|
+
print_green_success "Canceled expiration for instance #{instance['name']} ..."
|
|
2943
|
+
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
2944
|
+
end
|
|
2945
|
+
return 0, nil
|
|
2946
|
+
end
|
|
2947
|
+
|
|
2948
|
+
def cancel_shutdown(args)
|
|
2949
|
+
options = {}
|
|
2950
|
+
params = {}
|
|
2951
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
2952
|
+
opts.banner = subcommand_usage("[instance]")
|
|
2953
|
+
build_standard_update_options(opts, options, [:query]) # query params instead of p
|
|
2954
|
+
opts.footer = <<-EOT
|
|
2955
|
+
Cancel shutdown for an instance.
|
|
2956
|
+
[instance] is required. This is the name or id of an instance
|
|
2957
|
+
EOT
|
|
2958
|
+
end
|
|
2959
|
+
optparse.parse!(args)
|
|
2960
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
2961
|
+
connect(options)
|
|
2962
|
+
params.merge!(parse_query_options(options))
|
|
2963
|
+
payload = options[:payload] || {}
|
|
2964
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
2965
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
2966
|
+
@instances_interface.setopts(options)
|
|
2967
|
+
if options[:dry_run]
|
|
2968
|
+
print_dry_run @instances_interface.dry.cancel_shutdown(instance['id'], params, payload)
|
|
2969
|
+
return
|
|
2970
|
+
end
|
|
2971
|
+
json_response = @instances_interface.cancel_shutdown(instance['id'], params, payload)
|
|
2972
|
+
render_response(json_response, options) do
|
|
2973
|
+
print_green_success "Canceled shutdown for instance #{instance['name']} ..."
|
|
2974
|
+
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
2815
2975
|
end
|
|
2976
|
+
return 0, nil
|
|
2977
|
+
end
|
|
2978
|
+
|
|
2979
|
+
def extend_expiration(args)
|
|
2980
|
+
options = {}
|
|
2981
|
+
params = {}
|
|
2982
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
2983
|
+
opts.banner = subcommand_usage("[instance]")
|
|
2984
|
+
build_standard_update_options(opts, options, [:query]) # query params instead of p
|
|
2985
|
+
opts.footer = <<-EOT
|
|
2986
|
+
Extend expiration for an instance.
|
|
2987
|
+
[instance] is required. This is the name or id of an instance
|
|
2988
|
+
EOT
|
|
2989
|
+
end
|
|
2990
|
+
optparse.parse!(args)
|
|
2991
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
2992
|
+
connect(options)
|
|
2993
|
+
params.merge!(parse_query_options(options))
|
|
2994
|
+
payload = options[:payload] || {}
|
|
2995
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
2996
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
2997
|
+
@instances_interface.setopts(options)
|
|
2998
|
+
if options[:dry_run]
|
|
2999
|
+
print_dry_run @instances_interface.dry.extend_expiration(instance['id'], params, payload)
|
|
3000
|
+
return
|
|
3001
|
+
end
|
|
3002
|
+
json_response = @instances_interface.extend_expiration(instance['id'], params, payload)
|
|
3003
|
+
render_response(json_response, options) do
|
|
3004
|
+
print_green_success "Extended expiration for instance #{instance['name']} ..."
|
|
3005
|
+
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
3006
|
+
end
|
|
3007
|
+
return 0, nil
|
|
3008
|
+
end
|
|
3009
|
+
|
|
3010
|
+
def extend_shutdown(args)
|
|
3011
|
+
options = {}
|
|
3012
|
+
params = {}
|
|
3013
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
3014
|
+
opts.banner = subcommand_usage("[instance]")
|
|
3015
|
+
build_standard_update_options(opts, options, [:query]) # query params instead of p
|
|
3016
|
+
opts.footer = <<-EOT
|
|
3017
|
+
Extend shutdown for an instance.
|
|
3018
|
+
[instance] is required. This is the name or id of an instance
|
|
3019
|
+
EOT
|
|
3020
|
+
end
|
|
3021
|
+
optparse.parse!(args)
|
|
3022
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
3023
|
+
connect(options)
|
|
3024
|
+
params.merge!(parse_query_options(options))
|
|
3025
|
+
payload = options[:payload] || {}
|
|
3026
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
3027
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
3028
|
+
@instances_interface.setopts(options)
|
|
3029
|
+
if options[:dry_run]
|
|
3030
|
+
print_dry_run @instances_interface.dry.extend_shutdown(instance['id'], params, payload)
|
|
3031
|
+
return
|
|
3032
|
+
end
|
|
3033
|
+
json_response = @instances_interface.extend_shutdown(instance['id'], params, payload)
|
|
3034
|
+
render_response(json_response, options) do
|
|
3035
|
+
print_green_success "Extended shutdown for instance #{instance['name']} ..."
|
|
3036
|
+
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
3037
|
+
end
|
|
3038
|
+
return 0, nil
|
|
2816
3039
|
end
|
|
2817
3040
|
|
|
2818
3041
|
def firewall_disable(args)
|
|
@@ -3617,7 +3840,7 @@ EOT
|
|
|
3617
3840
|
opts.on('--process-id ID', String, "Display details about a specfic event." ) do |val|
|
|
3618
3841
|
options[:process_id] = val
|
|
3619
3842
|
end
|
|
3620
|
-
opts.add_hidden_option('process-id')
|
|
3843
|
+
opts.add_hidden_option('--process-id')
|
|
3621
3844
|
build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
3622
3845
|
opts.footer = "Display history details for a specific process.\n" +
|
|
3623
3846
|
"[instance] is required. This is the name or id of an instance.\n" +
|
|
@@ -3717,7 +3940,7 @@ EOT
|
|
|
3717
3940
|
opts.on('--event-id ID', String, "Display details about a specfic event." ) do |val|
|
|
3718
3941
|
options[:event_id] = val
|
|
3719
3942
|
end
|
|
3720
|
-
opts.add_hidden_option('event-id')
|
|
3943
|
+
opts.add_hidden_option('--event-id')
|
|
3721
3944
|
build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
3722
3945
|
opts.footer = "Display history details for a specific process event.\n" +
|
|
3723
3946
|
"[instance] is required. This is the name or id of an instance.\n" +
|
|
@@ -4014,6 +4237,106 @@ EOT
|
|
|
4014
4237
|
return 0, nil
|
|
4015
4238
|
end
|
|
4016
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
|
+
|
|
4017
4340
|
private
|
|
4018
4341
|
|
|
4019
4342
|
def find_zone_by_name_or_id(group_id, val)
|