morpheus-cli 4.2.20 → 5.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +1 -1
  3. data/lib/morpheus/api/api_client.rb +26 -0
  4. data/lib/morpheus/api/billing_interface.rb +34 -0
  5. data/lib/morpheus/api/catalog_item_types_interface.rb +9 -0
  6. data/lib/morpheus/api/deploy_interface.rb +1 -1
  7. data/lib/morpheus/api/deployments_interface.rb +20 -1
  8. data/lib/morpheus/api/forgot_password_interface.rb +17 -0
  9. data/lib/morpheus/api/instances_interface.rb +7 -0
  10. data/lib/morpheus/api/rest_interface.rb +0 -6
  11. data/lib/morpheus/api/roles_interface.rb +14 -0
  12. data/lib/morpheus/api/search_interface.rb +13 -0
  13. data/lib/morpheus/api/servers_interface.rb +7 -0
  14. data/lib/morpheus/api/usage_interface.rb +18 -0
  15. data/lib/morpheus/cli.rb +6 -3
  16. data/lib/morpheus/cli/apps.rb +3 -4
  17. data/lib/morpheus/cli/backup_jobs_command.rb +3 -0
  18. data/lib/morpheus/cli/backups_command.rb +3 -0
  19. data/lib/morpheus/cli/budgets_command.rb +4 -4
  20. data/lib/morpheus/cli/catalog_command.rb +507 -0
  21. data/lib/morpheus/cli/cli_command.rb +45 -20
  22. data/lib/morpheus/cli/commands/standard/curl_command.rb +26 -12
  23. data/lib/morpheus/cli/commands/standard/history_command.rb +3 -1
  24. data/lib/morpheus/cli/commands/standard/man_command.rb +74 -40
  25. data/lib/morpheus/cli/commands/standard/source_command.rb +1 -1
  26. data/lib/morpheus/cli/commands/standard/update_command.rb +76 -0
  27. data/lib/morpheus/cli/containers_command.rb +14 -0
  28. data/lib/morpheus/cli/deploy.rb +199 -90
  29. data/lib/morpheus/cli/deployments.rb +342 -29
  30. data/lib/morpheus/cli/deploys.rb +206 -41
  31. data/lib/morpheus/cli/error_handler.rb +7 -0
  32. data/lib/morpheus/cli/forgot_password.rb +133 -0
  33. data/lib/morpheus/cli/groups.rb +1 -1
  34. data/lib/morpheus/cli/health_command.rb +2 -2
  35. data/lib/morpheus/cli/hosts.rb +181 -26
  36. data/lib/morpheus/cli/instances.rb +102 -33
  37. data/lib/morpheus/cli/invoices_command.rb +33 -16
  38. data/lib/morpheus/cli/jobs_command.rb +28 -6
  39. data/lib/morpheus/cli/library_option_lists_command.rb +14 -6
  40. data/lib/morpheus/cli/logs_command.rb +9 -6
  41. data/lib/morpheus/cli/mixins/accounts_helper.rb +7 -6
  42. data/lib/morpheus/cli/mixins/backups_helper.rb +2 -4
  43. data/lib/morpheus/cli/mixins/catalog_helper.rb +66 -0
  44. data/lib/morpheus/cli/mixins/deployments_helper.rb +31 -3
  45. data/lib/morpheus/cli/mixins/option_source_helper.rb +1 -1
  46. data/lib/morpheus/cli/mixins/print_helper.rb +46 -21
  47. data/lib/morpheus/cli/mixins/provisioning_helper.rb +24 -4
  48. data/lib/morpheus/cli/network_pools_command.rb +14 -6
  49. data/lib/morpheus/cli/option_types.rb +266 -17
  50. data/lib/morpheus/cli/ping.rb +0 -1
  51. data/lib/morpheus/cli/provisioning_licenses_command.rb +2 -2
  52. data/lib/morpheus/cli/remote.rb +35 -12
  53. data/lib/morpheus/cli/reports_command.rb +99 -30
  54. data/lib/morpheus/cli/roles.rb +305 -3
  55. data/lib/morpheus/cli/search_command.rb +182 -0
  56. data/lib/morpheus/cli/service_plans_command.rb +2 -2
  57. data/lib/morpheus/cli/setup.rb +1 -1
  58. data/lib/morpheus/cli/shell.rb +33 -11
  59. data/lib/morpheus/cli/storage_providers_command.rb +40 -56
  60. data/lib/morpheus/cli/tasks.rb +20 -21
  61. data/lib/morpheus/cli/tenants_command.rb +1 -1
  62. data/lib/morpheus/cli/usage_command.rb +203 -0
  63. data/lib/morpheus/cli/user_settings_command.rb +1 -0
  64. data/lib/morpheus/cli/users.rb +12 -1
  65. data/lib/morpheus/cli/version.rb +1 -1
  66. data/lib/morpheus/cli/virtual_images.rb +280 -199
  67. data/lib/morpheus/cli/whoami.rb +6 -6
  68. data/lib/morpheus/cli/workflows.rb +34 -41
  69. data/lib/morpheus/formatters.rb +48 -5
  70. data/lib/morpheus/terminal.rb +6 -2
  71. metadata +13 -2
