morpheus-cli 5.5.2.2 → 5.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Dockerfile +1 -1
  4. data/README.md +57 -4
  5. data/Rakefile +9 -0
  6. data/bin/morpheus +4 -4
  7. data/lib/morpheus/api/api_client.rb +8 -2
  8. data/lib/morpheus/api/archive_buckets_interface.rb +1 -1
  9. data/lib/morpheus/api/archive_files_interface.rb +3 -3
  10. data/lib/morpheus/api/clients_interface.rb +2 -2
  11. data/lib/morpheus/api/clusters_interface.rb +8 -1
  12. data/lib/morpheus/api/containers_interface.rb +29 -16
  13. data/lib/morpheus/api/custom_instance_types_interface.rb +0 -2
  14. data/lib/morpheus/api/doc_interface.rb +8 -6
  15. data/lib/morpheus/api/file_copy_request_interface.rb +1 -1
  16. data/lib/morpheus/api/health_interface.rb +1 -1
  17. data/lib/morpheus/api/image_builder_interface.rb +3 -3
  18. data/lib/morpheus/api/instances_interface.rb +25 -0
  19. data/lib/morpheus/api/logs_interface.rb +2 -4
  20. data/lib/morpheus/api/monitoring_interface.rb +6 -6
  21. data/lib/morpheus/api/packages_interface.rb +1 -1
  22. data/lib/morpheus/api/reports_interface.rb +1 -1
  23. data/lib/morpheus/api/servers_interface.rb +9 -1
  24. data/lib/morpheus/api/storage_providers_interface.rb +2 -2
  25. data/lib/morpheus/api/virtual_images_interface.rb +1 -1
  26. data/lib/morpheus/api.rb +2 -0
  27. data/lib/morpheus/benchmarking.rb +1 -1
  28. data/lib/morpheus/cli/cli_command.rb +69 -36
  29. data/lib/morpheus/cli/cli_registry.rb +19 -10
  30. data/lib/morpheus/cli/commands/access_token_command.rb +1 -1
  31. data/lib/morpheus/cli/commands/apps.rb +1 -1
  32. data/lib/morpheus/cli/commands/archives_command.rb +25 -33
  33. data/lib/morpheus/cli/commands/blueprints_command.rb +10 -21
  34. data/lib/morpheus/cli/commands/boot_scripts_command.rb +2 -2
  35. data/lib/morpheus/cli/commands/cat_command.rb +1 -1
  36. data/lib/morpheus/cli/commands/catalog_item_types_command.rb +12 -12
  37. data/lib/morpheus/cli/commands/clouds.rb +3 -3
  38. data/lib/morpheus/cli/commands/clusters.rb +154 -3
  39. data/lib/morpheus/cli/commands/containers_command.rb +398 -253
  40. data/lib/morpheus/cli/commands/deployments.rb +1 -1
  41. data/lib/morpheus/cli/commands/deploys.rb +9 -9
  42. data/lib/morpheus/cli/commands/doc.rb +15 -16
  43. data/lib/morpheus/cli/commands/execution_request_command.rb +2 -2
  44. data/lib/morpheus/cli/commands/file_copy_request_command.rb +5 -5
  45. data/lib/morpheus/cli/commands/groups.rb +2 -2
  46. data/lib/morpheus/cli/commands/health_command.rb +4 -4
  47. data/lib/morpheus/cli/commands/hosts.rb +43 -5
  48. data/lib/morpheus/cli/commands/image_builder_command.rb +1 -1
  49. data/lib/morpheus/cli/commands/instances.rb +419 -148
  50. data/lib/morpheus/cli/commands/integrations_command.rb +22 -20
  51. data/lib/morpheus/cli/commands/key_pairs.rb +2 -2
  52. data/lib/morpheus/cli/commands/library_container_scripts_command.rb +2 -2
  53. data/lib/morpheus/cli/commands/library_container_templates_command.rb +2 -2
  54. data/lib/morpheus/cli/commands/library_instance_types_command.rb +3 -3
  55. data/lib/morpheus/cli/commands/library_spec_templates_command.rb +2 -2
  56. data/lib/morpheus/cli/commands/login.rb +1 -1
  57. data/lib/morpheus/cli/commands/man_command.rb +32 -18
  58. data/lib/morpheus/cli/commands/packages_command.rb +11 -11
  59. data/lib/morpheus/cli/commands/plugins.rb +1 -1
  60. data/lib/morpheus/cli/commands/policies_command.rb +4 -4
  61. data/lib/morpheus/cli/commands/preseed_scripts_command.rb +2 -2
  62. data/lib/morpheus/cli/commands/remote.rb +1 -1
  63. data/lib/morpheus/cli/commands/reports_command.rb +3 -3
  64. data/lib/morpheus/cli/commands/security_groups.rb +1 -1
  65. data/lib/morpheus/cli/commands/shell.rb +40 -62
  66. data/lib/morpheus/cli/commands/snapshots.rb +3 -5
  67. data/lib/morpheus/cli/commands/source_command.rb +8 -16
  68. data/lib/morpheus/cli/commands/storage_providers_command.rb +7 -7
  69. data/lib/morpheus/cli/commands/tasks.rb +2 -2
  70. data/lib/morpheus/cli/commands/vdi_pools_command.rb +6 -6
  71. data/lib/morpheus/cli/commands/view.rb +5 -1
  72. data/lib/morpheus/cli/commands/whitelabel_settings_command.rb +4 -4
  73. data/lib/morpheus/cli/commands/whoami.rb +2 -2
  74. data/lib/morpheus/cli/credentials.rb +30 -8
  75. data/lib/morpheus/cli/dot_file.rb +8 -15
  76. data/lib/morpheus/cli/error_handler.rb +16 -0
  77. data/lib/morpheus/cli/errors.rb +8 -1
  78. data/lib/morpheus/cli/mixins/print_helper.rb +17 -13
  79. data/lib/morpheus/cli/mixins/rest_command.rb +18 -18
  80. data/lib/morpheus/cli/mixins/secondary_rest_command.rb +12 -12
  81. data/lib/morpheus/cli/option_parser.rb +5 -1
  82. data/lib/morpheus/cli/option_types.rb +59 -12
  83. data/lib/morpheus/cli/version.rb +1 -1
  84. data/lib/morpheus/cli.rb +26 -16
  85. data/lib/morpheus/ext/rest_client.rb +3 -2
  86. data/lib/morpheus/formatters.rb +1 -1
  87. data/lib/morpheus/logging.rb +4 -4
  88. data/lib/morpheus/morpkg.rb +4 -4
  89. data/lib/morpheus/rest_client.rb +2 -2
  90. data/lib/morpheus/routes.rb +2 -2
  91. data/lib/morpheus/terminal.rb +65 -16
  92. data/lib/morpheus.rb +1 -1
  93. data/morpheus-cli.gemspec +1 -0
  94. data/test/api/containers_interface_test.rb +68 -0
  95. data/test/api/doc_interface_test.rb +35 -0
  96. data/test/api/instances_interface_test.rb +22 -0
  97. data/test/api/whoami_interface_test.rb +14 -0
  98. data/test/cli/access_token_test.rb +36 -0
  99. data/test/cli/auth_test.rb +82 -0
  100. data/test/cli/cli_test.rb +48 -0
  101. data/test/cli/containers_test.rb +92 -0
  102. data/test/cli/doc_test.rb +35 -0
  103. data/test/cli/help_test.rb +25 -0
  104. data/test/cli/instances_test.rb +36 -0
  105. data/test/cli/man_test.rb +14 -0
  106. data/test/cli/remote_test.rb +89 -0
  107. data/test/cli/roles_test.rb +34 -0
  108. data/test/cli/shell_test.rb +81 -0
  109. data/test/cli/version_test.rb +23 -0
  110. data/test/cli/view_test.rb +55 -0
  111. data/test/cli/whoami_test.rb +17 -0
  112. data/test/morpheus_test.rb +16 -0
  113. data/test/test_case.rb +338 -0
  114. data/test/test_config.rb +137 -0
  115. data/test/test_data_helper.rb +97 -0
  116. metadata +61 -3
