morpheus-cli 6.1.1 → 6.2.0
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 +8 -4
- data/lib/morpheus/api/backup_jobs_interface.rb +4 -0
- data/lib/morpheus/api/backup_restores_interface.rb +23 -0
- data/lib/morpheus/api/backup_results_interface.rb +28 -0
- data/lib/morpheus/api/backups_interface.rb +5 -4
- data/lib/morpheus/cli/cli_command.rb +172 -45
- data/lib/morpheus/cli/commands/appliance_settings_command.rb +7 -19
- data/lib/morpheus/cli/commands/apps.rb +1 -1
- data/lib/morpheus/cli/commands/backup_jobs_command.rb +77 -20
- data/lib/morpheus/cli/commands/backup_restores_command.rb +144 -0
- data/lib/morpheus/cli/commands/backup_results_command.rb +149 -0
- data/lib/morpheus/cli/commands/backups_command.rb +214 -93
- data/lib/morpheus/cli/commands/hosts.rb +15 -2
- data/lib/morpheus/cli/commands/instances.rb +23 -3
- data/lib/morpheus/cli/commands/load_balancer_pools.rb +37 -1
- data/lib/morpheus/cli/commands/security_groups.rb +58 -37
- data/lib/morpheus/cli/commands/service_catalog_command.rb +50 -83
- data/lib/morpheus/cli/commands/view.rb +20 -20
- data/lib/morpheus/cli/mixins/backups_helper.rb +58 -0
- data/lib/morpheus/cli/mixins/print_helper.rb +27 -4
- data/lib/morpheus/cli/option_types.rb +10 -7
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/formatters.rb +1 -1
- data/lib/morpheus/routes.rb +18 -3
- metadata +6 -8
- data/lib/morpheus/api/doc_interface.rb +0 -50
- data/lib/morpheus/cli/commands/doc.rb +0 -182
- data/test/api/doc_interface_test.rb +0 -35
- data/test/cli/doc_test.rb +0 -35
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morpheus-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Estes
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-
|
14
|
+
date: 2023-07-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -199,6 +199,8 @@ files:
|
|
199
199
|
- lib/morpheus/api/audit_interface.rb
|
200
200
|
- lib/morpheus/api/auth_interface.rb
|
201
201
|
- lib/morpheus/api/backup_jobs_interface.rb
|
202
|
+
- lib/morpheus/api/backup_restores_interface.rb
|
203
|
+
- lib/morpheus/api/backup_results_interface.rb
|
202
204
|
- lib/morpheus/api/backup_service_types_interface.rb
|
203
205
|
- lib/morpheus/api/backup_services_interface.rb
|
204
206
|
- lib/morpheus/api/backup_settings_interface.rb
|
@@ -226,7 +228,6 @@ files:
|
|
226
228
|
- lib/morpheus/api/datastores_interface.rb
|
227
229
|
- lib/morpheus/api/deploy_interface.rb
|
228
230
|
- lib/morpheus/api/deployments_interface.rb
|
229
|
-
- lib/morpheus/api/doc_interface.rb
|
230
231
|
- lib/morpheus/api/environments_interface.rb
|
231
232
|
- lib/morpheus/api/execute_schedules_interface.rb
|
232
233
|
- lib/morpheus/api/execution_request_interface.rb
|
@@ -372,6 +373,8 @@ files:
|
|
372
373
|
- lib/morpheus/cli/commands/archives_command.rb
|
373
374
|
- lib/morpheus/cli/commands/audit.rb
|
374
375
|
- lib/morpheus/cli/commands/backup_jobs_command.rb
|
376
|
+
- lib/morpheus/cli/commands/backup_restores_command.rb
|
377
|
+
- lib/morpheus/cli/commands/backup_results_command.rb
|
375
378
|
- lib/morpheus/cli/commands/backup_services_command.rb
|
376
379
|
- lib/morpheus/cli/commands/backup_settings_command.rb
|
377
380
|
- lib/morpheus/cli/commands/backups_command.rb
|
@@ -400,7 +403,6 @@ files:
|
|
400
403
|
- lib/morpheus/cli/commands/deploy.rb
|
401
404
|
- lib/morpheus/cli/commands/deployments.rb
|
402
405
|
- lib/morpheus/cli/commands/deploys.rb
|
403
|
-
- lib/morpheus/cli/commands/doc.rb
|
404
406
|
- lib/morpheus/cli/commands/echo_command.rb
|
405
407
|
- lib/morpheus/cli/commands/edit_profile_command.rb
|
406
408
|
- lib/morpheus/cli/commands/edit_rc_command.rb
|
@@ -578,14 +580,12 @@ files:
|
|
578
580
|
- lib/morpheus/util.rb
|
579
581
|
- morpheus-cli.gemspec
|
580
582
|
- test/api/containers_interface_test.rb
|
581
|
-
- test/api/doc_interface_test.rb
|
582
583
|
- test/api/instances_interface_test.rb
|
583
584
|
- test/api/whoami_interface_test.rb
|
584
585
|
- test/cli/access_token_test.rb
|
585
586
|
- test/cli/auth_test.rb
|
586
587
|
- test/cli/cli_test.rb
|
587
588
|
- test/cli/containers_test.rb
|
588
|
-
- test/cli/doc_test.rb
|
589
589
|
- test/cli/help_test.rb
|
590
590
|
- test/cli/instances_test.rb
|
591
591
|
- test/cli/man_test.rb
|
@@ -624,14 +624,12 @@ specification_version: 4
|
|
624
624
|
summary: Provides CLI Interface to the Morpheus Public/Private Cloud Appliance
|
625
625
|
test_files:
|
626
626
|
- test/api/containers_interface_test.rb
|
627
|
-
- test/api/doc_interface_test.rb
|
628
627
|
- test/api/instances_interface_test.rb
|
629
628
|
- test/api/whoami_interface_test.rb
|
630
629
|
- test/cli/access_token_test.rb
|
631
630
|
- test/cli/auth_test.rb
|
632
631
|
- test/cli/cli_test.rb
|
633
632
|
- test/cli/containers_test.rb
|
634
|
-
- test/cli/doc_test.rb
|
635
633
|
- test/cli/help_test.rb
|
636
634
|
- test/cli/instances_test.rb
|
637
635
|
- test/cli/man_test.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'morpheus/api/api_client'
|
2
|
-
|
3
|
-
class Morpheus::DocInterface < Morpheus::APIClient
|
4
|
-
|
5
|
-
def list(params={})
|
6
|
-
url = "/api/doc"
|
7
|
-
headers = {params: params}
|
8
|
-
execute(method: :get, url: url, headers: headers)
|
9
|
-
end
|
10
|
-
|
11
|
-
def openapi(params={})
|
12
|
-
url = "/api/doc/openapi"
|
13
|
-
fmt = params.delete('format')
|
14
|
-
if fmt
|
15
|
-
url = url + "." + fmt
|
16
|
-
end
|
17
|
-
is_yaml = fmt == "yml" || fmt == "yaml"
|
18
|
-
headers = {params: params}
|
19
|
-
execute(method: :get, url: url, headers: headers, timeout: 172800, parse_json: !is_yaml)
|
20
|
-
end
|
21
|
-
|
22
|
-
def download_openapi(outfile, params={})
|
23
|
-
# note that RestClient.execute still requires the full path with base_url
|
24
|
-
url = "#{@base_url}/api/doc/openapi"
|
25
|
-
fmt = params.delete('format')
|
26
|
-
if fmt
|
27
|
-
url = url + "." + fmt
|
28
|
-
end
|
29
|
-
headers = {params: params, authorization: "Bearer #{@access_token}"}
|
30
|
-
opts = {method: :get, url: url, headers: headers, timeout: 172800, parse_json: false}
|
31
|
-
|
32
|
-
if @dry_run
|
33
|
-
return opts
|
34
|
-
end
|
35
|
-
|
36
|
-
http_response = nil
|
37
|
-
File.open(File.expand_path(outfile), 'w') {|f|
|
38
|
-
block = proc { |response|
|
39
|
-
response.read_body do |chunk|
|
40
|
-
# writing to #{outfile} ..."
|
41
|
-
f.write chunk
|
42
|
-
end
|
43
|
-
}
|
44
|
-
opts[:block_response] = block
|
45
|
-
http_response = Morpheus::RestClient.execute(opts)
|
46
|
-
}
|
47
|
-
http_response
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
@@ -1,182 +0,0 @@
|
|
1
|
-
require 'morpheus/cli/cli_command'
|
2
|
-
|
3
|
-
# This provides commands for authentication
|
4
|
-
# This also includes credential management.
|
5
|
-
class Morpheus::Cli::Doc
|
6
|
-
include Morpheus::Cli::CliCommand
|
7
|
-
|
8
|
-
set_command_name :'doc'
|
9
|
-
register_subcommands :list
|
10
|
-
register_subcommands :get => :openapi
|
11
|
-
register_subcommands :download => :download_openapi
|
12
|
-
|
13
|
-
# hidden until doc complete (or close to it)
|
14
|
-
set_command_hidden
|
15
|
-
|
16
|
-
def initialize()
|
17
|
-
# @appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
|
18
|
-
end
|
19
|
-
|
20
|
-
def handle(args)
|
21
|
-
handle_subcommand(args)
|
22
|
-
end
|
23
|
-
|
24
|
-
def connect(options)
|
25
|
-
# @api_client = establish_remote_appliance_connection(options.merge({:no_prompt => true, :skip_verify_access_token => true, :skip_login => true}))
|
26
|
-
@api_client = establish_remote_appliance_connection(options)
|
27
|
-
@doc_interface = @api_client.doc
|
28
|
-
end
|
29
|
-
|
30
|
-
def list(args)
|
31
|
-
exit_code, err = 0, nil
|
32
|
-
params, options = {}, {}
|
33
|
-
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
34
|
-
opts.banner = subcommand_usage()
|
35
|
-
build_standard_get_options(opts, options)
|
36
|
-
opts.footer = <<-EOT
|
37
|
-
List documentation links.
|
38
|
-
EOT
|
39
|
-
end
|
40
|
-
optparse.parse!(args)
|
41
|
-
verify_args!(args:args, optparse:optparse, count:0)
|
42
|
-
connect(options)
|
43
|
-
# construct the api request
|
44
|
-
params.merge!(parse_list_options(options))
|
45
|
-
# execute the api request
|
46
|
-
@doc_interface.setopts(options)
|
47
|
-
if options[:dry_run]
|
48
|
-
print_dry_run @doc_interface.dry.list(params)
|
49
|
-
return 0, nil
|
50
|
-
end
|
51
|
-
json_response = @doc_interface.list(params)
|
52
|
-
render_response(json_response, options, "links") do
|
53
|
-
title = "Morpheus Documentation"
|
54
|
-
print_h1 title, options
|
55
|
-
if json_response['links'].empty?
|
56
|
-
print yellow, "No help links found.",reset,"\n"
|
57
|
-
else
|
58
|
-
columns = {
|
59
|
-
"Link Name" => 'name',
|
60
|
-
"URL" => 'url',
|
61
|
-
"Description" => {display_method:'description', max_width: (options[:wrap] ? nil : 50)},
|
62
|
-
}
|
63
|
-
print as_pretty_table(json_response['links'], columns.upcase_keys!, options)
|
64
|
-
# print_results_pagination(json_response)
|
65
|
-
end
|
66
|
-
print reset,"\n"
|
67
|
-
end
|
68
|
-
return exit_code, err
|
69
|
-
end
|
70
|
-
|
71
|
-
def openapi(args)
|
72
|
-
exit_code, err = 0, nil
|
73
|
-
params, options = {}, {}
|
74
|
-
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
75
|
-
opts.banner = subcommand_usage()
|
76
|
-
# opts.on(nil, "--refresh", "Refresh the document. By default the openapi.yml and openapi.json are cached by the server.") do
|
77
|
-
# params['refresh'] = true
|
78
|
-
# end
|
79
|
-
# opts.on('-g', '--generate', "Alias for --refresh") do
|
80
|
-
# params['refresh'] = true
|
81
|
-
# end
|
82
|
-
build_standard_get_options(opts, options, [], [:csv])
|
83
|
-
opts.footer = <<-EOT
|
84
|
-
Print the Morpheus API OpenAPI Documentation (swagger).
|
85
|
-
The default format is JSON. Supports json or yaml.
|
86
|
-
EOT
|
87
|
-
end
|
88
|
-
optparse.parse!(args)
|
89
|
-
verify_args!(args:args, optparse:optparse, count:0)
|
90
|
-
connect(options)
|
91
|
-
# construct the api request
|
92
|
-
params.merge!(parse_list_options(options))
|
93
|
-
# for now, always use .json, and just convert to yaml for display on cli side
|
94
|
-
openapi_format = options[:yaml] ? "yaml" : "json"
|
95
|
-
# params['format'] = openapi_format
|
96
|
-
# execute the api request
|
97
|
-
@doc_interface.setopts(options)
|
98
|
-
if options[:dry_run]
|
99
|
-
params['format'] = openapi_format
|
100
|
-
print_dry_run @doc_interface.dry.openapi(params)
|
101
|
-
return 0, nil
|
102
|
-
end
|
103
|
-
json_response = @doc_interface.openapi(params)
|
104
|
-
# default format is to print header and json
|
105
|
-
render_response(json_response, options) do
|
106
|
-
title = "Morpheus API openapi.#{openapi_format}"
|
107
|
-
print_h1 title, options
|
108
|
-
print cyan
|
109
|
-
print as_json(json_response, options)
|
110
|
-
print reset,"\n"
|
111
|
-
end
|
112
|
-
return exit_code, err
|
113
|
-
end
|
114
|
-
|
115
|
-
def download_openapi(args)
|
116
|
-
exit_code, err = 0, nil
|
117
|
-
params, options = {}, {}
|
118
|
-
optparse = Morpheus::Cli::OptionParser.new do |opts|
|
119
|
-
opts.banner = subcommand_usage("[local-file]")
|
120
|
-
# build_standard_get_options(opts, options, [], [:csv,:out])
|
121
|
-
opts.on(nil, '--yaml', "YAML Output") do
|
122
|
-
options[:yaml] = true
|
123
|
-
options[:format] = :yaml
|
124
|
-
end
|
125
|
-
# opts.on(nil, "--refresh", "Refresh the document. By default the openapi.yml and openapi.json are cached by the server.") do
|
126
|
-
# params['refresh'] = true
|
127
|
-
# end
|
128
|
-
# opts.on('-g', '--generate', "Alias for --refresh") do
|
129
|
-
# params['refresh'] = true
|
130
|
-
# end
|
131
|
-
opts.on( '-f', '--force', "Overwrite existing [local-file] if it exists." ) do
|
132
|
-
options[:overwrite] = true
|
133
|
-
end
|
134
|
-
opts.on( '-p', '--mkdir', "Create missing directories for [local-file] if they do not exist." ) do
|
135
|
-
options[:mkdir] = true
|
136
|
-
end
|
137
|
-
build_common_options(opts, options, [:dry_run, :quiet, :remote])
|
138
|
-
opts.footer = <<-EOT
|
139
|
-
Download the Morpheus API OpenAPI Documentation (swagger).
|
140
|
-
[local-file] is required. This is the full local filepath for the downloaded file.
|
141
|
-
The default format is JSON. Supports json or yaml.
|
142
|
-
EOT
|
143
|
-
end
|
144
|
-
optparse.parse!(args)
|
145
|
-
verify_args!(args:args, optparse:optparse, count:1)
|
146
|
-
connect(options)
|
147
|
-
# parse args
|
148
|
-
outfile = args[0]
|
149
|
-
if !validate_outfile(outfile, options)
|
150
|
-
return 1, "Failed to validate outfile"
|
151
|
-
end
|
152
|
-
# construct the api request
|
153
|
-
params.merge!(parse_list_options(options))
|
154
|
-
if outfile.include?(".yml") || outfile.include?(".yaml")
|
155
|
-
options[:yaml] = true
|
156
|
-
end
|
157
|
-
openapi_format = options[:yaml] ? "yaml" : "json"
|
158
|
-
params['format'] = openapi_format
|
159
|
-
# execute the api request
|
160
|
-
@doc_interface.setopts(options)
|
161
|
-
if options[:dry_run]
|
162
|
-
print_dry_run @doc_interface.dry.download_openapi(outfile, params)
|
163
|
-
return 0, nil
|
164
|
-
end
|
165
|
-
print cyan + "Downloading openapi.#{openapi_format} to #{outfile} ... " if !options[:quiet]
|
166
|
-
http_response = @doc_interface.download_openapi(outfile, params)
|
167
|
-
if http_response.code.to_i == 200
|
168
|
-
print green + "SUCCESS" + reset + "\n" if !options[:quiet]
|
169
|
-
return 0, nil
|
170
|
-
else
|
171
|
-
print red + "ERROR" + reset + " HTTP #{http_response.code}" + "\n" if !options[:quiet]
|
172
|
-
if File.exist?(outfile) && File.file?(outfile)
|
173
|
-
Morpheus::Logging::DarkPrinter.puts "Deleting bad file download: #{outfile}" if Morpheus::Logging.debug?
|
174
|
-
File.delete(outfile)
|
175
|
-
end
|
176
|
-
return 1, "HTTP #{http_response.code}"
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
protected
|
181
|
-
|
182
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'morpheus_test'
|
2
|
-
|
3
|
-
# Tests for Morpheus::DocInterface
|
4
|
-
class MorpheusTest::DocInterfaceTest < MorpheusTest::TestCase
|
5
|
-
|
6
|
-
def test_doc_list
|
7
|
-
@doc_interface = client.doc
|
8
|
-
response = @doc_interface.list()
|
9
|
-
assert_equal response['links'].class, Array
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_doc_get
|
13
|
-
@doc_interface = client.doc
|
14
|
-
response = @doc_interface.openapi()
|
15
|
-
assert_equal response['openapi'], '3.0.3'
|
16
|
-
# todo: fix this, can be cached and fail
|
17
|
-
#assert_equal response['version'], Morpheus::Cli::Remote.load_remote(@config.remote_name)[:build_version]
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_doc_get_yaml
|
21
|
-
@doc_interface = client.doc
|
22
|
-
response = @doc_interface.openapi({'format' => "yaml"})
|
23
|
-
assert response.body
|
24
|
-
assert YAML.load(response.body)
|
25
|
-
end
|
26
|
-
|
27
|
-
# def test_doc_download
|
28
|
-
# @doc_interface = client.doc
|
29
|
-
# response = @doc_interface.download_openapi('/path/to/openapi.json')
|
30
|
-
# yaml_content = response.body
|
31
|
-
# yaml_data = YAML.load(yaml_content)
|
32
|
-
# assert_not_nil yaml_data
|
33
|
-
# end
|
34
|
-
|
35
|
-
end
|
data/test/cli/doc_test.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'morpheus_test'
|
2
|
-
|
3
|
-
# Tests for Morpheus::Cli::Doc
|
4
|
-
class MorpheusTest::DocTest < MorpheusTest::TestCase
|
5
|
-
|
6
|
-
def test_doc_list
|
7
|
-
assert_execute("doc list")
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_doc_get
|
11
|
-
# using --quiet because the output is massive
|
12
|
-
assert_execute("doc get --quiet")
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_doc_get_yaml
|
16
|
-
# using --quiet because the output is massive
|
17
|
-
assert_execute("doc get --yaml --quiet")
|
18
|
-
end
|
19
|
-
|
20
|
-
# def test_doc_download
|
21
|
-
# assert_execute("doc download '/path/to/openapi.json')
|
22
|
-
# end
|
23
|
-
|
24
|
-
# def test_doc_download_yaml
|
25
|
-
# assert_execute("doc download '/path/to/openapi.yaml' --yaml")
|
26
|
-
# end
|
27
|
-
|
28
|
-
def test_doc_get_unauthorized
|
29
|
-
# authentication is NOT required for this api
|
30
|
-
without_authentication do
|
31
|
-
assert_error("doc get -q")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|