morpheus-cli 4.2.16 → 4.2.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/README.md +8 -6
  4. data/lib/morpheus/api/api_client.rb +32 -14
  5. data/lib/morpheus/api/auth_interface.rb +4 -2
  6. data/lib/morpheus/api/backup_jobs_interface.rb +9 -0
  7. data/lib/morpheus/api/backups_interface.rb +16 -0
  8. data/lib/morpheus/api/deploy_interface.rb +25 -56
  9. data/lib/morpheus/api/deployments_interface.rb +43 -54
  10. data/lib/morpheus/api/doc_interface.rb +57 -0
  11. data/lib/morpheus/api/instances_interface.rb +5 -0
  12. data/lib/morpheus/api/rest_interface.rb +40 -0
  13. data/lib/morpheus/api/user_sources_interface.rb +0 -15
  14. data/lib/morpheus/api/users_interface.rb +2 -3
  15. data/lib/morpheus/benchmarking.rb +2 -2
  16. data/lib/morpheus/cli.rb +3 -1
  17. data/lib/morpheus/cli/access_token_command.rb +27 -10
  18. data/lib/morpheus/cli/apps.rb +21 -15
  19. data/lib/morpheus/cli/backup_jobs_command.rb +276 -0
  20. data/lib/morpheus/cli/backups_command.rb +271 -0
  21. data/lib/morpheus/cli/boot_scripts_command.rb +1 -1
  22. data/lib/morpheus/cli/cli_command.rb +92 -41
  23. data/lib/morpheus/cli/clusters.rb +0 -18
  24. data/lib/morpheus/cli/commands/standard/benchmark_command.rb +7 -7
  25. data/lib/morpheus/cli/commands/standard/man_command.rb +1 -1
  26. data/lib/morpheus/cli/credentials.rb +13 -9
  27. data/lib/morpheus/cli/deploy.rb +374 -0
  28. data/lib/morpheus/cli/deployments.rb +521 -197
  29. data/lib/morpheus/cli/deploys.rb +271 -126
  30. data/lib/morpheus/cli/doc.rb +182 -0
  31. data/lib/morpheus/cli/error_handler.rb +23 -8
  32. data/lib/morpheus/cli/errors.rb +3 -2
  33. data/lib/morpheus/cli/image_builder_command.rb +2 -2
  34. data/lib/morpheus/cli/instances.rb +136 -17
  35. data/lib/morpheus/cli/invoices_command.rb +51 -38
  36. data/lib/morpheus/cli/library_layouts_command.rb +1 -1
  37. data/lib/morpheus/cli/login.rb +9 -3
  38. data/lib/morpheus/cli/mixins/accounts_helper.rb +158 -100
  39. data/lib/morpheus/cli/mixins/backups_helper.rb +115 -0
  40. data/lib/morpheus/cli/mixins/deployments_helper.rb +135 -0
  41. data/lib/morpheus/cli/mixins/option_source_helper.rb +1 -1
  42. data/lib/morpheus/cli/mixins/print_helper.rb +110 -74
  43. data/lib/morpheus/cli/mixins/provisioning_helper.rb +2 -2
  44. data/lib/morpheus/cli/mixins/whoami_helper.rb +19 -6
  45. data/lib/morpheus/cli/network_routers_command.rb +1 -1
  46. data/lib/morpheus/cli/option_parser.rb +48 -5
  47. data/lib/morpheus/cli/option_types.rb +1 -1
  48. data/lib/morpheus/cli/remote.rb +3 -2
  49. data/lib/morpheus/cli/roles.rb +49 -92
  50. data/lib/morpheus/cli/security_groups.rb +7 -1
  51. data/lib/morpheus/cli/service_plans_command.rb +10 -10
  52. data/lib/morpheus/cli/setup.rb +1 -1
  53. data/lib/morpheus/cli/shell.rb +7 -6
  54. data/lib/morpheus/cli/subnets_command.rb +1 -1
  55. data/lib/morpheus/cli/tenants_command.rb +133 -163
  56. data/lib/morpheus/cli/user_groups_command.rb +20 -65
  57. data/lib/morpheus/cli/user_settings_command.rb +115 -13
  58. data/lib/morpheus/cli/user_sources_command.rb +57 -24
  59. data/lib/morpheus/cli/users.rb +210 -186
  60. data/lib/morpheus/cli/version.rb +1 -1
  61. data/lib/morpheus/cli/whitelabel_settings_command.rb +29 -5
  62. data/lib/morpheus/cli/whoami.rb +113 -6
  63. data/lib/morpheus/cli/workflows.rb +1 -1
  64. data/lib/morpheus/ext/hash.rb +21 -0
  65. data/lib/morpheus/terminal.rb +1 -0
  66. metadata +12 -3
  67. data/lib/morpheus/cli/auth_command.rb +0 -105
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "4.2.16"
4
+ VERSION = "4.2.17"
5
5
  end