@@ -760,7 +760,7 @@ EOT
760
760
  options[:config_file] = val.to_s
761
761
  file_content = nil
762
762
  full_filename = File.expand_path(options[:config_file])
763
- if File.exists?(full_filename)
763
+ if File.exist?(full_filename)
764
764
  file_content = File.read(full_filename)
765
765
  else
766
766
  print_red_alert "File not found: #{full_filename}"
@@ -770,7 +770,7 @@ EOT
770
770
  config_map = parse_result[:data]
771
771
  if config_map.nil?
772
772
  # todo: bubble up JSON.parse error message
773
- raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:err]}"
773
+ raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:error]}"
774
774
  #raise_command_error "Failed to parse config as valid YAML or JSON."
775
775
  else
776
776
  params['config'] = config_map
@@ -813,7 +813,7 @@ EOT
813
813
  # config_map = parse_result[:data]
814
814
  # if config_map.nil?
815
815
  # # todo: bubble up JSON.parse error message
816
- # raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:err]}"
816
+ # raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:error]}"
817
817
  # #raise_command_error "Failed to parse config as valid YAML or JSON."
818
818
  # else
819
819
  # params['config'] = config_map
@@ -1065,26 +1065,28 @@ EOT
1065
1065
  return 1, "integration inventory not found for #{args[1]}" if integration_inventory.nil?
