morpheus-cli 5.3.2.2 → 5.4.0
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/api_client.rb +26 -1
- 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 +18 -5
- data/lib/morpheus/api/load_balancer_pools_interface.rb +4 -4
- data/lib/morpheus/api/load_balancer_profiles_interface.rb +10 -0
- data/lib/morpheus/api/load_balancer_virtual_servers_interface.rb +4 -4
- 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 +21 -0
- data/lib/morpheus/api/network_servers_interface.rb +98 -0
- data/lib/morpheus/api/rest_interface.rb +2 -1
- data/lib/morpheus/api/roles_interface.rb +7 -0
- 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 +21 -14
- 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} +0 -3
- 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} +3 -11
- data/lib/morpheus/cli/{archives_command.rb → commands/archives_command.rb} +0 -6
- 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} +0 -0
- 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} +51 -39
- 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} +0 -10
- 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} +364 -148
- 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_pools.rb +111 -0
- data/lib/morpheus/cli/{load_balancer_types.rb → commands/load_balancer_types.rb} +0 -4
- data/lib/morpheus/cli/commands/load_balancer_virtual_servers.rb +136 -0
- data/lib/morpheus/cli/commands/load_balancers.rb +89 -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 +806 -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} +291 -12
- data/lib/morpheus/cli/{network_services_command.rb → commands/network_services_command.rb} +0 -4
- 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/{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} +0 -7
- 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} +0 -0
- 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} +1 -7
- 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} +244 -39
- 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} +2 -103
- 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/{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} +0 -7
- 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} +0 -1
- data/lib/morpheus/cli/{user_settings_command.rb → commands/user_settings_command.rb} +0 -0
- data/lib/morpheus/cli/{user_sources_command.rb → commands/user_sources_command.rb} +0 -1
- data/lib/morpheus/cli/{users.rb → commands/users.rb} +0 -7
- 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/{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/load_balancers_helper.rb +2 -2
- data/lib/morpheus/cli/mixins/logs_helper.rb +1 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +1 -0
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +155 -112
- data/lib/morpheus/cli/mixins/rest_command.rb +154 -52
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +575 -0
- data/lib/morpheus/cli/option_parser.rb +25 -17
- data/lib/morpheus/cli/option_types.rb +96 -32
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +5 -128
- data/lib/morpheus/terminal.rb +5 -6
- data/morpheus-cli.gemspec +1 -1
- metadata +156 -143
- 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,
|
|
@@ -444,7 +441,7 @@ class Morpheus::Cli::Instances
|
|
|
444
441
|
opts.on('--refresh [SECONDS]', String, "Refresh until status is running,failed. Default interval is #{default_refresh_interval} seconds.") do |val|
|
|
445
442
|
options[:refresh_interval] = val.to_s.empty? ? default_refresh_interval : val.to_f
|
|
446
443
|
end
|
|
447
|
-
|
|
444
|
+
build_standard_add_options(opts, options) #, [:options, :payload, :json, :dry_run, :remote, :quiet])
|
|
448
445
|
opts.footer = "Create a new instance." + "\n" +
|
|
449
446
|
"[name] is required. This is the new instance name." + "\n" +
|
|
450
447
|
"The available options vary by --type."
|
|
@@ -462,33 +459,30 @@ class Morpheus::Cli::Instances
|
|
|
462
459
|
options[:instance_name] = args[0]
|
|
463
460
|
end
|
|
464
461
|
|
|
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"]} } })
|
|
462
|
+
if options[:payload]
|
|
463
|
+
payload = options[:payload]
|
|
464
|
+
# support -O OPTION switch on top of --payload
|
|
465
|
+
payload.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
|
466
|
+
# obviously should support every option that prompt supports on top of -- payload as well
|
|
467
|
+
# group, cloud and type for now
|
|
468
|
+
# todo: also support :layout, service_plan, :resource_pool, etc.
|
|
469
|
+
group = nil
|
|
470
|
+
if options[:group]
|
|
471
|
+
group = find_group_by_name_or_id_for_provisioning(options[:group])
|
|
472
|
+
if group.nil?
|
|
473
|
+
return 1, "group not found by #{options[:group]}"
|
|
482
474
|
end
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
payload.deep_merge!({"instance" => {"cloud" => cloud["name"] } })
|
|
475
|
+
payload.deep_merge!({"instance" => {"site" => {"id" => group["id"]} } })
|
|
476
|
+
end
|
|
477
|
+
if options[:cloud]
|
|
478
|
+
group_id = group ? group["id"] : ((payload["instance"] && payload["instance"]["site"].is_a?(Hash)) ? payload["instance"]["site"]["id"] : nil)
|
|
479
|
+
cloud = find_cloud_by_name_or_id_for_provisioning(group_id, options[:cloud])
|
|
480
|
+
if cloud.nil?
|
|
481
|
+
return 1, "cloud not found by #{options[:cloud]}"
|
|
491
482
|
end
|
|
483
|
+
payload["zoneId"] = cloud["id"]
|
|
484
|
+
payload.deep_merge!({"instance" => {"cloud" => cloud["name"] } })
|
|
485
|
+
end
|
|
492
486
|
if options[:cloud]
|
|
493
487
|
group_id = group ? group["id"] : ((payload["instance"] && payload["instance"]["site"].is_a?(Hash)) ? payload["instance"]["site"]["id"] : nil)
|
|
494
488
|
cloud = find_cloud_by_name_or_id_for_provisioning(group_id, options[:cloud])
|
|
@@ -498,96 +492,90 @@ class Morpheus::Cli::Instances
|
|
|
498
492
|
payload["zoneId"] = cloud["id"]
|
|
499
493
|
payload.deep_merge!({"instance" => {"cloud" => cloud["name"] } })
|
|
500
494
|
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"]} } })
|
|
495
|
+
if options[:instance_type_code]
|
|
496
|
+
# should just use find_instance_type_by_name_or_id
|
|
497
|
+
# note that the api actually will match name name or code
|
|
498
|
+
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])
|
|
499
|
+
if instance_type.nil?
|
|
500
|
+
return 1, "instance type not found by #{options[:cloud]}"
|
|
510
501
|
end
|
|
511
|
-
|
|
512
|
-
|
|
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
|
|
528
|
-
end
|
|
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
|
|
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]
|
|
502
|
+
payload.deep_merge!({"instance" => {"type" => instance_type["code"] } })
|
|
503
|
+
payload.deep_merge!({"instance" => {"instanceType" => {"code" => instance_type["code"]} } })
|
|
542
504
|
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]
|
|
505
|
+
else
|
|
506
|
+
# use active group by default
|
|
507
|
+
options[:group] ||= @active_group_id
|
|
508
|
+
options[:select_datastore] = true
|
|
509
|
+
options[:name_required] = true
|
|
510
|
+
# prompt for all the instance configuration options
|
|
511
|
+
# this provisioning helper method handles all (most) of the parsing and prompting
|
|
512
|
+
# and it relies on the method to exit non-zero on error, like a bad CLOUD or TYPE value
|
|
513
|
+
payload = prompt_new_instance(options)
|
|
514
|
+
# clean payload of empty objects
|
|
515
|
+
# note: this is temporary and should be fixed upstream in OptionTypes.prompt()
|
|
516
|
+
if payload['instance'].is_a?(Hash)
|
|
517
|
+
payload['instance'].keys.each do |k|
|
|
518
|
+
v = payload['instance'][k]
|
|
519
|
+
payload['instance'].delete(k) if v.is_a?(Hash) && v.empty?
|
|
563
520
|
end
|
|
564
521
|
end
|
|
565
|
-
if
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
if options[:dry_run]
|
|
571
|
-
print_dry_run @instances_interface.dry.create(payload)
|
|
572
|
-
return 0
|
|
522
|
+
if payload['config'].is_a?(Hash)
|
|
523
|
+
payload['config'].keys.each do |k|
|
|
524
|
+
v = payload['config'][k]
|
|
525
|
+
payload['config'].delete(k) if v.is_a?(Hash) && v.empty?
|
|
526
|
+
end
|
|
573
527
|
end
|
|
528
|
+
end
|
|
574
529
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
530
|
+
payload['instance'] ||= {}
|
|
531
|
+
if options[:instance_name]
|
|
532
|
+
payload['instance']['name'] = options[:instance_name]
|
|
533
|
+
end
|
|
534
|
+
if options[:description] && !payload['instance']['description']
|
|
535
|
+
payload['instance']['description'] = options[:description]
|
|
536
|
+
end
|
|
537
|
+
if options[:environment] && !payload['instance']['instanceContext']
|
|
538
|
+
payload['instance']['instanceContext'] = options[:environment]
|
|
539
|
+
end
|
|
540
|
+
payload[:copies] = options[:copies] if options[:copies] && options[:copies] > 0
|
|
541
|
+
payload[:layoutSize] = options[:layout_size] if options[:layout_size] && options[:layout_size] > 0 # aka Scale Factor
|
|
542
|
+
payload[:createBackup] = options[:create_backup] if !options[:create_backup].nil?
|
|
543
|
+
payload['instance']['expireDays'] = options[:expire_days] if options[:expire_days]
|
|
544
|
+
payload['instance']['shutdownDays'] = options[:shutdown_days] if options[:shutdown_days]
|
|
545
|
+
if options.key?(:create_user)
|
|
546
|
+
payload['config'] ||= {}
|
|
547
|
+
payload['config']['createUser'] = options[:create_user]
|
|
548
|
+
end
|
|
549
|
+
if options[:user_group_id]
|
|
550
|
+
payload['instance']['userGroup'] = {'id' => options[:user_group_id] }
|
|
551
|
+
end
|
|
552
|
+
if options[:workflow_id]
|
|
553
|
+
if options[:workflow_id].to_s =~ /\A\d{1,}\Z/
|
|
554
|
+
payload['taskSetId'] = options[:workflow_id].to_i
|
|
555
|
+
else
|
|
556
|
+
payload['taskSetName'] = options[:workflow_id]
|
|
585
557
|
end
|
|
558
|
+
end
|
|
559
|
+
if options[:enable_load_balancer]
|
|
560
|
+
lb_payload = prompt_instance_load_balancer(payload['instance'], nil, options)
|
|
561
|
+
payload.deep_merge!(lb_payload)
|
|
562
|
+
end
|
|
563
|
+
@instances_interface.setopts(options)
|
|
564
|
+
if options[:dry_run]
|
|
565
|
+
print_dry_run @instances_interface.dry.create(payload)
|
|
586
566
|
return 0
|
|
587
|
-
rescue RestClient::Exception => e
|
|
588
|
-
print_rest_exception(e, options)
|
|
589
|
-
return 1
|
|
590
567
|
end
|
|
568
|
+
|
|
569
|
+
json_response = @instances_interface.create(payload)
|
|
570
|
+
render_response(json_response, options, "instance") do
|
|
571
|
+
instance_id = json_response["instance"]["id"]
|
|
572
|
+
instance_name = json_response["instance"]["name"]
|
|
573
|
+
print_green_success "Provisioning instance [#{instance_id}] #{instance_name}"
|
|
574
|
+
# print details
|
|
575
|
+
get_args = [instance_id] + (options[:remote] ? ["-r",options[:remote]] : []) + (options[:refresh_interval] ? ['--refresh', options[:refresh_interval].to_s] : [])
|
|
576
|
+
get(get_args)
|
|
577
|
+
end
|
|
578
|
+
return 0, nil
|
|
591
579
|
end
|
|
592
580
|
|
|
593
581
|
def update(args)
|
|
@@ -1373,7 +1361,6 @@ class Morpheus::Cli::Instances
|
|
|
1373
1361
|
"Status" => lambda {|it| format_instance_status(it) }
|
|
1374
1362
|
}
|
|
1375
1363
|
description_cols.delete("Labels") if labels.nil? || labels.empty?
|
|
1376
|
-
description_cols.delete("Tags") if tags.nil? || tags.empty?
|
|
1377
1364
|
description_cols.delete("Apps") if instance['apps'].nil? || instance['apps'].empty?
|
|
1378
1365
|
description_cols.delete("Power Schedule") if instance['powerSchedule'].nil?
|
|
1379
1366
|
description_cols.delete("Expire Date") if instance['expireDate'].nil?
|
|
@@ -1702,19 +1689,77 @@ class Morpheus::Cli::Instances
|
|
|
1702
1689
|
options = {:options => {}}
|
|
1703
1690
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1704
1691
|
opts.banner = subcommand_usage("[instance] -g GROUP")
|
|
1705
|
-
opts.on('--name VALUE', String, "Name") do |val|
|
|
1706
|
-
options[:options]['name'] = val
|
|
1707
|
-
end
|
|
1708
1692
|
opts.on( '-g', '--group GROUP', "Group Name or ID for the new instance" ) do |val|
|
|
1709
1693
|
options[:group] = val
|
|
1710
1694
|
end
|
|
1711
1695
|
opts.on( '-c', '--cloud CLOUD', "Cloud Name or ID for the new instance" ) do |val|
|
|
1712
1696
|
options[:cloud] = val
|
|
1713
1697
|
end
|
|
1698
|
+
opts.on('--name VALUE', String, "Name") do |val|
|
|
1699
|
+
options[:options]['name'] = val
|
|
1700
|
+
end
|
|
1701
|
+
opts.on("--description [TEXT]", String, "Description") do |val|
|
|
1702
|
+
options[:description] = val.to_s
|
|
1703
|
+
end
|
|
1704
|
+
opts.on("--environment ENV", String, "Environment code") do |val|
|
|
1705
|
+
options[:environment] = val.to_s
|
|
1706
|
+
end
|
|
1707
|
+
opts.on('--tags LIST', String, "Metadata tags in the format 'ping=pong,flash=bang'") do |val|
|
|
1708
|
+
options[:metadata] = val
|
|
1709
|
+
end
|
|
1710
|
+
opts.on('--metadata LIST', String, "Metadata tags in the format 'ping=pong,flash=bang'") do |val|
|
|
1711
|
+
options[:metadata] = val
|
|
1712
|
+
end
|
|
1713
|
+
opts.add_hidden_option('--metadata')
|
|
1714
|
+
opts.on('--labels LIST', String, "Labels (keywords) in the format 'foo, bar'") do |val|
|
|
1715
|
+
options[:labels] = val.split(',').collect {|it| it.to_s.strip }.compact.uniq.join(',')
|
|
1716
|
+
end
|
|
1717
|
+
# opts.on("--copies NUMBER", Integer, "Number of copies to provision") do |val|
|
|
1718
|
+
# options[:copies] = val.to_i
|
|
1719
|
+
# end
|
|
1720
|
+
# opts.on("--layout-size NUMBER", Integer, "Apply a multiply factor of containers/vms within the instance") do |val|
|
|
1721
|
+
# options[:layout_size] = val.to_i
|
|
1722
|
+
# end
|
|
1723
|
+
# opts.on( '-l', '--layout LAYOUT', "Layout ID" ) do |val|
|
|
1724
|
+
# options[:layout] = val
|
|
1725
|
+
# end
|
|
1726
|
+
opts.on( '-p', '--plan PLAN', "Service plan ID") do |val|
|
|
1727
|
+
options[:service_plan] = val
|
|
1728
|
+
end
|
|
1729
|
+
opts.on( '--resource-pool ID', String, "Resource pool ID" ) do |val|
|
|
1730
|
+
options[:resource_pool] = val
|
|
1731
|
+
end
|
|
1732
|
+
opts.on("--workflow ID", String, "Automation: Workflow ID") do |val|
|
|
1733
|
+
options[:workflow_id] = val
|
|
1734
|
+
end
|
|
1735
|
+
opts.on("--ports ARRAY", String, "Exposed Ports, JSON formatted list of objects containing name and port") do |val|
|
|
1736
|
+
# expects format like --ports '[{"name":"web","port":8080}]'
|
|
1737
|
+
ports_array = JSON.parse(val)
|
|
1738
|
+
options[:ports] = ports_array
|
|
1739
|
+
options[:options]['ports'] = ports_array
|
|
1740
|
+
end
|
|
1741
|
+
# opts.on('-L', "--lb", "Enable Load Balancer") do
|
|
1742
|
+
# options[:enable_load_balancer] = true
|
|
1743
|
+
# end
|
|
1714
1744
|
opts.on("--create-user on|off", String, "User Config: Create Your User. Default is on") do |val|
|
|
1715
1745
|
options[:create_user] = !['false','off','0'].include?(val.to_s)
|
|
1716
1746
|
end
|
|
1717
|
-
|
|
1747
|
+
opts.on("--user-group USERGROUP", String, "User Config: User Group") do |val|
|
|
1748
|
+
options[:user_group_id] = val
|
|
1749
|
+
end
|
|
1750
|
+
opts.on("--shutdown-days DAYS", Integer, "Automation: Shutdown Days") do |val|
|
|
1751
|
+
options[:shutdown_days] = val.to_i
|
|
1752
|
+
end
|
|
1753
|
+
opts.on("--expire-days DAYS", Integer, "Automation: Expiration Days") do |val|
|
|
1754
|
+
options[:expire_days] = val.to_i
|
|
1755
|
+
end
|
|
1756
|
+
opts.on("--create-backup [on|off]", String, "Automation: Create Backups.") do |val|
|
|
1757
|
+
options[:create_backup] = ['on','true','1',''].include?(val.to_s.downcase) ? 'on' : 'off'
|
|
1758
|
+
end
|
|
1759
|
+
opts.on("--security-groups LIST", String, "Security Groups, comma separated list of security group IDs") do |val|
|
|
1760
|
+
options[:security_groups] = val.split(",").collect {|s| s.strip }.select {|s| !s.to_s.empty? }
|
|
1761
|
+
end
|
|
1762
|
+
build_standard_post_options(opts, options, [:auto_confirm])
|
|
1718
1763
|
end
|
|
1719
1764
|
optparse.parse!(args)
|
|
1720
1765
|
if args.count < 1 || args.count > 2
|
|
@@ -1732,12 +1777,20 @@ class Morpheus::Cli::Instances
|
|
|
1732
1777
|
|
|
1733
1778
|
# defaults derived from clone
|
|
1734
1779
|
options[:default_name] = instance['name'] + '-clone' if instance['name']
|
|
1780
|
+
options[:default_description] = instance['description'] if !instance['description'].to_s.empty?
|
|
1781
|
+
options[:default_environment] = instance['environment'] if instance['environment']
|
|
1735
1782
|
options[:default_group] = instance['group']['id'] if instance['group']
|
|
1736
1783
|
options[:default_cloud] = instance['cloud']['name'] if instance['cloud']
|
|
1737
1784
|
options[:default_plan] = instance['plan']['name'] if instance['plan']
|
|
1738
1785
|
options[:default_resource_pool] = instance['config']['resourcePoolId'] if instance['config']
|
|
1739
1786
|
options[:default_config] = instance['config']
|
|
1740
1787
|
options[:default_security_group] = instance['config']['securityGroups'][0]['id'] if instance['config'] && (instance['config']['securityGroups'] || []).count > 0
|
|
1788
|
+
if instance['labels'] && !instance['labels'].empty?
|
|
1789
|
+
options[:default_labels] = (instance['labels'] || []).join(',')
|
|
1790
|
+
end
|
|
1791
|
+
if instance['tags'] && !instance['tags'].empty?
|
|
1792
|
+
options[:current_tags] = instance['tags']
|
|
1793
|
+
end
|
|
1741
1794
|
|
|
1742
1795
|
# immutable derived from clone
|
|
1743
1796
|
options[:instance_type_code] = instance['instanceType']['code'] if instance['instanceType']
|
|
@@ -1775,13 +1828,52 @@ class Morpheus::Cli::Instances
|
|
|
1775
1828
|
payload.deep_merge!(passed_options)
|
|
1776
1829
|
end
|
|
1777
1830
|
|
|
1831
|
+
#payload['instance'] ||= {}
|
|
1832
|
+
# if options[:instance_name]
|
|
1833
|
+
# payload['instance']['name'] = options[:instance_name]
|
|
1834
|
+
# end
|
|
1835
|
+
# if options[:description] && !payload['instance']['description']
|
|
1836
|
+
# payload['instance']['description'] = options[:description]
|
|
1837
|
+
# end
|
|
1838
|
+
# if options[:environment] && !payload['instance']['instanceContext']
|
|
1839
|
+
# payload['instance']['instanceContext'] = options[:environment]
|
|
1840
|
+
# end
|
|
1841
|
+
|
|
1842
|
+
#payload[:copies] = options[:copies] if options[:copies] && options[:copies] > 0
|
|
1843
|
+
if options[:layout_size] && options[:layout_size] > 0 # aka Scale Factor
|
|
1844
|
+
payload[:layoutSize] = options[:layout_size]
|
|
1845
|
+
end
|
|
1846
|
+
if !options[:create_backup].nil?
|
|
1847
|
+
payload[:createBackup] = options[:create_backup]
|
|
1848
|
+
end
|
|
1849
|
+
if options[:expire_days]
|
|
1850
|
+
payload['instance'] ||= {}
|
|
1851
|
+
payload['instance']['expireDays'] = options[:expire_days]
|
|
1852
|
+
end
|
|
1853
|
+
if options[:shutdown_days]
|
|
1854
|
+
payload['instance'] ||= {}
|
|
1855
|
+
payload['shutdownDays'] = options[:shutdown_days]
|
|
1856
|
+
end
|
|
1778
1857
|
# JD: this actually fixed a customer problem
|
|
1779
1858
|
# It appears to be important to pass this... not sure if config.createUser is necessary...
|
|
1780
1859
|
if options[:create_user].nil?
|
|
1781
1860
|
options[:create_user] = true
|
|
1782
1861
|
end
|
|
1783
|
-
if options
|
|
1784
|
-
payload
|
|
1862
|
+
if options.key?(:create_user)
|
|
1863
|
+
payload['config'] ||= {}
|
|
1864
|
+
payload['config']['createUser'] = options[:create_user]
|
|
1865
|
+
payload['createUser'] = options[:create_user]
|
|
1866
|
+
end
|
|
1867
|
+
if options[:user_group_id]
|
|
1868
|
+
payload['instance'] ||= {}
|
|
1869
|
+
payload['instance']['userGroup'] = {'id' => options[:user_group_id] }
|
|
1870
|
+
end
|
|
1871
|
+
if options[:workflow_id]
|
|
1872
|
+
if options[:workflow_id].to_s =~ /\A\d{1,}\Z/
|
|
1873
|
+
payload['taskSetId'] = options[:workflow_id].to_i
|
|
1874
|
+
else
|
|
1875
|
+
payload['taskSetName'] = options[:workflow_id]
|
|
1876
|
+
end
|
|
1785
1877
|
end
|
|
1786
1878
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to clone the instance #{instance['name']} as '#{payload['name']}'?", options)
|
|
1787
1879
|
return 9, "aborted command"
|
|
@@ -1931,7 +2023,7 @@ class Morpheus::Cli::Instances
|
|
|
1931
2023
|
opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is off.") do |val|
|
|
1932
2024
|
params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
1933
2025
|
end
|
|
1934
|
-
opts.add_hidden_option('muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
2026
|
+
opts.add_hidden_option('--muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
1935
2027
|
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
|
1936
2028
|
opts.footer = "Stop an instance.\n" +
|
|
1937
2029
|
"[instance] is required. This is the name or id of an instance. Supports 1-N [instance] arguments."
|
|
@@ -2059,7 +2151,7 @@ class Morpheus::Cli::Instances
|
|
|
2059
2151
|
opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is on.") do |val|
|
|
2060
2152
|
params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
2061
2153
|
end
|
|
2062
|
-
opts.add_hidden_option('muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
2154
|
+
opts.add_hidden_option('--muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
2063
2155
|
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
|
2064
2156
|
opts.footer = "Restart an instance.\n" +
|
|
2065
2157
|
"[instance] is required. This is the name or id of an instance. Supports 1-N [instance] arguments."
|
|
@@ -2127,7 +2219,7 @@ class Morpheus::Cli::Instances
|
|
|
2127
2219
|
opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is on.") do |val|
|
|
2128
2220
|
params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
2129
2221
|
end
|
|
2130
|
-
opts.add_hidden_option('muteMonitoring')
|
|
2222
|
+
opts.add_hidden_option('--muteMonitoring')
|
|
2131
2223
|
opts.on('--server [on|off]', String, "Suspend instance server. Default is off.") do |val|
|
|
2132
2224
|
params['server'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
2133
2225
|
end
|
|
@@ -2233,7 +2325,7 @@ class Morpheus::Cli::Instances
|
|
|
2233
2325
|
opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is off.") do |val|
|
|
2234
2326
|
params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
2235
2327
|
end
|
|
2236
|
-
opts.add_hidden_option('muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
2328
|
+
opts.add_hidden_option('--muteMonitoring') if opts.is_a?(Morpheus::Cli::OptionParser)
|
|
2237
2329
|
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
|
2238
2330
|
opts.footer = "Stop service on an instance.\n" +
|
|
2239
2331
|
"[instance] is required. This is the name or id of an instance. Supports 1-N [instance] arguments."
|
|
@@ -2361,7 +2453,7 @@ class Morpheus::Cli::Instances
|
|
|
2361
2453
|
opts.on('--muteMonitoring [on|off]', String, "Mute monitoring. Default is on.") do |val|
|
|
2362
2454
|
params['muteMonitoring'] = val.nil? || val.to_s == 'on' || val.to_s == 'true'
|
|
2363
2455
|
end
|
|
2364
|
-
opts.add_hidden_option('muteMonitoring')
|
|
2456
|
+
opts.add_hidden_option('--muteMonitoring')
|
|
2365
2457
|
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
|
2366
2458
|
opts.footer = "Restart service on an instance.\n" +
|
|
2367
2459
|
"[instance] is required. This is the name or id of an instance. Supports 1-N [instance] arguments."
|
|
@@ -2785,34 +2877,158 @@ EOT
|
|
|
2785
2877
|
|
|
2786
2878
|
def cancel_removal(args)
|
|
2787
2879
|
options = {}
|
|
2880
|
+
params = {}
|
|
2788
2881
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
2789
2882
|
opts.banner = subcommand_usage("[instance]")
|
|
2790
|
-
|
|
2883
|
+
build_standard_update_options(opts, options)
|
|
2884
|
+
opts.footer = <<-EOT
|
|
2885
|
+
Cancel removal of an instance.
|
|
2886
|
+
This is a way to undo delete of an instance still pending removal.
|
|
2887
|
+
[instance] is required. This is the name or id of an instance
|
|
2888
|
+
EOT
|
|
2791
2889
|
end
|
|
2792
2890
|
optparse.parse!(args)
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2891
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
2892
|
+
connect(options)
|
|
2893
|
+
params.merge!(parse_query_options(options))
|
|
2894
|
+
payload = options[:payload] || {}
|
|
2895
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
2896
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
2897
|
+
@instances_interface.setopts(options)
|
|
2898
|
+
if options[:dry_run]
|
|
2899
|
+
print_dry_run @instances_interface.dry.cancel_removal(instance['id'], params, payload)
|
|
2900
|
+
return
|
|
2901
|
+
end
|
|
2902
|
+
json_response = @instances_interface.cancel_removal(instance['id'], params, payload)
|
|
2903
|
+
render_response(json_response, options) do
|
|
2904
|
+
print_green_success "Canceled removal for instance #{instance['name']} ..."
|
|
2905
|
+
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
2796
2906
|
end
|
|
2907
|
+
return 0, nil
|
|
2908
|
+
end
|
|
2909
|
+
|
|
2910
|
+
def cancel_expiration(args)
|
|
2911
|
+
options = {}
|
|
2912
|
+
params = {}
|
|
2913
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
2914
|
+
opts.banner = subcommand_usage("[instance]")
|
|
2915
|
+
build_standard_update_options(opts, options, [:query]) # query params instead of p
|
|
2916
|
+
opts.footer = <<-EOT
|
|
2917
|
+
Cancel expiration of an instance.
|
|
2918
|
+
[instance] is required. This is the name or id of an instance
|
|
2919
|
+
EOT
|
|
2920
|
+
end
|
|
2921
|
+
optparse.parse!(args)
|
|
2922
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
2797
2923
|
connect(options)
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
if options[:json]
|
|
2807
|
-
print as_json(json_response, options), "\n"
|
|
2808
|
-
return
|
|
2809
|
-
elsif !options[:quiet]
|
|
2810
|
-
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
2811
|
-
end
|
|
2812
|
-
rescue RestClient::Exception => e
|
|
2813
|
-
print_rest_exception(e, options)
|
|
2814
|
-
exit 1
|
|
2924
|
+
params.merge!(parse_query_options(options))
|
|
2925
|
+
payload = options[:payload] || {}
|
|
2926
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
2927
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
2928
|
+
@instances_interface.setopts(options)
|
|
2929
|
+
if options[:dry_run]
|
|
2930
|
+
print_dry_run @instances_interface.dry.cancel_expiration(instance['id'], params, payload)
|
|
2931
|
+
return
|
|
2815
2932
|
end
|
|
2933
|
+
json_response = @instances_interface.cancel_expiration(instance['id'], params, payload)
|
|
2934
|
+
render_response(json_response, options) do
|
|
2935
|
+
print_green_success "Canceled expiration for instance #{instance['name']} ..."
|
|
2936
|
+
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
2937
|
+
end
|
|
2938
|
+
return 0, nil
|
|
2939
|
+
end
|
|
2940
|
+
|
|
2941
|
+
def cancel_shutdown(args)
|
|
2942
|
+
options = {}
|
|
2943
|
+
params = {}
|
|
2944
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
2945
|
+
opts.banner = subcommand_usage("[instance]")
|
|
2946
|
+
build_standard_update_options(opts, options, [:query]) # query params instead of p
|
|
2947
|
+
opts.footer = <<-EOT
|
|
2948
|
+
Cancel shutdown for an instance.
|
|
2949
|
+
[instance] is required. This is the name or id of an instance
|
|
2950
|
+
EOT
|
|
2951
|
+
end
|
|
2952
|
+
optparse.parse!(args)
|
|
2953
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
2954
|
+
connect(options)
|
|
2955
|
+
params.merge!(parse_query_options(options))
|
|
2956
|
+
payload = options[:payload] || {}
|
|
2957
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
2958
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
2959
|
+
@instances_interface.setopts(options)
|
|
2960
|
+
if options[:dry_run]
|
|
2961
|
+
print_dry_run @instances_interface.dry.cancel_shutdown(instance['id'], params, payload)
|
|
2962
|
+
return
|
|
2963
|
+
end
|
|
2964
|
+
json_response = @instances_interface.cancel_shutdown(instance['id'], params, payload)
|
|
2965
|
+
render_response(json_response, options) do
|
|
2966
|
+
print_green_success "Canceled shutdown for instance #{instance['name']} ..."
|
|
2967
|
+
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
2968
|
+
end
|
|
2969
|
+
return 0, nil
|
|
2970
|
+
end
|
|
2971
|
+
|
|
2972
|
+
def extend_expiration(args)
|
|
2973
|
+
options = {}
|
|
2974
|
+
params = {}
|
|
2975
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
2976
|
+
opts.banner = subcommand_usage("[instance]")
|
|
2977
|
+
build_standard_update_options(opts, options, [:query]) # query params instead of p
|
|
2978
|
+
opts.footer = <<-EOT
|
|
2979
|
+
Extend expiration for an instance.
|
|
2980
|
+
[instance] is required. This is the name or id of an instance
|
|
2981
|
+
EOT
|
|
2982
|
+
end
|
|
2983
|
+
optparse.parse!(args)
|
|
2984
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
2985
|
+
connect(options)
|
|
2986
|
+
params.merge!(parse_query_options(options))
|
|
2987
|
+
payload = options[:payload] || {}
|
|
2988
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
2989
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
2990
|
+
@instances_interface.setopts(options)
|
|
2991
|
+
if options[:dry_run]
|
|
2992
|
+
print_dry_run @instances_interface.dry.extend_expiration(instance['id'], params, payload)
|
|
2993
|
+
return
|
|
2994
|
+
end
|
|
2995
|
+
json_response = @instances_interface.extend_expiration(instance['id'], params, payload)
|
|
2996
|
+
render_response(json_response, options) do
|
|
2997
|
+
print_green_success "Extended expiration for instance #{instance['name']} ..."
|
|
2998
|
+
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
2999
|
+
end
|
|
3000
|
+
return 0, nil
|
|
3001
|
+
end
|
|
3002
|
+
|
|
3003
|
+
def extend_shutdown(args)
|
|
3004
|
+
options = {}
|
|
3005
|
+
params = {}
|
|
3006
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
3007
|
+
opts.banner = subcommand_usage("[instance]")
|
|
3008
|
+
build_standard_update_options(opts, options, [:query]) # query params instead of p
|
|
3009
|
+
opts.footer = <<-EOT
|
|
3010
|
+
Extend shutdown for an instance.
|
|
3011
|
+
[instance] is required. This is the name or id of an instance
|
|
3012
|
+
EOT
|
|
3013
|
+
end
|
|
3014
|
+
optparse.parse!(args)
|
|
3015
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
3016
|
+
connect(options)
|
|
3017
|
+
params.merge!(parse_query_options(options))
|
|
3018
|
+
payload = options[:payload] || {}
|
|
3019
|
+
payload.deep_merge!(parse_passed_options(options))
|
|
3020
|
+
instance = find_instance_by_name_or_id(args[0])
|
|
3021
|
+
@instances_interface.setopts(options)
|
|
3022
|
+
if options[:dry_run]
|
|
3023
|
+
print_dry_run @instances_interface.dry.extend_shutdown(instance['id'], params, payload)
|
|
3024
|
+
return
|
|
3025
|
+
end
|
|
3026
|
+
json_response = @instances_interface.extend_shutdown(instance['id'], params, payload)
|
|
3027
|
+
render_response(json_response, options) do
|
|
3028
|
+
print_green_success "Extended shutdown for instance #{instance['name']} ..."
|
|
3029
|
+
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
3030
|
+
end
|
|
3031
|
+
return 0, nil
|
|
2816
3032
|
end
|
|
2817
3033
|
|
|
2818
3034
|
def firewall_disable(args)
|
|
@@ -3617,7 +3833,7 @@ EOT
|
|
|
3617
3833
|
opts.on('--process-id ID', String, "Display details about a specfic event." ) do |val|
|
|
3618
3834
|
options[:process_id] = val
|
|
3619
3835
|
end
|
|
3620
|
-
opts.add_hidden_option('process-id')
|
|
3836
|
+
opts.add_hidden_option('--process-id')
|
|
3621
3837
|
build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
3622
3838
|
opts.footer = "Display history details for a specific process.\n" +
|
|
3623
3839
|
"[instance] is required. This is the name or id of an instance.\n" +
|
|
@@ -3717,7 +3933,7 @@ EOT
|
|
|
3717
3933
|
opts.on('--event-id ID', String, "Display details about a specfic event." ) do |val|
|
|
3718
3934
|
options[:event_id] = val
|
|
3719
3935
|
end
|
|
3720
|
-
opts.add_hidden_option('event-id')
|
|
3936
|
+
opts.add_hidden_option('--event-id')
|
|
3721
3937
|
build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
3722
3938
|
opts.footer = "Display history details for a specific process event.\n" +
|
|
3723
3939
|
"[instance] is required. This is the name or id of an instance.\n" +
|