morpheus-cli 3.6.12 → 3.6.13

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/lib/morpheus/api/clouds_interface.rb +2 -2
  3. data/lib/morpheus/cli/account_groups_command.rb +84 -106
  4. data/lib/morpheus/cli/apps.rb +12 -11
  5. data/lib/morpheus/cli/archives_command.rb +2 -9
  6. data/lib/morpheus/cli/blueprints_command.rb +0 -8
  7. data/lib/morpheus/cli/boot_scripts_command.rb +3 -6
  8. data/lib/morpheus/cli/cli_command.rb +6 -2
  9. data/lib/morpheus/cli/cloud_datastores_command.rb +2 -5
  10. data/lib/morpheus/cli/clouds.rb +9 -10
  11. data/lib/morpheus/cli/commands/standard/history_command.rb +7 -3
  12. data/lib/morpheus/cli/containers_command.rb +0 -1
  13. data/lib/morpheus/cli/cypher_command.rb +0 -2
  14. data/lib/morpheus/cli/deployments.rb +6 -5
  15. data/lib/morpheus/cli/deploys.rb +0 -2
  16. data/lib/morpheus/cli/groups.rb +7 -10
  17. data/lib/morpheus/cli/hosts.rb +7 -4
  18. data/lib/morpheus/cli/image_builder_command.rb +1 -7
  19. data/lib/morpheus/cli/instances.rb +26 -40
  20. data/lib/morpheus/cli/key_pairs.rb +2 -2
  21. data/lib/morpheus/cli/library_option_lists_command.rb +13 -19
  22. data/lib/morpheus/cli/library_option_types_command.rb +2 -2
  23. data/lib/morpheus/cli/license.rb +0 -1
  24. data/lib/morpheus/cli/load_balancers.rb +1 -2
  25. data/lib/morpheus/cli/mixins/accounts_helper.rb +4 -12
  26. data/lib/morpheus/cli/mixins/print_helper.rb +53 -2
  27. data/lib/morpheus/cli/mixins/processes_helper.rb +0 -1
  28. data/lib/morpheus/cli/mixins/whoami_helper.rb +0 -1
  29. data/lib/morpheus/cli/monitoring_contacts_command.rb +0 -1
  30. data/lib/morpheus/cli/network_domains_command.rb +1 -4
  31. data/lib/morpheus/cli/network_groups_command.rb +2 -5
  32. data/lib/morpheus/cli/network_pool_servers_command.rb +2 -5
  33. data/lib/morpheus/cli/network_pools_command.rb +2 -5
  34. data/lib/morpheus/cli/network_proxies_command.rb +2 -5
  35. data/lib/morpheus/cli/network_services_command.rb +2 -5
  36. data/lib/morpheus/cli/networks_command.rb +2 -5
  37. data/lib/morpheus/cli/old_cypher_command.rb +0 -2
  38. data/lib/morpheus/cli/policies_command.rb +1 -4
  39. data/lib/morpheus/cli/preseed_scripts_command.rb +2 -5
  40. data/lib/morpheus/cli/remote.rb +3 -4
  41. data/lib/morpheus/cli/roles.rb +5 -5
  42. data/lib/morpheus/cli/security_group_rules.rb +0 -1
  43. data/lib/morpheus/cli/security_groups.rb +0 -1
  44. data/lib/morpheus/cli/shell.rb +89 -38
  45. data/lib/morpheus/cli/storage_providers_command.rb +2 -5
  46. data/lib/morpheus/cli/tasks.rb +2 -3
  47. data/lib/morpheus/cli/users.rb +1 -1
  48. data/lib/morpheus/cli/version.rb +1 -1
  49. data/lib/morpheus/cli/virtual_images.rb +4 -7
  50. data/lib/morpheus/cli/whoami.rb +1 -1
  51. data/lib/morpheus/cli/workflows.rb +0 -2
  52. data/lib/morpheus/formatters.rb +17 -0
  53. data/lib/morpheus/logging.rb +17 -7
  54. data/morpheus-cli.gemspec +0 -1
  55. metadata +2 -16
@@ -4,7 +4,6 @@ require 'yaml'
4
4
  require 'rest_client'
5
5
  require 'optparse'
6
6
  require 'filesize'
7
- require 'table_print'
8
7
  require 'morpheus/cli/cli_command'
9
8
 
10
9
  class Morpheus::Cli::ArchivesCommand