1066
1066
  # construct payload
1067
1067
  object_key = integration_inventory_object_key
1068
- payload = build_payload(options, object_key)
1069
- if options[:tenants]
1070
- #params['tenants'] = options[:tenants]
1071
- params['tenants'] = options[:tenants].collect do |val|
1072
- if val.to_s =~ /\A\d{1,}\Z/
1073
- val.to_i
1074
- else
1075
- # todo: use /api/options/allTenants to avoid permission errors here..
1076
- record = find_by_name_or_id(:account, val)
1077
- if record.nil?
1078
- exit 1 #return 1, "Tenant not found by '#{val}'"
1079
- else
1080
- record['id']
1068
+ payload = parse_payload(options, object_key)
1069
+ if payload.nil?
1070
+ if options[:tenants]
1071
+ #params['tenants'] = options[:tenants]
1072
+ params['tenants'] = options[:tenants].collect do |val|
1073
+ if val.to_s =~ /\A\d{1,}\Z/
1074
+ val.to_i
1075
+ else
1076
+ # todo: use /api/options/allTenants to avoid permission errors here..
1077
+ record = find_by_name_or_id(:account, val)
1078
+ if record.nil?
1079
+ exit 1 #return 1, "Tenant not found by '#{val}'"
1080
+ else
1081
+ record['id']
1082
+ end
1081
1083
  end
1082
1084
  end
1083
1085
  end
1084
- end
1085
- payload.deep_merge!({object_key => params})
1086
- if payload.empty? || payload[object_key].empty?
1087
- raise_command_error "Specify at least one option to update.\n#{optparse}"
1086
+ payload.deep_merge!({object_key => params})
1087
+ if payload.empty? || payload[object_key].empty?
1088
+ raise_command_error "Specify at least one option to update.\n#{optparse}"
1089
+ end
1088
1090
  end
1089
1091
  # make request
1090
1092
  @integrations_interface.setopts(options)
@@ -146,7 +146,7 @@ class Morpheus::Cli::KeyPairs
146
146
  optparse = Morpheus::Cli::OptionParser.new do |opts|
147
147
  opts.banner = subcommand_usage("[name] [options]")
148
148
  opts.on('', '--public-key-file FILENAME', "Public Key File" ) do |filename|
149
- if File.exists?(File.expand_path(filename))
149
+ if File.exist?(File.expand_path(filename))
150
150
  options['publicKey'] = File.read(File.expand_path(filename))
151
151
  options[:options] ||= {}
152
152
  options[:options]['publicKey'] = options['publicKey']
@@ -163,7 +163,7 @@ class Morpheus::Cli::KeyPairs
163
163
  end
164
164
 
165
165
  opts.on('', '--private-key-file FILENAME', "Private Key File" ) do |filename|
166
- if File.exists?(File.expand_path(filename))
166
+ if File.exist?(File.expand_path(filename))
167
167
  options['privateKey'] = File.read(File.expand_path(filename))
168
168
  options[:options] ||= {}
169
169
  options[:options]['privateKey'] = options['privateKey']
@@ -172,7 +172,7 @@ class Morpheus::Cli::LibraryContainerScriptsCommand
172
172
  end
173
173
  opts.on('--file FILE', "File containing the script. This can be used instead of --script" ) do |filename|
174
174
  full_filename = File.expand_path(filename)
175
- if File.exists?(full_filename)
175
+ if File.exist?(full_filename)
176
176
  params['script'] = File.read(full_filename)