@@ -0,0 +1,182 @@
1
+ require 'morpheus/cli/cli_command'
2
+
3
+ class Morpheus::Cli::SearchCommand
4
+ include Morpheus::Cli::CliCommand
5
+
6
+ set_command_name :search
7
+ set_command_description "Global search for finding all types of objects"
8
+
9
+ def connect(opts)
10
+ @api_client = establish_remote_appliance_connection(opts)
11
+ @search_interface = @api_client.search
12
+ end
13
+
14
+ def handle(args)
15
+ options = {}
16
+ params = {}
17
+ optparse = Morpheus::Cli::OptionParser.new do |opts|
18
+ opts.banner = "Usage: #{prog_name} #{command_name} [phrase]"
19
+ opts.on("-g", "--go", "Go get details for the top search result instead of printing the list.") do
20
+ options[:go] = true
21
+ end
22
+ build_standard_list_options(opts, options)
23
+ opts.footer = <<-EOT
24
+ Global search for finding all types of objects
25
+ [phrase] is required. This is the phrase to search for.
26
+ Prints the list of search results with the most relevant first.
27
+ or use the --go option to get details about the top result instead.
28
+ EOT
29
+ end
30
+ optparse.parse!(args)
31
+ connect(options)
32
+ # verify_args!(args:args, optparse:optparse, min:1)
33
+ if args.count > 0
34
+ options[:phrase] = args.join(" ")
35
+ end
36
+ if options[:phrase].to_s.empty?
37
+ raise_command_error "[phrase] is required.", args, optparse
38
+ end
39
+ params.merge!(parse_list_options(options))
40
+ @search_interface.setopts(options)
41
+ if options[:dry_run]
42
+ print_dry_run @search_interface.dry.list(params)
43
+ return
44
+ end
45
+ json_response = @search_interface.list(params)
46
+ search_results = json_response["hits"] || json_response["results"] || []
47
+ top_result = search_results[0]
48
+ if options[:go]
49
+ if top_result
50
+ print cyan,"Loading top search result: #{format_morpheus_type(top_result['type'])} #{top_result['name'] || top_result['id']} (score: #{top_result['score']})",reset,"\n"
51
+ return go_to_search_result(top_result, options)
52
+ else
53
+ # print cyan,"No results found.",reset,"\n"
54
+ raise_command_error "No search results for phrase '#{options[:phrase]}'"
55
+ end
56
+ end
57
+ render_response(json_response, options, "hits") do
58
+ print_h1 "Morpheus Search", parse_list_subtitles(options), options
59
+ if search_results.empty?
60
+ print cyan,"No results found.",reset,"\n"
61
+ else
62
+ columns = {
63
+ "Type" => lambda {|it| format_morpheus_type(it['type']) },
64
+ "ID" => 'id',
65
+ # "UUID" => 'uuid',
66
+ "Name" => 'name',
67
+ "Decription" => 'description',
68
+ #"Score" => 'score',
69
+ "Date Created" => lambda {|it| format_local_dt(it['dateCreated']) },
70
+ }
71
+ print as_pretty_table(search_results, columns.upcase_keys!, options)
72
+ print_results_pagination(json_response)
73
+ end
74
+ print reset,"\n"
75
+ end
76
+ if search_results.empty?
77
+ return 1, "no results found"
78
+ else
79
+ return 0, nil
80
+ end
81
+ end
82
+
83
+ protected
84
+
85
+ def format_morpheus_type(val)
86
+ if val == "ComputeSite"
87
+ "Group"
88
+ elsif val == "ComputeZone"
89
+ "Cloud"
90
+ elsif val == "ComputeServer"
91
+ "Host"
92
+ elsif val == "ComputeServerGroup"
93
+ "Cluster"
94
+ elsif val == "ComputeZonePool"
95
+ "Pool"
96
+ else
97
+ val
98
+ end
99
+ end
100
+
101
+ def go_to_search_result(result, options)
102
+ result_type = result['type']
103
+ cmd_class = lookup_morpheus_command(result['type'])
104
+ if cmd_class
105
+ get_options = []
106
+ get_options += (options[:remote] ? ["-r",options[:remote]] : [])
107
+ get_options += (options[:json] ? ["--json"] : [])
108
+ get_options += (options[:yaml] ? ["--yaml"] : [])
109
+ return cmd_class.new.handle(["get", result['id']] + get_options)
110
+ else
111
+ raise_command_error "Sorry, result cannot be loaded. type: #{result_type}, id: #{result['id']}, name: #{result['name']}"
112
+ end
113
+ end
114
+
115
+
116
+ def lookup_morpheus_command(result_type)
117
+ case result_type.to_s.downcase
118
+ when "computezone","cloud","zone"
119
+ Morpheus::Cli::Clouds
120
+ when "computesite","group"
121
+ Morpheus::Cli::Groups
122
+ when "computeserver","server","host"
123
+ Morpheus::Cli::Hosts
124
+ when "computeservergroup","serverGroup","cluster"
125
+ Morpheus::Cli::Clusters
126
+ when "instance"
127
+ Morpheus::Cli::Instances
128
+ when "app"
129
+ Morpheus::Cli::Apps
130
+ when "container"
131
+ Morpheus::Cli::Containers
132
+ when "computezonefolder","zonefolder","resourcefolder"
133
+ # crap, need result.zoneId, or resource-folders should not require cloud actually, get by id
134
+ # Morpheus::Cli::CloudFoldersCommand
135
+ nil
136
+ when "computezonepool","zonepool","resourcepool"
137
+ # crap, need result.zoneId, or resource-pools should not require cloud actually, get by id
138
+ # Morpheus::Cli::CloudResourcePoolsCommand
139
+ nil
140
+ # when "chassis"
141
+ # Morpheus::Cli::ChassisCommand
142
+ when "network"
143
+ Morpheus::Cli::NetworksCommand
144
+ when "networkgroup"
145
+ Morpheus::Cli::NetworkGroupsCommand
146
+ when "networkpool"
147
+ Morpheus::Cli::NetworkPoolsCommand
148
+ when "networkdomain"
149
+ Morpheus::Cli::NetworkDomainsCommand
150
+ when "virtualimage"
151
+ Morpheus::Cli::VirtualImages
152
+ when "loadbalancer"
153
+ Morpheus::Cli::LoadBalancers
154
+ # when "virtualserver","loadbalancerinstance"
155
+ # Morpheus::Cli::LoadBalancerInstances
156
+ when "instancetype"
157
+ # Morpheus::Cli::LibraryInstanceTypesCommand
158
+ Morpheus::Cli::LibraryInstanceTypes
159
+ when "instancetypelayout","layout"
160
+ Morpheus::Cli::LibraryLayoutsCommand
161
+ when "certificate"
162
+ # todo: WHAT! didnt I write certs already!?
163
+ Morpheus::Cli::CertificatesCommand
164
+ when "keypair"
165
+ Morpheus::Cli::KeyPairs
166
+ when "integration"
167
+ Morpheus::Cli::IntegrationsCommand
168
+ when "account","tenant"
169
+ Morpheus::Cli::TenantsCommand
170
+ when "user"
171
+ Morpheus::Cli::Users
172
+ when "role"
173
+ Morpheus::Cli::Roles
174
+ when "wikipage","wiki"
175
+ Morpheus::Cli::WikiCommand
176
+ else
177
+ nil
178
+ end
179
+ end
180
+
181
+ end
182
+
@@ -409,9 +409,9 @@ class Morpheus::Cli::ServicePlanCommand
409
409
  while Morpheus::Cli::OptionTypes.confirm("Add #{price_sets.empty? ? '' : 'another '}price set?", {:default => false}) do