@@ -131,11 +130,7 @@ class Morpheus::Cli::ArchivesCommand
131
130
  :visibility,
132
131
  {:isPublic => {label: 'Public URL'.upcase}}
133
132
  ]
134
- term_width = current_terminal_width()
135
- # if term_width > 170
136
- # columns += [:cpu, :memory, :storage]
137
- # end
138
- # custom pretty table columns ...
133
+
139
134
  if options[:include_fields]
140
135
  columns = options[:include_fields]
141
136
  end
@@ -1774,9 +1769,7 @@ class Morpheus::Cli::ArchivesCommand
1774
1769
  rows = archive_buckets.collect do |it|
1775
1770
  {id: it['id'], name: it['name']}
1776
1771
  end
1777
- print red
1778
- tp rows, [:id, :name]
1779
- print reset,"\n"
1772
+ puts as_pretty_table(rows, [:id, :name], {color:red})
1780
1773
  return nil
1781
1774
  else
1782
1775
  return archive_buckets[0]
@@ -1714,14 +1714,6 @@ class Morpheus::Cli::BlueprintsCommand
1714
1714
  if tiers.empty?
1715
1715
  print yellow,"No tiers found.",reset,"\n"
1716
1716
  else
1717
- # rows = tiers.collect do |tier|
1718
- # {
1719
- # id: tier['id'],
1720
- # name: tier['name'],
1721
- # }
1722
- # end
1723
- # print cyan
1724
- # tp rows, [:name]
1725
1717
  print cyan
1726
1718
  tiers.each do |tier_name|
1727
1719
  puts tier_name
@@ -1,7 +1,6 @@
1
1
  require 'rest_client'
2
2
  require 'optparse'
3
3
  require 'filesize'
4
- require 'table_print'
5
4
  require 'morpheus/cli/cli_command'
6
5
 
7
6
  class Morpheus::Cli::BootScriptsCommand
@@ -369,13 +368,11 @@ class Morpheus::Cli::BootScriptsCommand
369
368
  return nil
370
369
  elsif boot_scripts.size > 1
371
370
  print_red_alert "#{boot_scripts.size} boot scripts found by name #{name}"
372
- # print_boot_scripts_table(boot_scripts, {color: red})
373
- rows = boot_scripts.collect do |boot_script|
371
+ rows = boot_scripts.collect do |it|
374
372
  {id: it['id'], name: it['fileName']}
375
373
  end
376
- print red
377
- tp rows, [:id, :name]
378
- print reset,"\n"
374
+ print "\n"
375
+ puts as_pretty_table(rows, [:id, :name], {color:red})
379
376
  return nil
380
377
  else
381
378
  return boot_scripts[0]
@@ -443,10 +443,10 @@ module Morpheus
443
443
  header_list = [val.to_s]
444
444
  header_list.each do |h|
445
445
  header_parts = val.to_s.split(":")
446
- header_key, header_value = header_parts[0], header_parts[1..-1].join(":")
446
+ header_key, header_value = header_parts[0], header_parts[1..-1].join(":").strip
447
447
  if header_parts.size() < 2
448
448
  header_parts = val.to_s.split("=")
449
- header_key, header_value = header_parts[0], header_parts[1..-1].join("=")
449
+ header_key, header_value = header_parts[0], header_parts[1..-1].join("=").strip
450
450
  end
451
451
  if header_parts.size() < 2
452
452
  raise_command_error "Invalid HEADER value '#{val}'. HEADER should contain a key and a value. eg. -H 'X-Morpheus-Lease: $MORPHEUS_LEASE_TOKEN'"
@@ -534,6 +534,10 @@ module Morpheus
534
534
  opts.on('-F', '--fields x,y,z', Array, "Filter Output to a limited set of fields. Default is all fields.") do |val|
535
535
  options[:include_fields] = val
536
536
  end
537
+ opts.on(nil, '--all-fields', "Show all fields. Useful for showing hidden columns on wide tables.") do
538
+ options[:all_fields] = true
539
+ end
540
+ opts.add_hidden_option('--all-fields') if opts.is_a?(Morpheus::Cli::OptionParser)
537
541
 
538
542
  when :thin
539
543
  opts.on( '--thin', '--thin', "Format headers and columns with thin borders." ) do |val|
@@ -1,7 +1,6 @@
1
1
  require 'rest_client'
2
2
  require 'optparse'
3
3
  require 'filesize'