177
177
  else
178
178
  print_red_alert "File not found: #{full_filename}"
@@ -266,7 +266,7 @@ class Morpheus::Cli::LibraryContainerScriptsCommand
266
266
  end
267
267
  opts.on('--file FILE', "File containing the script. This can be used instead of --script" ) do |filename|
268
268
  full_filename = File.expand_path(filename)
269
- if File.exists?(full_filename)
269
+ if File.exist?(full_filename)
270
270
  params['script'] = File.read(full_filename)
271
271
  else
272
272
  print_red_alert "File not found: #{full_filename}"
@@ -195,7 +195,7 @@ class Morpheus::Cli::LibraryContainerTemplatesCommand
195
195
  end
196
196
  opts.on('--file FILE', "File containing the template. This can be used instead of --template" ) do |filename|
197
197
  full_filename = File.expand_path(filename)
198
- if File.exists?(full_filename)
198
+ if File.exist?(full_filename)
199
199
  params['template'] = File.read(full_filename)
200
200
  else
201
201
  print_red_alert "File not found: #{full_filename}"
@@ -312,7 +312,7 @@ class Morpheus::Cli::LibraryContainerTemplatesCommand
312
312
  end
313
313
  opts.on('--file FILE', "File containing the template. This can be used instead of --template" ) do |filename|
314
314
  full_filename = File.expand_path(filename)
315
- if File.exists?(full_filename)
315
+ if File.exist?(full_filename)
316
316
  params['template'] = File.read(full_filename)
317
317
  else
318
318
  print_red_alert "File not found: #{full_filename}"
@@ -306,7 +306,7 @@ class Morpheus::Cli::LibraryInstanceTypesCommand
306
306
  params.deep_merge!(v_prompt)
307
307
  if params['logo']
308
308
  filename = File.expand_path(params['logo'])
309
- if !File.exists?(filename)
309
+ if !File.exist?(filename)
310
310
  print_red_alert "File not found: #{filename}"
311
311
  exit 1
312
312
  end
@@ -523,7 +523,7 @@ class Morpheus::Cli::LibraryInstanceTypesCommand
523
523
  logo_file = 'null' # clear it
524
524
  else
525
525
  filename = File.expand_path(filename)
526
- if !File.exists?(filename)
526
+ if !File.exist?(filename)
527
527
  print_red_alert "File not found: #{filename}"
528
528
  exit 1
529
529
  end
@@ -571,7 +571,7 @@ class Morpheus::Cli::LibraryInstanceTypesCommand
571
571
  dark_logo_file = 'null' # clear it
572
572
  else
573
573
  filename = File.expand_path(filename)
574
- if !File.exists?(filename)
574
+ if !File.exist?(filename)
575
575
  print_red_alert "File not found: #{filename}"
576
576
  exit 1
577
577
  end
@@ -207,7 +207,7 @@ class Morpheus::Cli::LibrarySpecTemplatesCommand
207
207
  opts.on('--file FILE', "File containing the template. This can be used instead of --content" ) do |filename|
208
208
  file_params['sourceType'] = 'local' if file_params['sourceType'].nil?
209
209
  full_filename = File.expand_path(filename)
210
- if File.exists?(full_filename)
210
+ if File.exist?(full_filename)
211
211
  file_params['content'] = File.read(full_filename)
212
212
  else
213
213
  print_red_alert "File not found: #{full_filename}"
@@ -363,7 +363,7 @@ class Morpheus::Cli::LibrarySpecTemplatesCommand
363
363
  opts.on('--file FILE', "File containing the template. This can be used instead of --content" ) do |filename|
364
364
  file_params['sourceType'] = 'local' if file_params['sourceType'].nil?
365
365
  full_filename = File.expand_path(filename)
366
- if File.exists?(full_filename)
366
+ if File.exist?(full_filename)
367
367
  file_params['content'] = File.read(full_filename)
368
368
  else
369
369
  print_red_alert "File not found: #{full_filename}"
@@ -33,7 +33,7 @@ class Morpheus::Cli::Login
33
33
  end
34
34
  opts.on( '--password-file FILE', String, "Password File, read a file containing the password." ) do |val|
35
35
  password_file = File.expand_path(val)
