morpheus-cli 4.2.8 → 4.2.10
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.rb +1 -1
- data/lib/morpheus/api/activity_interface.rb +9 -0
- data/lib/morpheus/api/api_client.rb +83 -27
- data/lib/morpheus/api/apps_interface.rb +21 -0
- data/lib/morpheus/api/dashboard_interface.rb +5 -21
- data/lib/morpheus/api/instances_interface.rb +3 -10
- data/lib/morpheus/api/invoice_line_items_interface.rb +14 -0
- data/lib/morpheus/api/invoices_interface.rb +7 -12
- data/lib/morpheus/api/library_layouts_interface.rb +8 -0
- data/lib/morpheus/api/ping_interface.rb +20 -0
- data/lib/morpheus/api/projects_interface.rb +33 -0
- data/lib/morpheus/api/setup_interface.rb +19 -36
- data/lib/morpheus/api/user_settings_interface.rb +0 -6
- data/lib/morpheus/api/whoami_interface.rb +4 -8
- data/lib/morpheus/benchmarking.rb +16 -26
- data/lib/morpheus/cli.rb +10 -5
- data/lib/morpheus/cli/access_token_command.rb +5 -8
- data/lib/morpheus/cli/activity_command.rb +146 -0
- data/lib/morpheus/cli/apps.rb +312 -121
- data/lib/morpheus/cli/archives_command.rb +1 -1
- data/lib/morpheus/cli/auth_command.rb +4 -11
- data/lib/morpheus/cli/blueprints_command.rb +196 -137
- data/lib/morpheus/cli/change_password_command.rb +1 -1
- data/lib/morpheus/cli/cli_command.rb +225 -72
- data/lib/morpheus/cli/cli_registry.rb +2 -2
- data/lib/morpheus/cli/cloud_datastores_command.rb +1 -1
- data/lib/morpheus/cli/clouds.rb +5 -20
- data/lib/morpheus/cli/clusters.rb +4 -28
- data/lib/morpheus/cli/commands/standard/alias_command.rb +2 -9
- data/lib/morpheus/cli/commands/standard/benchmark_command.rb +2 -0
- data/lib/morpheus/cli/commands/standard/curl_command.rb +2 -3
- data/lib/morpheus/cli/commands/standard/history_command.rb +3 -6
- data/lib/morpheus/cli/commands/standard/man_command.rb +10 -7
- data/lib/morpheus/cli/commands/standard/ssl_verification_command.rb +10 -9
- data/lib/morpheus/cli/containers_command.rb +3 -3
- data/lib/morpheus/cli/credentials.rb +13 -16
- data/lib/morpheus/cli/error_handler.rb +18 -12
- data/lib/morpheus/cli/errors.rb +45 -0
- data/lib/morpheus/cli/execute_schedules_command.rb +1 -1
- data/lib/morpheus/cli/execution_request_command.rb +4 -4
- data/lib/morpheus/cli/groups.rb +84 -132
- data/lib/morpheus/cli/hosts.rb +6 -16
- data/lib/morpheus/cli/instances.rb +100 -183
- data/lib/morpheus/cli/invoices_command.rb +505 -71
- data/lib/morpheus/cli/library_layouts_command.rb +254 -166
- data/lib/morpheus/cli/library_option_lists_command.rb +0 -87
- data/lib/morpheus/cli/library_option_types_command.rb +0 -96
- data/lib/morpheus/cli/license.rb +3 -0
- data/lib/morpheus/cli/login.rb +17 -37
- data/lib/morpheus/cli/logout.rb +9 -5
- data/lib/morpheus/cli/mixins/accounts_helper.rb +83 -7
- data/lib/morpheus/cli/mixins/operations_helper.rb +41 -0
- data/lib/morpheus/cli/mixins/option_source_helper.rb +255 -0
- data/lib/morpheus/cli/mixins/print_helper.rb +18 -4
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +222 -13
- data/lib/morpheus/cli/mixins/remote_helper.rb +139 -0
- data/lib/morpheus/cli/monitoring_checks_command.rb +11 -3
- data/lib/morpheus/cli/network_groups_command.rb +8 -2
- data/lib/morpheus/cli/option_types.rb +1 -1
- data/lib/morpheus/cli/ping.rb +252 -0
- data/lib/morpheus/cli/price_sets_command.rb +16 -27
- data/lib/morpheus/cli/prices_command.rb +34 -27
- data/lib/morpheus/cli/processes_command.rb +81 -7
- data/lib/morpheus/cli/projects_command.rb +607 -0
- data/lib/morpheus/cli/recent_activity_command.rb +87 -65
- data/lib/morpheus/cli/remote.rb +965 -974
- data/lib/morpheus/cli/reports_command.rb +3 -15
- data/lib/morpheus/cli/roles.rb +8 -31
- data/lib/morpheus/cli/service_plans_command.rb +25 -31
- data/lib/morpheus/cli/setup.rb +392 -0
- data/lib/morpheus/cli/shell.rb +144 -56
- data/lib/morpheus/cli/subnets_command.rb +71 -11
- data/lib/morpheus/cli/tasks.rb +3 -3
- data/lib/morpheus/cli/user_sources_command.rb +4 -4
- data/lib/morpheus/cli/users.rb +135 -109
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/whitelabel_settings_command.rb +7 -7
- data/lib/morpheus/cli/whoami.rb +90 -129
- data/lib/morpheus/cli/wiki_command.rb +2 -14
- data/lib/morpheus/ext/rest_client.rb +36 -0
- data/lib/morpheus/formatters.rb +42 -5
- data/lib/morpheus/rest_client.rb +0 -10
- data/lib/morpheus/terminal.rb +41 -1
- data/lib/morpheus/util.rb +24 -0
- metadata +16 -3
- data/lib/morpheus/cli/command_error.rb +0 -22
|
@@ -3,21 +3,18 @@ require 'rest_client'
|
|
|
3
3
|
require 'optparse'
|
|
4
4
|
require 'filesize'
|
|
5
5
|
require 'morpheus/cli/cli_command'
|
|
6
|
-
require 'morpheus/cli/mixins/accounts_helper'
|
|
7
|
-
require 'morpheus/cli/mixins/provisioning_helper'
|
|
8
|
-
require 'morpheus/cli/mixins/processes_helper'
|
|
9
|
-
require 'morpheus/cli/mixins/logs_helper'
|
|
10
|
-
require 'morpheus/cli/option_types'
|
|
11
6
|
|
|
12
7
|
class Morpheus::Cli::Instances
|
|
13
8
|
include Morpheus::Cli::CliCommand
|
|
14
|
-
include Morpheus::Cli::AccountsHelper
|
|
9
|
+
include Morpheus::Cli::AccountsHelper # needed? replace with OptionSourceHelper
|
|
10
|
+
include Morpheus::Cli::OptionSourceHelper
|
|
15
11
|
include Morpheus::Cli::ProvisioningHelper
|
|
16
12
|
include Morpheus::Cli::ProcessesHelper
|
|
17
13
|
include Morpheus::Cli::LogsHelper
|
|
14
|
+
|
|
18
15
|
set_command_name :instances
|
|
19
16
|
set_command_description "View and manage instances."
|
|
20
|
-
register_subcommands :list, :count, :get, :view, :add, :update, :
|
|
17
|
+
register_subcommands :list, :count, :get, :view, :add, :update, :remove, :cancel_removal, :logs, :history, {:'history-details' => :history_details}, {:'history-event' => :history_event_details}, :stats, :stop, :start, :restart, :actions, :action, :suspend, :eject, :backup, :backups, :stop_service, :start_service, :restart_service, :resize, :clone, :envs, :setenv, :delenv, :security_groups, :apply_security_groups, :run_workflow, :import_snapshot, :console, :status_check, {:containers => :list_containers}, :scaling, {:'scaling-update' => :scaling_update}
|
|
21
18
|
register_subcommands :wiki, :update_wiki
|
|
22
19
|
register_subcommands :exec => :execution_request
|
|
23
20
|
#register_subcommands :firewall_disable, :firewall_enable
|
|
@@ -66,27 +63,31 @@ class Morpheus::Cli::Instances
|
|
|
66
63
|
opts.on( '-H', '--host HOST', "Host Name or ID" ) do |val|
|
|
67
64
|
options[:host] = val
|
|
68
65
|
end
|
|
69
|
-
opts.on( '--
|
|
70
|
-
options[:
|
|
66
|
+
opts.on( '--owner USER', "Owner Username or ID" ) do |val|
|
|
67
|
+
options[:owner] = val
|
|
68
|
+
end
|
|
69
|
+
opts.on( '--created-by USER', "Alias for --owner" ) do |val|
|
|
70
|
+
options[:owner] = val
|
|
71
71
|
end
|
|
72
|
+
opts.add_hidden_option('--created-by')
|
|
72
73
|
opts.on('--details', "Display more details: memory and storage usage used / max values." ) do
|
|
73
74
|
options[:details] = true
|
|
74
75
|
end
|
|
75
76
|
opts.on('--status STATUS', "Filter by status i.e. provisioning,running,starting,stopping") do |val|
|
|
76
|
-
params['status']
|
|
77
|
-
params['status'] << val
|
|
77
|
+
params['status'] = (params['status'] || []) + val.to_s.split(',').collect {|s| s.strip }.select {|s| s != "" }
|
|
78
78
|
end
|
|
79
79
|
opts.on('--pending-removal', "Include instances pending removal.") do
|
|
80
|
-
options[:
|
|
80
|
+
options[:showDeleted] = true
|
|
81
|
+
end
|
|
82
|
+
opts.on('--pending-removal-only', "Only instances pending removal.") do
|
|
83
|
+
options[:deleted] = true
|
|
81
84
|
end
|
|
82
85
|
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
83
86
|
opts.footer = "List instances."
|
|
84
87
|
end
|
|
85
88
|
optparse.parse!(args)
|
|
89
|
+
verify_args!(args:args, count:0, optparse:optparse)
|
|
86
90
|
connect(options)
|
|
87
|
-
if args.count != 0
|
|
88
|
-
raise_command_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args}\n#{optparse}"
|
|
89
|
-
end
|
|
90
91
|
begin
|
|
91
92
|
params.merge!(parse_list_options(options))
|
|
92
93
|
group = options[:group] ? find_group_by_name_or_id_for_provisioning(options[:group]) : nil
|
|
@@ -107,14 +108,18 @@ class Morpheus::Cli::Instances
|
|
|
107
108
|
end
|
|
108
109
|
|
|
109
110
|
account = nil
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
#todo: user = find_available_user_option(owner_id)
|
|
112
|
+
|
|
113
|
+
if options[:owner]
|
|
114
|
+
created_by_ids = find_all_user_ids(account ? account['id'] : nil, options[:owner])
|
|
112
115
|
return if created_by_ids.nil?
|
|
113
116
|
params['createdBy'] = created_by_ids
|
|
117
|
+
params['ownerId'] = created_by_ids # 4.2.1+
|
|
114
118
|
end
|
|
115
119
|
|
|
116
|
-
params['showDeleted'] = true if options[:
|
|
117
|
-
|
|
120
|
+
params['showDeleted'] = true if options[:showDeleted]
|
|
121
|
+
params['deleted'] = true if options[:deleted]
|
|
122
|
+
|
|
118
123
|
@instances_interface.setopts(options)
|
|
119
124
|
if options[:dry_run]
|
|
120
125
|
print_dry_run @instances_interface.dry.list(params)
|
|
@@ -152,8 +157,8 @@ class Morpheus::Cli::Instances
|
|
|
152
157
|
if host
|
|
153
158
|
subtitles << "Host: #{host['name']}".strip
|
|
154
159
|
end
|
|
155
|
-
if options[:
|
|
156
|
-
subtitles << "Created By: #{options[:
|
|
160
|
+
if options[:owner]
|
|
161
|
+
subtitles << "Created By: #{options[:owner]}"
|
|
157
162
|
end
|
|
158
163
|
subtitles += parse_list_subtitles(options)
|
|
159
164
|
print_h1 title, subtitles, options
|
|
@@ -191,13 +196,15 @@ class Morpheus::Cli::Instances
|
|
|
191
196
|
name: instance['name'],
|
|
192
197
|
connection: format_instance_connection_string(instance),
|
|
193
198
|
environment: instance['instanceContext'],
|
|
194
|
-
user: instance['createdBy'].is_a?(Hash) ? instance['createdBy']['username'] : instance['createdBy'],
|
|
199
|
+
user: (instance['owner'] ? (instance['owner']['username'] || instance['owner']['id']) : (instance['createdBy'].is_a?(Hash) ? instance['createdBy']['username'] : instance['createdBy'])),
|
|
200
|
+
tenant: (instance['owner'] ? (instance['owner']['username'] || instance['owner']['id']) : (instance['createdBy'].is_a?(Hash) ? instance['createdBy']['username'] : instance['createdBy'])),
|
|
195
201
|
nodes: instance['containers'].count,
|
|
196
202
|
status: format_instance_status(instance, cyan),
|
|
197
203
|
type: instance['instanceType']['name'],
|
|
198
204
|
group: !instance['group'].nil? ? instance['group']['name'] : nil,
|
|
199
205
|
cloud: !instance['cloud'].nil? ? instance['cloud']['name'] : nil,
|
|
200
206
|
version: instance['instanceVersion'] ? instance['instanceVersion'] : '',
|
|
207
|
+
created: format_local_dt(instance['dateCreated']),
|
|
201
208
|
cpu: cpu_usage_str + cyan,
|
|
202
209
|
memory: memory_usage_str + cyan,
|
|
203
210
|
storage: storage_usage_str + cyan
|
|
@@ -206,7 +213,9 @@ class Morpheus::Cli::Instances
|
|
|
206
213
|
}
|
|
207
214
|
columns = [:id, {:name => {:max_width => 50}}, :group, :cloud,
|
|
208
215
|
:type, :version, :environment,
|
|
209
|
-
{:
|
|
216
|
+
{:created => {:display_name => "CREATED"}},
|
|
217
|
+
# {:tenant => {:display_name => "TENANT"}},
|
|
218
|
+
{:user => {:display_name => "OWNER", :max_width => 20}},
|
|
210
219
|
:nodes, {:connection => {:max_width => 30}}, :status, :cpu, :memory, :storage]
|
|
211
220
|
# custom pretty table columns ... this is handled in as_pretty_table now(),
|
|
212
221
|
# todo: remove all these.. and try to always pass rows as the json data itself..
|
|
@@ -239,9 +248,13 @@ class Morpheus::Cli::Instances
|
|
|
239
248
|
opts.on( '-H', '--host HOST', "Host Name or ID" ) do |val|
|
|
240
249
|
options[:host] = val
|
|
241
250
|
end
|
|
242
|
-
opts.on( '--
|
|
243
|
-
options[:
|
|
251
|
+
opts.on( '--owner USER', "Owner Username or ID" ) do |val|
|
|
252
|
+
options[:owner] = val
|
|
244
253
|
end
|
|
254
|
+
opts.on( '--created-by USER', "Alias for --owner" ) do |val|
|
|
255
|
+
options[:owner] = val
|
|
256
|
+
end
|
|
257
|
+
opts.add_hidden_option('--created-by')
|
|
245
258
|
opts.on( '-s', '--search PHRASE', "Search Phrase" ) do |phrase|
|
|
246
259
|
options[:phrase] = phrase
|
|
247
260
|
end
|
|
@@ -271,10 +284,11 @@ class Morpheus::Cli::Instances
|
|
|
271
284
|
end
|
|
272
285
|
|
|
273
286
|
account = nil
|
|
274
|
-
if options[:
|
|
275
|
-
created_by_ids = find_all_user_ids(account ? account['id'] : nil, options[:
|
|
287
|
+
if options[:owner]
|
|
288
|
+
created_by_ids = find_all_user_ids(account ? account['id'] : nil, options[:owner])
|
|
276
289
|
return if created_by_ids.nil?
|
|
277
290
|
params['createdBy'] = created_by_ids
|
|
291
|
+
# params['ownerId'] = created_by_ids # 4.2.1+
|
|
278
292
|
end
|
|
279
293
|
|
|
280
294
|
@instances_interface.setopts(options)
|
|
@@ -486,9 +500,7 @@ class Morpheus::Cli::Instances
|
|
|
486
500
|
end
|
|
487
501
|
|
|
488
502
|
def update(args)
|
|
489
|
-
|
|
490
|
-
options = {}
|
|
491
|
-
params = {}
|
|
503
|
+
params, payload, options = {}, {}, {}
|
|
492
504
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
493
505
|
opts.banner = subcommand_usage("[instance]")
|
|
494
506
|
opts.on('--name VALUE', String, "Name") do |val|
|
|
@@ -518,9 +530,13 @@ class Morpheus::Cli::Instances
|
|
|
518
530
|
opts.on('--power-schedule-type ID', String, "Power Schedule Type ID") do |val|
|
|
519
531
|
params['powerScheduleType'] = val == "null" ? nil : val
|
|
520
532
|
end
|
|
521
|
-
opts.on('--
|
|
522
|
-
options[:
|
|
533
|
+
opts.on( '--owner USER', "Owner Username or ID" ) do |val|
|
|
534
|
+
options[:owner] = val == 'null' ? nil : val
|
|
535
|
+
end
|
|
536
|
+
opts.on( '--created-by USER', "Alias for --owner" ) do |val|
|
|
537
|
+
options[:owner] = val == 'null' ? nil : val
|
|
523
538
|
end
|
|
539
|
+
opts.add_hidden_option('--created-by')
|
|
524
540
|
# opts.on("--shutdown-days [DAYS]", Integer, "Automation: Shutdown Days") do |val|
|
|
525
541
|
# params['shutdownDays'] = val.to_s.empty? ? nil : val.to_i
|
|
526
542
|
# end
|
|
@@ -540,141 +556,50 @@ class Morpheus::Cli::Instances
|
|
|
540
556
|
instance = find_instance_by_name_or_id(args[0])
|
|
541
557
|
return 1 if instance.nil?
|
|
542
558
|
new_group = nil
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
return 1 if new_group.nil?
|
|
546
|
-
params['site'] = {'id' => new_group['id']}
|
|
547
|
-
end
|
|
548
|
-
if options[:metadata]
|
|
549
|
-
if options[:metadata] == "[]" || options[:metadata] == "null"
|
|
550
|
-
params['metadata'] = []
|
|
551
|
-
else
|
|
552
|
-
# parse string into format name:value, name:value
|
|
553
|
-
# merge IDs from current metadata
|
|
554
|
-
# todo: should allow quoted semicolons..
|
|
555
|
-
metadata_list = options[:metadata].split(",").select {|it| !it.to_s.empty? }
|
|
556
|
-
metadata_list = metadata_list.collect do |it|
|
|
557
|
-
metadata_pair = it.split(":")
|
|
558
|
-
row = {}
|
|
559
|
-
row['name'] = metadata_pair[0].to_s.strip
|
|
560
|
-
row['value'] = metadata_pair[1].to_s.strip
|
|
561
|
-
existing_metadata = (instance['metadata'] || []).find { |m| m['name'] == it['name'] }
|
|
562
|
-
if existing_metadata
|
|
563
|
-
row['id'] = existing_metadata['id']
|
|
564
|
-
end
|
|
565
|
-
row
|
|
566
|
-
end
|
|
567
|
-
params['metadata'] = metadata_list
|
|
568
|
-
end
|
|
569
|
-
end
|
|
570
|
-
params.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
|
571
|
-
payload = nil
|
|
559
|
+
|
|
560
|
+
|
|
572
561
|
if options[:payload]
|
|
573
562
|
payload = options[:payload]
|
|
574
|
-
# support args and option parameters on top of payload
|
|
575
|
-
if !params.empty?
|
|
576
|
-
payload['instance'] ||= {}
|
|
577
|
-
payload['instance'].deep_merge!(params)
|
|
578
|
-
end
|
|
579
|
-
else
|
|
580
|
-
if params.empty? && options[:created_by_id].nil?
|
|
581
|
-
print_red_alert "Specify at least one option to update"
|
|
582
|
-
puts optparse
|
|
583
|
-
exit 1
|
|
584
|
-
end
|
|
585
|
-
payload = {}
|
|
586
|
-
payload['instance'] = params
|
|
587
|
-
if options[:created_by_id]
|
|
588
|
-
payload['createdById'] = options[:created_by_id].to_i
|
|
589
|
-
end
|
|
590
563
|
end
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
print_green_success "Updated instance #{instance['name']}"
|
|
602
|
-
#list([])
|
|
603
|
-
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
604
|
-
end
|
|
605
|
-
return 0
|
|
606
|
-
rescue RestClient::Exception => e
|
|
607
|
-
print_rest_exception(e, options)
|
|
608
|
-
exit 1
|
|
609
|
-
end
|
|
610
|
-
end
|
|
611
|
-
|
|
612
|
-
def update_notes(args)
|
|
613
|
-
usage = "Usage: morpheus instances update-notes [instance] [options]"
|
|
614
|
-
options = {}
|
|
615
|
-
params = {}
|
|
616
|
-
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
617
|
-
opts.banner = subcommand_usage("[instance]")
|
|
618
|
-
opts.on('--notes VALUE', String, "Notes content (Markdown)") do |val|
|
|
619
|
-
params['notes'] = val
|
|
620
|
-
end
|
|
621
|
-
opts.on('--file FILE', "File containing the notes content. This can be used instead of --notes") do |filename|
|
|
622
|
-
full_filename = File.expand_path(filename)
|
|
623
|
-
if File.exists?(full_filename)
|
|
624
|
-
params['notes'] = File.read(full_filename)
|
|
564
|
+
payload['instance'] ||= {}
|
|
565
|
+
payload.deep_merge!({'instance' => parse_passed_options(options)})
|
|
566
|
+
|
|
567
|
+
if options.key?(:owner) && [nil].include?(options[:owner])
|
|
568
|
+
# allow clearing
|
|
569
|
+
params['ownerId'] = nil
|
|
570
|
+
elsif options[:owner]
|
|
571
|
+
owner_id = options[:owner].to_s
|
|
572
|
+
if owner_id.to_s =~ /\A\d{1,}\Z/
|
|
573
|
+
# allow id without lookup
|
|
625
574
|
else
|
|
626
|
-
|
|
627
|
-
return 1
|
|
628
|
-
|
|
629
|
-
# use the filename as the name by default.
|
|
630
|
-
if !params['name']
|
|
631
|
-
params['name'] = File.basename(full_filename)
|
|
575
|
+
user = find_available_user_option(owner_id)
|
|
576
|
+
return 1 if user.nil?
|
|
577
|
+
owner_id = user['id']
|
|
632
578
|
end
|
|
579
|
+
params['ownerId'] = owner_id
|
|
580
|
+
#payload['createdById'] = options[:owner].to_i # pre 4.2.1 api
|
|
633
581
|
end
|
|
634
|
-
|
|
635
|
-
|
|
582
|
+
if params.empty? && options[:owner].nil?
|
|
583
|
+
print_red_alert "Specify at least one option to update"
|
|
584
|
+
puts optparse
|
|
585
|
+
exit 1
|
|
636
586
|
end
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
optparse.parse!(args)
|
|
640
|
-
if args.count != 1
|
|
641
|
-
puts_error "#{Morpheus::Terminal.angry_prompt}wrong number of arguments. Expected 1 and received #{args.count} #{args.inspect}\n#{optparse}"
|
|
642
|
-
return 1
|
|
643
|
-
end
|
|
644
|
-
connect(options)
|
|
645
|
-
print_error "#{yellow}DEPRECATION WARNING: `instances update-notes` is deprecated in 4.0, use `instances update-wiki` instead.#{reset}\n"
|
|
646
|
-
begin
|
|
647
|
-
instance = find_instance_by_name_or_id(args[0])
|
|
648
|
-
return 1 if instance.nil?
|
|
649
|
-
new_group = nil
|
|
650
|
-
params.deep_merge!(options[:options].reject {|k,v| k.is_a?(Symbol) }) if options[:options]
|
|
651
|
-
payload = nil
|
|
652
|
-
if options[:payload]
|
|
653
|
-
payload = options[:payload]
|
|
654
|
-
# support args and option parameters on top of payload
|
|
655
|
-
if !params.empty?
|
|
656
|
-
payload['instance'] ||= {}
|
|
657
|
-
payload['instance'].deep_merge!(params)
|
|
658
|
-
end
|
|
659
|
-
else
|
|
660
|
-
if params['notes'].nil?
|
|
661
|
-
v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'notes', 'type' => 'code-editor', 'fieldLabel' => 'Notes', 'required' => true, 'description' => 'Notes (Markdown)'}], options[:options])
|
|
662
|
-
params['notes'] = v_prompt['notes']
|
|
663
|
-
end
|
|
664
|
-
payload = {}
|
|
665
|
-
payload['instance'] = params
|
|
587
|
+
if !params.empty?
|
|
588
|
+
payload['instance'].deep_merge!(params)
|
|
666
589
|
end
|
|
590
|
+
payload.delete('instance') if payload['instance'] && payload['instance'].empty?
|
|
591
|
+
raise_command_error "Specify at least one option to update.\n#{optparse}" if payload.empty?
|
|
667
592
|
@instances_interface.setopts(options)
|
|
668
593
|
if options[:dry_run]
|
|
669
|
-
print_dry_run @instances_interface.dry.
|
|
594
|
+
print_dry_run @instances_interface.dry.update(instance["id"], payload)
|
|
670
595
|
return
|
|
671
596
|
end
|
|
672
|
-
json_response = @instances_interface.
|
|
597
|
+
json_response = @instances_interface.update(instance["id"], payload)
|
|
673
598
|
|
|
674
599
|
if options[:json]
|
|
675
600
|
puts as_json(json_response, options)
|
|
676
601
|
else
|
|
677
|
-
print_green_success "Updated
|
|
602
|
+
print_green_success "Updated instance #{instance['name']}"
|
|
678
603
|
#list([])
|
|
679
604
|
get([instance['id']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
680
605
|
end
|
|
@@ -783,23 +708,11 @@ class Morpheus::Cli::Instances
|
|
|
783
708
|
|
|
784
709
|
link = "#{@appliance_url}/login/oauth-redirect?access_token=#{@access_token}\\&redirectUri=/provisioning/instances/#{instance['id']}#!wiki"
|
|
785
710
|
|
|
786
|
-
open_command = nil
|
|
787
|
-
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
|
788
|
-
open_command = "start #{link}"
|
|
789
|
-
elsif RbConfig::CONFIG['host_os'] =~ /darwin/
|
|
790
|
-
open_command = "open #{link}"
|
|
791
|
-
elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
|
|
792
|
-
open_command = "xdg-open #{link}"
|
|
793
|
-
end
|
|
794
|
-
|
|
795
711
|
if options[:dry_run]
|
|
796
|
-
puts
|
|
712
|
+
puts Morpheus::Util.open_url_command(link)
|
|
797
713
|
return 0
|
|
798
714
|
end
|
|
799
|
-
|
|
800
|
-
system(open_command)
|
|
801
|
-
|
|
802
|
-
return 0
|
|
715
|
+
return Morpheus::Util.open_url(link)
|
|
803
716
|
rescue RestClient::Exception => e
|
|
804
717
|
print_rest_exception(e, options)
|
|
805
718
|
exit 1
|
|
@@ -976,7 +889,7 @@ class Morpheus::Cli::Instances
|
|
|
976
889
|
opts.on( '-n', '--node NODE_ID', "Scope console to specific Container or VM" ) do |node_id|
|
|
977
890
|
options[:node_id] = node_id.to_i
|
|
978
891
|
end
|
|
979
|
-
build_common_options(opts, options, [:remote])
|
|
892
|
+
build_common_options(opts, options, [:dry_run, :remote])
|
|
980
893
|
end
|
|
981
894
|
optparse.parse!(args)
|
|
982
895
|
if args.count < 1
|
|
@@ -993,13 +906,11 @@ class Morpheus::Cli::Instances
|
|
|
993
906
|
link += "?containerId=#{options[:node_id]}"
|
|
994
907
|
end
|
|
995
908
|
|
|
996
|
-
if
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
system "open #{link}"
|
|
1000
|
-
elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
|
|
1001
|
-
system "xdg-open #{link}"
|
|
909
|
+
if options[:dry_run]
|
|
910
|
+
puts Morpheus::Util.open_url_command(link)
|
|
911
|
+
return 0
|
|
1002
912
|
end
|
|
913
|
+
return Morpheus::Util.open_url(link)
|
|
1003
914
|
rescue RestClient::Exception => e
|
|
1004
915
|
print_rest_exception(e, options)
|
|
1005
916
|
exit 1
|
|
@@ -1307,11 +1218,17 @@ class Morpheus::Cli::Instances
|
|
|
1307
1218
|
"Labels" => lambda {|it| it['tags'] ? it['tags'].join(',') : '' },
|
|
1308
1219
|
"Metadata" => lambda {|it| it['metadata'] ? it['metadata'].collect {|m| "#{m['name']}: #{m['value']}" }.join(', ') : '' },
|
|
1309
1220
|
"Power Schedule" => lambda {|it| (it['powerSchedule'] && it['powerSchedule']['type']) ? it['powerSchedule']['type']['name'] : '' },
|
|
1310
|
-
"
|
|
1221
|
+
"Owner" => lambda {|it|
|
|
1222
|
+
if it['owner']
|
|
1223
|
+
(it['owner']['username'] || it['owner']['id'])
|
|
1224
|
+
else
|
|
1225
|
+
it['createdBy'] ? (it['createdBy']['username'] || it['createdBy']['id']) : ''
|
|
1226
|
+
end
|
|
1227
|
+
},
|
|
1228
|
+
#"Tenant" => lambda {|it| it['tenant'] ? it['tenant']['name'] : '' },
|
|
1311
1229
|
"Date Created" => lambda {|it| format_local_dt(it['dateCreated']) },
|
|
1312
1230
|
"Nodes" => lambda {|it| it['containers'] ? it['containers'].count : 0 },
|
|
1313
1231
|
"Connection" => lambda {|it| format_instance_connection_string(it) },
|
|
1314
|
-
#"Account" => lambda {|it| it['account'] ? it['account']['name'] : '' },
|
|
1315
1232
|
"Status" => lambda {|it| format_instance_status(it) }
|
|
1316
1233
|
}
|
|
1317
1234
|
|
|
@@ -2355,7 +2272,7 @@ class Morpheus::Cli::Instances
|
|
|
2355
2272
|
options = {}
|
|
2356
2273
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
2357
2274
|
opts.banner = subcommand_usage("[id or name list]")
|
|
2358
|
-
opts.footer = "
|
|
2275
|
+
opts.footer = "List the actions available to specified instance(s)."
|
|
2359
2276
|
build_common_options(opts, options, [:json, :dry_run, :remote])
|
|
2360
2277
|
end
|
|
2361
2278
|
optparse.parse!(args)
|
|
@@ -2924,6 +2841,7 @@ class Morpheus::Cli::Instances
|
|
|
2924
2841
|
|
|
2925
2842
|
def import_snapshot(args)
|
|
2926
2843
|
options = {}
|
|
2844
|
+
query_params = {}
|
|
2927
2845
|
storage_provider_id = nil
|
|
2928
2846
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
2929
2847
|
opts.banner = subcommand_usage("[instance]")
|
|
@@ -2933,9 +2851,8 @@ class Morpheus::Cli::Instances
|
|
|
2933
2851
|
build_common_options(opts, options, [:auto_confirm, :json, :dry_run, :remote])
|
|
2934
2852
|
end
|
|
2935
2853
|
optparse.parse!(args)
|
|
2936
|
-
if args.count
|
|
2937
|
-
|
|
2938
|
-
exit 1
|
|
2854
|
+
if args.count != 1
|
|
2855
|
+
raise_command_error "wrong number of arguments, expected 1 and got (#{args.count}) #{args.join(' ')}\n#{optparse}"
|
|
2939
2856
|
end
|
|
2940
2857
|
connect(options)
|
|
2941
2858
|
begin
|
|
@@ -2951,7 +2868,7 @@ class Morpheus::Cli::Instances
|
|
|
2951
2868
|
options[:options] ||= {}
|
|
2952
2869
|
options[:options]['storageProviderId'] = storage_provider_id if storage_provider_id
|
|
2953
2870
|
storage_provider_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'storageProviderId', 'type' => 'select', 'fieldLabel' => 'Storage Provider', 'optionSource' => 'storageProviders', 'required' => false, 'description' => 'Select Storage Provider.'}], options[:options], @api_client, {})
|
|
2954
|
-
if !storage_provider_prompt['storageProviderId'].empty?
|
|
2871
|
+
if !storage_provider_prompt['storageProviderId'].to_s.empty?
|
|
2955
2872
|
payload['storageProviderId'] = storage_provider_prompt['storageProviderId']
|
|
2956
2873
|
end
|
|
2957
2874
|
rescue RestClient::Exception => e
|
|
@@ -2961,10 +2878,10 @@ class Morpheus::Cli::Instances
|
|
|
2961
2878
|
end
|
|
2962
2879
|
@instances_interface.setopts(options)
|
|
2963
2880
|
if options[:dry_run]
|
|
2964
|
-
print_dry_run @instances_interface.dry.import_snapshot(instance['id'], payload)
|
|
2881
|
+
print_dry_run @instances_interface.dry.import_snapshot(instance['id'], query_params, payload)
|
|
2965
2882
|
return
|
|
2966
2883
|
end
|
|
2967
|
-
json_response = @instances_interface.import_snapshot(instance['id'], payload)
|
|
2884
|
+
json_response = @instances_interface.import_snapshot(instance['id'], query_params, payload)
|
|
2968
2885
|
if options[:json]
|
|
2969
2886
|
puts as_json(json_response, options)
|
|
2970
2887
|
else
|
|
@@ -3677,9 +3594,9 @@ class Morpheus::Cli::Instances
|
|
|
3677
3594
|
execution_request = json_response['executionRequest']
|
|
3678
3595
|
print_green_success "Executing request #{execution_request['uniqueId']}"
|
|
3679
3596
|
if do_refresh
|
|
3680
|
-
Morpheus::Cli::ExecutionRequestCommand.new.handle(["get", execution_request['uniqueId'], "--refresh"])
|
|
3597
|
+
Morpheus::Cli::ExecutionRequestCommand.new.handle(["get", execution_request['uniqueId'], "--refresh"]+ (options[:remote] ? ["-r",options[:remote]] : []))
|
|
3681
3598
|
else
|
|
3682
|
-
Morpheus::Cli::ExecutionRequestCommand.new.handle(["get", execution_request['uniqueId']])
|
|
3599
|
+
Morpheus::Cli::ExecutionRequestCommand.new.handle(["get", execution_request['uniqueId']]+ (options[:remote] ? ["-r",options[:remote]] : []))
|
|
3683
3600
|
end
|
|
3684
3601
|
return 0
|
|
3685
3602
|
rescue RestClient::Exception => e
|