4
- require 'table_print'
5
4
  require 'morpheus/cli/cli_command'
6
5
  require 'morpheus/cli/mixins/infrastructure_helper'
7
6
 
@@ -379,13 +378,11 @@ class Morpheus::Cli::CloudDatastoresCommand
379
378
  return nil
380
379
  elsif datastores.size > 1
381
380
  print_red_alert "#{datastores.size} datastores found by name #{name}"
382
- # print_datastores_table(datastores, {color: red})
383
381
  rows = datastores.collect do |it|
384
382
  {id: it['id'], name: it['name']}
385
383
  end
386
- print red
387
- tp rows, [:id, :name]
388
- print reset,"\n"
384
+ print "\n"
385
+ puts as_pretty_table(rows, [:id, :name], {color:red})
389
386
  return nil
390
387
  else
391
388
  datastore = datastores[0]
@@ -90,7 +90,7 @@ class Morpheus::Cli::Clouds
90
90
  if clouds.empty?
91
91
  print cyan,"No clouds found.",reset,"\n"
92
92
  else
93
- print_clouds_table(clouds)
93
+ print_clouds_table(clouds, options)
94
94
  print_results_pagination(json_response)
95
95
  end
96
96
  print reset,"\n"
@@ -623,10 +623,9 @@ class Morpheus::Cli::Clouds
623
623
  end
624
624
  cloud_types = get_available_cloud_types() # @clouds_interface.dry.cloud_types({})['zoneTypes']
625
625
  if options[:json]
626
- print JSON.pretty_generate({zoneTypes: cloud_types})
627
- print "\n"
626
+ puts as_json({zoneTypes: cloud_types}, options)
628
627
  else
629
- print_h1 "Morpheus Cloud Types"
628
+ print_h1 "Morpheus Cloud Types", options
630
629
  if cloud_types.empty?
631
630
  print yellow,"No instances found.",reset,"\n"
632
631
  else
@@ -635,9 +634,12 @@ class Morpheus::Cli::Clouds
635
634
  rows = cloud_types.collect do |cloud_type|
636
635
  {id: cloud_type['id'], name: cloud_type['name'], code: cloud_type['code']}
637
636
  end
638
- tp rows, :id, :name, :code
637
+ #print "\n"
638
+ puts as_pretty_table(rows, [:id, :name, :code], options)
639
+ #print_results_pagination({size:rows.size,total:rows.size})
640
+ #print "\n"
639
641
  end
640
- print reset,"\n"
642
+ #print reset,"\n"
641
643
  end
642
644
  rescue RestClient::Exception => e
643
645
  print_rest_exception(e, options)
@@ -664,10 +666,7 @@ class Morpheus::Cli::Clouds
664
666
  columns = [
665
667
  :id, :name, :type, :location, :groups, :servers, :status
666
668
  ]
667
- print table_color
668
- tp rows, columns
669
- print reset
670
-
669
+ print as_pretty_table(rows, columns, opts)
671
670
  end
672
671
 
673
672
  def add_cloud_option_types(cloud_type)
@@ -11,13 +11,17 @@ class Morpheus::Cli::HistoryCommand
11
11
  # todo: support all the other :list options too, not just max
12
12
  # AND start logging every terminal command, not just shell...
13
13
  def handle(args)
14
- options = {}
14
+ options = {show_pagination:false}
15
15
  optparse = Morpheus::Cli::OptionParser.new do|opts|
16
16
  opts.banner = "Usage: morpheus #{command_name}"
17
- opts.on( '-n', '--max-commands MAX', "Max Results. Default is 25" ) do |val|
17
+ # -n is a hidden alias for -m
18
+ opts.on( '-n', '--max-commands MAX', "Alias for -m, --max option." ) do |val|
18
19
  options[:max] = val
19
20
  end
20
21
  opts.add_hidden_option('-n')
22
+ opts.on( '-p', '--pagination', "Display pagination and count info eg. Viewing 1-M of N" ) do
23
+ options[:show_pagination] = true
24
+ end
21
25
  opts.on( nil, '--flush', "Flush history, purges entire shell history file." ) do |val|
22
26
  options[:do_flush] = true
23
27
  end
@@ -31,6 +35,7 @@ Examples:
31
35
  history -m 100
32
36
  history --flush
33
37
 
38
+ The most recently executed commands are seen by default. Use --reverse to see the oldest commands.
34
39
  EOT
