morpheus-cli 5.5.2.1 → 5.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Dockerfile +1 -1
- data/README.md +57 -4
- data/Rakefile +9 -0
- data/bin/morpheus +4 -4
- data/lib/morpheus/api/api_client.rb +8 -2
- data/lib/morpheus/api/archive_buckets_interface.rb +1 -1
- data/lib/morpheus/api/archive_files_interface.rb +3 -3
- data/lib/morpheus/api/clients_interface.rb +2 -2
- data/lib/morpheus/api/clusters_interface.rb +8 -1
- data/lib/morpheus/api/containers_interface.rb +29 -16
- data/lib/morpheus/api/custom_instance_types_interface.rb +0 -2
- data/lib/morpheus/api/doc_interface.rb +8 -6
- data/lib/morpheus/api/file_copy_request_interface.rb +1 -1
- data/lib/morpheus/api/health_interface.rb +1 -1
- data/lib/morpheus/api/image_builder_interface.rb +3 -3
- data/lib/morpheus/api/instances_interface.rb +25 -0
- data/lib/morpheus/api/logs_interface.rb +2 -4
- data/lib/morpheus/api/monitoring_interface.rb +6 -6
- data/lib/morpheus/api/packages_interface.rb +1 -1
- data/lib/morpheus/api/reports_interface.rb +1 -1
- data/lib/morpheus/api/servers_interface.rb +9 -1
- data/lib/morpheus/api/storage_providers_interface.rb +2 -2
- data/lib/morpheus/api/virtual_images_interface.rb +1 -1
- data/lib/morpheus/api.rb +2 -0
- data/lib/morpheus/benchmarking.rb +1 -1
- data/lib/morpheus/cli/cli_command.rb +69 -36
- data/lib/morpheus/cli/cli_registry.rb +19 -10
- data/lib/morpheus/cli/commands/access_token_command.rb +1 -1
- data/lib/morpheus/cli/commands/apps.rb +1 -1
- data/lib/morpheus/cli/commands/archives_command.rb +25 -33
- data/lib/morpheus/cli/commands/blueprints_command.rb +10 -21
- data/lib/morpheus/cli/commands/boot_scripts_command.rb +2 -2
- data/lib/morpheus/cli/commands/cat_command.rb +1 -1
- data/lib/morpheus/cli/commands/catalog_item_types_command.rb +12 -12
- data/lib/morpheus/cli/commands/clouds.rb +3 -3
- data/lib/morpheus/cli/commands/clusters.rb +154 -3
- data/lib/morpheus/cli/commands/containers_command.rb +398 -253
- data/lib/morpheus/cli/commands/deployments.rb +1 -1
- data/lib/morpheus/cli/commands/deploys.rb +9 -9
- data/lib/morpheus/cli/commands/doc.rb +15 -16
- data/lib/morpheus/cli/commands/execution_request_command.rb +2 -2
- data/lib/morpheus/cli/commands/file_copy_request_command.rb +5 -5
- data/lib/morpheus/cli/commands/groups.rb +2 -2
- data/lib/morpheus/cli/commands/health_command.rb +4 -4
- data/lib/morpheus/cli/commands/hosts.rb +43 -5
- data/lib/morpheus/cli/commands/image_builder_command.rb +1 -1
- data/lib/morpheus/cli/commands/instances.rb +419 -148
- data/lib/morpheus/cli/commands/integrations_command.rb +22 -20
- data/lib/morpheus/cli/commands/key_pairs.rb +2 -2
- data/lib/morpheus/cli/commands/library_container_scripts_command.rb +2 -2
- data/lib/morpheus/cli/commands/library_container_templates_command.rb +2 -2
- data/lib/morpheus/cli/commands/library_instance_types_command.rb +3 -3
- data/lib/morpheus/cli/commands/library_spec_templates_command.rb +2 -2
- data/lib/morpheus/cli/commands/login.rb +1 -1
- data/lib/morpheus/cli/commands/man_command.rb +32 -18
- data/lib/morpheus/cli/commands/packages_command.rb +11 -11
- data/lib/morpheus/cli/commands/plugins.rb +1 -1
- data/lib/morpheus/cli/commands/policies_command.rb +4 -4
- data/lib/morpheus/cli/commands/preseed_scripts_command.rb +2 -2
- data/lib/morpheus/cli/commands/remote.rb +1 -1
- data/lib/morpheus/cli/commands/reports_command.rb +3 -3
- data/lib/morpheus/cli/commands/roles.rb +6 -3
- data/lib/morpheus/cli/commands/security_groups.rb +1 -1
- data/lib/morpheus/cli/commands/shell.rb +40 -62
- data/lib/morpheus/cli/commands/snapshots.rb +3 -5
- data/lib/morpheus/cli/commands/source_command.rb +8 -16
- data/lib/morpheus/cli/commands/storage_providers_command.rb +7 -7
- data/lib/morpheus/cli/commands/tasks.rb +2 -2
- data/lib/morpheus/cli/commands/vdi_pools_command.rb +6 -6
- data/lib/morpheus/cli/commands/view.rb +5 -1
- data/lib/morpheus/cli/commands/whitelabel_settings_command.rb +4 -4
- data/lib/morpheus/cli/commands/whoami.rb +2 -2
- data/lib/morpheus/cli/credentials.rb +30 -8
- data/lib/morpheus/cli/dot_file.rb +8 -15
- data/lib/morpheus/cli/error_handler.rb +16 -0
- data/lib/morpheus/cli/errors.rb +8 -1
- data/lib/morpheus/cli/mixins/print_helper.rb +17 -13
- data/lib/morpheus/cli/mixins/rest_command.rb +18 -18
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +12 -12
- data/lib/morpheus/cli/option_parser.rb +5 -1
- data/lib/morpheus/cli/option_types.rb +59 -12
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli.rb +26 -16
- data/lib/morpheus/ext/rest_client.rb +3 -2
- data/lib/morpheus/formatters.rb +1 -1
- data/lib/morpheus/logging.rb +4 -4
- data/lib/morpheus/morpkg.rb +4 -4
- data/lib/morpheus/rest_client.rb +2 -2
- data/lib/morpheus/routes.rb +2 -2
- data/lib/morpheus/terminal.rb +65 -16
- data/lib/morpheus.rb +1 -1
- data/morpheus-cli.gemspec +1 -0
- data/test/api/containers_interface_test.rb +68 -0
- data/test/api/doc_interface_test.rb +35 -0
- data/test/api/instances_interface_test.rb +22 -0
- data/test/api/whoami_interface_test.rb +14 -0
- data/test/cli/access_token_test.rb +36 -0
- data/test/cli/auth_test.rb +82 -0
- data/test/cli/cli_test.rb +48 -0
- data/test/cli/containers_test.rb +92 -0
- data/test/cli/doc_test.rb +35 -0
- data/test/cli/help_test.rb +25 -0
- data/test/cli/instances_test.rb +36 -0
- data/test/cli/man_test.rb +14 -0
- data/test/cli/remote_test.rb +89 -0
- data/test/cli/roles_test.rb +34 -0
- data/test/cli/shell_test.rb +81 -0
- data/test/cli/version_test.rb +23 -0
- data/test/cli/view_test.rb +55 -0
- data/test/cli/whoami_test.rb +17 -0
- data/test/morpheus_test.rb +16 -0
- data/test/test_case.rb +338 -0
- data/test/test_config.rb +137 -0
- data/test/test_data_helper.rb +97 -0
- metadata +61 -3
|
@@ -661,7 +661,7 @@ EOT
|
|
|
661
661
|
Dir.chdir(base_working_dir)
|
|
662
662
|
fmap = nil
|
|
663
663
|
full_file_pattern = File.expand_path(file_pattern)
|
|
664
|
-
if File.
|
|
664
|
+
if File.exist?(full_file_pattern)
|
|
665
665
|
if File.directory?(full_file_pattern)
|
|
666
666
|
fmap = {'path' => full_file_pattern, 'pattern' => '**/*'}
|
|
667
667
|
else
|
|
@@ -121,7 +121,7 @@ EOT
|
|
|
121
121
|
config_map = parse_result[:data]
|
|
122
122
|
if config_map.nil?
|
|
123
123
|
# todo: bubble up JSON.parse error message
|
|
124
|
-
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:
|
|
124
|
+
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:error]}"
|
|
125
125
|
else
|
|
126
126
|
params['config'] = config_map
|
|
127
127
|
options[:options]['config'] = params['config'] # or file_content
|
|
@@ -131,7 +131,7 @@ EOT
|
|
|
131
131
|
options[:config_file] = val.to_s
|
|
132
132
|
file_content = nil
|
|
133
133
|
full_filename = File.expand_path(options[:config_file])
|
|
134
|
-
if File.
|
|
134
|
+
if File.exist?(full_filename)
|
|
135
135
|
file_content = File.read(full_filename)
|
|
136
136
|
else
|
|
137
137
|
print_red_alert "File not found: #{full_filename}"
|
|
@@ -141,7 +141,7 @@ EOT
|
|
|
141
141
|
config_map = parse_result[:data]
|
|
142
142
|
if config_map.nil?
|
|
143
143
|
# todo: bubble up JSON.parse error message
|
|
144
|
-
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:
|
|
144
|
+
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:error]}"
|
|
145
145
|
#raise_command_error "Failed to parse config as valid YAML or JSON."
|
|
146
146
|
else
|
|
147
147
|
params['config'] = config_map
|
|
@@ -215,7 +215,7 @@ EOT
|
|
|
215
215
|
config_map = parse_result[:data]
|
|
216
216
|
if config_map.nil?
|
|
217
217
|
# todo: bubble up JSON.parse error message
|
|
218
|
-
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:
|
|
218
|
+
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:error]}"
|
|
219
219
|
else
|
|
220
220
|
params['config'] = config_map
|
|
221
221
|
options[:options]['config'] = params['config'] # or file_content
|
|
@@ -225,7 +225,7 @@ EOT
|
|
|
225
225
|
options[:config_file] = val.to_s
|
|
226
226
|
file_content = nil
|
|
227
227
|
full_filename = File.expand_path(options[:config_file])
|
|
228
|
-
if File.
|
|
228
|
+
if File.exist?(full_filename)
|
|
229
229
|
file_content = File.read(full_filename)
|
|
230
230
|
else
|
|
231
231
|
print_red_alert "File not found: #{full_filename}"
|
|
@@ -235,7 +235,7 @@ EOT
|
|
|
235
235
|
config_map = parse_result[:data]
|
|
236
236
|
if config_map.nil?
|
|
237
237
|
# todo: bubble up JSON.parse error message
|
|
238
|
-
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:
|
|
238
|
+
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:error]}"
|
|
239
239
|
#raise_command_error "Failed to parse config as valid YAML or JSON."
|
|
240
240
|
else
|
|
241
241
|
params['config'] = config_map
|
|
@@ -329,7 +329,7 @@ EOT
|
|
|
329
329
|
config_map = parse_result[:data]
|
|
330
330
|
if config_map.nil?
|
|
331
331
|
# todo: bubble up JSON.parse error message
|
|
332
|
-
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:
|
|
332
|
+
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:error]}"
|
|
333
333
|
else
|
|
334
334
|
params['config'] = config_map
|
|
335
335
|
options[:options]['config'] = params['config'] # or file_content
|
|
@@ -339,7 +339,7 @@ EOT
|
|
|
339
339
|
options[:config_file] = val.to_s
|
|
340
340
|
file_content = nil
|
|
341
341
|
full_filename = File.expand_path(options[:config_file])
|
|
342
|
-
if File.
|
|
342
|
+
if File.exist?(full_filename)
|
|
343
343
|
file_content = File.read(full_filename)
|
|
344
344
|
else
|
|
345
345
|
print_red_alert "File not found: #{full_filename}"
|
|
@@ -349,7 +349,7 @@ EOT
|
|
|
349
349
|
config_map = parse_result[:data]
|
|
350
350
|
if config_map.nil?
|
|
351
351
|
# todo: bubble up JSON.parse error message
|
|
352
|
-
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:
|
|
352
|
+
raise_command_error "Failed to parse config as YAML or JSON. Error: #{parse_result[:error]}"
|
|
353
353
|
#raise_command_error "Failed to parse config as valid YAML or JSON."
|
|
354
354
|
else
|
|
355
355
|
params['config'] = config_map
|
|
@@ -6,10 +6,9 @@ class Morpheus::Cli::Doc
|
|
|
6
6
|
include Morpheus::Cli::CliCommand
|
|
7
7
|
|
|
8
8
|
set_command_name :'doc'
|
|
9
|
-
#set_command_name :'access'
|
|
10
9
|
register_subcommands :list
|
|
11
|
-
register_subcommands :get => :
|
|
12
|
-
register_subcommands :download => :
|
|
10
|
+
register_subcommands :get => :openapi
|
|
11
|
+
register_subcommands :download => :download_openapi
|
|
13
12
|
|
|
14
13
|
# hidden until doc complete (or close to it)
|
|
15
14
|
set_command_hidden
|
|
@@ -68,12 +67,12 @@ EOT
|
|
|
68
67
|
return exit_code, err
|
|
69
68
|
end
|
|
70
69
|
|
|
71
|
-
def
|
|
70
|
+
def openapi(args)
|
|
72
71
|
exit_code, err = 0, nil
|
|
73
72
|
params, options = {}, {}
|
|
74
73
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
75
74
|
opts.banner = subcommand_usage()
|
|
76
|
-
opts.on(nil, "--refresh", "Refresh the document. By default the
|
|
75
|
+
opts.on(nil, "--refresh", "Refresh the document. By default the openapi.yml and openapi.json are cached by the server.") do
|
|
77
76
|
params['refresh'] = true
|
|
78
77
|
end
|
|
79
78
|
opts.on('-g', '--generate', "Alias for --refresh") do
|
|
@@ -81,7 +80,7 @@ EOT
|
|
|
81
80
|
end
|
|
82
81
|
build_standard_get_options(opts, options, [], [:csv])
|
|
83
82
|
opts.footer = <<-EOT
|
|
84
|
-
Print the Morpheus API
|
|
83
|
+
Print the Morpheus API OpenAPI Documentation (swagger).
|
|
85
84
|
The default format is JSON. Supports json or yaml.
|
|
86
85
|
EOT
|
|
87
86
|
end
|
|
@@ -97,13 +96,13 @@ EOT
|
|
|
97
96
|
@doc_interface.setopts(options)
|
|
98
97
|
if options[:dry_run]
|
|
99
98
|
params['format'] = openapi_format
|
|
100
|
-
print_dry_run @doc_interface.dry.
|
|
99
|
+
print_dry_run @doc_interface.dry.openapi(params)
|
|
101
100
|
return 0, nil
|
|
102
101
|
end
|
|
103
|
-
json_response = @doc_interface.
|
|
102
|
+
json_response = @doc_interface.openapi(params)
|
|
104
103
|
# default format is to print header and json
|
|
105
104
|
render_response(json_response, options) do
|
|
106
|
-
title = "Morpheus API
|
|
105
|
+
title = "Morpheus API openapi.#{openapi_format}"
|
|
107
106
|
print_h1 title, options
|
|
108
107
|
print cyan
|
|
109
108
|
print as_json(json_response, options)
|
|
@@ -112,7 +111,7 @@ EOT
|
|
|
112
111
|
return exit_code, err
|
|
113
112
|
end
|
|
114
113
|
|
|
115
|
-
def
|
|
114
|
+
def download_openapi(args)
|
|
116
115
|
exit_code, err = 0, nil
|
|
117
116
|
params, options = {}, {}
|
|
118
117
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
@@ -122,7 +121,7 @@ EOT
|
|
|
122
121
|
options[:yaml] = true
|
|
123
122
|
options[:format] = :yaml
|
|
124
123
|
end
|
|
125
|
-
opts.on(nil, "--refresh", "Refresh the document. By default the
|
|
124
|
+
opts.on(nil, "--refresh", "Refresh the document. By default the openapi.yml and openapi.json are cached by the server.") do
|
|
126
125
|
params['refresh'] = true
|
|
127
126
|
end
|
|
128
127
|
opts.on('-g', '--generate', "Alias for --refresh") do
|
|
@@ -136,7 +135,7 @@ EOT
|
|
|
136
135
|
end
|
|
137
136
|
build_common_options(opts, options, [:dry_run, :quiet, :remote])
|
|
138
137
|
opts.footer = <<-EOT
|
|
139
|
-
Download the Morpheus API
|
|
138
|
+
Download the Morpheus API OpenAPI Documentation (swagger).
|
|
140
139
|
[local-file] is required. This is the full local filepath for the downloaded file.
|
|
141
140
|
The default format is JSON. Supports json or yaml.
|
|
142
141
|
EOT
|
|
@@ -159,17 +158,17 @@ EOT
|
|
|
159
158
|
# execute the api request
|
|
160
159
|
@doc_interface.setopts(options)
|
|
161
160
|
if options[:dry_run]
|
|
162
|
-
print_dry_run @doc_interface.dry.
|
|
161
|
+
print_dry_run @doc_interface.dry.download_openapi(outfile, params)
|
|
163
162
|
return 0, nil
|
|
164
163
|
end
|
|
165
|
-
print cyan + "Downloading
|
|
166
|
-
http_response = @doc_interface.
|
|
164
|
+
print cyan + "Downloading openapi.#{openapi_format} to #{outfile} ... " if !options[:quiet]
|
|
165
|
+
http_response = @doc_interface.download_openapi(outfile, params)
|
|
167
166
|
if http_response.code.to_i == 200
|
|
168
167
|
print green + "SUCCESS" + reset + "\n" if !options[:quiet]
|
|
169
168
|
return 0, nil
|
|
170
169
|
else
|
|
171
170
|
print red + "ERROR" + reset + " HTTP #{http_response.code}" + "\n" if !options[:quiet]
|
|
172
|
-
if File.
|
|
171
|
+
if File.exist?(outfile) && File.file?(outfile)
|
|
173
172
|
Morpheus::Logging::DarkPrinter.puts "Deleting bad file download: #{outfile}" if Morpheus::Logging.debug?
|
|
174
173
|
File.delete(outfile)
|
|
175
174
|
end
|
|
@@ -161,7 +161,7 @@ class Morpheus::Cli::ExecutionRequestCommand
|
|
|
161
161
|
end
|
|
162
162
|
opts.on('--file FILE', "File containing the script. This can be used instead of --script" ) do |filename|
|
|
163
163
|
full_filename = File.expand_path(filename)
|
|
164
|
-
if File.
|
|
164
|
+
if File.exist?(full_filename)
|
|
165
165
|
script_content = File.read(full_filename)
|
|
166
166
|
else
|
|
167
167
|
print_red_alert "File not found: #{full_filename}"
|
|
@@ -249,7 +249,7 @@ class Morpheus::Cli::ExecutionRequestCommand
|
|
|
249
249
|
end
|
|
250
250
|
opts.on('--file FILE', "File containing the script. This can be used instead of --script" ) do |filename|
|
|
251
251
|
full_filename = File.expand_path(filename)
|
|
252
|
-
if File.
|
|
252
|
+
if File.exist?(full_filename)
|
|
253
253
|
script_content = File.read(full_filename)
|
|
254
254
|
else
|
|
255
255
|
print_red_alert "File not found: #{full_filename}"
|
|
@@ -190,7 +190,7 @@ class Morpheus::Cli::FileCopyRequestCommand
|
|
|
190
190
|
filename = v_prompt['file']
|
|
191
191
|
end
|
|
192
192
|
full_filename = File.expand_path(filename)
|
|
193
|
-
if !File.
|
|
193
|
+
if !File.exist?(full_filename)
|
|
194
194
|
print_red_alert "File not found: #{full_filename}"
|
|
195
195
|
return 1
|
|
196
196
|
end
|
|
@@ -266,12 +266,12 @@ class Morpheus::Cli::FileCopyRequestCommand
|
|
|
266
266
|
filename = args[1]
|
|
267
267
|
end
|
|
268
268
|
outfile = File.expand_path(filename)
|
|
269
|
-
if Dir.
|
|
269
|
+
if Dir.exist?(outfile)
|
|
270
270
|
print_red_alert "[file] is invalid. It is the name of an existing directory: #{outfile}"
|
|
271
271
|
return 1
|
|
272
272
|
end
|
|
273
273
|
destination_dir = File.dirname(outfile)
|
|
274
|
-
if !Dir.
|
|
274
|
+
if !Dir.exist?(destination_dir)
|
|
275
275
|
if do_mkdir
|
|
276
276
|
print cyan,"Creating local directory #{destination_dir}",reset,"\n"
|
|
277
277
|
FileUtils.mkdir_p(destination_dir)
|
|
@@ -280,7 +280,7 @@ class Morpheus::Cli::FileCopyRequestCommand
|
|
|
280
280
|
return 1
|
|
281
281
|
end
|
|
282
282
|
end
|
|
283
|
-
if File.
|
|
283
|
+
if File.exist?(outfile)
|
|
284
284
|
if do_overwrite
|
|
285
285
|
# uhh need to be careful wih the passed filepath here..
|
|
286
286
|
# don't delete, just overwrite.
|
|
@@ -320,7 +320,7 @@ class Morpheus::Cli::FileCopyRequestCommand
|
|
|
320
320
|
print red + "ERROR" + reset + " HTTP #{http_response.code}" + "\n"
|
|
321
321
|
end
|
|
322
322
|
# F it, just remove a bad result
|
|
323
|
-
if File.
|
|
323
|
+
if File.exist?(outfile) && File.file?(outfile)
|
|
324
324
|
Morpheus::Logging::DarkPrinter.puts "Deleting bad file download: #{outfile}" if Morpheus::Logging.debug?
|
|
325
325
|
File.delete(outfile)
|
|
326
326
|
end
|
|
@@ -559,7 +559,7 @@ EOT
|
|
|
559
559
|
build_option_type_options(opts, options, update_wiki_page_option_types)
|
|
560
560
|
opts.on('--file FILE', "File containing the wiki content. This can be used instead of --content") do |filename|
|
|
561
561
|
full_filename = File.expand_path(filename)
|
|
562
|
-
if File.
|
|
562
|
+
if File.exist?(full_filename)
|
|
563
563
|
params['content'] = File.read(full_filename)
|
|
564
564
|
else
|
|
565
565
|
print_red_alert "File not found: #{full_filename}"
|
|
@@ -732,7 +732,7 @@ public
|
|
|
732
732
|
|
|
733
733
|
def save_groups(groups_map)
|
|
734
734
|
fn = groups_file_path
|
|
735
|
-
if !Dir.
|
|
735
|
+
if !Dir.exist?(File.dirname(fn))
|
|
736
736
|
FileUtils.mkdir_p(File.dirname(fn))
|
|
737
737
|
end
|
|
738
738
|
File.open(fn, 'w') {|f| f.write groups_map.to_yaml } #Store
|
|
@@ -610,11 +610,11 @@ class Morpheus::Cli::HealthCommand
|
|
|
610
610
|
outfile = args[0]
|
|
611
611
|
outfile = File.expand_path(outfile)
|
|
612
612
|
|
|
613
|
-
if Dir.
|
|
613
|
+
if Dir.exist?(outfile)
|
|
614
614
|
raise_command_error("[file] is invalid. It is the name of an existing directory: #{outfile}", args, optparse)
|
|
615
615
|
end
|
|
616
616
|
destination_dir = File.dirname(outfile)
|
|
617
|
-
if !Dir.
|
|
617
|
+
if !Dir.exist?(destination_dir)
|
|
618
618
|
if do_mkdir
|
|
619
619
|
print cyan,"Creating local directory #{destination_dir}",reset,"\n"
|
|
620
620
|
FileUtils.mkdir_p(destination_dir)
|
|
@@ -622,7 +622,7 @@ class Morpheus::Cli::HealthCommand
|
|
|
622
622
|
raise_command_error("[file] is invalid. Directory not found: #{destination_dir}", args, optparse)
|
|
623
623
|
end
|
|
624
624
|
end
|
|
625
|
-
if File.
|
|
625
|
+
if File.exist?(outfile)
|
|
626
626
|
if do_overwrite
|
|
627
627
|
# uhh need to be careful wih the passed filepath here..
|
|
628
628
|
# don't delete, just overwrite.
|
|
@@ -654,7 +654,7 @@ class Morpheus::Cli::HealthCommand
|
|
|
654
654
|
print red + "ERROR" + reset + " HTTP #{http_response.code}" + "\n"
|
|
655
655
|
end
|
|
656
656
|
# F it, just remove a bad result
|
|
657
|
-
if File.
|
|
657
|
+
if File.exist?(outfile) && File.file?(outfile)
|
|
658
658
|
Morpheus::Logging::DarkPrinter.puts "Deleting bad file download: #{outfile}" if Morpheus::Logging.debug?
|
|
659
659
|
File.delete(outfile)
|
|
660
660
|
end
|
|
@@ -7,7 +7,7 @@ class Morpheus::Cli::Hosts
|
|
|
7
7
|
include Morpheus::Cli::LogsHelper
|
|
8
8
|
set_command_name :hosts
|
|
9
9
|
set_command_description "View and manage hosts (servers)."
|
|
10
|
-
register_subcommands :list, :count, :get, :view, :stats, :add, :update, :remove, :logs, :start, :stop, :resize,
|
|
10
|
+
register_subcommands :list, :count, :get, :view, :stats, :add, :update, :remove, :logs, :start, :stop, :resize, :restart,
|
|
11
11
|
:run_workflow, :make_managed, :upgrade_agent, :snapshots, :software, :software_sync, :update_network_label,
|
|
12
12
|
{:'types' => :list_types},
|
|
13
13
|
{:exec => :execution_request},
|
|
@@ -1243,6 +1243,44 @@ class Morpheus::Cli::Hosts
|
|
|
1243
1243
|
end
|
|
1244
1244
|
end
|
|
1245
1245
|
|
|
1246
|
+
def restart(args)
|
|
1247
|
+
options = {}
|
|
1248
|
+
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
1249
|
+
opts.banner = subcommand_usage("[name]")
|
|
1250
|
+
build_common_options(opts, options, [:auto_confirm, :quiet, :json, :dry_run, :remote])
|
|
1251
|
+
opts.footer = "Restart a host.\n" +
|
|
1252
|
+
"[name] is required. This is the name or id of a host."
|
|
1253
|
+
end
|
|
1254
|
+
optparse.parse!(args)
|
|
1255
|
+
if args.count < 1
|
|
1256
|
+
puts optparse
|
|
1257
|
+
exit 1
|
|
1258
|
+
end
|
|
1259
|
+
connect(options)
|
|
1260
|
+
begin
|
|
1261
|
+
server = find_host_by_name_or_id(args[0])
|
|
1262
|
+
unless options[:yes] || ::Morpheus::Cli::OptionTypes::confirm("Are you sure you would like to restart the server '#{server['name']}'?", options)
|
|
1263
|
+
exit 1
|
|
1264
|
+
end
|
|
1265
|
+
@servers_interface.setopts(options)
|
|
1266
|
+
if options[:dry_run]
|
|
1267
|
+
print_dry_run @servers_interface.dry.restart(server['id'])
|
|
1268
|
+
return
|
|
1269
|
+
end
|
|
1270
|
+
json_response = @servers_interface.restart(server['id'])
|
|
1271
|
+
if options[:json]
|
|
1272
|
+
print JSON.pretty_generate(json_response)
|
|
1273
|
+
print "\n"
|
|
1274
|
+
elsif !options[:quiet]
|
|
1275
|
+
print_green_success "Restarting #{server["name"]}"
|
|
1276
|
+
end
|
|
1277
|
+
rescue RestClient::Exception => e
|
|
1278
|
+
print_rest_exception(e, options)
|
|
1279
|
+
exit 1
|
|
1280
|
+
end
|
|
1281
|
+
end
|
|
1282
|
+
|
|
1283
|
+
|
|
1246
1284
|
def resize(args)
|
|
1247
1285
|
options = {}
|
|
1248
1286
|
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
|
@@ -1280,7 +1318,7 @@ class Morpheus::Cli::Hosts
|
|
|
1280
1318
|
end
|
|
1281
1319
|
|
|
1282
1320
|
# prompt for service plan
|
|
1283
|
-
service_plans_json = @servers_interface.service_plans({zoneId: cloud_id, serverTypeId: server_type_id})
|
|
1321
|
+
service_plans_json = @servers_interface.service_plans({zoneId: cloud_id, serverTypeId: server_type_id, serverId: server['id']})
|
|
1284
1322
|
service_plans = service_plans_json["plans"]
|
|
1285
1323
|
service_plans_dropdown = service_plans.collect {|sp| {'name' => sp["name"], 'value' => sp["id"]} } # already sorted
|
|
1286
1324
|
service_plans_dropdown.each do |plan|
|
|
@@ -1288,7 +1326,7 @@ class Morpheus::Cli::Hosts
|
|
|
1288
1326
|
plan['name'] = "#{plan['name']} (current)"
|
|
1289
1327
|
end
|
|
1290
1328
|
end
|
|
1291
|
-
plan_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'plan', 'type' => 'select', 'fieldLabel' => 'Plan', 'selectOptions' => service_plans_dropdown, 'required' => true, 'description' => 'Choose the appropriately sized plan for this server'}],options[:options])
|
|
1329
|
+
plan_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'plan', 'type' => 'select', 'fieldLabel' => 'Plan', 'selectOptions' => service_plans_dropdown, 'required' => true, 'defaultValue' => plan_id, 'description' => 'Choose the appropriately sized plan for this server'}],options[:options])
|
|
1292
1330
|
service_plan = service_plans.find {|sp| sp["id"] == plan_prompt['plan'].to_i }
|
|
1293
1331
|
payload[:server][:plan] = {id: service_plan["id"]}
|
|
1294
1332
|
|
|
@@ -1550,7 +1588,7 @@ class Morpheus::Cli::Hosts
|
|
|
1550
1588
|
end
|
|
1551
1589
|
opts.on('--file FILE', "File containing the script. This can be used instead of --script" ) do |filename|
|
|
1552
1590
|
full_filename = File.expand_path(filename)
|
|
1553
|
-
if File.
|
|
1591
|
+
if File.exist?(full_filename)
|
|
1554
1592
|
script_content = File.read(full_filename)
|
|
1555
1593
|
else
|
|
1556
1594
|
print_red_alert "File not found: #{full_filename}"
|
|
@@ -1883,7 +1921,7 @@ class Morpheus::Cli::Hosts
|
|
|
1883
1921
|
build_option_type_options(opts, options, update_wiki_page_option_types)
|
|
1884
1922
|
opts.on('--file FILE', "File containing the wiki content. This can be used instead of --content") do |filename|
|
|
1885
1923
|
full_filename = File.expand_path(filename)
|
|
1886
|
-
if File.
|
|
1924
|
+
if File.exist?(full_filename)
|
|
1887
1925
|
params['content'] = File.read(full_filename)
|
|
1888
1926
|
else
|
|
1889
1927
|
print_red_alert "File not found: #{full_filename}"
|
|
@@ -972,7 +972,7 @@ class Morpheus::Cli::ImageBuilderCommand
|
|
|
972
972
|
payload['config'] = options['config']
|
|
973
973
|
elsif options['configFile']
|
|
974
974
|
config_file = File.expand_path(options['configFile'])
|
|
975
|
-
if !File.
|
|
975
|
+
if !File.exist?(config_file) || !File.file?(config_file)
|
|
976
976
|
print_red_alert "File not found: #{config_file}"
|
|
977
977
|
return false
|
|
978
978
|
end
|