36
- if !File.exists?(password_file) || !File.file?(password_file) # check readable too
36
+ if !File.exist?(password_file) || !File.file?(password_file) # check readable too
37
37
  raise ::OptionParser::InvalidOption.new("File not found: #{password_file}")
38
38
  end
39
39
  password = File.read(password_file) #.to_s.split("\n").first.strip
@@ -8,12 +8,24 @@ class Morpheus::Cli::ManCommand
8
8
  # this should be read only anyway...
9
9
  @@default_editor = "less" # ENV['EDITOR']
10
10
 
11
+ def self.man_file_path
12
+ File.join(Morpheus::Cli.home_directory, "CLI-Manual-#{Morpheus::Cli::VERSION}.md")
13
+ end
14
+
11
15
  def handle(args)
12
16
  options = {}
13
17
  regenerate = false
14
- editor = @@default_editor
15
18
  open_as_link = false # true please
16
19
  goto_wiki = false
20
+ editor = @@default_editor
21
+ #todo: windows
22
+ if !$stdin.tty?
23
+ editor = "cat"
24
+ end
25
+ # no editor for windows atm
26
+ if Morpheus::Cli.windows?
27
+ open_as_link = true
28
+ end
17
29
  optparse = Morpheus::Cli::OptionParser.new do|opts|
18
30
  opts.banner = "Usage: morpheus man"
19
31
  opts.on('-w','--wiki', "Open the morpheus-cli wiki instead of the local man page") do
@@ -81,16 +93,16 @@ EOT
81
93
  print_error "#{red}It is the name of an existing directory.#{reset}\n"
82
94
  return 1
83
95
  end
84
- if File.exists?(fn) && options[:overwrite] != true
96
+ if File.exist?(fn) && options[:overwrite] != true
85
97
  print_error "#{red}Output file '#{fn}' already exists.#{reset}\n"
86
98
  print_error "#{red}Use --overwrite to overwrite the existing file.#{reset}\n"
87
99
  return 1
88
100
  end
89
101
  end
90
102
  exit_code, err = 0, nil
91
- if regenerate || !File.exists?(fn)
103
+ if regenerate || !File.exist?(fn)
92
104
  #Morpheus::Logging::DarkPrinter.puts "generating manual #{fn} ..." if Morpheus::Logging.debug? && !options[:quiet]
93
- exit_code, err = Morpheus::Cli::ManCommand.generate_manual(options)
105
+ exit_code, err = generate_manual(options)
94
106
  end
95
107
 
96
108
  if options[:quiet]
@@ -99,7 +111,7 @@ EOT
99
111
 
100
112
  Morpheus::Logging::DarkPrinter.puts "opening manual file #{fn}" if Morpheus::Logging.debug? && !options[:quiet]
101
113
 
102
- if open_as_link # not used atm
114
+ if open_as_link # windows only atm
103
115
  link = "file://#{fn}"
104
116
  if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
105
117
  system "start #{link}"
@@ -142,13 +154,9 @@ EOT
142
154
  return has_it
143
155
  end
144
156
 
145
- def self.man_file_path
146
- File.join(Morpheus::Cli.home_directory, "CLI-Manual-#{Morpheus::Cli::VERSION}.md")
147
- end
148
-
149
157
  # def self.save_manual(fn, content)
150
- # # fn = man_file_path()
151
- # if !Dir.exists?(File.dirname(fn))
158
+ # # fn = Morpheus::Cli::ManCommand.man_file_path
159
+ # if !Dir.exist?(File.dirname(fn))
152
160
  # FileUtils.mkdir_p(File.dirname(fn))
153
161
  # end
154
162
  # Morpheus::Logging::DarkPrinter.puts "saving manual to #{fn}" if Morpheus::Logging.debug?
@@ -156,19 +164,19 @@ EOT
156
164
  # FileUtils.chmod(0600, fn)
157
165
  # end
158
166
 
159
- def self.generate_manual(options={})
167
+ def generate_manual(options={})
160
168
  # todo: use pandoc or something else to convert the CLI-Manual.md to a man page
161
169
  # and install it, so the os command `man morpheus` will work too.
162
- fn = man_file_path()
170
+ fn = Morpheus::Cli::ManCommand.man_file_path
163
171
  if options[:outfile]
164
172
  fn = File.expand_path(options[:outfile])
165
- if File.exists?(fn) && options[:overwrite] != true
173
+ if File.exist?(fn) && options[:overwrite] != true
166
174
  print_error "#{red}Output file '#{options[:outfile]}' already exists.#{reset}\n"