410
410
  price_unit = prompt_price_unit(options)
411
411
 
412
- avail_price_sets ||= @price_sets_interface.list['priceSets'].collect {|it| {'name' => it['name'], 'value' => it['id'], 'priceUnit' => it['priceUnit']}}
412
+ avail_price_sets ||= @price_sets_interface.list({'priceUnit' => price_unit, 'max' => 10000})['priceSets'].collect {|it| {'name' => it['name'], 'value' => it['id'], 'priceUnit' => it['priceUnit']}}
413
413
 
414
- if price_set_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'priceSet', 'type' => 'select', 'fieldLabel' => 'Price Set', 'selectOptions' => avail_price_sets.reject {|it| it['priceUnit'] != price_unit}, 'required' => false, 'description' => 'Select Price.'}],options[:options],@api_client,{}, options[:no_prompt], true)['priceSet']
414
+ if price_set_id = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'priceSet', 'type' => 'select', 'fieldLabel' => 'Price Set', 'selectOptions' => avail_price_sets, 'required' => false, 'description' => 'Select Price.'}],options[:options],@api_client,{}, options[:no_prompt], true)['priceSet']
415
415
  price_set = avail_price_sets.find {|it| it['value'] == price_set_id}
416
416
  price_sets << {'id' => price_set['value'], 'priceUnit' => price_set['priceUnit']}