35
40
  end
36
41
  raw_cmd = "#{command_name} #{args.join(' ')}"
@@ -47,7 +52,6 @@ EOT
47
52
  Morpheus::Cli::Shell.instance.flush_history
48
53
  return 0
49
54
  else
50
- # supports all the :list options
51
55
  Morpheus::Cli::Shell.instance.print_history(options)
52
56
  return 0
53
57
  end
@@ -2,7 +2,6 @@ require 'io/console'
2
2
  require 'rest_client'
3
3
  require 'optparse'
4
4
  require 'filesize'
5
- require 'table_print'
6
5
  require 'morpheus/cli/cli_command'
7
6
  require 'morpheus/cli/mixins/provisioning_helper'
8
7
  require 'morpheus/cli/option_types'
@@ -1,6 +1,4 @@
1
1
  require 'json'
2
- require 'yaml'
3
- require 'table_print'
4
2
  require 'morpheus/cli/cli_command'
5
3
 
6
4
  class Morpheus::Cli::CypherCommand
@@ -1,7 +1,6 @@
1
1
  require 'io/console'
2
2
  require 'rest_client'
3
3
  require 'optparse'
4
- require 'table_print'
5
4
  require 'morpheus/cli/cli_command'
6
5
 
7
6
  class Morpheus::Cli::Deployments
@@ -50,10 +49,11 @@ class Morpheus::Cli::Deployments
50
49
  print yellow,"No deployments currently configured.",reset,"\n"
51
50
  else
52
51
  print cyan
53
- deployments_table_data = deployments.collect do |deployment|
52
+ rows = deployments.collect do |deployment|
54
53
  {name: deployment['name'], id: deployment['id'], description: deployment['description'], updated: format_local_dt(deployment['lastUpdated'])}
55
54
  end
56
- tp deployments_table_data, :id, :name, :description, :updated
55
+ columns = [:id, :name, :description, :updated]
56
+ print as_pretty_table(rows, columns, options)
57
57
  end
58
58
  print reset,"\n"
59
59
  end
@@ -98,10 +98,11 @@ class Morpheus::Cli::Deployments
98
98
  print yellow,"No deployment versions currently exist.",reset,"\n"
99
99
  else
100
100
  print cyan
101
- versions_table_data = versions.collect do |version|
101
+ rows = versions.collect do |version|
102
102
  {version: version['userVersion'], type: version['deployType'], updated: format_local_dt(version['lastUpdated'])}
103
103
  end
104
- tp versions_table_data, :version, :type, :updated
104
+ coumns = [:version, :type, :updated]
105
+ print as_pretty_table(rows, columns, options)
105
106
  end
106
107
  print reset,"\n"
107
108
  end
@@ -1,9 +1,7 @@
1
1
  # require 'yaml'
2
2
  require 'io/console'
3
3
  require 'rest_client'
4
- require 'optparse'
5
4
  require 'filesize'
6
- require 'table_print'
7
5
  require 'morpheus/cli/cli_command'
8
6
 
9
7
  class Morpheus::Cli::Deploys
@@ -3,7 +3,6 @@ require 'yaml'
3
3
  require 'io/console'
4
4
  require 'rest_client'
5
5
  require 'optparse'
6
- require 'table_print'
7
6
  require 'morpheus/cli/cli_command'
8
7
  require 'morpheus/cli/mixins/infrastructure_helper'
9
8
  require 'morpheus/logging'
@@ -59,13 +58,13 @@ class Morpheus::Cli::Groups
59
58
  if groups.empty?
60
59
  print yellow,"No groups currently configured.",reset,"\n"
61
60
  else
62
- print_groups_table(groups)
61
+ print_groups_table(groups, options)
63
62
  print_results_pagination(json_response)
64
63
  if @active_group_id
65
64
  active_group = groups.find { |it| it['id'] == @active_group_id }
66
65
  active_group = active_group || find_group_by_name_or_id(@active_group_id)
67
66
  #unless @appliances.keys.size == 1
68
- print cyan, "\n# => Currently using group #{active_group['name']}\n", reset
67
+ print cyan, "\n# => Currently using group #{green}#{active_group['name']}#{reset}\n", reset
69
68
  #end
70
69
  else
71
70
  unless options[:remote]
