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
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Morpheus::Cli
|
|
2
|
+
|
|
3
|
+
# A standard error to raise in your CliCommand classes.
|
|
4
|
+
class CommandError < StandardError
|
|
5
|
+
|
|
6
|
+
attr_reader :args, :exit_code
|
|
7
|
+
|
|
8
|
+
def initialize(msg, args=[], optparse=nil, exit_code=nil)
|
|
9
|
+
@args = args
|
|
10
|
+
@optparse = optparse
|
|
11
|
+
@exit_code = exit_code # || 1
|
|
12
|
+
super(msg)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# An error indicating the command was not recoginzed
|
|
17
|
+
class CommandNotFoundError < CommandError
|
|
18
|
+
|
|
19
|
+
def initialize(msg, args=[], optparse=nil, exit_code=nil)
|
|
20
|
+
super(msg, args, optparse, exit_code || 127)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# An error for wrong number of arguments
|
|
26
|
+
# could use ::OptionParser::MissingArgument, ::OptionParser::NeedlessArgument
|
|
27
|
+
# maybe return an error code niftier than 1?
|
|
28
|
+
class CommandArgumentsError < CommandError
|
|
29
|
+
|
|
30
|
+
def initialize(msg, args=[], optparse=nil, exit_code=nil)
|
|
31
|
+
super(msg, args, optparse, exit_code || 1)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# An error indicating authorization is required (unable to aquire access token)
|
|
37
|
+
class AuthorizationRequiredError < CommandError
|
|
38
|
+
|
|
39
|
+
def initialize(msg, args=[], optparse=nil, exit_code=nil)
|
|
40
|
+
super(msg, args, optparse, exit_code || 1)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -127,7 +127,7 @@ class Morpheus::Cli::ExecuteSchedulesCommand
|
|
|
127
127
|
print cyan
|
|
128
128
|
description_cols = {
|
|
129
129
|
"ID" => lambda {|it| it['id'] },
|
|
130
|
-
#"
|
|
130
|
+
#"Tenant" => lambda {|it| it['owner'] ? it['owner']['name'] : '' },
|
|
131
131
|
"Name" => lambda {|it| it['name'] },
|
|
132
132
|
"Description" => lambda {|it| it['description'] },
|
|
133
133
|
"Type" => lambda {|it| format_schedule_type(it['scheduleType']) },
|
|
@@ -213,9 +213,9 @@ class Morpheus::Cli::ExecutionRequestCommand
|
|
|
213
213
|
execution_request = json_response['executionRequest']
|
|
214
214
|
print_green_success "Executing request #{execution_request['uniqueId']}"
|
|
215
215
|
if do_refresh
|
|
216
|
-
get([execution_request['uniqueId'], "--refresh"])
|
|
216
|
+
get([execution_request['uniqueId'], "--refresh"] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
217
217
|
else
|
|
218
|
-
get([execution_request['uniqueId']])
|
|
218
|
+
get([execution_request['uniqueId']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
219
219
|
end
|
|
220
220
|
return 0
|
|
221
221
|
rescue RestClient::Exception => e
|
|
@@ -288,9 +288,9 @@ class Morpheus::Cli::ExecutionRequestCommand
|
|
|
288
288
|
execution_request = json_response['executionRequest']
|
|
289
289
|
print_green_success "Executing request #{execution_request['uniqueId']} against lease"
|
|
290
290
|
if do_refresh
|
|
291
|
-
get([execution_request['uniqueId'], "--refresh"])
|
|
291
|
+
get([execution_request['uniqueId'], "--refresh"] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
292
292
|
else
|
|
293
|
-
get([execution_request['uniqueId']])
|
|
293
|
+
get([execution_request['uniqueId']] + (options[:remote] ? ["-r",options[:remote]] : []))
|
|
294
294
|
end
|
|
295
295
|
return 0
|
|
296
296
|
rescue RestClient::Exception => e
|
data/lib/morpheus/cli/groups.rb
CHANGED
|
@@ -10,6 +10,7 @@ require 'morpheus/logging'
|
|
|
10
10
|
class Morpheus::Cli::Groups
|
|
11
11
|
include Morpheus::Cli::CliCommand
|
|
12
12
|
include Morpheus::Cli::InfrastructureHelper
|
|
13
|
+
include Morpheus::Cli::OptionSourceHelper
|
|
13
14
|
|
|
14
15
|
register_subcommands :list, :get, :add, :update, :use, :unuse, :add_cloud, :remove_cloud, :remove, :current => :print_current
|
|
15
16
|
alias_subcommand :details, :get
|
|
@@ -22,8 +23,9 @@ class Morpheus::Cli::Groups
|
|
|
22
23
|
|
|
23
24
|
def connect(opts)
|
|
24
25
|
@api_client = establish_remote_appliance_connection(opts)
|
|
25
|
-
@groups_interface =
|
|
26
|
-
@clouds_interface =
|
|
26
|
+
@groups_interface = @api_client.groups
|
|
27
|
+
@clouds_interface = @api_client.clouds
|
|
28
|
+
@options_interface = @api_client.options
|
|
27
29
|
@active_group_id = Morpheus::Cli::Groups.active_groups[@appliance_name]
|
|
28
30
|
end
|
|
29
31
|
|
|
@@ -36,22 +38,21 @@ class Morpheus::Cli::Groups
|
|
|
36
38
|
params = {}
|
|
37
39
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
38
40
|
opts.banner = subcommand_usage()
|
|
39
|
-
|
|
40
|
-
opts.footer = "List groups
|
|
41
|
+
build_standard_list_options(opts, options)
|
|
42
|
+
opts.footer = "List groups."
|
|
41
43
|
end
|
|
42
44
|
optparse.parse!(args)
|
|
45
|
+
verify_args!(args:args, optparse:optparse, count:0)
|
|
43
46
|
connect(options)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return 0 if render_result
|
|
54
|
-
|
|
47
|
+
params.merge!(parse_list_options(options))
|
|
48
|
+
@groups_interface.setopts(options)
|
|
49
|
+
if options[:dry_run]
|
|
50
|
+
print_dry_run @groups_interface.list(params)
|
|
51
|
+
return 0, nil
|
|
52
|
+
end
|
|
53
|
+
json_response = @groups_interface.list(params)
|
|
54
|
+
exit_code, err = 0, nil
|
|
55
|
+
render_response(json_response, options) do
|
|
55
56
|
groups = json_response['groups']
|
|
56
57
|
subtitles = []
|
|
57
58
|
subtitles += parse_list_subtitles(options)
|
|
@@ -61,39 +62,24 @@ class Morpheus::Cli::Groups
|
|
|
61
62
|
else
|
|
62
63
|
print_groups_table(groups, options)
|
|
63
64
|
print_results_pagination(json_response)
|
|
64
|
-
if @active_group_id
|
|
65
|
-
active_group = groups.find { |it| it['id'] == @active_group_id }
|
|
66
|
-
active_group = active_group || find_group_by_name_or_id(@active_group_id)
|
|
67
|
-
#unless @appliances.keys.size == 1
|
|
68
|
-
print cyan, "\n# => Currently using group #{active_group['name']}\n", reset
|
|
69
|
-
#end
|
|
70
|
-
else
|
|
71
|
-
unless options[:remote]
|
|
72
|
-
print cyan, "\n# => No active group, see `groups use`\n", reset
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
65
|
end
|
|
76
66
|
print reset,"\n"
|
|
77
|
-
return 0
|
|
78
|
-
rescue RestClient::Exception => e
|
|
79
|
-
print_rest_exception(e, options)
|
|
80
|
-
exit 1
|
|
81
67
|
end
|
|
68
|
+
return exit_code, err
|
|
82
69
|
end
|
|
83
70
|
|
|
84
71
|
def get(args)
|
|
85
72
|
options = {}
|
|
86
73
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
87
74
|
opts.banner = subcommand_usage("[name]")
|
|
88
|
-
|
|
89
|
-
opts.footer =
|
|
90
|
-
|
|
75
|
+
build_standard_get_options(opts, options)
|
|
76
|
+
opts.footer = <<-EOT
|
|
77
|
+
Get details about a group.
|
|
78
|
+
[name] is required. This is the name or id of a group. Supports 1-N arguments.
|
|
79
|
+
EOT
|
|
91
80
|
end
|
|
92
81
|
optparse.parse!(args)
|
|
93
|
-
|
|
94
|
-
puts optparse
|
|
95
|
-
exit 1
|
|
96
|
-
end
|
|
82
|
+
verify_args!(args:args, optparse:optparse, min:1)
|
|
97
83
|
connect(options)
|
|
98
84
|
id_list = parse_id_list(args)
|
|
99
85
|
return run_command_for_each_arg(id_list) do |arg|
|
|
@@ -140,12 +126,11 @@ class Morpheus::Cli::Groups
|
|
|
140
126
|
# puts "Clouds: #{group['zones'].collect {|it| it['name'] }.join(', ')}"
|
|
141
127
|
# puts "Hosts: #{group['serverCount']}"
|
|
142
128
|
if is_active
|
|
143
|
-
|
|
129
|
+
print "\n"
|
|
130
|
+
print cyan, "=> This is the active group", reset, "\n" # remove me...
|
|
144
131
|
end
|
|
145
|
-
|
|
146
132
|
print reset,"\n"
|
|
147
|
-
|
|
148
|
-
#puts instance
|
|
133
|
+
return 0, nil
|
|
149
134
|
rescue RestClient::Exception => e
|
|
150
135
|
print_rest_exception(e, options)
|
|
151
136
|
exit 1
|
|
@@ -165,15 +150,11 @@ class Morpheus::Cli::Groups
|
|
|
165
150
|
opts.on( '--use', '--use', "Make this the current active group" ) do
|
|
166
151
|
use_it = true
|
|
167
152
|
end
|
|
168
|
-
|
|
169
|
-
build_common_options(opts, options, [:options, :json, :dry_run, :remote])
|
|
153
|
+
build_standard_add_options(opts, options)
|
|
170
154
|
opts.footer = "Create a new group."
|
|
171
155
|
end
|
|
172
156
|
optparse.parse!(args)
|
|
173
|
-
|
|
174
|
-
# puts optparse
|
|
175
|
-
# exit 1
|
|
176
|
-
# end
|
|
157
|
+
verify_args!(args:args, optparse:optparse, max:1)
|
|
177
158
|
connect(options)
|
|
178
159
|
begin
|
|
179
160
|
# group = {name: args[0], location: params[:location]}
|
|
@@ -223,14 +204,11 @@ class Morpheus::Cli::Groups
|
|
|
223
204
|
# opts.on( '-l', '--location LOCATION', "Location" ) do |val|
|
|
224
205
|
# params[:location] = val
|
|
225
206
|
# end
|
|
226
|
-
|
|
227
|
-
opts.footer = "Update
|
|
207
|
+
build_standard_update_options(opts, options)
|
|
208
|
+
opts.footer = "Update a group."
|
|
228
209
|
end
|
|
229
210
|
optparse.parse!(args)
|
|
230
|
-
|
|
231
|
-
puts optparse
|
|
232
|
-
exit 1
|
|
233
|
-
end
|
|
211
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
234
212
|
connect(options)
|
|
235
213
|
begin
|
|
236
214
|
group = find_group_by_name_or_id(args[0])
|
|
@@ -270,14 +248,11 @@ class Morpheus::Cli::Groups
|
|
|
270
248
|
options = {}
|
|
271
249
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
272
250
|
opts.banner = subcommand_usage("[name]", "CLOUD")
|
|
273
|
-
|
|
251
|
+
build_standard_update_options(opts, options)
|
|
274
252
|
opts.footer = "Add a cloud to a group."
|
|
275
253
|
end
|
|
276
254
|
optparse.parse!(args)
|
|
277
|
-
|
|
278
|
-
puts optparse
|
|
279
|
-
exit 1
|
|
280
|
-
end
|
|
255
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
|
281
256
|
connect(options)
|
|
282
257
|
begin
|
|
283
258
|
group = find_group_by_name_or_id(args[0])
|
|
@@ -313,15 +288,12 @@ class Morpheus::Cli::Groups
|
|
|
313
288
|
def remove_cloud(args)
|
|
314
289
|
options = {}
|
|
315
290
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
316
|
-
opts.banner = subcommand_usage("[name]
|
|
317
|
-
|
|
291
|
+
opts.banner = subcommand_usage("[name] [cloud]")
|
|
292
|
+
build_standard_update_options(opts, options)
|
|
318
293
|
opts.footer = "Remove a cloud from a group."
|
|
319
294
|
end
|
|
320
295
|
optparse.parse!(args)
|
|
321
|
-
|
|
322
|
-
puts optparse
|
|
323
|
-
exit 1
|
|
324
|
-
end
|
|
296
|
+
verify_args!(args:args, optparse:optparse, count:2)
|
|
325
297
|
connect(options)
|
|
326
298
|
begin
|
|
327
299
|
group = find_group_by_name_or_id(args[0])
|
|
@@ -358,15 +330,11 @@ class Morpheus::Cli::Groups
|
|
|
358
330
|
options = {}
|
|
359
331
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
360
332
|
opts.banner = subcommand_usage("[name]")
|
|
361
|
-
|
|
333
|
+
build_standard_remove_options(opts, options)
|
|
362
334
|
opts.footer = "Delete a group."
|
|
363
|
-
# more info to display here
|
|
364
335
|
end
|
|
365
336
|
optparse.parse!(args)
|
|
366
|
-
|
|
367
|
-
puts optparse
|
|
368
|
-
exit 1
|
|
369
|
-
end
|
|
337
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
370
338
|
connect(options)
|
|
371
339
|
|
|
372
340
|
begin
|
|
@@ -397,42 +365,42 @@ class Morpheus::Cli::Groups
|
|
|
397
365
|
options = {}
|
|
398
366
|
optparse = Morpheus::Cli::OptionParser.new do|opts|
|
|
399
367
|
opts.banner = subcommand_usage("[name]")
|
|
400
|
-
opts.footer =
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
368
|
+
opts.footer = <<-EOT
|
|
369
|
+
This sets the active group.
|
|
370
|
+
The active group will be auto-selected for use during provisioning.
|
|
371
|
+
[name] is required. This is the name or id of a group.
|
|
372
|
+
EOT
|
|
404
373
|
build_common_options(opts, options, [:quiet, :remote])
|
|
405
374
|
end
|
|
406
375
|
optparse.parse!(args)
|
|
407
|
-
|
|
408
|
-
puts optparse
|
|
409
|
-
return 1
|
|
410
|
-
end
|
|
376
|
+
verify_args!(args:args, optparse:optparse, count:1)
|
|
411
377
|
connect(options)
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
378
|
+
|
|
379
|
+
group = find_group_option(args[0]) #uses /api/options
|
|
380
|
+
if !group
|
|
381
|
+
raise_command_error "Group not found by name #{args[0]}"
|
|
382
|
+
end
|
|
383
|
+
exit_code, err = 0, nil
|
|
384
|
+
is_already_active = @active_group_id == group['id']
|
|
385
|
+
if is_already_active
|
|
386
|
+
unless options[:quiet]
|
|
387
|
+
print reset,"Already using the group #{group['name']}","\n",reset
|
|
418
388
|
end
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
::Morpheus::Cli::Groups.set_active_group(@appliance_name, group['id'])
|
|
425
|
-
# ::Morpheus::Cli::Groups.save_groups(@active_groups)
|
|
426
|
-
unless options[:quiet]
|
|
427
|
-
print cyan,"Switched active group to #{group['name']}","\n",reset
|
|
428
|
-
end
|
|
429
|
-
#list([])
|
|
389
|
+
else
|
|
390
|
+
::Morpheus::Cli::Groups.set_active_group(@appliance_name, group['id'])
|
|
391
|
+
# ::Morpheus::Cli::Groups.save_groups(@active_groups)
|
|
392
|
+
unless options[:quiet]
|
|
393
|
+
print cyan,"Switched active group to #{group['name']}","\n",reset
|
|
430
394
|
end
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
395
|
+
#list([])
|
|
396
|
+
end
|
|
397
|
+
if is_already_active
|
|
398
|
+
print_green_success "Group #{group['name']} is still active"
|
|
399
|
+
else
|
|
400
|
+
print_green_success "Group #{group['name']} is now active"
|
|
435
401
|
end
|
|
402
|
+
return 0
|
|
403
|
+
|
|
436
404
|
|
|
437
405
|
end
|
|
438
406
|
|
|
@@ -443,24 +411,23 @@ class Morpheus::Cli::Groups
|
|
|
443
411
|
opts.footer = "" +
|
|
444
412
|
"This will clear the current active group.\n" +
|
|
445
413
|
"You will be prompted for a Group during provisioning."
|
|
446
|
-
build_common_options(opts, options, [])
|
|
414
|
+
build_common_options(opts, options, [:quiet, :remote])
|
|
447
415
|
end
|
|
448
416
|
optparse.parse!(args)
|
|
449
|
-
|
|
450
|
-
|
|
417
|
+
verify_args!(args:args, optparse:optparse, count:0)
|
|
418
|
+
connect(options.merge({:skip_verify_access_token => true, :skip_login => true}))
|
|
419
|
+
exit_code, err = 0, nil
|
|
451
420
|
if @active_group_id
|
|
452
421
|
::Morpheus::Cli::Groups.clear_active_group(@appliance_name)
|
|
453
|
-
#
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
# puts "You will be prompted for Group during provisioning."
|
|
457
|
-
# print reset
|
|
458
|
-
# end
|
|
459
|
-
return true
|
|
422
|
+
# print_green_success "Group #{@active_group_id} is no longer active."
|
|
423
|
+
print_green_success "Group is no longer active."
|
|
424
|
+
return 0, nil
|
|
460
425
|
else
|
|
461
|
-
|
|
462
|
-
|
|
426
|
+
# print reset,"You are not using any group for appliance #{@appliance_name}",reset,"\n"
|
|
427
|
+
print reset,"You are not using any group",reset,"\n"
|
|
428
|
+
# exit_code = 1
|
|
463
429
|
end
|
|
430
|
+
return exit_code, err
|
|
464
431
|
end
|
|
465
432
|
|
|
466
433
|
def print_current(args)
|
|
@@ -580,23 +547,11 @@ class Morpheus::Cli::Groups
|
|
|
580
547
|
|
|
581
548
|
link = "#{@appliance_url}/login/oauth-redirect?access_token=#{@access_token}\\&redirectUri=/infrastructure/groups/#{group['id']}#!wiki"
|
|
582
549
|
|
|
583
|
-
open_command = nil
|
|
584
|
-
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
|
585
|
-
open_command = "start #{link}"
|
|
586
|
-
elsif RbConfig::CONFIG['host_os'] =~ /darwin/
|
|
587
|
-
open_command = "open #{link}"
|
|
588
|
-
elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
|
|
589
|
-
open_command = "xdg-open #{link}"
|
|
590
|
-
end
|
|
591
|
-
|
|
592
550
|
if options[:dry_run]
|
|
593
|
-
puts
|
|
551
|
+
puts Morpheus::Util.open_url_command(link)
|
|
594
552
|
return 0
|
|
595
553
|
end
|
|
596
|
-
|
|
597
|
-
system(open_command)
|
|
598
|
-
|
|
599
|
-
return 0
|
|
554
|
+
return Morpheus::Util.open_url(link)
|
|
600
555
|
rescue RestClient::Exception => e
|
|
601
556
|
print_rest_exception(e, options)
|
|
602
557
|
exit 1
|
|
@@ -685,13 +640,10 @@ class Morpheus::Cli::Groups
|
|
|
685
640
|
|
|
686
641
|
def print_groups_table(groups, opts={})
|
|
687
642
|
table_color = opts[:color] || cyan
|
|
688
|
-
|
|
643
|
+
active_group = @active_group_id ? groups.find {|group| group['id'] == @active_group_id } : nil
|
|
689
644
|
rows = groups.collect do |group|
|
|
690
|
-
is_active = @active_group_id && (@active_group_id == group['id'])
|
|
691
645
|
{
|
|
692
|
-
|
|
693
|
-
id: group['id'],
|
|
694
|
-
# name: is_active ? "#{green}#{group['name']}#{reset}#{table_color}" : group['name'],
|
|
646
|
+
id: active_group ? (((@active_group_id && (@active_group_id == group['id'])) ? "=> " : " ") + group['id'].to_s) : group['id'],
|
|
695
647
|
name: group['name'],
|
|
696
648
|
location: group['location'],
|
|
697
649
|
cloud_count: group['zones'] ? group['zones'].size : 0,
|
|
@@ -699,8 +651,8 @@ class Morpheus::Cli::Groups
|
|
|
699
651
|
}
|
|
700
652
|
end
|
|
701
653
|
columns = [
|
|
702
|
-
{:active => {:display_name => ""}},
|
|
703
|
-
{:id => {:
|
|
654
|
+
#{:active => {:display_name => ""}},
|
|
655
|
+
{:id => {:display_name => (active_group ? " ID" : "ID")}},
|
|
704
656
|
{:name => {:width => 16}},
|
|
705
657
|
{:location => {:width => 32}},
|
|
706
658
|
{:cloud_count => {:display_name => "CLOUDS"}},
|
data/lib/morpheus/cli/hosts.rb
CHANGED
|
@@ -146,6 +146,7 @@ class Morpheus::Cli::Hosts
|
|
|
146
146
|
created_by_ids = find_all_user_ids(account ? account['id'] : nil, options[:created_by])
|
|
147
147
|
return if created_by_ids.nil?
|
|
148
148
|
params['createdBy'] = created_by_ids
|
|
149
|
+
# params['ownerId'] = created_by_ids # 4.2.1+
|
|
149
150
|
end
|
|
150
151
|
|
|
151
152
|
cluster = nil
|
|
@@ -366,6 +367,7 @@ class Morpheus::Cli::Hosts
|
|
|
366
367
|
created_by_ids = find_all_user_ids(account ? account['id'] : nil, options[:created_by])
|
|
367
368
|
return if created_by_ids.nil?
|
|
368
369
|
params['createdBy'] = created_by_ids
|
|
370
|
+
# params['ownerId'] = created_by_ids # 4.2.1+
|
|
369
371
|
end
|
|
370
372
|
@servers_interface.setopts(options)
|
|
371
373
|
if options[:dry_run]
|
|
@@ -1435,9 +1437,9 @@ class Morpheus::Cli::Hosts
|
|
|
1435
1437
|
execution_request = json_response['executionRequest']
|
|
1436
1438
|
print_green_success "Executing request #{execution_request['uniqueId']}"
|
|
1437
1439
|
if do_refresh
|
|
1438
|
-
Morpheus::Cli::ExecutionRequestCommand.new.handle(["get", execution_request['uniqueId'], "--refresh"])
|
|
1440
|
+
Morpheus::Cli::ExecutionRequestCommand.new.handle(["get", execution_request['uniqueId'], "--refresh"]+ (options[:remote] ? ["-r",options[:remote]] : []))
|
|
1439
1441
|
else
|
|
1440
|
-
Morpheus::Cli::ExecutionRequestCommand.new.handle(["get", execution_request['uniqueId']])
|
|
1442
|
+
Morpheus::Cli::ExecutionRequestCommand.new.handle(["get", execution_request['uniqueId']]+ (options[:remote] ? ["-r",options[:remote]] : []))
|
|
1441
1443
|
end
|
|
1442
1444
|
return 0
|
|
1443
1445
|
rescue RestClient::Exception => e
|
|
@@ -1568,23 +1570,11 @@ class Morpheus::Cli::Hosts
|
|
|
1568
1570
|
link << "#!#{options[:link_tab]}"
|
|
1569
1571
|
end
|
|
1570
1572
|
|
|
1571
|
-
open_command = nil
|
|
1572
|
-
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
|
1573
|
-
open_command = "start #{link}"
|
|
1574
|
-
elsif RbConfig::CONFIG['host_os'] =~ /darwin/
|
|
1575
|
-
open_command = "open #{link}"
|
|
1576
|
-
elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
|
|
1577
|
-
open_command = "xdg-open #{link}"
|
|
1578
|
-
end
|
|
1579
|
-
|
|
1580
1573
|
if options[:dry_run]
|
|
1581
|
-
puts
|
|
1574
|
+
puts Morpheus::Util.open_url_command(link)
|
|
1582
1575
|
return 0
|
|
1583
1576
|
end
|
|
1584
|
-
|
|
1585
|
-
system(open_command)
|
|
1586
|
-
|
|
1587
|
-
return 0
|
|
1577
|
+
return Morpheus::Util.open_url(link)
|
|
1588
1578
|
rescue RestClient::Exception => e
|
|
1589
1579
|
print_rest_exception(e, options)
|
|
1590
1580
|
exit 1
|