morpheus-cli 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +1 -1
- data/lib/morpheus/api/api_client.rb +12 -0
- data/lib/morpheus/api/billing_interface.rb +1 -0
- data/lib/morpheus/api/deploy_interface.rb +1 -1
- data/lib/morpheus/api/deployments_interface.rb +20 -1
- data/lib/morpheus/api/forgot_password_interface.rb +17 -0
- data/lib/morpheus/api/instances_interface.rb +7 -0
- data/lib/morpheus/api/search_interface.rb +13 -0
- data/lib/morpheus/api/servers_interface.rb +7 -0
- data/lib/morpheus/api/usage_interface.rb +18 -0
- data/lib/morpheus/cli.rb +4 -1
- data/lib/morpheus/cli/cli_command.rb +26 -9
- data/lib/morpheus/cli/commands/standard/curl_command.rb +3 -5
- data/lib/morpheus/cli/commands/standard/history_command.rb +3 -1
- data/lib/morpheus/cli/commands/standard/man_command.rb +74 -40
- data/lib/morpheus/cli/deploy.rb +199 -90
- data/lib/morpheus/cli/deployments.rb +341 -28
- data/lib/morpheus/cli/deploys.rb +206 -41
- data/lib/morpheus/cli/error_handler.rb +7 -0
- data/lib/morpheus/cli/forgot_password.rb +133 -0
- data/lib/morpheus/cli/health_command.rb +2 -2
- data/lib/morpheus/cli/hosts.rb +169 -32
- data/lib/morpheus/cli/instances.rb +83 -32
- data/lib/morpheus/cli/invoices_command.rb +33 -16
- data/lib/morpheus/cli/logs_command.rb +9 -6
- data/lib/morpheus/cli/mixins/deployments_helper.rb +31 -2
- data/lib/morpheus/cli/mixins/print_helper.rb +0 -21
- data/lib/morpheus/cli/mixins/provisioning_helper.rb +24 -4
- data/lib/morpheus/cli/option_types.rb +266 -17
- data/lib/morpheus/cli/remote.rb +35 -10
- data/lib/morpheus/cli/reports_command.rb +99 -30
- data/lib/morpheus/cli/search_command.rb +182 -0
- data/lib/morpheus/cli/setup.rb +1 -1
- data/lib/morpheus/cli/shell.rb +33 -11
- data/lib/morpheus/cli/tasks.rb +20 -21
- data/lib/morpheus/cli/usage_command.rb +64 -11
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/virtual_images.rb +280 -199
- data/lib/morpheus/cli/whoami.rb +6 -6
- data/lib/morpheus/cli/workflows.rb +33 -40
- data/lib/morpheus/formatters.rb +22 -0
- data/lib/morpheus/terminal.rb +6 -2
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30d7a10e197c41b49f453d0d43fa28027e8759e8a889b531045626b0ad2157f8
|
4
|
+
data.tar.gz: f5bc8ef27e0c29feb0fbd9005ce7d013746ecdf005c92a049ff7537301c1fcbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 616bb0355ed1a3a6c07f26a8e6aa291cb99f7208f754c94146d8ac08ffc735c7231c081fd4e56bf0c6490c2a0931e10995332023e46f66314213c3af0e5e8545
|
7
|
+
data.tar.gz: ae11e6b85aa13a6349dc54e6d9421cbe9cde6071332de409570e6796dd2a09da3d932c349652de6adfe5321c88816f066c25aeebc651e6a63bd9106cddde15a3
|
data/Dockerfile
CHANGED
@@ -342,10 +342,18 @@ class Morpheus::APIClient
|
|
342
342
|
Morpheus::AuthInterface.new({url: @base_url, client_id: @client_id}).setopts(@options)
|
343
343
|
end
|
344
344
|
|
345
|
+
def forgot
|
346
|
+
Morpheus::ForgotPasswordInterface.new(common_interface_options).setopts(@options)
|
347
|
+
end
|
348
|
+
|
345
349
|
def whoami
|
346
350
|
Morpheus::WhoamiInterface.new(common_interface_options).setopts(@options)
|
347
351
|
end
|
348
352
|
|
353
|
+
def search
|
354
|
+
Morpheus::SearchInterface.new(common_interface_options).setopts(@options)
|
355
|
+
end
|
356
|
+
|
349
357
|
def user_settings
|
350
358
|
Morpheus::UserSettingsInterface.new(common_interface_options).setopts(@options)
|
351
359
|
end
|
@@ -768,6 +776,10 @@ class Morpheus::APIClient
|
|
768
776
|
Morpheus::CatalogItemTypesInterface.new(common_interface_options).setopts(@options)
|
769
777
|
end
|
770
778
|
|
779
|
+
def usage
|
780
|
+
Morpheus::UsageInterface.new(common_interface_options).setopts(@options)
|
781
|
+
end
|
782
|
+
|
771
783
|
def billing
|
772
784
|
Morpheus::BillingInterface.new(common_interface_options).setopts(@options)
|
773
785
|
end
|
@@ -18,7 +18,7 @@ class Morpheus::DeployInterface < Morpheus::APIClient
|
|
18
18
|
execute(method: :get, url: "#{base_path}", params: params)
|
19
19
|
end
|
20
20
|
|
21
|
-
def get(
|
21
|
+
def get(id, params={})
|
22
22
|
validate_id!(id)
|
23
23
|
execute(method: :get, url: "#{base_path}/#{id}", params: params)
|
24
24
|
end
|
@@ -40,7 +40,8 @@ class Morpheus::DeploymentsInterface < Morpheus::RestInterface
|
|
40
40
|
if destination.empty? || destination == "/" || destination == "." || destination.include?("../")
|
41
41
|
raise "#{self.class}.upload_file() passed a bad destination: '#{destination}'"
|
42
42
|
end
|
43
|
-
url = "#{@base_url}/#{base_path}/#{deployment_id}/versions/#{id}/files"
|
43
|
+
# url = "#{@base_url}/#{base_path}/#{deployment_id}/versions/#{id}/files"
|
44
|
+
url = "#{base_path}/#{deployment_id}/versions/#{id}/files"
|
44
45
|
if !destination.to_s.empty?
|
45
46
|
url += "/#{destination}"
|
46
47
|
end
|
@@ -57,4 +58,22 @@ class Morpheus::DeploymentsInterface < Morpheus::RestInterface
|
|
57
58
|
execute(method: :post, url: url, headers: headers, payload: payload, params: params, timeout: 172800)
|
58
59
|
end
|
59
60
|
|
61
|
+
# upload a file without multipart
|
62
|
+
# local_file is the full absolute local filename
|
63
|
+
# destination should be the full remote file path, including the file name.
|
64
|
+
def destroy_file(deployment_id, id, destination, params={})
|
65
|
+
if destination.empty? || destination == "/" || destination == "." || destination.include?("../")
|
66
|
+
raise "#{self.class}.upload_file() passed a bad destination: '#{destination}'"
|
67
|
+
end
|
68
|
+
# url = "#{@base_url}/#{base_path}/#{deployment_id}/versions/#{id}/files"
|
69
|
+
url = "#{base_path}/#{deployment_id}/versions/#{id}/files"
|
70
|
+
if !destination.to_s.empty?
|
71
|
+
url += "/#{destination}"
|
72
|
+
end
|
73
|
+
# use URI to escape path
|
74
|
+
uri = URI.parse(url)
|
75
|
+
url = uri.path
|
76
|
+
execute(method: :delete, url: url, params: params)
|
77
|
+
end
|
78
|
+
|
60
79
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
# There is no Authorization required for this API.
|
3
|
+
class Morpheus::ForgotPasswordInterface < Morpheus::APIClient
|
4
|
+
|
5
|
+
def authorization_required?
|
6
|
+
false
|
7
|
+
end
|
8
|
+
|
9
|
+
def send_email(payload, params={})
|
10
|
+
execute(method: :post, url: "/api/forgot/send-email", params: params, payload: payload.to_json)
|
11
|
+
end
|
12
|
+
|
13
|
+
def reset_password(payload, params={})
|
14
|
+
execute(method: :post, url: "/api/forgot/reset-password", params: params, payload: payload.to_json)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -218,6 +218,13 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
218
218
|
execute(opts)
|
219
219
|
end
|
220
220
|
|
221
|
+
def snapshots(instance_id, params={})
|
222
|
+
url = "#{@base_url}/api/instances/#{instance_id}/snapshots"
|
223
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
224
|
+
opts = {method: :get, url: url, headers: headers}
|
225
|
+
execute(opts)
|
226
|
+
end
|
227
|
+
|
221
228
|
def import_snapshot(id, params={}, payload={})
|
222
229
|
url = "#{@base_url}/api/instances/#{id}/import-snapshot"
|
223
230
|
headers = {:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -169,4 +169,11 @@ class Morpheus::ServersInterface < Morpheus::APIClient
|
|
169
169
|
execute(opts)
|
170
170
|
end
|
171
171
|
|
172
|
+
def snapshots(id, params={})
|
173
|
+
url = "#{@base_url}/api/servers/#{id}/snapshots"
|
174
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
175
|
+
opts = {method: :get, url: url, headers: headers}
|
176
|
+
execute(opts)
|
177
|
+
end
|
178
|
+
|
172
179
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::UsageInterface < Morpheus::APIClient
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"/api/usage" # not /usages ?
|
7
|
+
end
|
8
|
+
|
9
|
+
def list(params={})
|
10
|
+
execute(method: :get, url: "#{base_path}", params: params)
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(id, params={})
|
14
|
+
validate_id!(id)
|
15
|
+
execute(method: :get, url: "#{base_path}/#{id}", params: params)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/lib/morpheus/cli.rb
CHANGED
@@ -74,9 +74,11 @@ module Morpheus
|
|
74
74
|
load 'morpheus/cli/setup.rb'
|
75
75
|
load 'morpheus/cli/login.rb'
|
76
76
|
load 'morpheus/cli/logout.rb'
|
77
|
+
load 'morpheus/cli/forgot_password.rb'
|
77
78
|
load 'morpheus/cli/whoami.rb'
|
78
79
|
load 'morpheus/cli/access_token_command.rb'
|
79
80
|
load 'morpheus/cli/user_settings_command.rb'
|
81
|
+
load 'morpheus/cli/search_command.rb'
|
80
82
|
load 'morpheus/cli/dashboard_command.rb'
|
81
83
|
load 'morpheus/cli/recent_activity_command.rb' # deprecated, removing soon
|
82
84
|
load 'morpheus/cli/activity_command.rb'
|
@@ -94,11 +96,12 @@ module Morpheus
|
|
94
96
|
load 'morpheus/cli/tasks.rb'
|
95
97
|
load 'morpheus/cli/workflows.rb'
|
96
98
|
load 'morpheus/cli/deployments.rb'
|
99
|
+
load 'morpheus/cli/deploy.rb'
|
100
|
+
load 'morpheus/cli/deploys.rb'
|
97
101
|
load 'morpheus/cli/instances.rb'
|
98
102
|
load 'morpheus/cli/containers_command.rb'
|
99
103
|
load 'morpheus/cli/apps.rb'
|
100
104
|
load 'morpheus/cli/blueprints_command.rb'
|
101
|
-
load 'morpheus/cli/deploys.rb'
|
102
105
|
load 'morpheus/cli/license.rb'
|
103
106
|
load 'morpheus/cli/instance_types.rb'
|
104
107
|
load 'morpheus/cli/jobs_command.rb'
|
@@ -309,6 +309,15 @@ module Morpheus
|
|
309
309
|
opts.add_hidden_option('-a, --account') if opts.is_a?(Morpheus::Cli::OptionParser)
|
310
310
|
opts.add_hidden_option('-A, --account-id') if opts.is_a?(Morpheus::Cli::OptionParser)
|
311
311
|
|
312
|
+
when :details
|
313
|
+
opts.on('-a', '--all', "Show all details." ) do
|
314
|
+
options[:details] = true
|
315
|
+
end
|
316
|
+
opts.on('--details', '--details', "Show more details" ) do
|
317
|
+
options[:details] = true
|
318
|
+
end
|
319
|
+
opts.add_hidden_option('--details')
|
320
|
+
|
312
321
|
when :options
|
313
322
|
options[:options] ||= {}
|
314
323
|
opts.on( '-O', '--option OPTION', "Option in the format -O field=\"value\"" ) do |option|
|
@@ -602,13 +611,13 @@ module Morpheus
|
|
602
611
|
end
|
603
612
|
# opts.add_hidden_option('-H') if opts.is_a?(Morpheus::Cli::OptionParser)
|
604
613
|
# opts.add_hidden_option('--header') if opts.is_a?(Morpheus::Cli::OptionParser)
|
605
|
-
opts.add_hidden_option('--
|
614
|
+
opts.add_hidden_option('-H, --header') if opts.is_a?(Morpheus::Cli::OptionParser)
|
606
615
|
|
607
616
|
#when :timeout
|
608
617
|
opts.on( '--timeout SECONDS', "Timeout for api requests. Default is typically 30 seconds." ) do |val|
|
609
618
|
options[:timeout] = val ? val.to_f : nil
|
610
619
|
end
|
611
|
-
|
620
|
+
opts.add_hidden_option('--timeout') if opts.is_a?(Morpheus::Cli::OptionParser)
|
612
621
|
|
613
622
|
when :auto_confirm
|
614
623
|
opts.on( '-y', '--yes', "Auto Confirm" ) do
|
@@ -715,7 +724,7 @@ module Morpheus
|
|
715
724
|
|
716
725
|
|
717
726
|
when :dry_run
|
718
|
-
opts.on('-d','--dry-run', "Dry Run, print the API request instead of executing it") do
|
727
|
+
opts.on('-d','--dry-run', "Dry Run, print the API request instead of executing it.") do
|
719
728
|
# todo: this should print after parsing obv..
|
720
729
|
# need a hook after parse! or a standard_handle(options) { ... } paradigm
|
721
730
|
# either that or hook it up in every command somehow, maybe a hook on connect()
|
@@ -727,7 +736,7 @@ module Morpheus
|
|
727
736
|
end
|
728
737
|
options[:dry_run] = true
|
729
738
|
end
|
730
|
-
opts.on(nil,'--curl', "
|
739
|
+
opts.on(nil,'--curl', "Curl, print the API request as a curl command instead of executing it.") do
|
731
740
|
# print once and dont munge json
|
732
741
|
if !options[:dry_run] && !options[:json]
|
733
742
|
puts "#{cyan}#{bold}#{dark}DRY RUN#{reset}"
|
@@ -830,6 +839,10 @@ module Morpheus
|
|
830
839
|
opts
|
831
840
|
end
|
832
841
|
|
842
|
+
def prog_name
|
843
|
+
self.class.prog_name
|
844
|
+
end
|
845
|
+
|
833
846
|
def command_name
|
834
847
|
self.class.command_name
|
835
848
|
end
|
@@ -870,14 +883,14 @@ module Morpheus
|
|
870
883
|
|
871
884
|
def usage
|
872
885
|
if !subcommands.empty?
|
873
|
-
"Usage:
|
886
|
+
"Usage: #{prog_name} #{command_name} [command] [options]"
|
874
887
|
else
|
875
|
-
"Usage:
|
888
|
+
"Usage: #{prog_name} #{command_name} [options]"
|
876
889
|
end
|
877
890
|
end
|
878
891
|
|
879
892
|
def my_help_command
|
880
|
-
"
|
893
|
+
"#{prog_name} #{command_name} --help"
|
881
894
|
end
|
882
895
|
|
883
896
|
def subcommand_usage(*extra)
|
@@ -888,7 +901,7 @@ module Morpheus
|
|
888
901
|
extra.shift
|
889
902
|
end
|
890
903
|
#extra = ["[options]"] if extra.empty?
|
891
|
-
"Usage:
|
904
|
+
"Usage: #{prog_name} #{command_name} #{subcommand_name} #{extra.join(' ')}".squeeze(' ').strip
|
892
905
|
end
|
893
906
|
|
894
907
|
# a string to describe the usage of your command
|
@@ -939,7 +952,7 @@ module Morpheus
|
|
939
952
|
end
|
940
953
|
cmd_method = subcommands[subcommand_name]
|
941
954
|
if !cmd_method
|
942
|
-
error_msg = "'#{command_name} #{subcommand_name}' is not a
|
955
|
+
error_msg = "'#{command_name} #{subcommand_name}' is not a #{prog_name} command.\n#{full_command_usage}"
|
943
956
|
raise CommandNotFoundError.new(error_msg)
|
944
957
|
end
|
945
958
|
self.send(cmd_method, args[1..-1])
|
@@ -1295,6 +1308,10 @@ module Morpheus
|
|
1295
1308
|
|
1296
1309
|
module ClassMethods
|
1297
1310
|
|
1311
|
+
def prog_name
|
1312
|
+
"morpheus"
|
1313
|
+
end
|
1314
|
+
|
1298
1315
|
def set_command_name(cmd_name)
|
1299
1316
|
@command_name = cmd_name
|
1300
1317
|
Morpheus::Cli::CliRegistry.add(self, self.command_name)
|
@@ -41,7 +41,7 @@ class Morpheus::Cli::CurlCommand
|
|
41
41
|
opts.on( '--progress', '--progress', "Display progress output by excluding the -s option." ) do
|
42
42
|
show_progress = true
|
43
43
|
end
|
44
|
-
build_common_options(opts, options, [:dry_run, :remote])
|
44
|
+
build_common_options(opts, options, [:dry_run, :json, :remote])
|
45
45
|
opts.add_hidden_option('--curl')
|
46
46
|
#opts.add_hidden_option('--scrub')
|
47
47
|
opts.footer = <<-EOT
|
@@ -140,16 +140,14 @@ EOT
|
|
140
140
|
print reset
|
141
141
|
# print result
|
142
142
|
curl_output = `#{curl_cmd}`
|
143
|
-
if options[:pretty]
|
143
|
+
if options[:pretty] || options[:json]
|
144
144
|
output_lines = curl_output.split("\n")
|
145
145
|
last_line = output_lines.pop
|
146
146
|
if output_lines.size > 0
|
147
147
|
puts output_lines.join("\n")
|
148
148
|
end
|
149
149
|
begin
|
150
|
-
|
151
|
-
json_string = JSON.pretty_generate(json_data)
|
152
|
-
puts json_string
|
150
|
+
puts as_json(JSON.parse(last_line), options)
|
153
151
|
rescue => ex
|
154
152
|
Morpheus::Logging::DarkPrinter.puts "failed to parse curl result as JSON data Error: #{ex.message}" if Morpheus::Logging.debug?
|
155
153
|
puts last_line
|
@@ -6,7 +6,9 @@ require 'morpheus/cli/cli_command'
|
|
6
6
|
class Morpheus::Cli::HistoryCommand
|
7
7
|
include Morpheus::Cli::CliCommand
|
8
8
|
set_command_name :'history'
|
9
|
-
|
9
|
+
set_command_description "View morpheus shell command history"
|
10
|
+
# hidden for now because it is a shell command, shouldnt just be shell command though
|
11
|
+
set_command_hidden
|
10
12
|
|
11
13
|
# todo: support all the other :list options too, not just max
|
12
14
|
# AND start logging every terminal command, not just shell...
|
@@ -9,7 +9,7 @@ class Morpheus::Cli::ManCommand
|
|
9
9
|
|
10
10
|
# this should be read only anyway...
|
11
11
|
@@default_editor = "less" # ENV['EDITOR']
|
12
|
-
|
12
|
+
|
13
13
|
def handle(args)
|
14
14
|
options = {}
|
15
15
|
regenerate = false
|
@@ -28,6 +28,12 @@ class Morpheus::Cli::ManCommand
|
|
28
28
|
opts.on('-g','--generate', "Regenerate the manual file") do
|
29
29
|
regenerate = true
|
30
30
|
end
|
31
|
+
opts.on('-o','--out FILE', "Write manual file to a custom location") do |val|
|
32
|
+
options[:outfile] = val
|
33
|
+
end
|
34
|
+
opts.on('--overwrite', '--overwrite', "Overwrite output file if it already exists.") do |val|
|
35
|
+
options[:overwrite] = true
|
36
|
+
end
|
31
37
|
opts.on('-q','--quiet', "Do not open manual, for use with the -g option.") do
|
32
38
|
options[:quiet] = true
|
33
39
|
end
|
@@ -47,7 +53,8 @@ class Morpheus::Cli::ManCommand
|
|
47
53
|
end
|
48
54
|
opts.footer = <<-EOT
|
49
55
|
Open the morpheus manual located at #{Morpheus::Cli::ManCommand.man_file_path}
|
50
|
-
The -g
|
56
|
+
The -g option can be used to regenerate the file.
|
57
|
+
The --out FILE option be used to write the manual file to a custom location.
|
51
58
|
EOT
|
52
59
|
end
|
53
60
|
optparse.parse!(args)
|
@@ -65,18 +72,35 @@ EOT
|
|
65
72
|
end
|
66
73
|
|
67
74
|
fn = Morpheus::Cli::ManCommand.man_file_path
|
75
|
+
if options[:outfile]
|
76
|
+
regenerate = true
|
77
|
+
fn = File.expand_path(options[:outfile])
|
78
|
+
if File.directory?(fn)
|
79
|
+
# if you give me a directory, could still work and use the default filename
|
80
|
+
# fn = File.join(fn, "CLI-Manual-#{Morpheus::Cli::VERSION}.md")
|
81
|
+
# raise_command_error "outfile is invalid. It is the name of an existing directory: #{fn}"
|
82
|
+
print_error "#{red}Output file '#{fn}' is invalid.#{reset}\n"
|
83
|
+
print_error "#{red}It is the name of an existing directory.#{reset}\n"
|
84
|
+
return 1
|
85
|
+
end
|
86
|
+
if File.exists?(fn) && options[:overwrite] != true
|
87
|
+
print_error "#{red}Output file '#{fn}' already exists.#{reset}\n"
|
88
|
+
print_error "#{red}Use --overwrite to overwrite the existing file.#{reset}\n"
|
89
|
+
return 1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
exit_code, err = 0, nil
|
68
93
|
if regenerate || !File.exists?(fn)
|
69
94
|
#Morpheus::Logging::DarkPrinter.puts "generating manual #{fn} ..." if Morpheus::Logging.debug? && !options[:quiet]
|
70
|
-
Morpheus::Cli::ManCommand.generate_manual(options)
|
95
|
+
exit_code, err = Morpheus::Cli::ManCommand.generate_manual(options)
|
71
96
|
end
|
72
97
|
|
73
98
|
if options[:quiet]
|
74
|
-
return
|
99
|
+
return exit_code, err
|
75
100
|
end
|
76
101
|
|
77
102
|
Morpheus::Logging::DarkPrinter.puts "opening manual file #{fn}" if Morpheus::Logging.debug? && !options[:quiet]
|
78
103
|
|
79
|
-
|
80
104
|
if open_as_link # not used atm
|
81
105
|
link = "file://#{fn}"
|
82
106
|
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
@@ -138,6 +162,14 @@ EOT
|
|
138
162
|
# todo: use pandoc or something else to convert the CLI-Manual.md to a man page
|
139
163
|
# and install it, so the os command `man morpheus` will work too.
|
140
164
|
fn = man_file_path()
|
165
|
+
if options[:outfile]
|
166
|
+
fn = File.expand_path(options[:outfile])
|
167
|
+
if File.exists?(fn) && options[:overwrite] != true
|
168
|
+
print_error "#{red}Output file '#{options[:outfile]}' already exists.#{reset}\n"
|
169
|
+
print_error "#{red}Use --overwrite to overwrite the existing file.#{reset}\n"
|
170
|
+
return 1, "output file already exists"
|
171
|
+
end
|
172
|
+
end
|
141
173
|
if !Dir.exists?(File.dirname(fn))
|
142
174
|
FileUtils.mkdir_p(File.dirname(fn))
|
143
175
|
end
|
@@ -153,7 +185,7 @@ EOT
|
|
153
185
|
begin
|
154
186
|
|
155
187
|
manpage.print <<-ENDTEXT
|
156
|
-
|
188
|
+
#{prog_name} v#{Morpheus::Cli::VERSION}
|
157
189
|
|
158
190
|
## NAME
|
159
191
|
|
@@ -170,17 +202,17 @@ morpheus v#{Morpheus::Cli::VERSION}
|
|
170
202
|
This is a command line interface for managing a Morpheus Appliance.
|
171
203
|
All communication with the remote appliance is done via the Morpheus API.
|
172
204
|
|
173
|
-
|
205
|
+
Use the command `#{prog_name} remote add` to connect to your Morpheus appliance.
|
174
206
|
|
175
207
|
To learn more, visit https://github.com/gomorpheus/morpheus-cli/wiki/Getting-Started
|
176
208
|
|
177
|
-
To learn more about the Morpheus Appliance, visit https://www.morpheusdata.com
|
209
|
+
To learn more about the Morpheus Appliance, visit https://www.morpheusdata.com
|
178
210
|
|
179
211
|
To learn more about the Morpheus API, visit https://apidocs.morpheusdata.com
|
180
212
|
|
181
213
|
## GLOBAL OPTIONS
|
182
214
|
|
183
|
-
|
215
|
+
There are several global options available.
|
184
216
|
|
185
217
|
-v, --version Print the version.
|
186
218
|
--noprofile Do not read and execute the personal initialization script .morpheus_profile
|
@@ -190,30 +222,42 @@ morpheus v#{Morpheus::Cli::VERSION}
|
|
190
222
|
|
191
223
|
## COMMON OPTIONS
|
192
224
|
|
193
|
-
There are
|
225
|
+
There are many common options that are supported by a most commands.
|
194
226
|
|
195
227
|
-O, --option OPTION Option value in the format -O var="value" (deprecated soon in favor of first class options)
|
196
228
|
-N, --no-prompt Skip prompts. Use default values for all optional fields.
|
229
|
+
--payload FILE Payload from a local JSON or YAML file, skip all prompting
|
230
|
+
--payload-dir DIRECTORY Payload from a local directory containing 1-N JSON or YAML files, skip all prompting
|
231
|
+
--payload-json JSON Payload JSON, skip all prompting
|
232
|
+
--payload-yaml YAML Payload YAML, skip all prompting
|
197
233
|
-j, --json JSON Output
|
198
234
|
-d, --dry-run Dry Run, print the API request instead of executing it
|
199
|
-
|
200
|
-
|
201
|
-
-
|
202
|
-
|
235
|
+
--curl Dry Run to output API request as a curl command.
|
236
|
+
--scrub Mask secrets in output, such as the Authorization header. For use with --curl and --dry-run.
|
237
|
+
-r, --remote REMOTE Remote name. The current remote is used by default.
|
238
|
+
--remote-url URL Remote url. This allows adhoc requests instead of using a configured remote.
|
239
|
+
-T, --token TOKEN Access token for authentication with --remote. Saved credentials are used by default.
|
240
|
+
-U, --username USERNAME Username for authentication.
|
241
|
+
-P, --password PASSWORD Password for authentication.
|
242
|
+
-I, --insecure Allow insecure HTTPS communication. i.e. bad SSL certificate.
|
243
|
+
-H, --header HEADER Additional HTTP header to include with requests.
|
244
|
+
--timeout SECONDS Timeout for api requests. Default is typically 30 seconds.
|
245
|
+
-y, --yes Auto Confirm
|
246
|
+
-q, --quiet No Output, do not print to stdout
|
203
247
|
|
204
248
|
## MORPHEUS COMMANDS
|
205
249
|
|
206
|
-
|
207
|
-
|
250
|
+
The morpheus executable is divided into commands.
|
251
|
+
Each morpheus command may have 0-N sub-commands that it supports.
|
208
252
|
Commands generally map to the functionality provided in the Morpheus UI.
|
209
253
|
|
210
254
|
You can get help for any morpheus command by using the -h option.
|
211
255
|
|
212
|
-
The available commands and their options are
|
256
|
+
The available commands and their options are documented below.
|
213
257
|
ENDTEXT
|
214
258
|
|
215
259
|
terminal = Morpheus::Terminal.new($stdin, manpage)
|
216
|
-
Morpheus::Logging::DarkPrinter.puts "appending command help
|
260
|
+
Morpheus::Logging::DarkPrinter.puts "appending command help `#{prog_name} --help`" if Morpheus::Logging.debug? && !options[:quiet]
|
217
261
|
|
218
262
|
manpage.print "\n"
|
219
263
|
manpage.print "## morpheus\n"
|
@@ -226,7 +270,7 @@ ENDTEXT
|
|
226
270
|
Morpheus::Cli::CliRegistry.all.keys.sort.each do |cmd|
|
227
271
|
cmd_klass = Morpheus::Cli::CliRegistry.instance.get(cmd)
|
228
272
|
cmd_instance = cmd_klass.new
|
229
|
-
Morpheus::Logging::DarkPrinter.puts "appending command help
|
273
|
+
Morpheus::Logging::DarkPrinter.puts "appending command help `#{prog_name} #{cmd} --help`" if Morpheus::Logging.debug? && !options[:quiet]
|
230
274
|
#help_cmd = "morpheus #{cmd} --help"
|
231
275
|
#help_output = `#{help_cmd}`
|
232
276
|
manpage.print "\n"
|
@@ -243,7 +287,7 @@ ENDTEXT
|
|
243
287
|
subcommands = cmd_klass.visible_subcommands
|
244
288
|
if subcommands && subcommands.size > 0
|
245
289
|
subcommands.sort.each do |subcommand, subcommand_method|
|
246
|
-
Morpheus::Logging::DarkPrinter.puts "appending command help
|
290
|
+
Morpheus::Logging::DarkPrinter.puts "appending command help `#{prog_name} #{cmd} #{subcommand} --help`" if Morpheus::Logging.debug? && !options[:quiet]
|
247
291
|
manpage.print "\n"
|
248
292
|
manpage.print "#### morpheus #{cmd} #{subcommand}\n"
|
249
293
|
manpage.print "\n"
|
@@ -289,7 +333,7 @@ morpheus> remote list
|
|
289
333
|
Morpheus Appliances
|
290
334
|
==================
|
291
335
|
|
292
|
-
You have no appliances configured. See the
|
336
|
+
You have no appliances configured. See the `#{prog_name} remote add` command.
|
293
337
|
|
294
338
|
```
|
295
339
|
|
@@ -319,11 +363,10 @@ The `appliances` YAML file contains a list of known appliances, keyed by name.
|
|
319
363
|
Example:
|
320
364
|
```yaml
|
321
365
|
:qa:
|
322
|
-
:host: https://qa.
|
366
|
+
:host: https://qa.mymorpheus.com
|
323
367
|
:active: true
|
324
368
|
:production:
|
325
|
-
:host: https://
|
326
|
-
:active: false
|
369
|
+
:host: https://mymorpheus.com
|
327
370
|
```
|
328
371
|
|
329
372
|
### credentials file
|
@@ -349,7 +392,7 @@ This may be inhibited by using the `--noprofile` option.
|
|
349
392
|
|
350
393
|
### .morpheusrc file
|
351
394
|
|
352
|
-
When started as an interactive shell with the
|
395
|
+
When started as an interactive shell with the `#{prog_name} shell` command,
|
353
396
|
Morpheus reads and executes `$MORPHEUS_CLI_HOME/.morpheusrc` (if it exists). This may be inhibited by using the `--norc` option.
|
354
397
|
|
355
398
|
An example startup script might look like this:
|
@@ -357,20 +400,11 @@ An example startup script might look like this:
|
|
357
400
|
```
|
358
401
|
# .morpheusrc
|
359
402
|
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
# greeting
|
367
|
-
echo "Welcome back human, have fun!"
|
368
|
-
|
369
|
-
# print current user information
|
370
|
-
whoami
|
371
|
-
|
372
|
-
# print the list of instances in our cloud
|
373
|
-
our-instances
|
403
|
+
set-prompt "%cyan%username%reset@%magenta%remote %cyanmorpheus> %reset"
|
404
|
+
version
|
405
|
+
remote current
|
406
|
+
echo "Welcome back %username"
|
407
|
+
echo
|
374
408
|
|
375
409
|
```
|
376
410
|
|
@@ -383,7 +417,7 @@ ENDTEXT
|
|
383
417
|
terminal = Morpheus::Terminal.new()
|
384
418
|
end
|
385
419
|
|
386
|
-
return
|
420
|
+
return 0, nil
|
387
421
|
end
|
388
422
|
|
389
423
|
end
|