@@ -487,23 +486,21 @@ class Morpheus::Cli::Groups
487
486
  {
488
487
  active: (is_active ? "=>" : ""),
489
488
  id: group['id'],
490
- name: group['name'],
489
+ name: is_active ? "#{green}#{group['name']}#{reset}#{table_color}" : group['name'],
491
490
  location: group['location'],
492
491
  cloud_count: group['zones'] ? group['zones'].size : 0,
493
492
  server_count: group['serverCount']
494
493
  }
495
494
  end
496
495
  columns = [
497
- {:active => {:display_name => ""}},
496
+ #{:active => {:display_name => ""}},
498
497
  {:id => {:width => 10}},
499
498
  {:name => {:width => 16}},
500
499
  {:location => {:width => 32}},
501
- {:cloud_count => {:display_name => "Clouds"}},
502
- {:server_count => {:display_name => "Hosts"}}
500
+ {:cloud_count => {:display_name => "CLOUDS"}},
501
+ {:server_count => {:display_name => "HOSTS"}}
503
502
  ]
504
- print table_color
505
- tp rows, columns
506
- print reset
503
+ print as_pretty_table(rows, columns, opts)
507
504
  end
508
505
 
509
506
  def add_group_option_types()
@@ -193,6 +193,12 @@ class Morpheus::Cli::Hosts
193
193
  cpu_usage_str = !stats ? "" : generate_usage_bar((stats['usedCpu'] || stats['cpuUsage']).to_f, 100, {max_bars: 10})
194
194
  memory_usage_str = !stats ? "" : generate_usage_bar(stats['usedMemory'], stats['maxMemory'], {max_bars: 10})
195
195
  storage_usage_str = !stats ? "" : generate_usage_bar(stats['usedStorage'], stats['maxStorage'], {max_bars: 10})
196
+ # if stats['maxMemory'] && stats['maxMemory'].to_i != 0
197
+ # memory_usage_str = memory_usage_str + cyan + format_bytes_short(stats['usedMemory']).strip.rjust(7, ' ') + " / " + format_bytes_short(stats['maxMemory']).strip
198
+ # end
199
+ # if stats['maxStorage'] && stats['maxStorage'].to_i != 0
200
+ # storage_usage_str = storage_usage_str + cyan + format_bytes_short(stats['usedStorage']).strip.rjust(7, ' ') + " / " + format_bytes_short(stats['maxStorage']).strip
201
+ # end
196
202
  row = {
197
203
  id: server['id'],
198
204
  tenant: server['account'] ? server['account']['name'] : server['accountId'],
@@ -213,10 +219,7 @@ class Morpheus::Cli::Hosts
213
219
  if multi_tenant
214
220
  columns.insert(4, :tenant)
215
221
  end
216
- term_width = current_terminal_width()
217
- if term_width > 170
218
- columns += [:cpu, :memory, :storage]
219
- end
222
+ columns += [:cpu, :memory, :storage]
220
223
  # custom pretty table columns ...
221
224
  if options[:include_fields]
222
225
  columns = options[:include_fields]
@@ -3,7 +3,6 @@ require 'yaml'
3
3
  require 'rest_client'
4
4
  require 'optparse'
5
5
  require 'filesize'
6
- require 'table_print'
7
6
  require 'morpheus/cli/cli_command'
8
7
  require 'morpheus/cli/mixins/provisioning_helper'
9
8
  require 'morpheus/cli/boot_scripts_command'
@@ -116,10 +115,6 @@ class Morpheus::Cli::ImageBuilderCommand
116
115
  }
117
116
  columns = [:id, :name, :type, {:lastRunDate => {label: 'Last Run Date'.upcase}},
118
117
  :status, {:result => {max_width: 60}}]
119
- term_width = current_terminal_width()
120
- # if term_width > 170
121
- # columns += [:cpu, :memory, :storage]
122
- # end
123
118
  # custom pretty table columns ...
124
119
  if options[:include_fields]
125
120
  columns = options[:include_fields]
@@ -736,8 +731,7 @@ class Morpheus::Cli::ImageBuilderCommand
736
731
  rows = image_builds.collect do |it|
737
732
  {id: it['id'], name: it['name']}
738
733
  end
739
- print red
740
- tp rows, [:id, :name]
734
+ print as_pretty_table(rows, [:id, :name], {color:red})
741
735
  print reset,"\n"
742
736
  return nil
743
737
  else
@@ -2,7 +2,6 @@ require 'io/console'
2
2
  require 'rest_client'
3
3
  require 'optparse'
4
4
  require 'filesize'