6
6
  end
@@ -29,9 +29,13 @@ class Morpheus::Cli::WhitelabelSettingsCommand
29
29
  options = {}
30
30
  optparse = Morpheus::Cli::OptionParser.new do |opts|
31
31
  opts.banner = subcommand_usage()
32
- opts.on( '-a', '--tenant TENANT', "Tenant Name or ID" ) do |val|
32
+ opts.on( '--tenant TENANT', String, "Tenant Name or ID" ) do |val|
33
33
  options[:account] = val
34
34
  end
35
+ opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID" ) do |val|
36
+ options[:account] = val
37
+ end
38
+ opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
35
39
  opts.on('--details', "Show full (not truncated) contents of Terms of Use, Privacy Policy, Override CSS" ) do
36
40
  options[:details] = true
37
41
  end
@@ -148,13 +152,17 @@ class Morpheus::Cli::WhitelabelSettingsCommand
148
152
  query_params = {}
149
153
  optparse = Morpheus::Cli::OptionParser.new do |opts|
150
154
  opts.banner = opts.banner = subcommand_usage()
155
+ opts.on( '--tenant TENANT', String, "Tenant Name or ID" ) do |val|
156
+ options[:account] = val
157
+ end
151
158
  opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID" ) do |val|
152
159
  options[:account] = val
153
160
  end
161
+ opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
154
162
  opts.on('--active [on|off]', String, "Can be used to enable / disable whitelabel feature") do |val|