417
417
  avail_price_sets.reject! {|it| it['value'] == price_set_id}
@@ -9,7 +9,7 @@ class Morpheus::Cli::Setup
9
9
 
10
10
  set_command_name :setup
11
11
 
12
- register_subcommands :init
12
+ # register_subcommands :init
13
13
 
14
14
  # no authorization needed
15
15
  def connect(options={})
@@ -92,6 +92,13 @@ class Morpheus::Cli::Shell
92
92
  def recalculate_auto_complete_commands
93
93
  @morpheus_commands = Morpheus::Cli::CliRegistry.all.keys.reject {|k| [:shell].include?(k) }
94
94
  @shell_commands = [:clear, :history, :reload, :help, :exit]
95
+ @shell_command_descriptions = {
96
+ :clear => "Clear terminal output and move cursor to the top",
97
+ :history => "View morpheus shell command history",
98
+ :reload => "Reload the shell, can be useful when developing",
99
+ :help => "Print this help",
100
+ :exit => "Exit the morpheus shell"
101
+ }
95
102
  @alias_commands = Morpheus::Cli::CliRegistry.all_aliases.keys
96
103
  @exploded_commands = []
97
104
  Morpheus::Cli::CliRegistry.all.each do |cmd, klass|
@@ -336,6 +343,11 @@ class Morpheus::Cli::Shell
336
343
  #Morpheus::Logging::DarkPrinter.puts "Shell command: #{input}"
337
344
  input = input.to_s.strip
338
345
 
346
+ # allow pasting in commands that have 'morpheus ' prefix
347
+ if input[0..(prog_name.size)] == "#{prog_name} "
348
+ input = input[(prog_name.size + 1)..-1] || ""
349
+ end
350
+
339
351
  if !input.empty?
340
352
 
341
353
  if input == 'exit'
@@ -345,26 +357,36 @@ class Morpheus::Cli::Shell
345
357
  return 0
346
358
  #exit 0
347
359
  elsif input == 'help'
360
+ out = ""
348
361
  if @temporary_shell_mode
349
- puts "You are in a (temporary) morpheus shell"
362
+ out << "You are in a (temporary) morpheus shell\n"
350
363
  else
351
- puts "You are in a morpheus shell."
364
+ out << "You are in a morpheus shell.\n"
352
365
  end
353
- puts "See the available commands below."
366
+ out << "See the available commands below.\n"
354
367
 
355
- puts "\nCommands:"
368
+ out << "\nCommands:"
356
369
  # commands = @morpheus_commands + @shell_commands