5
- require 'table_print'
6
5
  require 'morpheus/cli/cli_command'
7
6
  require 'morpheus/cli/mixins/accounts_helper'
8
7
  require 'morpheus/cli/mixins/provisioning_helper'
@@ -158,6 +157,12 @@ class Morpheus::Cli::Instances
158
157
  cpu_usage_str = !stats ? "" : generate_usage_bar((stats['usedCpu'] || stats['cpuUsage']).to_f, 100, {max_bars: 10})
159
158
  memory_usage_str = !stats ? "" : generate_usage_bar(stats['usedMemory'], stats['maxMemory'], {max_bars: 10})
160
159
  storage_usage_str = !stats ? "" : generate_usage_bar(stats['usedStorage'], stats['maxStorage'], {max_bars: 10})
160
+ # if stats['maxMemory'] && stats['maxMemory'].to_i != 0
161
+ # memory_usage_str = memory_usage_str + cyan + format_bytes_short(stats['usedMemory']).strip.rjust(7, ' ') + " / " + format_bytes_short(stats['maxMemory']).strip
162
+ # end
163
+ # if stats['maxStorage'] && stats['maxStorage'].to_i != 0
164
+ # storage_usage_str = storage_usage_str + cyan + format_bytes_short(stats['usedStorage']).strip.rjust(7, ' ') + " / " + format_bytes_short(stats['maxStorage']).strip
165
+ # end
161
166
  row = {
162
167
  id: instance['id'],
163
168
  name: instance['name'],
@@ -170,16 +175,13 @@ class Morpheus::Cli::Instances
170
175
  cloud: !instance['cloud'].nil? ? instance['cloud']['name'] : nil,
171
176
  version: instance['instanceVersion'] ? instance['instanceVersion'] : '',
172
177
  cpu: cpu_usage_str + cyan,
173
- memory: memory_usage_str + cyan,
178
+ memory: memory_usage_str + cyan,
174
179
  storage: storage_usage_str + cyan
175
180
  }
176
181
  row
177
182
  }
178
- columns = [:id, {:name => {:max_width => 50}}, :group, :cloud, :type, :version, :environment, :nodes, {:connection => {:max_width => 30}}, :status]
179
- term_width = current_terminal_width()
180
- if term_width > 190
181
- columns += [:cpu, :memory, :storage]
182
- end
183
+ columns = [:id, {:name => {:max_width => 50}}, :group, :cloud, :type, :version, :environment,
184
+ :nodes, {:connection => {:max_width => 30}}, :status, :cpu, :memory, :storage]
183
185
  # custom pretty table columns ...
184
186
  if options[:include_fields]
185
187
  columns = options[:include_fields]
@@ -937,6 +939,12 @@ class Morpheus::Cli::Instances
937
939
  cpu_usage_str = !stats ? "" : generate_usage_bar((stats['usedCpu'] || stats['cpuUsage']).to_f, 100, {max_bars: 10})
938
940
  memory_usage_str = !stats ? "" : generate_usage_bar(stats['usedMemory'], stats['maxMemory'], {max_bars: 10})
939
941
  storage_usage_str = !stats ? "" : generate_usage_bar(stats['usedStorage'], stats['maxStorage'], {max_bars: 10})
942
+ if stats['maxMemory'] && stats['maxMemory'].to_i != 0
943
+ memory_usage_str = memory_usage_str + cyan + format_bytes_short(stats['usedMemory']).strip.rjust(7, ' ') + " / " + format_bytes_short(stats['maxMemory']).strip
944
+ end
945
+ if stats['maxStorage'] && stats['maxStorage'].to_i != 0
946
+ storage_usage_str = storage_usage_str + cyan + format_bytes_short(stats['usedStorage']).strip.rjust(7, ' ') + " / " + format_bytes_short(stats['maxStorage']).strip
947
+ end
940
948
  row = {
941
949
  id: container['id'],
942
950
  status: format_container_status(container),
@@ -945,16 +953,12 @@ class Morpheus::Cli::Instances
945
953
  cloud: container['cloud'] ? container['cloud']['name'] : '',
946
954
  location: format_container_connection_string(container),
947
955
  cpu: cpu_usage_str + cyan,
948
- memory: memory_usage_str + cyan,
956
+ memory: memory_usage_str + cyan,
949
957
  storage: storage_usage_str + cyan
950
958
  }
951
959
  row