167
175
  print_error "#{red}Use --overwrite to overwrite the existing file.#{reset}\n"
168
176
  return 1, "output file already exists"
169
177
  end
170
178
  end
171
- if !Dir.exists?(File.dirname(fn))
179
+ if !Dir.exist?(File.dirname(fn))
172
180
  FileUtils.mkdir_p(File.dirname(fn))
173
181
  end
174
182
  Morpheus::Logging::DarkPrinter.puts "generating manual #{fn}" if Morpheus::Logging.debug? && !options[:quiet]
@@ -202,7 +210,7 @@ EOT
202
210
 
203
211
  Use the command `#{prog_name} remote add` to connect to your Morpheus appliance.
204
212
 
205
- To learn more, visit https://github.com/gomorpheus/morpheus-cli/wiki/Getting-Started
213
+ To learn more, visit https://clidocs.morpheusdata.com
206
214
 
207
215
  To learn more about the Morpheus Appliance, visit https://www.morpheusdata.com
208
216
 
@@ -254,7 +262,11 @@ EOT
254
262
  The available commands and their options are documented below.
255
263
  ENDTEXT
256
264
 
257
- terminal = Morpheus::Terminal.new($stdin, manpage)
265
+
266
+ #terminal = Morpheus::Terminal.new($stdin, manpage)
267
+ terminal = my_terminal
268
+ terminal.with_stdout(manpage) do
269
+
258
270
  Morpheus::Logging::DarkPrinter.puts "appending command help `#{prog_name} --help`" if Morpheus::Logging.debug? && !options[:quiet]
259
271
 
260
272
  manpage.print "\n"