155
163
  params['enabled'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s == '1' || val.to_s == ''
156
164
  end
157
- opts.on("--appliance-name NAME", String, "Appliance name. Only available to master account") do |val|
165
+ opts.on("--appliance-name NAME", String, "Appliance name. Only available to master tenant") do |val|
158
166
  params['applianceName'] = val == 'null' ? nil : val
159
167
  end
160
168
  opts.on("--disable-support-menu [on|off]", ['on','off'], "Can be used to disable support menu") do |val|
@@ -314,9 +322,13 @@ class Morpheus::Cli::WhitelabelSettingsCommand
314
322
  options = {}
315
323
  optparse = Morpheus::Cli::OptionParser.new do |opts|
316
324
  opts.banner = opts.banner = subcommand_usage()
325
+ opts.on( '--tenant TENANT', String, "Tenant Name or ID" ) do |val|
326
+ options[:account] = val
327
+ end
317
328
  opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID" ) do |val|
318
329
  options[:account] = val
319
330
  end
331
+ opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
320
332
  opts.on("--header-logo FILE", String, "Header logo image. Local path of a file to upload (png|jpg|svg)") do |val|
321
333
  options[:headerLogo] = val
322
334
  end
@@ -412,9 +424,13 @@ class Morpheus::Cli::WhitelabelSettingsCommand
412
424
  options = {}
413
425
  optparse = Morpheus::Cli::OptionParser.new do |opts|
414
426
  opts.banner = opts.banner = subcommand_usage("[image-type]")
415
- opts.on( '-a', '--tenant TENANT', "Tenant Name or ID" ) do |val|
427
+ opts.on( '--tenant TENANT', String, "Tenant Name or ID" ) do |val|
428
+ options[:account] = val
429
+ end
430
+ opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID" ) do |val|
416
431
  options[:account] = val
417
432
  end
433
+ opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
418
434
  build_common_options(opts, options, [:json, :dry_run, :quiet, :remote])
419
435
  opts.footer = "Reset your whitelabel image.\n" +
420
436
  "[image-type] is required. This is the whitelabel image type (#{@image_types.collect {|k,v| k}.join('|')})"
@@ -468,9 +484,13 @@ class Morpheus::Cli::WhitelabelSettingsCommand
468
484
  options = {}
469
485
  optparse = Morpheus::Cli::OptionParser.new do |opts|
470
486
  opts.banner = opts.banner = subcommand_usage("[image-type]")
471
- opts.on( '-a', '--tenant TENANT', "Tenant Name or ID" ) do |val|
487
+ opts.on( '--tenant TENANT', String, "Tenant Name or ID" ) do |val|
488
+ options[:account] = val
489
+ end
490
+ opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID" ) do |val|
472
491
  options[:account] = val
473
492
  end
493
+ opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
474
494
  build_common_options(opts, options, [:json, :dry_run, :quiet, :remote])
475
495
  opts.footer = "View your image of specified [image-type].\n" +
476
496
  "[image-type] is required. This is the whitelabel image type (#{@image_types.collect {|k,v| k}.join('|')})\n" +
@@ -532,9 +552,13 @@ class Morpheus::Cli::WhitelabelSettingsCommand
532
552
  options = {}
533
553
  optparse = Morpheus::Cli::OptionParser.new do |opts|
534
554
  opts.banner = opts.banner = subcommand_usage("[image-type] [local-file]")
535
- opts.on( '-a', '--tenant TENANT', "Tenant Name or ID" ) do |val|
555
+ opts.on( '--tenant TENANT', String, "Tenant Name or ID" ) do |val|
556
+ options[:account] = val
557
+ end
558
+ opts.on( '-a', '--account ACCOUNT', "Tenant Name or ID" ) do |val|
536
559
  options[:account] = val
537
560
  end
561
+ opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
538
562
  opts.on( '-f', '--force', "Overwrite existing [local-file] if it exists." ) do
539
563
  options[:overwrite] = true
540
564
  end
@@ -1,11 +1,8 @@
1
- # require 'yaml'
2
- require 'io/console'
3
- require 'rest_client'
4
- require 'optparse'
5
1
  require 'morpheus/cli/cli_command'
6
2
  require 'morpheus/cli/mixins/whoami_helper'
7
3
  require 'morpheus/cli/mixins/accounts_helper'
8
- require 'json'
4
+ require 'fileutils'
5
+ require 'yaml'
9
6
 
10
7
  class Morpheus::Cli::Whoami
11
8
  include Morpheus::Cli::CliCommand
@@ -163,7 +160,7 @@ EOT
163
160
  print cyan
164
161
  print_description_list({
165
162
  "ID" => 'id',
166
- "Tenant" => lambda {|it| (it['account'] ? it['account']['name'] : '') + (@is_master_account ? " (Master Account)" : '') },
163
+ "Tenant" => lambda {|it| (it['account'] ? it['account']['name'] : '') + (@is_master_account ? " (Master Tenant)" : '') },
167
164
  "First Name" => 'firstName',
168
165
  "Last Name" => 'lastName',
169
166
  # "Name" => 'displayName',
@@ -232,4 +229,114 @@ EOT
232
229
  end
233
230
  end
234
231
 
232
+ # Whoami class methods
233
+ class << self
234
+ include Term::ANSIColor
235
+
236
+ # @@whoami_cache is for caching the the contents the Whoami api results
237
+ # as YAML files at $home/whoami/$appliance_name/$user_id.json
238
+ @@whoami_cache = nil
239
+
240
+ def whoami_cache
241
+ if @@whoami_cache.nil?
242
+ @@whoami_cache = {}
243
+ end
244
+ return @@whoami_cache
245
+ end
246
+
247
+ def clear_whoami_cache(appliance_name, user_id)
248
+ @@whoami_cache ||= {}
249
+ @@whoami_cache[appliance_name.to_s] ||= {}
250
+ @@whoami_cache[appliance_name.to_s][user_id.to_s] = result
251
+ end
252
+
253
+ def set_whoami_cache(appliance_name, user_id, result)
254
+ @@whoami_cache ||= {}
255
+ @@whoami_cache[appliance_name.to_s] ||= {}
256
+ @@whoami_cache[appliance_name.to_s][user_id.to_s] = result
257
+ end
258
+
259
+ def get_whoami_cache(appliance_name, user_id)
260
+ @@whoami_cache ||= {}
261
+ @@whoami_cache[appliance_name.to_s] ? @@whoami_cache[appliance_name.to_s][user_id.to_s] : nil
262
+ end
263
+
264
+ def whoami_file_path
265
+ File.join(Morpheus::Cli.home_directory, "cache", "whoami")
266
+ end
267
+
268
+ def save_whoami_file(appliance_name, user_id, json_response)
269
+ fn = File.join(whoami_file_path, appliance_name.to_s, user_id.to_s + ".json")
270
+ if !Dir.exists?(File.dirname(fn))
271
+ FileUtils.mkdir_p(File.dirname(fn))
272
+ end
273
+ Morpheus::Logging::DarkPrinter.puts "writing file #{fn}" if Morpheus::Logging.debug?
274
+ File.open(fn, 'w') {|f| f.write json_response.to_yaml }
275
+ FileUtils.chmod(0600, fn)
276
+ return json_response
277
+ end
278
+
279
+ def delete_whoami_file(appliance_name, user_id)
280
+ fn = File.join(whoami_file_path, appliance_name.to_s, user_id.to_s + ".json")
281
+ if File.exist?(fn)
282
+ #Morpheus::Logging::DarkPrinter.puts "deleting file #{fn}" if Morpheus::Logging.debug?
283
+ FileUtils.rm(fn)
284
+ end
285
+ return nil
286
+ end
287
+
288
+ def load_whoami_file(appliance_name, user_id)
289
+ raise "appliance_name is required" if appliance_name.to_s.empty?
290
+ raise "user_id is required" if user_id.to_s.empty?
291
+ fn = File.join(whoami_file_path, appliance_name.to_s, user_id.to_s + ".json")
292
+ if File.exist?(fn)
293
+ Morpheus::Logging::DarkPrinter.puts "reading file #{fn}" if Morpheus::Logging.debug?
294
+ return YAML.load_file(fn)
295
+ else
296
+ return nil
297
+ end
298
+ end
299
+
300
+ def save_whoami(appliance_name, user_id, result)
301
+ save_whoami_file(appliance_name, user_id, result)
302
+ set_whoami_cache(appliance_name, user_id, result)
303
+ end
304
+
305
+ def clear_whoami(appliance_name, user_id)
306
+ delete_whoami_file(appliance_name, user_id)
307
+ set_whoami_cache(appliance_name, user_id, nil)
308
+ end
309
+
310
+ def load_whoami(appliance_name, user_id, refresh=false)
311
+ result = nil
312
+ # load from cache (memory) or file or else api
313
+ if refresh == false
314
+ # load from memory
315
+ result = whoami_cache[appliance_name.to_s] ? whoami_cache[appliance_name.to_s][user_id.to_s] : nil
316
+ # load from file
317
+ if result.nil?
318
+ result = load_whoami_file(appliance_name, user_id)
319
+ set_whoami_cache(appliance_name, user_id, result)
320
+ end
321
+ end
322
+ # if result.nil?
323
+ # # appliance needs to be passed in here...heh
324
+ # appliance = ::Morpheus::Cli::Remote.load_remote(appliance_name)
325
+ # if appliance.nil?
326
+ # raise "Remote not found for name '#{appliance_name}'"
327
+ # end
328
+ # wallet = ::Morpheus::Cli::Credentials.new(appliance[:name], appliance[:url]).load_saved_credentials()
329
+ # if wallet.nil? || wallet['access_token'].nil?
330
+ # raise "Access token not found for remote '#{appliance_name}'"
331
+ # end
332
+ # access_token = wallet['access_token']
333
+ # whoami_interface = Morpheus::WhoamiInterface.new({url: appliance[:url], access_token: wallet['access_token']})
334
+ # whoami_response = whoami_interface.get()
335
+ # result = whoami_response
336
+ # end
337
+ return result
338
+ end
339
+
340
+ end
341
+
235
342
  end
@@ -619,7 +619,7 @@ class Morpheus::Cli::Workflows
619
619
  elsif target_type == 'appliance'
620
620
  # cool, run it locally.
621
621
  else
622
- raise_command_error "missing required option: --instance or --host\n#{optparse}"
622
+ raise_command_error "missing required option: --instance, --host or --appliance\n#{optparse}"
623
623
  end
624
624
 
625
625
  # todo: prompt to workflow optionTypes for customOptions
@@ -85,4 +85,25 @@ class Hash
85
85
  self
86
86
  end
87
87
 
88
+ def upcase_keys!
89
+ self.keys.each do |k|
90
+ self[k.to_s.upcase] = self.delete(k)
91
+ end
92
+ self
93
+ end
94
+
95
+ def downcase_keys!
96
+ self.keys.each do |k|
97
+ self[k.to_s.downcase] = self.delete(k)
98
+ end
99
+ self
100
+ end
101
+
102
+ def capitalize_keys!
103
+ self.keys.each do |k|
104
+ self[k.to_s.capitalize] = self.delete(k)
105
+ end
106
+ self
107
+ end
108
+
88
109
  end
@@ -264,6 +264,7 @@ module Morpheus
264
264
  opts.on('-V','--debug', "Print extra output for debugging.") do |json|
265
265
  @terminal_log_level = Morpheus::Logging::Logger::DEBUG
266
266
  Morpheus::Logging.set_log_level(Morpheus::Logging::Logger::DEBUG)
267
+ # if !options[:quiet]
267
268
  ::RestClient.log = Morpheus::Logging.debug? ? Morpheus::Logging::DarkPrinter.instance : nil
268
269
  end
269
270
  opts.on('-v','--version', "Print the version.") do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morpheus-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.16
4
+ version: 4.2.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Estes
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-06-18 00:00:00.000000000 Z
14
+ date: 2020-08-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -182,7 +182,9 @@ files:
182
182
  - lib/morpheus/api/archive_buckets_interface.rb
183
183
  - lib/morpheus/api/archive_files_interface.rb
184
184
  - lib/morpheus/api/auth_interface.rb
185
+ - lib/morpheus/api/backup_jobs_interface.rb
185
186
  - lib/morpheus/api/backup_settings_interface.rb
187
+ - lib/morpheus/api/backups_interface.rb
186
188
  - lib/morpheus/api/blueprints_interface.rb
187
189
  - lib/morpheus/api/budgets_interface.rb
188
190
  - lib/morpheus/api/cloud_datastores_interface.rb
@@ -198,6 +200,7 @@ files:
198
200
  - lib/morpheus/api/datastores_interface.rb
199
201
  - lib/morpheus/api/deploy_interface.rb
200
202
  - lib/morpheus/api/deployments_interface.rb
203
+ - lib/morpheus/api/doc_interface.rb
201
204
  - lib/morpheus/api/environments_interface.rb
202
205
  - lib/morpheus/api/execute_schedules_interface.rb
203
206
  - lib/morpheus/api/execution_request_interface.rb
@@ -266,6 +269,7 @@ files:
266
269
  - lib/morpheus/api/provisioning_licenses_interface.rb
267
270
  - lib/morpheus/api/provisioning_settings_interface.rb
268
271
  - lib/morpheus/api/reports_interface.rb
272
+ - lib/morpheus/api/rest_interface.rb
269
273
  - lib/morpheus/api/roles_interface.rb
270
274
  - lib/morpheus/api/security_group_rules_interface.rb
271
275
  - lib/morpheus/api/security_groups_interface.rb
@@ -295,8 +299,9 @@ files:
295
299
  - lib/morpheus/cli/approvals_command.rb
296
300
  - lib/morpheus/cli/apps.rb
297
301
  - lib/morpheus/cli/archives_command.rb
298
- - lib/morpheus/cli/auth_command.rb
302
+ - lib/morpheus/cli/backup_jobs_command.rb
299
303
  - lib/morpheus/cli/backup_settings_command.rb
304
+ - lib/morpheus/cli/backups_command.rb
300
305
  - lib/morpheus/cli/blueprints_command.rb
301
306
  - lib/morpheus/cli/boot_scripts_command.rb
302
307
  - lib/morpheus/cli/budgets_command.rb
@@ -333,8 +338,10 @@ files:
333
338
  - lib/morpheus/cli/credentials.rb
334
339
  - lib/morpheus/cli/cypher_command.rb
335
340
  - lib/morpheus/cli/dashboard_command.rb
341
+ - lib/morpheus/cli/deploy.rb
336
342
  - lib/morpheus/cli/deployments.rb
337
343
  - lib/morpheus/cli/deploys.rb
344
+ - lib/morpheus/cli/doc.rb
338
345
  - lib/morpheus/cli/dot_file.rb
339
346
  - lib/morpheus/cli/environments_command.rb
340
347
  - lib/morpheus/cli/error_handler.rb
@@ -372,6 +379,8 @@ files:
372
379
  - lib/morpheus/cli/logout.rb
373
380
  - lib/morpheus/cli/logs_command.rb
374
381
  - lib/morpheus/cli/mixins/accounts_helper.rb
382
+ - lib/morpheus/cli/mixins/backups_helper.rb
383
+ - lib/morpheus/cli/mixins/deployments_helper.rb
375
384
  - lib/morpheus/cli/mixins/infrastructure_helper.rb
376
385
  - lib/morpheus/cli/mixins/library_helper.rb
377
386
  - lib/morpheus/cli/mixins/logs_helper.rb
@@ -1,105 +0,0 @@
1
- require 'morpheus/cli/cli_command'
2
-
3
- # JD: this is not in use, we have login, logout and access-token instead
4
- # This provides commands for authentication
5
- # This also includes credential management.
6
- class Morpheus::Cli::AuthCommand
7
- include Morpheus::Cli::CliCommand
8
-
9
- set_command_name :'auth'
10
-
11
- register_subcommands :get
12
- # register_subcommands :list # yes plz
13
- # register_subcommands :'access-token' => :print_access_token
14
- # register_subcommands :'refresh-token' => :print_refresh_token
15
- # register_subcommands :'use-refresh-token' => :use_refresh_token
16
- register_subcommands :login, :logout
17
- register_subcommands :test => :login_test
18
-
19
- def connect(options)
20
- @api_client = establish_remote_appliance_connection(options.merge({:no_prompt => true, :skip_verify_access_token => true, :skip_login => true}))
21
- # automatically get @appliance_name, @appliance_url, @wallet
22
- if !@appliance_name
23
- raise_command_error "#{command_name} requires a remote to be specified, use -r [remote] or set the active remote with `remote use`"
24
- end
25
- if !@appliance_url
26
- unless options[:quiet]
27
- print red,"Unable to determine remote appliance url. Review your remote configuration.#{reset}\n"
28
- end
29
- return 1
30
- end
31
- #@wallet = Morpheus::Cli::Credentials.new(@appliance_name, @appliance_url).load_saved_credentials()
32
- if @wallet.nil? || @wallet['access_token'].nil?
33
- unless options[:quiet]
34
- print_error yellow,"You are not currently logged in to #{display_appliance(@appliance_name, @appliance_url)}",reset,"\n"
35
- print_error yellow,"Use `login` to authenticate.",reset,"\n"
36
- end
37
- return 1
38
- end
39
- end
40
-
41
- def handle(args)
42
- handle_subcommand(args)
43
- end
44
-
45
- def get(args)
46
- options = {}
47
- params = {}
48
- optparse = Morpheus::Cli::OptionParser.new do |opts|
49
- opts.banner = subcommand_usage()
50
- build_common_options(opts, options, [:remote, :quiet])
51
- opts.footer = "Print your current authentication info.\n" +
52
- "This contains tokens that should be kept secret, be careful."
53
- end
54
- optparse.parse!(args)
55
- if args.count != 0
56
- raise_command_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args.join(' ')}\n#{optparse}"
57
- end
58
- connect_result = connect(options)
59
- return connect_result if (connect_result.is_a?(Numeric) && connect_result != 0)
60
-
61
- # could fetch and show whoami info as well eh?
62
- # extra api call though..
63
-
64
- #print_h1 "Morpheus Credentials", [display_appliance(@appliance_name, @appliance_url)], options
65
- print_h1 "Morpheus Credentials", [], options
66
- description_cols = {
67
- "Remote" => lambda {|wallet| @appliance_name },
68
- "Username" => lambda {|wallet| wallet['username'] },
69
- "Access Token" => lambda {|wallet| wallet['access_token'] },
70
- "Refresh Token" => lambda {|wallet| wallet['refresh_token'] },
71
- "Login Date" => lambda {|wallet| format_local_dt(wallet['login_date']) },
72
- "Expire Date" => lambda {|wallet| wallet['expire_date'] ? format_local_dt(wallet['expire_date']) : "" },
73
- }
74
- print cyan
75
- puts as_description_list(@wallet, description_cols)
76
- print reset
77
- return 0
78
- end
79
-
80
- # these are all just aliases, heh
81
-
82
- def login(args)
83
- ::Morpheus::Cli::Login.new.handle(args)
84
- end
85
-
86
- def login_test(args)
87
- ::Morpheus::Cli::Login.new.handle(['--test'] + args)
88
- end
89
-
90
- def logout(args)
91
- ::Morpheus::Cli::Logout.new.handle(args)
92
- end
93
-
94
- def print_access_token(args)
95
- ::Morpheus::Cli::AccessTokenCommand.new.handle(args)
96
- end
97
-
98
- def use_refresh_token(args)
99
- ::Morpheus::Cli::AccessTokenCommand.new.handle(['refresh'] + args)
100
- end
101
-
102
-
103
- protected
104
-
105
- end