morpheus-cli 3.6.8 → 3.6.9
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/lib/morpheus/api/account_groups_interface.rb +2 -2
- data/lib/morpheus/api/accounts_interface.rb +4 -7
- data/lib/morpheus/api/api_client.rb +207 -70
- data/lib/morpheus/api/app_templates_interface.rb +7 -28
- data/lib/morpheus/api/apps_interface.rb +14 -21
- data/lib/morpheus/api/archive_buckets_interface.rb +2 -2
- data/lib/morpheus/api/archive_files_interface.rb +6 -6
- data/lib/morpheus/api/auth_interface.rb +14 -1
- data/lib/morpheus/api/blueprints_interface.rb +9 -16
- data/lib/morpheus/api/cloud_datastores_interface.rb +1 -1
- data/lib/morpheus/api/cloud_policies_interface.rb +1 -1
- data/lib/morpheus/api/clouds_interface.rb +18 -21
- data/lib/morpheus/api/cypher_interface.rb +19 -28
- data/lib/morpheus/api/file_copy_request_interface.rb +1 -1
- data/lib/morpheus/api/group_policies_interface.rb +1 -1
- data/lib/morpheus/api/groups_interface.rb +4 -4
- data/lib/morpheus/api/image_builder_boot_scripts_interface.rb +1 -1
- data/lib/morpheus/api/image_builder_image_builds_interface.rb +2 -2
- data/lib/morpheus/api/image_builder_preseed_scripts_interface.rb +1 -1
- data/lib/morpheus/api/instances_interface.rb +17 -23
- data/lib/morpheus/api/logs_interface.rb +7 -10
- data/lib/morpheus/api/network_domains_interface.rb +1 -1
- data/lib/morpheus/api/network_groups_interface.rb +1 -1
- data/lib/morpheus/api/network_pool_servers_interface.rb +1 -1
- data/lib/morpheus/api/network_pools_interface.rb +1 -1
- data/lib/morpheus/api/network_proxies_interface.rb +1 -1
- data/lib/morpheus/api/network_services_interface.rb +1 -1
- data/lib/morpheus/api/networks_interface.rb +1 -1
- data/lib/morpheus/api/old_cypher_interface.rb +55 -0
- data/lib/morpheus/api/packages_interface.rb +1 -1
- data/lib/morpheus/api/policies_interface.rb +1 -1
- data/lib/morpheus/api/setup_interface.rb +1 -1
- data/lib/morpheus/api/storage_providers_interface.rb +1 -1
- data/lib/morpheus/api/whoami_interface.rb +1 -1
- data/lib/morpheus/benchmarking.rb +277 -0
- data/lib/morpheus/cli.rb +6 -22
- data/lib/morpheus/cli/access_token_command.rb +172 -0
- data/lib/morpheus/cli/accounts.rb +5 -0
- data/lib/morpheus/cli/apps.rb +93 -37
- data/lib/morpheus/cli/archives_command.rb +0 -2
- data/lib/morpheus/cli/auth_command.rb +112 -0
- data/lib/morpheus/cli/blueprints_command.rb +50 -13
- data/lib/morpheus/cli/change_password_command.rb +148 -0
- data/lib/morpheus/cli/cli_command.rb +173 -49
- data/lib/morpheus/cli/clouds.rb +15 -5
- data/lib/morpheus/cli/command_error.rb +7 -1
- data/lib/morpheus/cli/{alias_command.rb → commands/standard/alias_command.rb} +79 -51
- data/lib/morpheus/cli/commands/standard/benchmark_command.rb +399 -0
- data/lib/morpheus/cli/commands/standard/coloring_command.rb +60 -0
- data/lib/morpheus/cli/{curl_command.rb → commands/standard/curl_command.rb} +0 -7
- data/lib/morpheus/cli/commands/standard/debug_command.rb +61 -0
- data/lib/morpheus/cli/{echo_command.rb → commands/standard/echo_command.rb} +1 -1
- data/lib/morpheus/cli/{edit_profile_command.rb → commands/standard/edit_profile_command.rb} +0 -0
- data/lib/morpheus/cli/{edit_rc_command.rb → commands/standard/edit_rc_command.rb} +0 -0
- data/lib/morpheus/cli/commands/standard/get_prompt_command.rb +39 -0
- data/lib/morpheus/cli/commands/standard/history_command.rb +76 -0
- data/lib/morpheus/cli/{log_level_command.rb → commands/standard/log_level_command.rb} +1 -1
- data/lib/morpheus/cli/{man_command.rb → commands/standard/man_command.rb} +2 -2
- data/lib/morpheus/cli/commands/standard/rm_command.rb +14 -0
- data/lib/morpheus/cli/commands/standard/set_prompt_command.rb +54 -0
- data/lib/morpheus/cli/{sleep_command.rb → commands/standard/sleep_command.rb} +0 -0
- data/lib/morpheus/cli/{source_command.rb → commands/standard/source_command.rb} +0 -0
- data/lib/morpheus/cli/{ssl_verification_command.rb → commands/standard/ssl_verification_command.rb} +1 -1
- data/lib/morpheus/cli/commands/standard/tee_command.rb +14 -0
- data/lib/morpheus/cli/{version_command.rb → commands/standard/version_command.rb} +0 -0
- data/lib/morpheus/cli/credentials.rb +276 -87
- data/lib/morpheus/cli/cypher_command.rb +333 -214
- data/lib/morpheus/cli/error_handler.rb +12 -2
- data/lib/morpheus/cli/groups.rb +44 -20
- data/lib/morpheus/cli/hosts.rb +39 -16
- data/lib/morpheus/cli/instances.rb +114 -62
- data/lib/morpheus/cli/login.rb +74 -21
- data/lib/morpheus/cli/logout.rb +3 -4
- data/lib/morpheus/cli/mixins/accounts_helper.rb +50 -18
- data/lib/morpheus/cli/mixins/print_helper.rb +207 -42
- data/lib/morpheus/cli/old_cypher_command.rb +414 -0
- data/lib/morpheus/cli/option_parser.rb +6 -1
- data/lib/morpheus/cli/processes_command.rb +3 -0
- data/lib/morpheus/cli/remote.rb +11 -17
- data/lib/morpheus/cli/roles.rb +17 -17
- data/lib/morpheus/cli/security_groups.rb +47 -17
- data/lib/morpheus/cli/shell.rb +139 -79
- data/lib/morpheus/cli/tenants_command.rb +353 -0
- data/lib/morpheus/cli/users.rb +26 -18
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/whoami.rb +14 -10
- data/lib/morpheus/formatters.rb +4 -4
- data/lib/morpheus/logging.rb +16 -8
- data/lib/morpheus/terminal.rb +63 -34
- metadata +28 -15
- data/lib/morpheus/cli/coloring_command.rb +0 -45
- data/lib/morpheus/cli/set_prompt_command.rb +0 -51
|
@@ -35,6 +35,9 @@ class Morpheus::Cli::ErrorHandler
|
|
|
35
35
|
# @stderr.puts "#{red}#{err.message}#{reset}"
|
|
36
36
|
puts_angry_error err.message
|
|
37
37
|
do_print_stacktrace = false
|
|
38
|
+
if err.exit_code
|
|
39
|
+
exit_code = err.exit_code
|
|
40
|
+
end
|
|
38
41
|
# @stderr.puts "Try -h for help with this command."
|
|
39
42
|
when Morpheus::Cli::ExpressionParser::InvalidExpression
|
|
40
43
|
# @stderr.puts "#{red}#{err.message}#{reset}"
|
|
@@ -112,8 +115,15 @@ class Morpheus::Cli::ErrorHandler
|
|
|
112
115
|
return
|
|
113
116
|
end
|
|
114
117
|
if err.response.code == 400
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
begin
|
|
119
|
+
print_rest_errors(JSON.parse(err.response.to_s), options)
|
|
120
|
+
rescue TypeError, JSON::ParserError => ex
|
|
121
|
+
end
|
|
122
|
+
elsif err.response.code == 404
|
|
123
|
+
begin
|
|
124
|
+
print_rest_errors(JSON.parse(err.response.to_s), options)
|
|
125
|
+
rescue TypeError, JSON::ParserError => ex
|
|
126
|
+
end
|
|
117
127
|
else
|
|
118
128
|
@stderr.print red, "Error Communicating with the Appliance. #{e}", reset, "\n"
|
|
119
129
|
if options[:json] || options[:debug]
|
data/lib/morpheus/cli/groups.rb
CHANGED
|
@@ -36,22 +36,25 @@ class Morpheus::Cli::Groups
|
|
|
36
36
|
params = {}
|
|
37
37
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
38
38
|
opts.banner = subcommand_usage()
|
|
39
|
-
build_common_options(opts, options, [:list, :json, :remote])
|
|
40
|
-
opts.footer = "
|
|
39
|
+
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
40
|
+
opts.footer = "List groups (sites)."
|
|
41
41
|
end
|
|
42
42
|
optparse.parse!(args)
|
|
43
43
|
connect(options)
|
|
44
44
|
begin
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
params.merge!(parse_list_options(options))
|
|
46
|
+
@groups_interface.setopts(options)
|
|
47
|
+
if options[:dry_run]
|
|
48
|
+
print_dry_run @groups_interface.get(params)
|
|
49
|
+
return 0
|
|
47
50
|
end
|
|
48
51
|
json_response = @groups_interface.get(params)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return
|
|
53
|
-
end
|
|
52
|
+
render_result = render_with_format(json_response, options, 'groups')
|
|
53
|
+
return 0 if render_result
|
|
54
|
+
|
|
54
55
|
groups = json_response['groups']
|
|
56
|
+
subtitles = []
|
|
57
|
+
subtitles += parse_list_subtitles(options)
|
|
55
58
|
print_h1 "Morpheus Groups"
|
|
56
59
|
if groups.empty?
|
|
57
60
|
print yellow,"No groups currently configured.",reset,"\n"
|
|
@@ -81,8 +84,9 @@ class Morpheus::Cli::Groups
|
|
|
81
84
|
options = {}
|
|
82
85
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
83
86
|
opts.banner = subcommand_usage("[name]")
|
|
84
|
-
build_common_options(opts, options, [:json, :remote])
|
|
85
|
-
opts.footer = "
|
|
87
|
+
build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
88
|
+
opts.footer = "Get details about a group.\n" +
|
|
89
|
+
"[name] is required. This is the name or id of a group. Supports 1-N arguments."
|
|
86
90
|
end
|
|
87
91
|
optparse.parse!(args)
|
|
88
92
|
if args.count < 1
|
|
@@ -90,14 +94,31 @@ class Morpheus::Cli::Groups
|
|
|
90
94
|
exit 1
|
|
91
95
|
end
|
|
92
96
|
connect(options)
|
|
97
|
+
id_list = parse_id_list(args)
|
|
98
|
+
return run_command_for_each_arg(id_list) do |arg|
|
|
99
|
+
_get(arg, options)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def _get(arg, options={})
|
|
93
104
|
begin
|
|
94
|
-
|
|
105
|
+
if options[:dry_run]
|
|
106
|
+
@groups_interface.setopts(options)
|
|
107
|
+
if arg.to_s =~ /\A\d{1,}\Z/
|
|
108
|
+
print_dry_run @groups_interface.dry.get(arg.to_i)
|
|
109
|
+
else
|
|
110
|
+
print_dry_run @groups_interface.dry.get({name:arg})
|
|
111
|
+
end
|
|
112
|
+
return 0
|
|
113
|
+
end
|
|
114
|
+
group = find_group_by_name_or_id(arg)
|
|
115
|
+
@groups_interface.setopts(options)
|
|
95
116
|
#json_response = @groups_interface.get(group['id'])
|
|
96
117
|
json_response = {'group' => group}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
118
|
+
|
|
119
|
+
render_result = render_with_format(json_response, options)
|
|
120
|
+
return 0 if render_result
|
|
121
|
+
|
|
101
122
|
group = json_response['group']
|
|
102
123
|
is_active = @active_group_id && (@active_group_id == group['id'])
|
|
103
124
|
print_h1 "Group Details"
|
|
@@ -169,7 +190,7 @@ class Morpheus::Cli::Groups
|
|
|
169
190
|
params = Morpheus::Cli::OptionTypes.prompt(all_option_types, options[:options], @api_client, {})
|
|
170
191
|
group_payload.merge!(params)
|
|
171
192
|
payload = {group: group_payload}
|
|
172
|
-
|
|
193
|
+
@groups_interface.setopts(options)
|
|
173
194
|
if options[:dry_run]
|
|
174
195
|
print_dry_run @groups_interface.dry.create(payload)
|
|
175
196
|
return
|
|
@@ -212,7 +233,7 @@ class Morpheus::Cli::Groups
|
|
|
212
233
|
connect(options)
|
|
213
234
|
begin
|
|
214
235
|
group = find_group_by_name_or_id(args[0])
|
|
215
|
-
group_payload = {
|
|
236
|
+
group_payload = {}
|
|
216
237
|
|
|
217
238
|
#params = Morpheus::Cli::OptionTypes.prompt(update_group_option_types, options[:options], @api_client, {})
|
|
218
239
|
params = options[:options] || {}
|
|
@@ -225,7 +246,7 @@ class Morpheus::Cli::Groups
|
|
|
225
246
|
group_payload.merge!(params)
|
|
226
247
|
|
|
227
248
|
payload = {group: group_payload}
|
|
228
|
-
|
|
249
|
+
@groups_interface.setopts(options)
|
|
229
250
|
if options[:dry_run]
|
|
230
251
|
print_dry_run @groups_interface.dry.update(group['id'], payload)
|
|
231
252
|
return
|
|
@@ -268,6 +289,7 @@ class Morpheus::Cli::Groups
|
|
|
268
289
|
end
|
|
269
290
|
new_zones = current_zones + [{'id' => cloud['id']}]
|
|
270
291
|
payload = {group: {id: group["id"], zones: new_zones}}
|
|
292
|
+
@groups_interface.setopts(options)
|
|
271
293
|
if options[:dry_run]
|
|
272
294
|
print_dry_run @groups_interface.dry.update_zones(group["id"], payload)
|
|
273
295
|
return
|
|
@@ -311,6 +333,7 @@ class Morpheus::Cli::Groups
|
|
|
311
333
|
end
|
|
312
334
|
new_zones = current_zones.reject {|it| it["id"] == cloud["id"] }
|
|
313
335
|
payload = {group: {id: group["id"], zones: new_zones}}
|
|
336
|
+
@groups_interface.setopts(options)
|
|
314
337
|
if options[:dry_run]
|
|
315
338
|
print_dry_run @groups_interface.dry.update_zones(group["id"], payload)
|
|
316
339
|
return
|
|
@@ -350,6 +373,7 @@ class Morpheus::Cli::Groups
|
|
|
350
373
|
unless options[:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the group #{group['name']}?")
|
|
351
374
|
exit
|
|
352
375
|
end
|
|
376
|
+
@groups_interface.setopts(options)
|
|
353
377
|
if options[:dry_run]
|
|
354
378
|
print_dry_run @groups_interface.dry.destroy(group['id'])
|
|
355
379
|
return
|
|
@@ -439,7 +463,7 @@ class Morpheus::Cli::Groups
|
|
|
439
463
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
440
464
|
opts.banner = subcommand_usage()
|
|
441
465
|
build_common_options(opts, options, [])
|
|
442
|
-
opts.footer = "
|
|
466
|
+
opts.footer = "Print the name of the current active group"
|
|
443
467
|
end
|
|
444
468
|
optparse.parse!(args)
|
|
445
469
|
connect(options)
|
data/lib/morpheus/cli/hosts.rb
CHANGED
|
@@ -12,6 +12,8 @@ class Morpheus::Cli::Hosts
|
|
|
12
12
|
include Morpheus::Cli::CliCommand
|
|
13
13
|
include Morpheus::Cli::AccountsHelper
|
|
14
14
|
include Morpheus::Cli::ProvisioningHelper
|
|
15
|
+
set_command_name :hosts
|
|
16
|
+
set_command_description "View and manage hosts (servers)."
|
|
15
17
|
register_subcommands :list, :count, :get, :stats, :add, :update, :remove, :logs, :start, :stop, :resize, :run_workflow, {:'make-managed' => :install_agent}, :upgrade_agent, :server_types
|
|
16
18
|
register_subcommands :exec => :execution_request
|
|
17
19
|
alias_subcommand :details, :get
|
|
@@ -23,6 +25,8 @@ class Morpheus::Cli::Hosts
|
|
|
23
25
|
|
|
24
26
|
def connect(opts)
|
|
25
27
|
@api_client = establish_remote_appliance_connection(opts)
|
|
28
|
+
@accounts_interface = @api_client.accounts
|
|
29
|
+
@users_interface = @api_client.users
|
|
26
30
|
@clouds_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).clouds
|
|
27
31
|
@options_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).options
|
|
28
32
|
@tasks_interface = Morpheus::APIClient.new(@access_token,nil,nil, @appliance_url).tasks
|
|
@@ -89,12 +93,16 @@ class Morpheus::Cli::Hosts
|
|
|
89
93
|
opts.on( '', '--noagent', "Show only Servers with No agent" ) do |val|
|
|
90
94
|
params[:agentInstalled] = false
|
|
91
95
|
end
|
|
96
|
+
opts.on( '--created-by USER', "Created By User Username or ID" ) do |val|
|
|
97
|
+
options[:created_by] = val
|
|
98
|
+
end
|
|
92
99
|
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
93
100
|
opts.footer = "List hosts."
|
|
94
101
|
end
|
|
95
102
|
optparse.parse!(args)
|
|
96
103
|
connect(options)
|
|
97
104
|
begin
|
|
105
|
+
params.merge!(parse_list_options(options))
|
|
98
106
|
account = nil
|
|
99
107
|
if options[:account]
|
|
100
108
|
account = find_account_by_name_or_id(options[:account])
|
|
@@ -116,8 +124,13 @@ class Morpheus::Cli::Hosts
|
|
|
116
124
|
params['zoneId'] = cloud['id']
|
|
117
125
|
end
|
|
118
126
|
|
|
119
|
-
|
|
127
|
+
if options[:created_by]
|
|
128
|
+
created_by_ids = find_all_user_ids(account ? account['id'] : nil, options[:created_by])
|
|
129
|
+
return if created_by_ids.nil?
|
|
130
|
+
params['createdBy'] = created_by_ids
|
|
131
|
+
end
|
|
120
132
|
|
|
133
|
+
@servers_interface.setopts(options)
|
|
121
134
|
if options[:dry_run]
|
|
122
135
|
print_dry_run @servers_interface.dry.list(params)
|
|
123
136
|
return
|
|
@@ -154,7 +167,7 @@ class Morpheus::Cli::Hosts
|
|
|
154
167
|
subtitles << "Cloud: #{cloud['name']}".strip
|
|
155
168
|
end
|
|
156
169
|
subtitles += parse_list_subtitles(options)
|
|
157
|
-
print_h1 title, subtitles
|
|
170
|
+
print_h1 title, subtitles, options
|
|
158
171
|
if servers.empty?
|
|
159
172
|
print yellow,"No hosts found.",reset,"\n"
|
|
160
173
|
else
|
|
@@ -233,6 +246,7 @@ class Morpheus::Cli::Hosts
|
|
|
233
246
|
begin
|
|
234
247
|
params = {}
|
|
235
248
|
params.merge!(parse_list_options(options))
|
|
249
|
+
@servers_interface.setopts(options)
|
|
236
250
|
if options[:dry_run]
|
|
237
251
|
print_dry_run @servers_interface.dry.list(params)
|
|
238
252
|
return
|
|
@@ -281,14 +295,14 @@ class Morpheus::Cli::Hosts
|
|
|
281
295
|
begin
|
|
282
296
|
if options[:dry_run]
|
|
283
297
|
if arg.to_s =~ /\A\d{1,}\Z/
|
|
284
|
-
print_dry_run @servers_interface.
|
|
298
|
+
print_dry_run @servers_interface.setopts(options).get(arg.to_i)
|
|
285
299
|
else
|
|
286
|
-
print_dry_run @servers_interface.
|
|
300
|
+
print_dry_run @servers_interface.setopts(options).list({name: arg})
|
|
287
301
|
end
|
|
288
302
|
return
|
|
289
303
|
end
|
|
290
304
|
server = find_host_by_name_or_id(arg)
|
|
291
|
-
json_response = @servers_interface.get(server['id'])
|
|
305
|
+
json_response = @servers_interface.setopts(options).get(server['id'])
|
|
292
306
|
if options[:json]
|
|
293
307
|
json_response.delete('stats') if options[:include_fields]
|
|
294
308
|
puts as_json(json_response, options, "server")
|
|
@@ -306,7 +320,7 @@ class Morpheus::Cli::Hosts
|
|
|
306
320
|
#stats = server['stats'] || json_response['stats'] || {}
|
|
307
321
|
stats = json_response['stats'] || {}
|
|
308
322
|
title = "Host Details"
|
|
309
|
-
print_h1 title
|
|
323
|
+
print_h1 title, [], options
|
|
310
324
|
print cyan
|
|
311
325
|
print_description_list({
|
|
312
326
|
"ID" => 'id',
|
|
@@ -324,7 +338,7 @@ class Morpheus::Cli::Hosts
|
|
|
324
338
|
"Power" => lambda {|it| format_server_power_state(it) },
|
|
325
339
|
}, server)
|
|
326
340
|
|
|
327
|
-
print_h2 "Host Usage"
|
|
341
|
+
print_h2 "Host Usage", options
|
|
328
342
|
print_stats_usage(stats)
|
|
329
343
|
print reset, "\n"
|
|
330
344
|
|
|
@@ -372,14 +386,14 @@ class Morpheus::Cli::Hosts
|
|
|
372
386
|
begin
|
|
373
387
|
if options[:dry_run]
|
|
374
388
|
if arg.to_s =~ /\A\d{1,}\Z/
|
|
375
|
-
print_dry_run @servers_interface.
|
|
389
|
+
print_dry_run @servers_interface.setopts(options).get(arg.to_i)
|
|
376
390
|
else
|
|
377
|
-
print_dry_run @servers_interface.
|
|
391
|
+
print_dry_run @servers_interface.setopts(options).list({name: arg})
|
|
378
392
|
end
|
|
379
393
|
return
|
|
380
394
|
end
|
|
381
395
|
server = find_host_by_name_or_id(arg)
|
|
382
|
-
json_response = @servers_interface.get(server['id'])
|
|
396
|
+
json_response = @servers_interface.setopts(options).get(server['id'])
|
|
383
397
|
if options[:json]
|
|
384
398
|
puts as_json(json_response, options, "stats")
|
|
385
399
|
return 0
|
|
@@ -394,11 +408,11 @@ class Morpheus::Cli::Hosts
|
|
|
394
408
|
#stats = server['stats'] || json_response['stats'] || {}
|
|
395
409
|
stats = json_response['stats'] || {}
|
|
396
410
|
title = "Host Stats: #{server['name']} (#{server['computeServerType'] ? server['computeServerType']['name'] : 'unmanaged'})"
|
|
397
|
-
print_h1 title
|
|
411
|
+
print_h1 title, [], options
|
|
398
412
|
puts cyan + "Power: ".rjust(12) + format_server_power_state(server).to_s
|
|
399
413
|
puts cyan + "Status: ".rjust(12) + format_host_status(server).to_s
|
|
400
414
|
puts cyan + "Nodes: ".rjust(12) + (server['containers'] ? server['containers'].size : '').to_s
|
|
401
|
-
#print_h2 "Host Usage"
|
|
415
|
+
#print_h2 "Host Usage", options
|
|
402
416
|
print_stats_usage(stats, {label_width: 10})
|
|
403
417
|
|
|
404
418
|
print reset, "\n"
|
|
@@ -428,6 +442,7 @@ class Morpheus::Cli::Hosts
|
|
|
428
442
|
params[k] = options[k] unless options[k].nil?
|
|
429
443
|
end
|
|
430
444
|
params[:query] = params.delete(:phrase) unless params[:phrase].nil?
|
|
445
|
+
@logs_interface.setopts(options)
|
|
431
446
|
if options[:dry_run]
|
|
432
447
|
print_dry_run @logs_interface.dry.server_logs([server['id']], params)
|
|
433
448
|
return
|
|
@@ -443,7 +458,7 @@ class Morpheus::Cli::Hosts
|
|
|
443
458
|
subtitles << "Search: #{params[:query]}".strip
|
|
444
459
|
end
|
|
445
460
|
# todo: startMs, endMs, sorts insteaad of sort..etc
|
|
446
|
-
print_h1 title, subtitles
|
|
461
|
+
print_h1 title, subtitles, options
|
|
447
462
|
if logs['data'].empty?
|
|
448
463
|
output << "#{cyan}No logs found.#{reset}\n"
|
|
449
464
|
else
|
|
@@ -495,7 +510,7 @@ class Morpheus::Cli::Hosts
|
|
|
495
510
|
print JSON.pretty_generate(cloud_server_types)
|
|
496
511
|
print "\n"
|
|
497
512
|
else
|
|
498
|
-
print_h1 "Morpheus Server Types - Cloud: #{zone['name']}"
|
|
513
|
+
print_h1 "Morpheus Server Types - Cloud: #{zone['name']}", [], options
|
|
499
514
|
if cloud_server_types.nil? || cloud_server_types.empty?
|
|
500
515
|
print yellow,"No server types found for the selected cloud",reset,"\n"
|
|
501
516
|
else
|
|
@@ -660,6 +675,7 @@ class Morpheus::Cli::Hosts
|
|
|
660
675
|
payload.deep_merge!(params)
|
|
661
676
|
|
|
662
677
|
end
|
|
678
|
+
@servers_interface.setopts(options)
|
|
663
679
|
if options[:dry_run]
|
|
664
680
|
print_dry_run @servers_interface.dry.create(payload)
|
|
665
681
|
return
|
|
@@ -733,6 +749,7 @@ class Morpheus::Cli::Hosts
|
|
|
733
749
|
payload['server'] = params
|
|
734
750
|
end
|
|
735
751
|
|
|
752
|
+
@servers_interface.setopts(options)
|
|
736
753
|
if options[:dry_run]
|
|
737
754
|
print_dry_run @servers_interface.dry.update(server["id"], payload)
|
|
738
755
|
return
|
|
@@ -789,6 +806,7 @@ class Morpheus::Cli::Hosts
|
|
|
789
806
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to remove the server '#{server['name']}'?", options)
|
|
790
807
|
exit 1
|
|
791
808
|
end
|
|
809
|
+
@servers_interface.setopts(options)
|
|
792
810
|
if options[:dry_run]
|
|
793
811
|
print_dry_run @servers_interface.dry.destroy(server['id'], query_params)
|
|
794
812
|
return
|
|
@@ -833,6 +851,7 @@ class Morpheus::Cli::Hosts
|
|
|
833
851
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to start #{objects_label}?", options)
|
|
834
852
|
return 9, "aborted command"
|
|
835
853
|
end
|
|
854
|
+
@servers_interface.setopts(options)
|
|
836
855
|
if options[:dry_run]
|
|
837
856
|
print_dry_run @servers_interface.dry.start(hosts.collect {|it| it['id'] })
|
|
838
857
|
return
|
|
@@ -877,6 +896,7 @@ class Morpheus::Cli::Hosts
|
|
|
877
896
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to stop #{objects_label}?", options)
|
|
878
897
|
return 9, "aborted command"
|
|
879
898
|
end
|
|
899
|
+
@servers_interface.setopts(options)
|
|
880
900
|
if options[:dry_run]
|
|
881
901
|
print_dry_run @servers_interface.dry.stop(hosts.collect {|it| it['id'] })
|
|
882
902
|
return
|
|
@@ -968,7 +988,7 @@ class Morpheus::Cli::Hosts
|
|
|
968
988
|
# only amazon supports this option
|
|
969
989
|
# for now, always do this
|
|
970
990
|
payload[:deleteOriginalVolumes] = true
|
|
971
|
-
|
|
991
|
+
@servers_interface.setopts(options)
|
|
972
992
|
if options[:dry_run]
|
|
973
993
|
print_dry_run @servers_interface.dry.resize(server['id'], payload)
|
|
974
994
|
return
|
|
@@ -1021,7 +1041,7 @@ class Morpheus::Cli::Hosts
|
|
|
1021
1041
|
payload['server']['account'] = {id: account}
|
|
1022
1042
|
end
|
|
1023
1043
|
payload['server'].merge!(params)
|
|
1024
|
-
|
|
1044
|
+
@servers_interface.setopts(options)
|
|
1025
1045
|
if options[:dry_run]
|
|
1026
1046
|
print_dry_run @servers_interface.dry.install_agent(host['id'], payload)
|
|
1027
1047
|
return
|
|
@@ -1055,6 +1075,7 @@ class Morpheus::Cli::Hosts
|
|
|
1055
1075
|
connect(options)
|
|
1056
1076
|
begin
|
|
1057
1077
|
host = find_host_by_name_or_id(args[0])
|
|
1078
|
+
@servers_interface.setopts(options)
|
|
1058
1079
|
if options[:dry_run]
|
|
1059
1080
|
print_dry_run @servers_interface.dry.upgrade(host['id'])
|
|
1060
1081
|
return
|
|
@@ -1134,6 +1155,7 @@ class Morpheus::Cli::Hosts
|
|
|
1134
1155
|
end
|
|
1135
1156
|
|
|
1136
1157
|
begin
|
|
1158
|
+
@servers_interface.setopts(options)
|
|
1137
1159
|
if options[:dry_run]
|
|
1138
1160
|
print_dry_run @servers_interface.dry.workflow(host['id'],workflow['id'], payload)
|
|
1139
1161
|
return
|
|
@@ -1209,6 +1231,7 @@ class Morpheus::Cli::Hosts
|
|
|
1209
1231
|
payload['script'] = script_content
|
|
1210
1232
|
end
|
|
1211
1233
|
# dry run?
|
|
1234
|
+
@servers_interface.setopts(options)
|
|
1212
1235
|
if options[:dry_run]
|
|
1213
1236
|
print_dry_run @execution_request_interface.dry.create(params, payload)
|
|
1214
1237
|
return 0
|
|
@@ -4,15 +4,18 @@ require 'optparse'
|
|
|
4
4
|
require 'filesize'
|
|
5
5
|
require 'table_print'
|
|
6
6
|
require 'morpheus/cli/cli_command'
|
|
7
|
+
require 'morpheus/cli/mixins/accounts_helper'
|
|
7
8
|
require 'morpheus/cli/mixins/provisioning_helper'
|
|
8
9
|
require 'morpheus/cli/mixins/processes_helper'
|
|
9
10
|
require 'morpheus/cli/option_types'
|
|
10
11
|
|
|
11
12
|
class Morpheus::Cli::Instances
|
|
12
13
|
include Morpheus::Cli::CliCommand
|
|
14
|
+
include Morpheus::Cli::AccountsHelper
|
|
13
15
|
include Morpheus::Cli::ProvisioningHelper
|
|
14
16
|
include Morpheus::Cli::ProcessesHelper
|
|
15
|
-
|
|
17
|
+
set_command_name :instances
|
|
18
|
+
set_command_description "View and manage instances."
|
|
16
19
|
register_subcommands :list, :count, :get, :add, :update, :update_notes, :remove, :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, :firewall_enable, :firewall_disable, :run_workflow, :import_snapshot, :console, :status_check, {:containers => :list_containers}, :scaling, {:'scaling-update' => :scaling_update}
|
|
17
20
|
register_subcommands :exec => :execution_request
|
|
18
21
|
# register_subcommands {:'lb-update' => :load_balancer_update}
|
|
@@ -25,6 +28,8 @@ class Morpheus::Cli::Instances
|
|
|
25
28
|
|
|
26
29
|
def connect(opts)
|
|
27
30
|
@api_client = establish_remote_appliance_connection(opts)
|
|
31
|
+
@accounts_interface = @api_client.accounts
|
|
32
|
+
@users_interface = @api_client.users
|
|
28
33
|
@instances_interface = @api_client.instances
|
|
29
34
|
@task_sets_interface = @api_client.task_sets
|
|
30
35
|
@logs_interface = @api_client.logs
|
|
@@ -55,6 +60,9 @@ class Morpheus::Cli::Instances
|
|
|
55
60
|
opts.on( '-H', '--host HOST', "Host Name or ID" ) do |val|
|
|
56
61
|
options[:host] = val
|
|
57
62
|
end
|
|
63
|
+
opts.on( '--created-by USER', "Created By User Username or ID" ) do |val|
|
|
64
|
+
options[:created_by] = val
|
|
65
|
+
end
|
|
58
66
|
build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
59
67
|
opts.footer = "List instances."
|
|
60
68
|
end
|
|
@@ -62,6 +70,7 @@ class Morpheus::Cli::Instances
|
|
|
62
70
|
connect(options)
|
|
63
71
|
begin
|
|
64
72
|
params = {}
|
|
73
|
+
params.merge!(parse_list_options(options))
|
|
65
74
|
group = options[:group] ? find_group_by_name_or_id_for_provisioning(options[:group]) : nil
|
|
66
75
|
if group
|
|
67
76
|
params['siteId'] = group['id']
|
|
@@ -79,11 +88,17 @@ class Morpheus::Cli::Instances
|
|
|
79
88
|
params['serverId'] = host['id']
|
|
80
89
|
end
|
|
81
90
|
|
|
82
|
-
|
|
91
|
+
account = nil
|
|
92
|
+
if options[:created_by]
|
|
93
|
+
created_by_ids = find_all_user_ids(account ? account['id'] : nil, options[:created_by])
|
|
94
|
+
return if created_by_ids.nil?
|
|
95
|
+
params['createdBy'] = created_by_ids
|
|
96
|
+
end
|
|
83
97
|
|
|
98
|
+
@instances_interface.setopts(options)
|
|
84
99
|
if options[:dry_run]
|
|
85
100
|
print_dry_run @instances_interface.dry.list(params)
|
|
86
|
-
return
|
|
101
|
+
return 0
|
|
87
102
|
end
|
|
88
103
|
json_response = @instances_interface.list(params)
|
|
89
104
|
if options[:json]
|
|
@@ -117,8 +132,11 @@ class Morpheus::Cli::Instances
|
|
|
117
132
|
if host
|
|
118
133
|
subtitles << "Host: #{host['name']}".strip
|
|
119
134
|
end
|
|
135
|
+
if options[:created_by]
|
|
136
|
+
subtitles << "Created By: #{options[:created_by]}"
|
|
137
|
+
end
|
|
120
138
|
subtitles += parse_list_subtitles(options)
|
|
121
|
-
print_h1 title, subtitles
|
|
139
|
+
print_h1 title, subtitles, options
|
|
122
140
|
if instances.empty?
|
|
123
141
|
print yellow,"No instances found.",reset,"\n"
|
|
124
142
|
else
|
|
@@ -191,6 +209,7 @@ class Morpheus::Cli::Instances
|
|
|
191
209
|
begin
|
|
192
210
|
params = {}
|
|
193
211
|
params.merge!(parse_list_options(options))
|
|
212
|
+
@instances_interface.setopts(options)
|
|
194
213
|
if options[:dry_run]
|
|
195
214
|
print_dry_run @instances_interface.dry.list(params)
|
|
196
215
|
return
|
|
@@ -331,7 +350,7 @@ class Morpheus::Cli::Instances
|
|
|
331
350
|
lb_payload = prompt_instance_load_balancer(payload['instance'], nil, options)
|
|
332
351
|
payload.deep_merge!(lb_payload)
|
|
333
352
|
end
|
|
334
|
-
|
|
353
|
+
@instances_interface.setopts(options)
|
|
335
354
|
if options[:dry_run]
|
|
336
355
|
print_dry_run @instances_interface.dry.create(payload)
|
|
337
356
|
return 0
|
|
@@ -443,7 +462,7 @@ class Morpheus::Cli::Instances
|
|
|
443
462
|
payload = {}
|
|
444
463
|
payload['instance'] = params
|
|
445
464
|
end
|
|
446
|
-
|
|
465
|
+
@instances_interface.setopts(options)
|
|
447
466
|
if options[:dry_run]
|
|
448
467
|
print_dry_run @instances_interface.dry.update(instance["id"], payload)
|
|
449
468
|
return
|
|
@@ -519,7 +538,7 @@ class Morpheus::Cli::Instances
|
|
|
519
538
|
payload = {}
|
|
520
539
|
payload['instance'] = params
|
|
521
540
|
end
|
|
522
|
-
|
|
541
|
+
@instances_interface.setopts(options)
|
|
523
542
|
if options[:dry_run]
|
|
524
543
|
print_dry_run @instances_interface.dry.update_notes(instance["id"], payload)
|
|
525
544
|
return
|
|
@@ -595,6 +614,7 @@ class Morpheus::Cli::Instances
|
|
|
595
614
|
def _stats(arg, options)
|
|
596
615
|
begin
|
|
597
616
|
instance = find_instance_by_name_or_id(arg)
|
|
617
|
+
@instances_interface.setopts(options)
|
|
598
618
|
if options[:dry_run]
|
|
599
619
|
print_dry_run @instances_interface.dry.get(instance['id'])
|
|
600
620
|
return 0
|
|
@@ -610,11 +630,11 @@ class Morpheus::Cli::Instances
|
|
|
610
630
|
instance = json_response['instance']
|
|
611
631
|
stats = instance['stats'] || json_response['stats'] || {}
|
|
612
632
|
title = "Instance Stats: #{instance['name']} (#{instance['instanceType']['name']})"
|
|
613
|
-
print_h1 title
|
|
633
|
+
print_h1 title, [], options
|
|
614
634
|
puts cyan + "Status: ".rjust(12) + format_instance_status(instance).to_s
|
|
615
635
|
puts cyan + "Nodes: ".rjust(12) + (instance['containers'] ? instance['containers'].count : '').to_s
|
|
616
636
|
# print "\n"
|
|
617
|
-
#print_h2 "Instance Usage"
|
|
637
|
+
#print_h2 "Instance Usage", options
|
|
618
638
|
print_stats_usage(stats)
|
|
619
639
|
print reset, "\n"
|
|
620
640
|
rescue RestClient::Exception => e
|
|
@@ -684,6 +704,7 @@ class Morpheus::Cli::Instances
|
|
|
684
704
|
params = {}
|
|
685
705
|
params.merge!(parse_list_options(options))
|
|
686
706
|
params[:query] = params.delete(:phrase) unless params[:phrase].nil?
|
|
707
|
+
@logs_interface.setopts(options)
|
|
687
708
|
if options[:dry_run]
|
|
688
709
|
print_dry_run @logs_interface.dry.container_logs(container_ids, params)
|
|
689
710
|
return
|
|
@@ -700,7 +721,7 @@ class Morpheus::Cli::Instances
|
|
|
700
721
|
subtitles << "Search: #{params[:query]}".strip
|
|
701
722
|
end
|
|
702
723
|
# todo: startMs, endMs, sorts insteaad of sort..etc
|
|
703
|
-
print_h1 title, subtitles
|
|
724
|
+
print_h1 title, subtitles, options
|
|
704
725
|
if logs['data'].empty?
|
|
705
726
|
puts "#{cyan}No logs found.#{reset}"
|
|
706
727
|
else
|
|
@@ -761,7 +782,7 @@ class Morpheus::Cli::Instances
|
|
|
761
782
|
# opts.on( nil, '--lb', "Display Load Balancer Details" ) do
|
|
762
783
|
# options[:include_lb] = true
|
|
763
784
|
# end
|
|
764
|
-
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
785
|
+
build_common_options(opts, options, [:query, :json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
765
786
|
opts.footer = "Get details about an instance.\n" +
|
|
766
787
|
"[instance] is required. This is the name or id of an instance. Supports 1-N [instance] arguments."
|
|
767
788
|
end
|
|
@@ -780,6 +801,7 @@ class Morpheus::Cli::Instances
|
|
|
780
801
|
def _get(arg, options={})
|
|
781
802
|
begin
|
|
782
803
|
if options[:dry_run]
|
|
804
|
+
@instances_interface.setopts(options)
|
|
783
805
|
if arg.to_s =~ /\A\d{1,}\Z/
|
|
784
806
|
print_dry_run @instances_interface.dry.get(arg.to_i)
|
|
785
807
|
else
|
|
@@ -788,7 +810,11 @@ class Morpheus::Cli::Instances
|
|
|
788
810
|
return
|
|
789
811
|
end
|
|
790
812
|
instance = find_instance_by_name_or_id(arg)
|
|
813
|
+
@instances_interface.setopts(options)
|
|
791
814
|
json_response = @instances_interface.get(instance['id'])
|
|
815
|
+
if options[:quiet]
|
|
816
|
+
return 0
|
|
817
|
+
end
|
|
792
818
|
if options[:json]
|
|
793
819
|
puts as_json(json_response, options, "instance")
|
|
794
820
|
return 0
|
|
@@ -830,7 +856,7 @@ class Morpheus::Cli::Instances
|
|
|
830
856
|
#current_load_balancer = current_instance_lb['loadBalancer']
|
|
831
857
|
end
|
|
832
858
|
|
|
833
|
-
print_h1 "Instance Details"
|
|
859
|
+
print_h1 "Instance Details", [], options
|
|
834
860
|
print cyan
|
|
835
861
|
description_cols = {
|
|
836
862
|
"ID" => 'id',
|
|
@@ -856,7 +882,7 @@ class Morpheus::Cli::Instances
|
|
|
856
882
|
print_description_list(description_cols, instance)
|
|
857
883
|
|
|
858
884
|
if instance['statusMessage']
|
|
859
|
-
print_h2 "Status Message"
|
|
885
|
+
print_h2 "Status Message", options
|
|
860
886
|
if instance['status'] == 'failed'
|
|
861
887
|
print red, instance['statusMessage'], reset
|
|
862
888
|
else
|
|
@@ -865,22 +891,22 @@ class Morpheus::Cli::Instances
|
|
|
865
891
|
print "\n"
|
|
866
892
|
end
|
|
867
893
|
if instance['errorMessage']
|
|
868
|
-
print_h2 "Error Message"
|
|
894
|
+
print_h2 "Error Message", options
|
|
869
895
|
print red, instance['errorMessage'], reset, "\n"
|
|
870
896
|
end
|
|
871
897
|
if !instance['notes'].to_s.empty?
|
|
872
|
-
print_h2 "Instance Notes"
|
|
898
|
+
print_h2 "Instance Notes", options
|
|
873
899
|
print cyan, instance['notes'], reset, "\n"
|
|
874
900
|
end
|
|
875
901
|
if stats
|
|
876
|
-
print_h2 "Instance Usage"
|
|
902
|
+
print_h2 "Instance Usage", options
|
|
877
903
|
print_stats_usage(stats)
|
|
878
904
|
end
|
|
879
905
|
print reset, "\n"
|
|
880
906
|
|
|
881
907
|
# if options[:include_lb]
|
|
882
908
|
if current_instance_lb
|
|
883
|
-
print_h2 "Load Balancer"
|
|
909
|
+
print_h2 "Load Balancer", options
|
|
884
910
|
print cyan
|
|
885
911
|
description_cols = {
|
|
886
912
|
"LB ID" => lambda {|it| it['loadBalancer']['id'] },
|
|
@@ -900,7 +926,7 @@ class Morpheus::Cli::Instances
|
|
|
900
926
|
# end
|
|
901
927
|
|
|
902
928
|
if options[:include_containers]
|
|
903
|
-
print_h2 "Instance Containers"
|
|
929
|
+
print_h2 "Instance Containers", options
|
|
904
930
|
|
|
905
931
|
if containers.empty?
|
|
906
932
|
print yellow,"No containers found for instance.",reset,"\n"
|
|
@@ -942,7 +968,7 @@ class Morpheus::Cli::Instances
|
|
|
942
968
|
end
|
|
943
969
|
|
|
944
970
|
if options[:include_scaling]
|
|
945
|
-
print_h2 "Instance Scaling"
|
|
971
|
+
print_h2 "Instance Scaling", options
|
|
946
972
|
if instance_threshold.nil? || instance_threshold.empty?
|
|
947
973
|
print yellow,"No scaling settings applied to this instance.",reset,"\n"
|
|
948
974
|
else
|
|
@@ -995,6 +1021,7 @@ class Morpheus::Cli::Instances
|
|
|
995
1021
|
begin
|
|
996
1022
|
instance = find_instance_by_name_or_id(arg)
|
|
997
1023
|
return 1 if instance.nil?
|
|
1024
|
+
@instances_interface.setopts(options)
|
|
998
1025
|
if options[:dry_run]
|
|
999
1026
|
print_dry_run @instances_interface.dry.containers(instance['id'], params)
|
|
1000
1027
|
return
|
|
@@ -1017,7 +1044,7 @@ class Morpheus::Cli::Instances
|
|
|
1017
1044
|
containers = json_response['containers']
|
|
1018
1045
|
containers = containers.sort { |x,y| x['id'] <=> y['id'] }
|
|
1019
1046
|
title = "Instance Containers: #{instance['name']} (#{instance['instanceType']['name']})"
|
|
1020
|
-
print_h1 title
|
|
1047
|
+
print_h1 title, [], options
|
|
1021
1048
|
if containers.empty?
|
|
1022
1049
|
print yellow,"No containers found for instance.",reset,"\n"
|
|
1023
1050
|
else
|
|
@@ -1077,6 +1104,7 @@ class Morpheus::Cli::Instances
|
|
|
1077
1104
|
begin
|
|
1078
1105
|
instance = find_instance_by_name_or_id(args[0])
|
|
1079
1106
|
params = {}
|
|
1107
|
+
@instances_interface.setopts(options)
|
|
1080
1108
|
if options[:dry_run]
|
|
1081
1109
|
print_dry_run @instances_interface.dry.backups(instance['id'], params)
|
|
1082
1110
|
return
|
|
@@ -1089,7 +1117,7 @@ class Morpheus::Cli::Instances
|
|
|
1089
1117
|
|
|
1090
1118
|
if json_response['backups'] && json_response['backups'][0] && json_response['backups'][0]['backupResults']
|
|
1091
1119
|
# new format
|
|
1092
|
-
print_h1 "Instance Backups: #{instance['name']} (#{instance['instanceType']['name']})"
|
|
1120
|
+
print_h1 "Instance Backups: #{instance['name']} (#{instance['instanceType']['name']})", [], options
|
|
1093
1121
|
|
|
1094
1122
|
|
|
1095
1123
|
backup = json_response['backups'][0]
|
|
@@ -1117,7 +1145,7 @@ class Morpheus::Cli::Instances
|
|
|
1117
1145
|
{id: it['id'], startDate: format_local_dt(it['dateCreated']), duration: format_duration_milliseconds(it['durationMillis']),
|
|
1118
1146
|
size: format_bytes(it['sizeInMb'], 'MB'), status: status_str }
|
|
1119
1147
|
}
|
|
1120
|
-
print_h1 "Backup Results"
|
|
1148
|
+
print_h1 "Backup Results", [], options
|
|
1121
1149
|
print cyan
|
|
1122
1150
|
puts as_pretty_table backup_rows, [
|
|
1123
1151
|
:id,
|
|
@@ -1129,11 +1157,11 @@ class Morpheus::Cli::Instances
|
|
|
1129
1157
|
print reset, "\n"
|
|
1130
1158
|
elsif json_response['backups'].size == 0
|
|
1131
1159
|
# no backup configured
|
|
1132
|
-
print_h1 "Instance Backups: #{instance['name']} (#{instance['instanceType']['name']})"
|
|
1160
|
+
print_h1 "Instance Backups: #{instance['name']} (#{instance['instanceType']['name']})", [], options
|
|
1133
1161
|
print "#{yellow}No backups configured#{reset}\n\n"
|
|
1134
1162
|
else
|
|
1135
1163
|
# old format
|
|
1136
|
-
print_h1 "Instance Backups: #{instance['name']} (#{instance['instanceType']['name']})"
|
|
1164
|
+
print_h1 "Instance Backups: #{instance['name']} (#{instance['instanceType']['name']})", [], options
|
|
1137
1165
|
backups = json_response['backups']
|
|
1138
1166
|
backup_rows = backups.collect {|r|
|
|
1139
1167
|
it = r['backup']
|
|
@@ -1202,7 +1230,7 @@ class Morpheus::Cli::Instances
|
|
|
1202
1230
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to clone the instance '#{instance['name']}'?", options)
|
|
1203
1231
|
exit 1
|
|
1204
1232
|
end
|
|
1205
|
-
|
|
1233
|
+
@instances_interface.setopts(options)
|
|
1206
1234
|
if options[:dry_run]
|
|
1207
1235
|
print_dry_run @instances_interface.dry.clone(instance['id'], payload)
|
|
1208
1236
|
return
|
|
@@ -1235,6 +1263,7 @@ class Morpheus::Cli::Instances
|
|
|
1235
1263
|
connect(options)
|
|
1236
1264
|
begin
|
|
1237
1265
|
instance = find_instance_by_name_or_id(args[0])
|
|
1266
|
+
@instances_interface.setopts(options)
|
|
1238
1267
|
if options[:dry_run]
|
|
1239
1268
|
print_dry_run @instances_interface.dry.get_envs(instance['id'])
|
|
1240
1269
|
return
|
|
@@ -1244,14 +1273,14 @@ class Morpheus::Cli::Instances
|
|
|
1244
1273
|
puts as_json(json_response, options)
|
|
1245
1274
|
return
|
|
1246
1275
|
end
|
|
1247
|
-
print_h1 "Instance Envs: #{instance['name']} (#{instance['instanceType']['name']})"
|
|
1276
|
+
print_h1 "Instance Envs: #{instance['name']} (#{instance['instanceType']['name']})", [], options
|
|
1248
1277
|
print cyan
|
|
1249
1278
|
envs = json_response['envs'] || {}
|
|
1250
1279
|
if json_response['readOnlyEnvs']
|
|
1251
1280
|
envs += json_response['readOnlyEnvs'].map { |k,v| {:name => k, :value => k.downcase.include?("password") || v['masked'] ? "********" : v['value'], :export => true}}
|
|
1252
1281
|
end
|
|
1253
1282
|
tp envs, :name, :value, :export
|
|
1254
|
-
print_h2 "Imported Envs"
|
|
1283
|
+
print_h2 "Imported Envs", options
|
|
1255
1284
|
imported_envs = json_response['importedEnvs'].map { |k,v| {:name => k, :value => k.downcase.include?("password") || v['masked'] ? "********" : v['value']}}
|
|
1256
1285
|
tp imported_envs
|
|
1257
1286
|
print reset, "\n"
|
|
@@ -1284,6 +1313,7 @@ class Morpheus::Cli::Instances
|
|
|
1284
1313
|
instance = find_instance_by_name_or_id(args[0])
|
|
1285
1314
|
evar = {name: args[1], value: args[2], export: options[:export], masked: options[:masked]}
|
|
1286
1315
|
payload = {envs: [evar]}
|
|
1316
|
+
@instances_interface.setopts(options)
|
|
1287
1317
|
if options[:dry_run]
|
|
1288
1318
|
print_dry_run @instances_interface.dry.create_env(instance['id'], payload)
|
|
1289
1319
|
return
|
|
@@ -1316,6 +1346,7 @@ class Morpheus::Cli::Instances
|
|
|
1316
1346
|
connect(options)
|
|
1317
1347
|
begin
|
|
1318
1348
|
instance = find_instance_by_name_or_id(args[0])
|
|
1349
|
+
@instances_interface.setopts(options)
|
|
1319
1350
|
if options[:dry_run]
|
|
1320
1351
|
print_dry_run @instances_interface.dry.del_env(instance['id'], args[1])
|
|
1321
1352
|
return
|
|
@@ -1367,10 +1398,11 @@ class Morpheus::Cli::Instances
|
|
|
1367
1398
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to stop #{instances.size == 1 ? 'instance' : (instances.size.to_s + ' instances')} #{anded_list(instances.collect {|it| it['name'] })}?", options)
|
|
1368
1399
|
return 9, "aborted command"
|
|
1369
1400
|
end
|
|
1401
|
+
@instances_interface.setopts(options)
|
|
1370
1402
|
if options[:dry_run]
|
|
1371
|
-
print_h1 "DRY RUN"
|
|
1403
|
+
print_h1 "DRY RUN", [], options
|
|
1372
1404
|
instances.each do |instance|
|
|
1373
|
-
print_dry_run @instances_interface.dry.stop(instance['id'], params)
|
|
1405
|
+
print_dry_run @instances_interface.dry.stop(instance['id'], params)
|
|
1374
1406
|
end
|
|
1375
1407
|
return 0
|
|
1376
1408
|
end
|
|
@@ -1427,10 +1459,11 @@ class Morpheus::Cli::Instances
|
|
|
1427
1459
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to start #{instances.size == 1 ? 'instance' : (instances.size.to_s + ' instances')} #{anded_list(instances.collect {|it| it['name'] })}?", options)
|
|
1428
1460
|
return 9, "aborted command"
|
|
1429
1461
|
end
|
|
1462
|
+
@instances_interface.setopts(options)
|
|
1430
1463
|
if options[:dry_run]
|
|
1431
|
-
print_h1 "DRY RUN"
|
|
1464
|
+
print_h1 "DRY RUN", [], options
|
|
1432
1465
|
instances.each do |instance|
|
|
1433
|
-
print_dry_run @instances_interface.dry.start(instance['id'], params)
|
|
1466
|
+
print_dry_run @instances_interface.dry.start(instance['id'], params)
|
|
1434
1467
|
end
|
|
1435
1468
|
return 0
|
|
1436
1469
|
end
|
|
@@ -1493,10 +1526,11 @@ class Morpheus::Cli::Instances
|
|
|
1493
1526
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to restart #{instances.size == 1 ? 'instance' : (instances.size.to_s + ' instances')} #{anded_list(instances.collect {|it| it['name'] })}?", options)
|
|
1494
1527
|
return 9, "aborted command"
|
|
1495
1528
|
end
|
|
1529
|
+
@instances_interface.setopts(options)
|
|
1496
1530
|
if options[:dry_run]
|
|
1497
|
-
print_h1 "DRY RUN"
|
|
1531
|
+
print_h1 "DRY RUN", [], options
|
|
1498
1532
|
instances.each do |instance|
|
|
1499
|
-
print_dry_run @instances_interface.dry.restart(instance['id'], params)
|
|
1533
|
+
print_dry_run @instances_interface.dry.restart(instance['id'], params)
|
|
1500
1534
|
end
|
|
1501
1535
|
return 0
|
|
1502
1536
|
end
|
|
@@ -1555,7 +1589,7 @@ class Morpheus::Cli::Instances
|
|
|
1555
1589
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to suspend #{instances.size == 1 ? 'instance' : (instances.size.to_s + ' instances')} #{anded_list(instances.collect {|it| it['name'] })}?", options)
|
|
1556
1590
|
return 9, "aborted command"
|
|
1557
1591
|
end
|
|
1558
|
-
|
|
1592
|
+
@instances_interface.setopts(options)
|
|
1559
1593
|
if options[:dry_run]
|
|
1560
1594
|
print_dry_run @instances_interface.dry.suspend(instances.collect {|it| it['id'] }, params)
|
|
1561
1595
|
return
|
|
@@ -1603,6 +1637,7 @@ class Morpheus::Cli::Instances
|
|
|
1603
1637
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to eject #{instances.size == 1 ? 'instance' : (instances.size.to_s + ' instances')} #{anded_list(instances.collect {|it| it['name'] })}?", options)
|
|
1604
1638
|
return 9, "aborted command"
|
|
1605
1639
|
end
|
|
1640
|
+
@instances_interface.setopts(options)
|
|
1606
1641
|
if options[:dry_run]
|
|
1607
1642
|
print_dry_run @instances_interface.dry.eject(instances.collect {|it| it['id'] }, params)
|
|
1608
1643
|
return
|
|
@@ -1657,10 +1692,11 @@ class Morpheus::Cli::Instances
|
|
|
1657
1692
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to stop service on #{instances.size == 1 ? 'instance' : (instances.size.to_s + ' instances')} #{anded_list(instances.collect {|it| it['name'] })}?", options)
|
|
1658
1693
|
return 9, "aborted command"
|
|
1659
1694
|
end
|
|
1695
|
+
@instances_interface.setopts(options)
|
|
1660
1696
|
if options[:dry_run]
|
|
1661
|
-
print_h1 "DRY RUN"
|
|
1697
|
+
print_h1 "DRY RUN", [], options
|
|
1662
1698
|
instances.each do |instance|
|
|
1663
|
-
print_dry_run @instances_interface.dry.stop(instance['id'], params)
|
|
1699
|
+
print_dry_run @instances_interface.dry.stop(instance['id'], params)
|
|
1664
1700
|
end
|
|
1665
1701
|
return 0
|
|
1666
1702
|
end
|
|
@@ -1717,10 +1753,11 @@ class Morpheus::Cli::Instances
|
|
|
1717
1753
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to start service on #{instances.size == 1 ? 'instance' : (instances.size.to_s + ' instances')} #{anded_list(instances.collect {|it| it['name'] })}?", options)
|
|
1718
1754
|
return 9, "aborted command"
|
|
1719
1755
|
end
|
|
1756
|
+
@instances_interface.setopts(options)
|
|
1720
1757
|
if options[:dry_run]
|
|
1721
|
-
print_h1 "DRY RUN"
|
|
1758
|
+
print_h1 "DRY RUN", [], options
|
|
1722
1759
|
instances.each do |instance|
|
|
1723
|
-
print_dry_run @instances_interface.dry.start(instance['id'], params)
|
|
1760
|
+
print_dry_run @instances_interface.dry.start(instance['id'], params)
|
|
1724
1761
|
end
|
|
1725
1762
|
return 0
|
|
1726
1763
|
end
|
|
@@ -1783,10 +1820,11 @@ class Morpheus::Cli::Instances
|
|
|
1783
1820
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to restart service on #{instances.size == 1 ? 'instance' : (instances.size.to_s + ' instances')} #{anded_list(instances.collect {|it| it['name'] })}?", options)
|
|
1784
1821
|
return 9, "aborted command"
|
|
1785
1822
|
end
|
|
1823
|
+
@instances_interface.setopts(options)
|
|
1786
1824
|
if options[:dry_run]
|
|
1787
|
-
print_h1 "DRY RUN"
|
|
1825
|
+
print_h1 "DRY RUN", [], options
|
|
1788
1826
|
instances.each do |instance|
|
|
1789
|
-
print_dry_run @instances_interface.dry.restart(instance['id'], params)
|
|
1827
|
+
print_dry_run @instances_interface.dry.restart(instance['id'], params)
|
|
1790
1828
|
end
|
|
1791
1829
|
return 0
|
|
1792
1830
|
end
|
|
@@ -1847,6 +1885,7 @@ class Morpheus::Cli::Instances
|
|
|
1847
1885
|
instance_ids = instances.collect {|instance| instance["id"] }
|
|
1848
1886
|
begin
|
|
1849
1887
|
# instance = find_instance_by_name_or_id(args[0])
|
|
1888
|
+
@instances_interface.setopts(options)
|
|
1850
1889
|
if options[:dry_run]
|
|
1851
1890
|
print_dry_run @instances_interface.dry.available_actions(instance_ids)
|
|
1852
1891
|
return 0
|
|
@@ -1856,7 +1895,7 @@ class Morpheus::Cli::Instances
|
|
|
1856
1895
|
puts as_json(json_response, options)
|
|
1857
1896
|
else
|
|
1858
1897
|
title = "Instance Actions: #{anded_list(id_list)}"
|
|
1859
|
-
print_h1 title
|
|
1898
|
+
print_h1 title, [], options
|
|
1860
1899
|
available_actions = json_response["actions"]
|
|
1861
1900
|
if (available_actions && available_actions.size > 0)
|
|
1862
1901
|
print as_pretty_table(available_actions, [:name, :code])
|
|
@@ -1908,7 +1947,7 @@ class Morpheus::Cli::Instances
|
|
|
1908
1947
|
instance_ids = instances.collect {|instance| instance["id"] }
|
|
1909
1948
|
|
|
1910
1949
|
# figure out what action to run
|
|
1911
|
-
available_actions = @instances_interface.available_actions(instance_ids)["actions"]
|
|
1950
|
+
available_actions = @instances_interface.available_actions(instance_ids, options)["actions"]
|
|
1912
1951
|
if available_actions.empty?
|
|
1913
1952
|
if instance_ids.size > 1
|
|
1914
1953
|
print_red_alert "The specified instances have no available actions in common."
|
|
@@ -1941,6 +1980,7 @@ class Morpheus::Cli::Instances
|
|
|
1941
1980
|
# return run_command_for_each_arg(containers) do |arg|
|
|
1942
1981
|
# _action(arg, action_id, options)
|
|
1943
1982
|
# end
|
|
1983
|
+
@instances_interface.setopts(options)
|
|
1944
1984
|
if options[:dry_run]
|
|
1945
1985
|
print_dry_run @instances_interface.dry.action(instance_ids, action_id)
|
|
1946
1986
|
return 0
|
|
@@ -1988,7 +2028,7 @@ class Morpheus::Cli::Instances
|
|
|
1988
2028
|
puts "\nDue to limitations by most Guest Operating Systems, Disk sizes can only be expanded and not reduced.\nIf a smaller plan is selected, memory and CPU (if relevant) will be reduced but storage will not.\n\n"
|
|
1989
2029
|
|
|
1990
2030
|
# prompt for service plan
|
|
1991
|
-
service_plans_json = @instances_interface.service_plans({zoneId: cloud_id, siteId: group_id, layoutId: layout_id})
|
|
2031
|
+
service_plans_json = @instances_interface.service_plans({zoneId: cloud_id, siteId: group_id, layoutId: layout_id}, options)
|
|
1992
2032
|
service_plans = service_plans_json["plans"]
|
|
1993
2033
|
service_plans_dropdown = service_plans.collect {|sp| {'name' => sp["name"], 'value' => sp["id"]} } # already sorted
|
|
1994
2034
|
service_plans_dropdown.each do |plan|
|
|
@@ -2003,7 +2043,7 @@ class Morpheus::Cli::Instances
|
|
|
2003
2043
|
#payload[:servicePlanId] = new_plan_id
|
|
2004
2044
|
payload[:instance][:plan] = {id: service_plan["id"]}
|
|
2005
2045
|
|
|
2006
|
-
volumes_response = @instances_interface.volumes(instance['id'])
|
|
2046
|
+
volumes_response = @instances_interface.volumes(instance['id'], options)
|
|
2007
2047
|
current_volumes = volumes_response['volumes'].sort {|x,y| x['displayOrder'] <=> y['displayOrder'] }
|
|
2008
2048
|
|
|
2009
2049
|
# prompt for volumes
|
|
@@ -2015,7 +2055,7 @@ class Morpheus::Cli::Instances
|
|
|
2015
2055
|
# only amazon supports this option
|
|
2016
2056
|
# for now, always do this
|
|
2017
2057
|
payload[:deleteOriginalVolumes] = true
|
|
2018
|
-
|
|
2058
|
+
@instances_interface.setopts(options)
|
|
2019
2059
|
if options[:dry_run]
|
|
2020
2060
|
print_dry_run @instances_interface.dry.resize(instance['id'], payload)
|
|
2021
2061
|
return
|
|
@@ -2051,6 +2091,7 @@ class Morpheus::Cli::Instances
|
|
|
2051
2091
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to backup the instance '#{instance['name']}'?", options)
|
|
2052
2092
|
exit 1
|
|
2053
2093
|
end
|
|
2094
|
+
@instances_interface.setopts(options)
|
|
2054
2095
|
if options[:dry_run]
|
|
2055
2096
|
print_dry_run @instances_interface.dry.backup(instance['id'])
|
|
2056
2097
|
return
|
|
@@ -2117,6 +2158,7 @@ class Morpheus::Cli::Instances
|
|
|
2117
2158
|
if query_params[:preserveVolumes].nil?
|
|
2118
2159
|
query_params[:removeVolumes] = 'on'
|
|
2119
2160
|
end
|
|
2161
|
+
@instances_interface.setopts(options)
|
|
2120
2162
|
if options[:dry_run]
|
|
2121
2163
|
print_dry_run @instances_interface.dry.destroy(instance['id'],query_params)
|
|
2122
2164
|
return
|
|
@@ -2149,6 +2191,7 @@ class Morpheus::Cli::Instances
|
|
|
2149
2191
|
connect(options)
|
|
2150
2192
|
begin
|
|
2151
2193
|
instance = find_instance_by_name_or_id(args[0])
|
|
2194
|
+
@instances_interface.setopts(options)
|
|
2152
2195
|
if options[:dry_run]
|
|
2153
2196
|
print_dry_run @instances_interface.dry.firewall_disable(instance['id'])
|
|
2154
2197
|
return
|
|
@@ -2180,6 +2223,7 @@ class Morpheus::Cli::Instances
|
|
|
2180
2223
|
connect(options)
|
|
2181
2224
|
begin
|
|
2182
2225
|
instance = find_instance_by_name_or_id(args[0])
|
|
2226
|
+
@instances_interface.setopts(options)
|
|
2183
2227
|
if options[:dry_run]
|
|
2184
2228
|
print_dry_run @instances_interface.dry.firewall_enable(instance['id'])
|
|
2185
2229
|
return
|
|
@@ -2211,6 +2255,7 @@ class Morpheus::Cli::Instances
|
|
|
2211
2255
|
connect(options)
|
|
2212
2256
|
begin
|
|
2213
2257
|
instance = find_instance_by_name_or_id(args[0])
|
|
2258
|
+
@instances_interface.setopts(options)
|
|
2214
2259
|
if options[:dry_run]
|
|
2215
2260
|
print_dry_run @instances_interface.dry.security_groups(instance['id'])
|
|
2216
2261
|
return
|
|
@@ -2221,7 +2266,7 @@ class Morpheus::Cli::Instances
|
|
|
2221
2266
|
return
|
|
2222
2267
|
end
|
|
2223
2268
|
securityGroups = json_response['securityGroups']
|
|
2224
|
-
print_h1 "Morpheus Security Groups for Instance: #{instance['name']}"
|
|
2269
|
+
print_h1 "Morpheus Security Groups for Instance: #{instance['name']}", [], options
|
|
2225
2270
|
print cyan
|
|
2226
2271
|
print_description_list({"Firewall Enabled" => lambda {|it| format_boolean it['firewallEnabled'] } }, json_response)
|
|
2227
2272
|
#print cyan, "Firewall Enabled=#{json_response['firewallEnabled']}\n\n"
|
|
@@ -2271,6 +2316,7 @@ class Morpheus::Cli::Instances
|
|
|
2271
2316
|
begin
|
|
2272
2317
|
instance = find_instance_by_name_or_id(args[0])
|
|
2273
2318
|
payload = {securityGroupIds: security_group_ids}
|
|
2319
|
+
@instances_interface.setopts(options)
|
|
2274
2320
|
if options[:dry_run]
|
|
2275
2321
|
print_dry_run @instances_interface.dry.apply_security_groups(instance['id'], payload)
|
|
2276
2322
|
return
|
|
@@ -2329,6 +2375,7 @@ class Morpheus::Cli::Instances
|
|
|
2329
2375
|
|
|
2330
2376
|
workflow_payload = {taskSet: {"#{workflow['id']}" => params }}
|
|
2331
2377
|
begin
|
|
2378
|
+
@instances_interface.setopts(options)
|
|
2332
2379
|
if options[:dry_run]
|
|
2333
2380
|
print_dry_run @instances_interface.dry.workflow(instance['id'],workflow['id'], workflow_payload)
|
|
2334
2381
|
return
|
|
@@ -2384,7 +2431,7 @@ class Morpheus::Cli::Instances
|
|
|
2384
2431
|
#print_rest_exception(e, options)
|
|
2385
2432
|
exit 1
|
|
2386
2433
|
end
|
|
2387
|
-
|
|
2434
|
+
@instances_interface.setopts(options)
|
|
2388
2435
|
if options[:dry_run]
|
|
2389
2436
|
print_dry_run @instances_interface.dry.import_snapshot(instance['id'], payload)
|
|
2390
2437
|
return
|
|
@@ -2405,6 +2452,7 @@ class Morpheus::Cli::Instances
|
|
|
2405
2452
|
|
|
2406
2453
|
def scaling(args)
|
|
2407
2454
|
options = {}
|
|
2455
|
+
params = {}
|
|
2408
2456
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
2409
2457
|
opts.banner = subcommand_usage("[name]")
|
|
2410
2458
|
build_common_options(opts, options, [:json, :yaml, :csv, :fields, :dry_run, :remote])
|
|
@@ -2426,11 +2474,12 @@ class Morpheus::Cli::Instances
|
|
|
2426
2474
|
def _scaling(arg, options)
|
|
2427
2475
|
instance = find_instance_by_name_or_id(arg)
|
|
2428
2476
|
return 1 if instance.nil?
|
|
2477
|
+
@instances_interface.setopts(options)
|
|
2429
2478
|
if options[:dry_run]
|
|
2430
2479
|
print_dry_run @instances_interface.dry.threshold(instance['id'], params)
|
|
2431
2480
|
return 0
|
|
2432
2481
|
end
|
|
2433
|
-
json_response = @instances_interface.threshold(instance['id'])
|
|
2482
|
+
json_response = @instances_interface.threshold(instance['id'], params)
|
|
2434
2483
|
if options[:json]
|
|
2435
2484
|
puts as_json(json_response, options, "instanceThreshold")
|
|
2436
2485
|
return 0
|
|
@@ -2445,11 +2494,11 @@ class Morpheus::Cli::Instances
|
|
|
2445
2494
|
instance_threshold = json_response['instanceThreshold']
|
|
2446
2495
|
|
|
2447
2496
|
title = "Instance Scaling: [#{instance['id']}] #{instance['name']} (#{instance['instanceType']['name']})"
|
|
2448
|
-
print_h1 title
|
|
2497
|
+
print_h1 title, [], options
|
|
2449
2498
|
if instance_threshold.empty?
|
|
2450
2499
|
print yellow,"No scaling settings applied to this instance.",reset,"\n"
|
|
2451
2500
|
else
|
|
2452
|
-
# print_h1 "Threshold Settings"
|
|
2501
|
+
# print_h1 "Threshold Settings", [], options
|
|
2453
2502
|
print cyan
|
|
2454
2503
|
print_instance_threshold_description_list(instance_threshold)
|
|
2455
2504
|
end
|
|
@@ -2561,7 +2610,7 @@ class Morpheus::Cli::Instances
|
|
|
2561
2610
|
# unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to update the scaling settings for instance '#{instance['name']}'?", options)
|
|
2562
2611
|
# return 9, "aborted command"
|
|
2563
2612
|
# end
|
|
2564
|
-
|
|
2613
|
+
@instances_interface.setopts(options)
|
|
2565
2614
|
if options[:dry_run]
|
|
2566
2615
|
print_dry_run @instances_interface.dry.update_threshold(instance['id'], payload)
|
|
2567
2616
|
return
|
|
@@ -2643,7 +2692,7 @@ class Morpheus::Cli::Instances
|
|
|
2643
2692
|
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to update the load balancer for instance '#{instance['name']}'?", options)
|
|
2644
2693
|
return 9, "aborted command"
|
|
2645
2694
|
end
|
|
2646
|
-
|
|
2695
|
+
@instances_interface.setopts(options)
|
|
2647
2696
|
if options[:dry_run]
|
|
2648
2697
|
print_dry_run @instances_interface.dry.update_load_balancer(instance['id'], payload)
|
|
2649
2698
|
return
|
|
@@ -2694,7 +2743,7 @@ class Morpheus::Cli::Instances
|
|
|
2694
2743
|
|
|
2695
2744
|
# no options here, just send DELETE request
|
|
2696
2745
|
payload = {}
|
|
2697
|
-
|
|
2746
|
+
@instances_interface.setopts(options)
|
|
2698
2747
|
if options[:dry_run]
|
|
2699
2748
|
print_dry_run @instances_interface.dry.remove_load_balancer(instance['id'], payload)
|
|
2700
2749
|
return
|
|
@@ -2760,6 +2809,7 @@ class Morpheus::Cli::Instances
|
|
|
2760
2809
|
params = {}
|
|
2761
2810
|
params.merge!(parse_list_options(options))
|
|
2762
2811
|
# params[:query] = params.delete(:phrase) unless params[:phrase].nil?
|
|
2812
|
+
@instances_interface.setopts(options)
|
|
2763
2813
|
if options[:dry_run]
|
|
2764
2814
|
print_dry_run @instances_interface.dry.history(instance['id'], params)
|
|
2765
2815
|
return
|
|
@@ -2782,7 +2832,7 @@ class Morpheus::Cli::Instances
|
|
|
2782
2832
|
subtitles << "Search: #{params[:query]}".strip
|
|
2783
2833
|
end
|
|
2784
2834
|
subtitles += parse_list_subtitles(options)
|
|
2785
|
-
print_h1 title, subtitles
|
|
2835
|
+
print_h1 title, subtitles, options
|
|
2786
2836
|
if json_response['processes'].empty?
|
|
2787
2837
|
print "#{cyan}No process history found.#{reset}\n\n"
|
|
2788
2838
|
else
|
|
@@ -2892,6 +2942,7 @@ class Morpheus::Cli::Instances
|
|
|
2892
2942
|
params = {}
|
|
2893
2943
|
params.merge!(parse_list_options(options))
|
|
2894
2944
|
params[:query] = params.delete(:phrase) unless params[:phrase].nil?
|
|
2945
|
+
@instances_interface.setopts(options)
|
|
2895
2946
|
if options[:dry_run]
|
|
2896
2947
|
print_dry_run @instances_interface.dry.history_details(instance['id'], process_id, params)
|
|
2897
2948
|
return
|
|
@@ -2912,10 +2963,10 @@ class Morpheus::Cli::Instances
|
|
|
2912
2963
|
subtitles = []
|
|
2913
2964
|
subtitles << " Process ID: #{process_id}"
|
|
2914
2965
|
subtitles += parse_list_subtitles(options)
|
|
2915
|
-
print_h1 title, subtitles
|
|
2966
|
+
print_h1 title, subtitles, options
|
|
2916
2967
|
print_process_details(process)
|
|
2917
2968
|
|
|
2918
|
-
print_h2 "Process Events"
|
|
2969
|
+
print_h2 "Process Events", options
|
|
2919
2970
|
process_events = process['events'] || process['processEvents'] || []
|
|
2920
2971
|
history_records = []
|
|
2921
2972
|
if process_events.empty?
|
|
@@ -2991,6 +3042,7 @@ class Morpheus::Cli::Instances
|
|
|
2991
3042
|
instance = find_instance_by_name_or_id(args[0])
|
|
2992
3043
|
params = {}
|
|
2993
3044
|
params.merge!(parse_list_options(options))
|
|
3045
|
+
@instances_interface.setopts(options)
|
|
2994
3046
|
if options[:dry_run]
|
|
2995
3047
|
print_dry_run @instances_interface.dry.history_event_details(instance['id'], process_event_id, params)
|
|
2996
3048
|
return
|
|
@@ -3010,7 +3062,7 @@ class Morpheus::Cli::Instances
|
|
|
3010
3062
|
title = "Instance History Event"
|
|
3011
3063
|
subtitles = []
|
|
3012
3064
|
subtitles += parse_list_subtitles(options)
|
|
3013
|
-
print_h1 title, subtitles
|
|
3065
|
+
print_h1 title, subtitles, options
|
|
3014
3066
|
print_process_event_details(process_event)
|
|
3015
3067
|
print reset, "\n"
|
|
3016
3068
|
return 0
|
|
@@ -3074,7 +3126,7 @@ class Morpheus::Cli::Instances
|
|
|
3074
3126
|
end
|
|
3075
3127
|
payload['script'] = script_content
|
|
3076
3128
|
end
|
|
3077
|
-
|
|
3129
|
+
@execution_request_interface.setopts(options)
|
|
3078
3130
|
if options[:dry_run]
|
|
3079
3131
|
print_dry_run @execution_request_interface.dry.create(params, payload)
|
|
3080
3132
|
return 0
|
|
@@ -3345,14 +3397,14 @@ private
|
|
|
3345
3397
|
print_description_list(description_cols, process)
|
|
3346
3398
|
|
|
3347
3399
|
if process['error']
|
|
3348
|
-
print_h2 "Error"
|
|
3400
|
+
print_h2 "Error", options
|
|
3349
3401
|
print reset
|
|
3350
3402
|
#puts format_process_error(process_event)
|
|
3351
3403
|
puts process['error'].to_s.strip
|
|
3352
3404
|
end
|
|
3353
3405
|
|
|
3354
3406
|
if process['output']
|
|
3355
|
-
print_h2 "Output"
|
|
3407
|
+
print_h2 "Output", options
|
|
3356
3408
|
print reset
|
|
3357
3409
|
#puts format_process_error(process_event)
|
|
3358
3410
|
puts process['output'].to_s.strip
|
|
@@ -3376,14 +3428,14 @@ private
|
|
|
3376
3428
|
print_description_list(description_cols, process_event)
|
|
3377
3429
|
|
|
3378
3430
|
if process_event['error']
|
|
3379
|
-
print_h2 "Error"
|
|
3431
|
+
print_h2 "Error", options
|
|
3380
3432
|
print reset
|
|
3381
3433
|
#puts format_process_error(process_event)
|
|
3382
3434
|
puts process_event['error'].to_s.strip
|
|
3383
3435
|
end
|
|
3384
3436
|
|
|
3385
3437
|
if process_event['output']
|
|
3386
|
-
print_h2 "Output"
|
|
3438
|
+
print_h2 "Output", options
|
|
3387
3439
|
print reset
|
|
3388
3440
|
#puts format_process_error(process_event)
|
|
3389
3441
|
puts process_event['output'].to_s.strip
|