952
960
  }
953
- columns = [:id, :status, :name, :type, :cloud, :location]
954
- term_width = current_terminal_width()
955
- if term_width > 190
956
- columns += [:cpu, :memory, :storage]
957
- end
961
+ columns = [:id, :status, :name, :type, :cloud, :location, :cpu, :memory, :storage]
958
962
  # custom pretty table columns ...
959
963
  if options[:include_fields]
960
964
  columns = options[:include_fields]
@@ -1054,6 +1058,12 @@ class Morpheus::Cli::Instances
1054
1058
  cpu_usage_str = !stats ? "" : generate_usage_bar((stats['usedCpu'] || stats['cpuUsage']).to_f, 100, {max_bars: 10})
1055
1059
  memory_usage_str = !stats ? "" : generate_usage_bar(stats['usedMemory'], stats['maxMemory'], {max_bars: 10})
1056
1060
  storage_usage_str = !stats ? "" : generate_usage_bar(stats['usedStorage'], stats['maxStorage'], {max_bars: 10})
1061
+ if stats['maxMemory'] && stats['maxMemory'].to_i != 0
1062
+ memory_usage_str = memory_usage_str + cyan + format_bytes_short(stats['usedMemory']).strip.rjust(7, ' ') + " / " + format_bytes_short(stats['maxMemory']).strip
1063
+ end
1064
+ if stats['maxStorage'] && stats['maxStorage'].to_i != 0
1065
+ storage_usage_str = storage_usage_str + cyan + format_bytes_short(stats['usedStorage']).strip.rjust(7, ' ') + " / " + format_bytes_short(stats['maxStorage']).strip
1066
+ end
1057
1067
  row = {
1058
1068
  id: container['id'],
1059
1069
  status: format_container_status(container),
@@ -1067,11 +1077,7 @@ class Morpheus::Cli::Instances
1067
1077
  }
1068
1078
  row
1069
1079
  }
1070
- columns = [:id, :status, :name, :type, :cloud, :location]
1071
- term_width = current_terminal_width()
1072
- if term_width > 190
1073
- columns += [:cpu, :memory, :storage]
1074
- end
1080
+ columns = [:id, :status, :name, :type, :cloud, :location, :cpu, :memory, :storage]
1075
1081
  # custom pretty table columns ...
1076
1082
  if options[:include_fields]
1077
1083
  columns = options[:include_fields]
@@ -1279,10 +1285,9 @@ class Morpheus::Cli::Instances
1279
1285
  if json_response['readOnlyEnvs']
1280
1286
  envs += json_response['readOnlyEnvs'].map { |k,v| {:name => k, :value => k.downcase.include?("password") || v['masked'] ? "********" : v['value'], :export => true}}
1281
1287
  end
1282
- tp envs, :name, :value, :export
1288
+ columns = [:name, :value, :export]
1283
1289
  print_h2 "Imported Envs", options
1284
- imported_envs = json_response['importedEnvs'].map { |k,v| {:name => k, :value => k.downcase.include?("password") || v['masked'] ? "********" : v['value']}}
1285
- tp imported_envs
1290
+ print as_pretty_table(envs, columns, options)
1286
1291
  print reset, "\n"
1287
1292
  rescue RestClient::Exception => e
1288
1293
  print_rest_exception(e, options)
@@ -3224,25 +3229,6 @@ private
3224
3229
  end
3225
3230
  end
3226
3231
 
3227
- # def print_instances_table(instances, opts={})
3228
- # table_color = opts[:color] || cyan
3229
- # rows = instances.collect {|instance|
3230
- # {
3231
- # id: instance['id'],
3232
- # name: instance['name'],
3233
- # connection: format_instance_connection_string(instance),
3234
- # environment: instance['instanceContext'],
3235
- # nodes: instance['containers'].count,
3236
- # status: format_instance_status(instance, table_color),
3237
- # type: instance['instanceType']['name'],
3238
- # group: !instance['group'].nil? ? instance['group']['name'] : nil,
3239
- # cloud: !instance['cloud'].nil? ? instance['cloud']['name'] : nil
3240
- # }
3241
- # }
3242
- # print table_color
3243
- # tp rows, :id, :name, :group, :cloud, :type, :environment, :nodes, :connection, :status
3244
- # print reset
3245
- # end
3246
3232
 
3247
3233
  def format_instance_status(instance, return_color=cyan)
3248
3234
  out = ""