357
- @morpheus_commands.sort.each {|cmd|
358
- puts "\t#{cmd.to_s}"
370
+ # @morpheus_commands.sort.each {|cmd|
371
+ # out << "\t#{cmd.to_s}\n"
372
+ # }
373
+ sorted_commands = Morpheus::Cli::CliRegistry.all.values.sort { |x,y| x.command_name.to_s <=> y.command_name.to_s }
374
+ sorted_commands.each {|cmd|
375
+ # JD: not ready to show description yet, gotta finish filling in every command first
376
+ # maybe change 'View and manage' to something more concise like 'Manage'
377
+ # out << "\t#{cmd.command_name.to_s.ljust(28, ' ')} #{cmd.command_description}\n"
378
+ out << "\t#{cmd.command_name.to_s}\n"
359
379
  }
360
380
  #puts "\n"
361
- puts "\nShell Commands:"
381
+ out << "\nShell Commands:\n"
362
382
  @shell_commands.each {|cmd|
363
- puts "\t#{cmd.to_s}"
383
+ # out << "\t#{cmd.to_s.ljust(28, ' ')} #{@shell_command_descriptions ? @shell_command_descriptions[cmd] : ''}\n"
384
+ out << "\t#{cmd.to_s}\n"
364
385
  }
365
- puts "\n"
366
- puts "For more information, see https://github.com/gomorpheus/morpheus-cli/wiki"
367
- #print "\n"
386
+ out << "\n"
387
+ out << "For more information, see https://github.com/gomorpheus/morpheus-cli/wiki"
388
+ out << "\n"
389
+ print out
368
390
  return 0
369
391
  elsif input =~ /^\s*#/
370
392
  Morpheus::Logging::DarkPrinter.puts "ignored comment: #{input}" if Morpheus::Logging.debug?
@@ -42,71 +42,39 @@ class Morpheus::Cli::StorageProvidersCommand
42
42
  def list(args)
43
43
  options = {}
44
44
  params = {}
45
+ ref_ids = []
45
46
  optparse = Morpheus::Cli::OptionParser.new do |opts|
46
- opts.banner = subcommand_usage()
47
- build_common_options(opts, options, [:list, :json, :yaml, :csv, :fields, :json, :dry_run, :remote])
47
+ opts.banner = subcommand_usage("[search]")
48
+ build_standard_list_options(opts, options)
48
49
  opts.footer = "List storage buckets."
49
50
  end
50
51
  optparse.parse!(args)
51
- if args.count != 0
52
- print_error Morpheus::Terminal.angry_prompt
53
- puts_error "wrong number of arguments, expected 0 and got #{args.count}\n#{optparse}"
54
- return 1
55
- end
56
52
  connect(options)
57
- begin
58
- params.merge!(parse_list_options(options))
59
- @storage_providers_interface.setopts(options)
60
- if options[:dry_run]
61
- print_dry_run @storage_providers_interface.dry.list(params)
62
- return
63
- end
64
- json_response = @storage_providers_interface.list(params)
65
- storage_providers = json_response["storageBuckets"]
66
- if options[:json]
67
- puts as_json(json_response, options, "storageBuckets")
68
- return 0
69
- elsif options[:yaml]
70
- puts as_yaml(json_response, options, "storageBuckets")
71
- return 0
72
- elsif options[:csv]
73
- puts records_as_csv(storage_providers, options)
74
- return 0
75
- end
76
- title = "Morpheus Storage Buckets"
77
- subtitles = []
78
- subtitles += parse_list_subtitles(options)
79
- print_h1 title, subtitles
80
- if storage_providers.empty?
53
+ if args.count > 0
54
+ options[:phrase] = args.join(" ")
55
+ end
56
+ params.merge!(parse_list_options(options))
57
+ @storage_providers_interface.setopts(options)
58
+ if options[:dry_run]
59
+ print_dry_run @storage_providers_interface.dry.list(params)
60
+ return
61
+ end
62
+ json_response = @storage_providers_interface.list(params)
63
+ storage_buckets = json_response['storageBuckets']
64
+ render_response(json_response, options, 'storageBuckets') do
65
+ print_h1 "Morpheus Storage Buckets", parse_list_subtitles(options), options
66
+ if storage_buckets.empty?
81
67
  print cyan,"No storage buckets found.",reset,"\n"
82
68
  else
83
- rows = storage_providers.collect {|storage_provider|
84
- row = {
85
- id: storage_provider['id'],
86
- name: storage_provider['name'],
87
- provider: format_storage_provider_type(storage_provider),
88
- bucket: format_bucket_name(storage_provider),
89
- backups: storage_provider['defaultBackupTarget'] ? 'Yes' : 'No',
90
- deployments: storage_provider['defaultDeploymentTarget'] ? 'Yes' : 'No',
91
- virtualImages: storage_provider['defaultVirtualImageTarget'] ? 'Yes' : 'No',
92
- }
93
- row
94
- }
95
- columns = [:id, :name, {:provider => {:display_name => "Provider Type".upcase} }, {:bucket => {:display_name => "Bucket Name".upcase} }, :backups, :deployments]
96
- if options[:include_fields]
97
- columns = options[:include_fields]
98
- rows = storage_providers
99
- end
100
- print cyan
101
- print as_pretty_table(rows, columns, options)
102
- print reset
103
- print_results_pagination(json_response, {:label => "storage bucket", :n_label => "storage buckets"})
69
+ print as_pretty_table(storage_buckets, storage_bucket_column_definitions.upcase_keys!, options)
70
+ print_results_pagination(json_response)
104
71
  end
105
72
  print reset,"\n"
106
- return 0
107
- rescue RestClient::Exception => e
108
- print_rest_exception(e, options)
109
- exit 1
73
+ end
74
+ if storage_buckets.empty?
75
+ return 1, "no storage buckets found"
76
+ else
77
+ return 0, nil
110
78
  end
111
79
  end
112
80
 
@@ -1232,6 +1200,22 @@ class Morpheus::Cli::StorageProvidersCommand
1232
1200
 
1233
1201
  private
1234
1202
 
1203
+ def storage_bucket_column_definitions()
1204
+ {
1205
+ "ID" => 'id',
1206
+ "Name" => 'name',
1207
+ # "Description" => 'description',
1208
+ "Provider Type" => lambda {|it| format_storage_provider_type(it) },
1209
+ "Bucket Name" => lambda {|it| format_bucket_name(it) },
1210
+ # "Source" => lambda {|it| it['source'] },
1211
+ "Backups" => lambda {|it| format_boolean(it['defaultBackupTarget']) },
1212
+ "Deployments" => lambda {|it| format_boolean(it['defaultDeploymentTarget']) },
1213
+ "Virtual Images" => lambda {|it| format_boolean(it['defaultVirtualImageTarget']) },
1214
+ # "Archive Snapshots" => lambda {|it| format_boolean(it['copyToStore']) },
1215
+ # "Created" => lambda {|it| format_local_dt(it['dateCreated']) },
1216
+ # "Updated" => lambda {|it| format_local_dt(it['lastUpdated']) },
1217
+ }
1218
+ end
1235
1219
 
1236
1220
  def get_storage_provider_types()
1237
1221
  [
@@ -27,34 +27,31 @@ class Morpheus::Cli::Tasks
27
27
  params = {}
28
28
  options = {}
29
29
  optparse = Morpheus::Cli::OptionParser.new do |opts|
30
- opts.banner = subcommand_usage()
30
+ opts.banner = subcommand_usage("[search]")
31
31
  opts.on('-t', '--type x,y,z', Array, "Filter by task type code(s)") do |val|
32
32
  params['taskTypeCodes'] = val
33
33
  end
34
- build_common_options(opts, options, [:list, :query, :json, :yaml, :csv, :fields, :dry_run, :remote])
34
+ build_standard_list_options(opts, options)
35
+ opts.footer = "List tasks."
35
36
  end
36
37
  optparse.parse!(args)
38
+ connect(options)
37
39
  if args.count > 0
38
- raise_command_error "wrong number of arguments, expected 0 and got (#{args.count}) #{args.join(' ')}\n#{optparse}"
40
+ options[:phrase] = args.join(" ")
39
41
  end
40
- connect(options)
41
- begin
42
- params.merge!(parse_list_options(options))
43
- @tasks_interface.setopts(options)
44
- if options[:dry_run]
45
- print_dry_run @tasks_interface.dry.list(params)
46
- return
47
- end
48
- json_response = @tasks_interface.list(params)
49
-
50
- render_result = render_with_format(json_response, options, 'tasks')
51
- return 0 if render_result
52
-
42
+ params.merge!(parse_list_options(options))
43
+ @tasks_interface.setopts(options)
44
+ if options[:dry_run]
45
+ print_dry_run @tasks_interface.dry.list(params)
46
+ return
47
+ end
48
+ json_response = @tasks_interface.list(params)
49
+ tasks = json_response['tasks']
50
+ render_response(json_response, options, 'tasks') do
53
51
  title = "Morpheus Tasks"
54
52
  subtitles = []
55
53
  subtitles += parse_list_subtitles(options)
56
54
  print_h1 title, subtitles
57
- tasks = json_response['tasks']
58
55
  if tasks.empty?
59
56
  print cyan,"No tasks found.",reset,"\n"
60
57
  else
@@ -63,11 +60,13 @@ class Morpheus::Cli::Tasks
63
60
  print_results_pagination(json_response)
64
61
  end
65
62
  print reset,"\n"
66
- return 0
67
- rescue RestClient::Exception => e
68
- print_rest_exception(e, options)
69
- exit 1
70
63
  end
64
+ if tasks.empty?
65
+ return 1, "no tasks found"
66
+ else
67
+ return 0, nil
68
+ end
69
+
71
70
  end
72
71
 
73
72
  def get(args)