@@ -406,12 +418,14 @@ echo
406
418
  ```
407
419
 
408
420
  ENDTEXT
421
+
422
+ end # end with_stdout(manpage)
409
423
 
410
424
  ensure
411
425
  manpage.close if manpage
412
426
  # $stdout = previous_stdout if previous_stdout
413
427
  # this is needed to re-establish instance with STDOUT, STDIN
414
- terminal = Morpheus::Terminal.new()
428
+ #terminal = Morpheus::Terminal.new()
415
429
  end
416
430
 
417
431
  return 0, nil
@@ -386,7 +386,7 @@ class Morpheus::Cli::PackagesCommand
386
386
  puts_error "bad argument: [morpkg-file]\nFile '#{local_file_path}' is invalid.\n#{optparse}"
387
387
  return 1
388
388
  end
389
- if !File.exists?(local_file_path)
389
+ if !File.exist?(local_file_path)
390
390
  print_error Morpheus::Terminal.angry_prompt
391
391
  puts_error "bad argument: [morpkg-file]\nFile '#{local_file_path}' was not found.\n"
392
392
  return 1
@@ -545,7 +545,7 @@ class Morpheus::Cli::PackagesCommand
545
545
  end
546
546
  end
547
547
  outfile = File.expand_path(outfile)
548
- if Dir.exists?(outfile)
548
+ if Dir.exist?(outfile)
549
549
  puts_error "#{Morpheus::Terminal.angry_prompt}--file is invalid. It is the name of an existing directory: #{outfile}"
550
550
  return 1
551
551
  end
@@ -554,7 +554,7 @@ class Morpheus::Cli::PackagesCommand
554
554
  outfile << ".morpkg"
555
555
  end
556
556
  destination_dir = File.dirname(outfile)
557
- if !Dir.exists?(destination_dir)
557
+ if !Dir.exist?(destination_dir)
558
558
  if do_mkdir
559
559
  print cyan,"Creating local directory #{destination_dir}",reset,"\n"
560
560
  FileUtils.mkdir_p(destination_dir)
@@ -563,7 +563,7 @@ class Morpheus::Cli::PackagesCommand
563
563
  return 1
564
564
  end
565
565
  end
566
- if File.exists?(outfile)
566
+ if File.exist?(outfile)
567
567
  if do_overwrite
568
568
  # uhh need to be careful wih the passed filepath here..
569
569
  # don't delete, just overwrite.
@@ -598,7 +598,7 @@ class Morpheus::Cli::PackagesCommand
598
598
 
599
599
  if do_unzip
600
600
  package_dir = File.join(File.dirname(outfile), File.basename(outfile).sub(/\.morpkg\Z/, ''))
601
- if File.exists?(package_dir)
601
+ if File.exist?(package_dir)
602
602
  print cyan,"Deleting existing directory #{package_dir}",reset,"\n"
603
603
  FileUtils.rm_rf(package_dir)
604
604
  end
@@ -619,7 +619,7 @@ class Morpheus::Cli::PackagesCommand
619
619
  #response_body = (http_response.body.kind_of?(Net::ReadAdapter) ? "" : http_response.body)
620
620
  end
621
621
  # F it, just remove a bad result
622
- if File.exists?(outfile) && File.file?(outfile)
622
+ if File.exist?(outfile) && File.file?(outfile)
623
623
  Morpheus::Logging::DarkPrinter.puts "Deleting bad file download: #{outfile}" if Morpheus::Logging.debug?
624
624
  File.delete(outfile)
625
625
  end
@@ -687,7 +687,7 @@ class Morpheus::Cli::PackagesCommand
687
687
  begin
688
688
  # validate source
689
689
  source_directory = File.expand_path(source_directory)
690
- if !File.exists?(source_directory)
690
+ if !File.exist?(source_directory)
691
691
  puts_error "#{Morpheus::Terminal.angry_prompt}[source] is invalid. Directory not found: #{source_directory}"
692
692
  return 1
693
693
  end
@@ -718,7 +718,7 @@ class Morpheus::Cli::PackagesCommand
718
718
  else
719
719
  outfile = File.expand_path(outfile)
720
720
  end
721
- if Dir.exists?(outfile)
721
+ if Dir.exist?(outfile)
722
722
  puts_error "#{Morpheus::Terminal.angry_prompt}[target] is invalid. It is the name of an existing directory: #{outfile}"
723
723
  return 1
724
724
  end
@@ -727,7 +727,7 @@ class Morpheus::Cli::PackagesCommand
727
727
  outfile << ".morpkg"
728
728
  end
729
729
  destination_dir = File.dirname(outfile)
730
- if !Dir.exists?(destination_dir)
730
+ if !Dir.exist?(destination_dir)
731
731
  if do_mkdir
732
732
  print cyan,"Creating local directory #{destination_dir}",reset,"\n"
733
733
  FileUtils.mkdir_p(destination_dir)
@@ -736,7 +736,7 @@ class Morpheus::Cli::PackagesCommand
736
736
  return 1
737
737
  end
738
738
  end
739
- if File.exists?(outfile)
739
+ if File.exist?(outfile)
740
740
  if do_overwrite
741
741
  # uhh need to be careful wih the passed filepath here..
742
742
  # don't delete, just overwrite.
@@ -783,7 +783,7 @@ class Morpheus::Cli::PackagesCommand
783
783
  end
784
784
  end
785
785
  # F it, just remove a bad result
786
- # if File.exists?(outfile) && File.file?(outfile)
786
+ # if File.exist?(outfile) && File.file?(outfile)
787
787
  # Morpheus::Logging::DarkPrinter.puts "Deleting bad build file: #{outfile}" if Morpheus::Logging.debug?
788
788
  # File.delete(outfile)
789
789
  # end
@@ -30,7 +30,7 @@ EOT
30
30
  connect(options)
31
31
  filename = args[0]
32
32
  filename = File.expand_path(filename)
33
- if !File.exists?(filename)
33
+ if !File.exist?(filename)
34
34
  raise_command_error "File not found: #{filename}"
35
35
  elsif !File.file?(filename)
36
36
  raise_command_error "File is a directory: #{filename}"
@@ -334,7 +334,7 @@ class Morpheus::Cli::PoliciesCommand
334
334
  options['eachUser'] = val.to_s == 'on' || val.to_s == 'true' || val.to_s.empty?
335
335
  end
336
336
 
337
- opts.on('-t', '--type ID', "Policy Type Name or ID") do |val|
337
+ opts.on('-t', '--type ID', "Policy Type Name, Code or ID") do |val|
338
338
  options['type'] = val
339
339
  end
340
340
  opts.on('--name VALUE', String, "Name for this policy") do |val|
@@ -417,7 +417,7 @@ class Morpheus::Cli::PoliciesCommand
417
417
  print_red_alert "No available policy types found!"
418
418
  return 1
419
419
  end
420
- policy_types_dropdown = available_policy_types.collect {|it| {'name' => it['name'], 'value' => it['id']} }
420
+ policy_types_dropdown = available_policy_types.collect {|it| {'name' => it['name'], 'value' => it['code'], 'id' => it['id']} }
421
421
  policy_type_id = nil
422
422
  policy_type = nil
423
423
  if options['type']
@@ -497,7 +497,7 @@ class Morpheus::Cli::PoliciesCommand
497
497
  payload['policy']['config'] = options['config']
498
498
  elsif options['configFile']
499
499
  config_file = File.expand_path(options['configFile'])
500
- if !File.exists?(config_file) || !File.file?(config_file)
500
+ if !File.exist?(config_file) || !File.file?(config_file)
501
501
  print_red_alert "File not found: #{config_file}"
502
502
  return false
503
503
  end
@@ -637,7 +637,7 @@ class Morpheus::Cli::PoliciesCommand
637
637
  payload['policy']['config'] = options['config']
638
638
  elsif options['configFile']
639
639
  config_file = File.expand_path(options['configFile'])
640
- if !File.exists?(config_file) || !File.file?(config_file)
640
+ if !File.exist?(config_file) || !File.file?(config_file)
641
641
  print_red_alert "File not found: #{config_file}"
642
642
  return false
643
643
  end
@@ -172,7 +172,7 @@ class Morpheus::Cli::PreseedScriptsCommand
172
172
  params = Morpheus::Cli::OptionTypes.prompt(my_options, options[:options], @api_client, options[:params])
173
173
  script_file = params.delete('file')
174
174
  if script_file
175
- if !File.exists?(script_file)
175
+ if !File.exist?(script_file)
176
176
  print_red_alert "File not found: #{script_file}"
177
177
  return 1
178
178
  end
@@ -243,7 +243,7 @@ class Morpheus::Cli::PreseedScriptsCommand
243
243
  # params = Morpheus::Cli::OptionTypes.prompt(my_options, options[:options], @api_client, options[:params])
244
244
  script_file = params.delete('file')
245
245
  if script_file
246
- if !File.exists?(script_file)
246
+ if !File.exist?(script_file)
247
247
  print_red_alert "File not found: #{script_file}"
248
248
  return 1
249
249
  end
@@ -1512,7 +1512,7 @@ EOT
1512
1512
 
1513
1513
  def save_appliances(new_config)
1514
1514
  fn = appliances_file_path
1515
- if !Dir.exists?(File.dirname(fn))
1515
+ if !Dir.exist?(File.dirname(fn))
1516
1516
  FileUtils.mkdir_p(File.dirname(fn))
1517
1517
  end
1518
1518
  File.open(fn, 'w') {|f| f.write new_config.to_yaml } #Store
@@ -396,12 +396,12 @@ class Morpheus::Cli::ReportsCommand
396
396
  report_format = "csv"
397
397
  end
398
398
 
399
- if Dir.exists?(outfile)
399
+ if Dir.exist?(outfile)
400
400
  print_red_alert "[file] is invalid. It is the name of an existing directory: #{outfile}"
401
401
  return 1
402
402
  end
403
403
  destination_dir = File.dirname(outfile)
404
- if !Dir.exists?(destination_dir)
404
+ if !Dir.exist?(destination_dir)
405
405
  if do_mkdir
406
406
  print cyan,"Creating local directory #{destination_dir}",reset,"\n"
407
407
  FileUtils.mkdir_p(destination_dir)
@@ -410,7 +410,7 @@ class Morpheus::Cli::ReportsCommand
410
410
  return 1
411
411
  end
412
412
  end
413
- if File.exists?(outfile)
413
+ if File.exist?(outfile)
414
414
  if do_overwrite
415
415
  # uhh need to be careful wih the passed filepath here..
416
416
  # don't delete, just overwrite.
@@ -1156,7 +1156,7 @@ class Morpheus::Cli::SecurityGroups
1156
1156
 
1157
1157
  def self.save_security_group(new_config)
1158
1158
  fn = security_group_file_path
1159
- if !Dir.exists?(File.dirname(fn))
1159
+ if !Dir.exist?(File.dirname(fn))
1160
1160
  FileUtils.mkdir_p(File.dirname(fn))
1161
1161
  end
1162
1162
  File.open(fn, 'w') {|f| f.write new_config.to_yaml } #Store