morpheus-cli 5.5.2.2 → 5.5.3.1
Sign up to get free protection for your applications and to get access to all the features.
- 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 +20 -2
- data/lib/morpheus/api/appliance_settings_interface.rb +15 -0
- 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/cypher_interface.rb +1 -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/guidance_settings_interface.rb +17 -0
- 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/monitoring_settings_interface.rb +25 -0
- data/lib/morpheus/api/network_server_groups_interface.rb +7 -0
- 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 +79 -37
- 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/appliance_settings_command.rb +57 -2
- data/lib/morpheus/cli/commands/apps.rb +1 -1
- data/lib/morpheus/cli/commands/archives_command.rb +25 -33
- data/lib/morpheus/cli/commands/backup_settings_command.rb +1 -1
- 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 +18 -13
- 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/cypher_command.rb +3 -0
- 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/guidance_command.rb +2 -2
- data/lib/morpheus/cli/commands/guidance_settings.rb +148 -0
- 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/log_settings_command.rb +1 -1
- data/lib/morpheus/cli/commands/login.rb +1 -1
- data/lib/morpheus/cli/commands/man_command.rb +32 -18
- data/lib/morpheus/cli/commands/monitoring_settings.rb +228 -0
- data/lib/morpheus/cli/commands/network_server_groups_command.rb +222 -0
- 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/provisioning_settings_command.rb +1 -1
- data/lib/morpheus/cli/commands/remote.rb +1 -1
- data/lib/morpheus/cli/commands/reports_command.rb +13 -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 +5 -5
- 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/provisioning_helper.rb +14 -12
- data/lib/morpheus/cli/mixins/rest_command.rb +23 -19
- data/lib/morpheus/cli/mixins/secondary_rest_command.rb +47 -24
- 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/ext/string.rb +6 -4
- 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 +41 -9
- 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 +67 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a66b8b7fa9512d6f649a5c369b2a5da24efe9e551b48cce4fe551bc68f9f842
|
4
|
+
data.tar.gz: 285fb4339cbf1c2ea71539d1bff2e8bed75ec6be097cffdaeda751ed49b59b6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fc26b54a4a2d2dfb83429e769acbc730a1f61ff1023468e49b17e056fdfc510d7f5cbb642d07cc76d26e46b1aa8cc7b631e8f658fe7f133c5c7c67301d026e6
|
7
|
+
data.tar.gz: c52f8eb39797f15a3ab811ff9f42557f879d9ef13269c633cee2f99cfce9ec2b51ab9f67ce8998ad68416b3cd94d5b5c44a642ea71167aeb93640e2baed65d82
|
data/.gitignore
CHANGED
data/Dockerfile
CHANGED
data/README.md
CHANGED
@@ -13,15 +13,21 @@ This library is a Ruby gem that provides a command line interface for interactin
|
|
13
13
|
|
14
14
|
Install it using rubygems
|
15
15
|
|
16
|
-
|
16
|
+
```shell
|
17
|
+
gem install morpheus-cli
|
18
|
+
```
|
17
19
|
|
18
20
|
Or add this line to your application's Gemfile:
|
19
21
|
|
20
|
-
|
22
|
+
```ruby
|
23
|
+
gem 'morpheus-cli'
|
24
|
+
```
|
21
25
|
|
22
26
|
And then execute:
|
23
27
|
|
24
|
-
|
28
|
+
```shell
|
29
|
+
bundle install
|
30
|
+
```
|
25
31
|
|
26
32
|
## Usage
|
27
33
|
|
@@ -29,7 +35,7 @@ And then execute:
|
|
29
35
|
|
30
36
|
This gem installs the [morpheus](https://github.com/gomorpheus/morpheus-cli/wiki/CLI-Manual) binary for running commands in your terminal shell.
|
31
37
|
|
32
|
-
```
|
38
|
+
```shell
|
33
39
|
morpheus remote add
|
34
40
|
morpheus instances list
|
35
41
|
```
|
@@ -39,3 +45,50 @@ morpheus instances list
|
|
39
45
|
If you are interested in interfacing with the Morpheus appliance in ruby directly, you can use [Morpheus::APIClient](https://github.com/gomorpheus/morpheus-cli/wiki/APIClient) or [Morpheus::Terminal](https://github.com/gomorpheus/morpheus-cli/wiki/Terminal).
|
40
46
|
|
41
47
|
For more detailed usage information, visit the [Morpheus CLI Wiki](https://github.com/gomorpheus/morpheus-cli/wiki).
|
48
|
+
|
49
|
+
|
50
|
+
## Development
|
51
|
+
|
52
|
+
New API interfaces get added under the library directory: `lib/morpheus/api/`.
|
53
|
+
New CLI commands get added under the library directory: `lib/morpheus/cli/commands/`.
|
54
|
+
|
55
|
+
While developing, you can quickly reload your code changes in a morpheus shell while developing:
|
56
|
+
|
57
|
+
```shell
|
58
|
+
morpheus shell
|
59
|
+
```
|
60
|
+
|
61
|
+
Then to reload changes without restarting the morpheus shell (and the ruby process), use:
|
62
|
+
|
63
|
+
```shell
|
64
|
+
reload
|
65
|
+
```
|
66
|
+
|
67
|
+
Don't forget to add unit tests for your new commands under the directory: `test/`.
|
68
|
+
|
69
|
+
## Testing
|
70
|
+
|
71
|
+
To run the CLI unit tests, first create a `test_config.yaml` and then run `rake test`.
|
72
|
+
|
73
|
+
### Prepare Test Environment
|
74
|
+
|
75
|
+
Create a `test_config.yaml` like this:
|
76
|
+
|
77
|
+
```shell
|
78
|
+
touch test_config.yaml
|
79
|
+
```
|
80
|
+
|
81
|
+
Enter your test environment url and credentials in `test_config.yaml` like so:
|
82
|
+
|
83
|
+
```yaml
|
84
|
+
url: 'http://localhost:8080'
|
85
|
+
username: testrunner
|
86
|
+
password: 'SecretPassword123$'
|
87
|
+
```
|
88
|
+
|
89
|
+
### Run Tests
|
90
|
+
|
91
|
+
```shell
|
92
|
+
rake test
|
93
|
+
```
|
94
|
+
|
data/Rakefile
CHANGED
data/bin/morpheus
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'morpheus
|
2
|
+
require 'morpheus'
|
3
3
|
|
4
4
|
# arguments
|
5
5
|
args = ARGV
|
6
6
|
|
7
7
|
# input pipe
|
8
8
|
# append piped data as arguments
|
9
|
-
if
|
10
|
-
pipe_data =
|
9
|
+
if !$stdin.tty?
|
10
|
+
pipe_data = $stdin.read
|
11
11
|
if pipe_data
|
12
12
|
args += pipe_data.split
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
# output pipe
|
17
|
-
# if
|
17
|
+
# if !$stdout.tty?
|
18
18
|
|
19
19
|
# end
|
20
20
|
|
@@ -9,7 +9,6 @@ class Morpheus::APIClient
|
|
9
9
|
|
10
10
|
CLIENT_ID = 'morph-cli' unless defined?(CLIENT_ID)
|
11
11
|
|
12
|
-
attr_accessor :client_id
|
13
12
|
# Initialize a new APIClient
|
14
13
|
# client = APIClient.new(url:"https://morpheus.yourcompany.com", verify_ssl:false)
|
15
14
|
# This old method signature is being deprecated:
|
@@ -40,9 +39,11 @@ class Morpheus::APIClient
|
|
40
39
|
end
|
41
40
|
@base_url = @base_url.chomp("/")
|
42
41
|
# todo: validate URI
|
42
|
+
@expires_at = nil
|
43
43
|
if expires_in != nil
|
44
44
|
@expires_at = Time.now + expires_in
|
45
45
|
end
|
46
|
+
@dry_run = false
|
46
47
|
set_ssl_verification_enabled(verify_ssl)
|
47
48
|
setopts(options)
|
48
49
|
end
|
@@ -797,10 +798,18 @@ class Morpheus::APIClient
|
|
797
798
|
Morpheus::BackupSettingsInterface.new(common_interface_options).setopts(@options)
|
798
799
|
end
|
799
800
|
|
801
|
+
def guidance_settings
|
802
|
+
Morpheus::GuidanceSettingsInterface.new(common_interface_options).setopts(@options)
|
803
|
+
end
|
804
|
+
|
800
805
|
def log_settings
|
801
806
|
Morpheus::LogSettingsInterface.new(common_interface_options).setopts(@options)
|
802
807
|
end
|
803
808
|
|
809
|
+
def monitoring_settings
|
810
|
+
Morpheus::MonitoringSettingsInterface.new(common_interface_options).setopts(@options)
|
811
|
+
end
|
812
|
+
|
804
813
|
def whitelabel_settings
|
805
814
|
Morpheus::WhitelabelSettingsInterface.new(common_interface_options).setopts(@options)
|
806
815
|
end
|
@@ -893,6 +902,10 @@ class Morpheus::APIClient
|
|
893
902
|
Morpheus::NetworkServersInterface.new(common_interface_options).setopts(@options)
|
894
903
|
end
|
895
904
|
|
905
|
+
def network_server_groups
|
906
|
+
Morpheus::NetworkServerGroupsInterface.new(common_interface_options).setopts(@options)
|
907
|
+
end
|
908
|
+
|
896
909
|
def network_edge_clusters
|
897
910
|
Morpheus::NetworkEdgeClustersInterface.new(common_interface_options).setopts(@options)
|
898
911
|
end
|
@@ -956,7 +969,12 @@ class Morpheus::APIClient
|
|
956
969
|
protected
|
957
970
|
|
958
971
|
def validate_id!(id, param_name='id')
|
959
|
-
|
972
|
+
if !(id.is_a?(String) || id.is_a?(Integer))
|
973
|
+
raise "#{self.class} passed an invalid #{param_name}! Expected String or Integer and got (#{id.class}) #{id.inspect}"
|
974
|
+
elsif id.to_s.strip.empty?
|
975
|
+
raise "#{self.class} passed a blank #{param_name}!"
|
976
|
+
end
|
977
|
+
return true
|
960
978
|
end
|
961
979
|
|
962
980
|
end
|
@@ -24,4 +24,19 @@ class Morpheus::ApplianceSettingsInterface < Morpheus::APIClient
|
|
24
24
|
opts = {method: :get, url: url, headers: headers}
|
25
25
|
execute(opts)
|
26
26
|
end
|
27
|
+
|
28
|
+
def maintenance(params={}, payload={})
|
29
|
+
url = "#{base_path}/maintenance"
|
30
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
31
|
+
opts = {method: :post, url: url, headers: headers, payload: payload}
|
32
|
+
execute(opts)
|
33
|
+
end
|
34
|
+
|
35
|
+
def reindex(params={}, payload={})
|
36
|
+
url = "#{base_path}/reindex"
|
37
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
38
|
+
opts = {method: :post, url: url, headers: headers, payload: payload}
|
39
|
+
execute(opts)
|
40
|
+
end
|
41
|
+
|
27
42
|
end
|
@@ -83,7 +83,7 @@ class Morpheus::ArchiveBucketsInterface < Morpheus::APIClient
|
|
83
83
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
84
84
|
opts = {method: :get, url: url, headers: headers, timeout: 172800}
|
85
85
|
# execute(opts, {parse_json:false})
|
86
|
-
if Dir.
|
86
|
+
if Dir.exist?(outfile)
|
87
87
|
raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
|
88
88
|
end
|
89
89
|
# if @verify_ssl == false
|
@@ -24,7 +24,7 @@ class Morpheus::ArchiveFilesInterface < Morpheus::APIClient
|
|
24
24
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
25
25
|
opts = {method: :get, url: url, headers: headers, timeout: 172800}
|
26
26
|
# execute(opts, {parse_json: false})
|
27
|
-
if Dir.
|
27
|
+
if Dir.exist?(outfile)
|
28
28
|
raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
|
29
29
|
end
|
30
30
|
# if @verify_ssl == false
|
@@ -53,7 +53,7 @@ class Morpheus::ArchiveFilesInterface < Morpheus::APIClient
|
|
53
53
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
54
54
|
opts = {method: :get, url: url, headers: headers, timeout: 172800}
|
55
55
|
# execute(opts, {parse_json: false})
|
56
|
-
if Dir.
|
56
|
+
if Dir.exist?(outfile)
|
57
57
|
raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
|
58
58
|
end
|
59
59
|
# if @verify_ssl == false
|
@@ -83,7 +83,7 @@ class Morpheus::ArchiveFilesInterface < Morpheus::APIClient
|
|
83
83
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
84
84
|
opts = {method: :get, url: url, headers: headers, timeout: 172800}
|
85
85
|
# execute(opts, {parse_json: false})
|
86
|
-
if Dir.
|
86
|
+
if Dir.exist?(outfile)
|
87
87
|
raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
|
88
88
|
end
|
89
89
|
# if @verify_ssl == false
|
@@ -10,14 +10,14 @@ class Morpheus::ClientsInterface < Morpheus::APIClient
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def get(id, params={})
|
13
|
-
|
13
|
+
raise "#{self.class}.get() passed a blank name!" if id.to_s == ''
|
14
14
|
url = "#{@base_url}/api/clients/#{id}"
|
15
15
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
16
16
|
opts = {method: :get, url: url, headers: headers}
|
17
17
|
execute(opts)
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
def create(payload)
|
21
21
|
url = "#{@base_url}/api/clients"
|
22
22
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
23
23
|
opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
|
@@ -113,7 +113,7 @@ class Morpheus::ClustersInterface < Morpheus::APIClient
|
|
113
113
|
url = "#{base_path}/#{id}/upgrade-cluster"
|
114
114
|
headers = { params: params, authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
115
115
|
execute(method: :post, url: url, headers: headers)
|
116
|
-
|
116
|
+
end
|
117
117
|
|
118
118
|
def list_services(id, params={})
|
119
119
|
url = "#{base_path}/#{id}/services"
|
@@ -306,4 +306,11 @@ class Morpheus::ClustersInterface < Morpheus::APIClient
|
|
306
306
|
execute(opts)
|
307
307
|
end
|
308
308
|
|
309
|
+
|
310
|
+
def apply_template(id, payload={})
|
311
|
+
url = "#{@base_url}/api/clusters/#{id}/apply-template"
|
312
|
+
|
313
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
314
|
+
execute(method: :post, url: url, headers: headers, payload: payload.to_json)
|
315
|
+
end
|
309
316
|
end
|
@@ -4,18 +4,21 @@ require 'morpheus/api/api_client'
|
|
4
4
|
# All of the PUT methods support passing an array of IDs.
|
5
5
|
class Morpheus::ContainersInterface < Morpheus::APIClient
|
6
6
|
|
7
|
+
def base_path
|
8
|
+
"/api/containers"
|
9
|
+
end
|
7
10
|
# not used atm.. index api needs some work, we should implement it
|
8
11
|
# so it just paginates all containers.
|
9
12
|
# right now you can to pass params as {:ids => [1,2,3]}
|
10
13
|
def list(params={})
|
11
|
-
url = "#{
|
14
|
+
url = "#{base_path}"
|
12
15
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
13
16
|
opts = {method: :get, url: url, headers: headers}
|
14
17
|
execute(opts)
|
15
18
|
end
|
16
19
|
|
17
20
|
def get(container_id)
|
18
|
-
url = "#{
|
21
|
+
url = "#{base_path}/#{container_id}"
|
19
22
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
20
23
|
opts = {method: :get, url: url, headers: headers}
|
21
24
|
execute(opts)
|
@@ -24,10 +27,10 @@ class Morpheus::ContainersInterface < Morpheus::APIClient
|
|
24
27
|
def stop(container_id, payload={})
|
25
28
|
url, params = "", {}
|
26
29
|
if container_id.is_a?(Array)
|
27
|
-
url = "#{
|
30
|
+
url = "#{base_path}/stop"
|
28
31
|
params = {ids: container_id}
|
29
32
|
else
|
30
|
-
url = "#{
|
33
|
+
url = "#{base_path}/#{container_id}/stop"
|
31
34
|
params = {}
|
32
35
|
end
|
33
36
|
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -38,10 +41,10 @@ class Morpheus::ContainersInterface < Morpheus::APIClient
|
|
38
41
|
def start(container_id, payload={})
|
39
42
|
url, params = "", {}
|
40
43
|
if container_id.is_a?(Array)
|
41
|
-
url = "#{
|
44
|
+
url = "#{base_path}/start"
|
42
45
|
params = {ids: container_id}
|
43
46
|
else
|
44
|
-
url = "#{
|
47
|
+
url = "#{base_path}/#{container_id}/start"
|
45
48
|
params = {}
|
46
49
|
end
|
47
50
|
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -52,10 +55,10 @@ class Morpheus::ContainersInterface < Morpheus::APIClient
|
|
52
55
|
def restart(container_id, payload={})
|
53
56
|
url, params = "", {}
|
54
57
|
if container_id.is_a?(Array)
|
55
|
-
url = "#{
|
58
|
+
url = "#{base_path}/restart"
|
56
59
|
params = {ids: container_id}
|
57
60
|
else
|
58
|
-
url = "#{
|
61
|
+
url = "#{base_path}/#{container_id}/restart"
|
59
62
|
params = {}
|
60
63
|
end
|
61
64
|
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -66,10 +69,10 @@ class Morpheus::ContainersInterface < Morpheus::APIClient
|
|
66
69
|
def suspend(container_id, payload={})
|
67
70
|
url, params = "", {}
|
68
71
|
if container_id.is_a?(Array)
|
69
|
-
url = "#{
|
72
|
+
url = "#{base_path}/suspend"
|
70
73
|
params = {ids: container_id}
|
71
74
|
else
|
72
|
-
url = "#{
|
75
|
+
url = "#{base_path}/#{container_id}/suspend"
|
73
76
|
params = {}
|
74
77
|
end
|
75
78
|
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -80,10 +83,10 @@ class Morpheus::ContainersInterface < Morpheus::APIClient
|
|
80
83
|
def eject(container_id, payload={})
|
81
84
|
url, params = "", {}
|
82
85
|
if container_id.is_a?(Array)
|
83
|
-
url = "#{
|
86
|
+
url = "#{base_path}/eject"
|
84
87
|
params = {ids: container_id}
|
85
88
|
else
|
86
|
-
url = "#{
|
89
|
+
url = "#{base_path}/#{container_id}/eject"
|
87
90
|
params = {}
|
88
91
|
end
|
89
92
|
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -94,10 +97,10 @@ class Morpheus::ContainersInterface < Morpheus::APIClient
|
|
94
97
|
def available_actions(container_id)
|
95
98
|
url, params = "", {}
|
96
99
|
if container_id.is_a?(Array)
|
97
|
-
url = "#{
|
100
|
+
url = "#{base_path}/actions"
|
98
101
|
params = {ids: container_id}
|
99
102
|
else
|
100
|
-
url = "#{
|
103
|
+
url = "#{base_path}/#{container_id}/actions"
|
101
104
|
params = {}
|
102
105
|
end
|
103
106
|
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -108,10 +111,10 @@ class Morpheus::ContainersInterface < Morpheus::APIClient
|
|
108
111
|
def action(container_id, action_code, payload={})
|
109
112
|
url, params = "", {}
|
110
113
|
if container_id.is_a?(Array)
|
111
|
-
url = "#{
|
114
|
+
url = "#{base_path}/action"
|
112
115
|
params = {ids: container_id, code: action_code}
|
113
116
|
else
|
114
|
-
url = "#{
|
117
|
+
url = "#{base_path}/#{container_id}/action"
|
115
118
|
params = {code: action_code}
|
116
119
|
end
|
117
120
|
headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -119,4 +122,14 @@ class Morpheus::ContainersInterface < Morpheus::APIClient
|
|
119
122
|
execute(opts)
|
120
123
|
end
|
121
124
|
|
125
|
+
def import(container_id, payload={}, headers={})
|
126
|
+
validate_id!(container_id)
|
127
|
+
execute(method: :put, url: "#{base_path}/#{container_id}/import", payload: payload, headers: headers)
|
128
|
+
end
|
129
|
+
|
130
|
+
def clone_image(container_id, payload={}, headers={})
|
131
|
+
validate_id!(container_id)
|
132
|
+
execute(method: :put, url: "#{base_path}/#{container_id}/clone-image", payload: payload, headers: headers)
|
133
|
+
end
|
134
|
+
|
122
135
|
end
|
@@ -73,7 +73,6 @@ class Morpheus::CustomInstanceTypesInterface < Morpheus::APIClient
|
|
73
73
|
def destroy_version(instance_type_id, id)
|
74
74
|
url = "#{@base_url}/api/custom-instance-types/#{instance_type_id}/versions/#{id}"
|
75
75
|
headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json'}
|
76
|
-
payload = options
|
77
76
|
execute(method: :delete, url: url, headers: headers)
|
78
77
|
end
|
79
78
|
|
@@ -94,7 +93,6 @@ class Morpheus::CustomInstanceTypesInterface < Morpheus::APIClient
|
|
94
93
|
def destroy_upgrade(instance_type_id, id)
|
95
94
|
url = "#{@base_url}/api/custom-instance-types/#{instance_type_id}/upgrades/#{id}"
|
96
95
|
headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json'}
|
97
|
-
payload = options
|
98
96
|
execute(method: :delete, url: url, headers: headers)
|
99
97
|
end
|
100
98
|
|
@@ -13,9 +13,8 @@ class Morpheus::DocInterface < Morpheus::APIClient
|
|
13
13
|
execute(method: :get, url: url, headers: headers)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
url = "/api/doc/
|
18
|
-
# prefer /swagger.yml instead of /swagger?format=yml
|
16
|
+
def openapi(params={})
|
17
|
+
url = "/api/doc/openapi"
|
19
18
|
fmt = params.delete('format')
|
20
19
|
if fmt
|
21
20
|
url = url + "." + fmt
|
@@ -25,10 +24,11 @@ class Morpheus::DocInterface < Morpheus::APIClient
|
|
25
24
|
execute(method: :get, url: url, headers: headers, timeout: 172800, parse_json: !is_yaml)
|
26
25
|
end
|
27
26
|
|
28
|
-
|
27
|
+
alias :swagger :openapi
|
28
|
+
|
29
|
+
def download_openapi(outfile, params={})
|
29
30
|
# note that RestClient.execute still requires the full path with base_url
|
30
|
-
url = "#{@base_url}/api/doc/
|
31
|
-
# prefer /swagger.yml instead of /swagger?format=yml
|
31
|
+
url = "#{@base_url}/api/doc/openapi"
|
32
32
|
fmt = params.delete('format')
|
33
33
|
if fmt
|
34
34
|
url = url + "." + fmt
|
@@ -54,4 +54,6 @@ class Morpheus::DocInterface < Morpheus::APIClient
|
|
54
54
|
http_response
|
55
55
|
end
|
56
56
|
|
57
|
+
alias :swagger :download_openapi
|
58
|
+
|
57
59
|
end
|
@@ -42,7 +42,7 @@ class Morpheus::FileCopyRequestInterface < Morpheus::APIClient
|
|
42
42
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
43
43
|
opts = {method: :get, url: url, headers: headers}
|
44
44
|
# execute(opts, {parse_json: false})
|
45
|
-
if Dir.
|
45
|
+
if Dir.exist?(outfile)
|
46
46
|
raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
|
47
47
|
end
|
48
48
|
# if @verify_ssl == false
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::GuidanceSettingsInterface < Morpheus::APIClient
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"/api/guidance-settings"
|
7
|
+
end
|
8
|
+
|
9
|
+
def get(params={}, headers={})
|
10
|
+
execute(method: :get, url: "#{base_path}", params: params, headers: headers)
|
11
|
+
end
|
12
|
+
|
13
|
+
def update(payload, params={}, headers={})
|
14
|
+
execute(method: :put, url: "#{base_path}", payload: payload, params: params, headers: headers)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -68,7 +68,7 @@ class Morpheus::HealthInterface < Morpheus::APIClient
|
|
68
68
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
69
69
|
opts = {method: :get, url: url, headers: headers}
|
70
70
|
# execute(opts, {parse_json: false})
|
71
|
-
if Dir.
|
71
|
+
if Dir.exist?(outfile)
|
72
72
|
raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
|
73
73
|
end
|
74
74
|
# if @verify_ssl == false
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'morpheus/api/api_client'
|
2
|
-
require 'morpheus/api/image_builder_image_builds_interface'
|
3
|
-
require 'morpheus/api/image_builder_preseed_scripts_interface'
|
4
|
-
require 'morpheus/api/image_builder_boot_scripts_interface'
|
2
|
+
# require 'morpheus/api/image_builder_image_builds_interface'
|
3
|
+
# require 'morpheus/api/image_builder_preseed_scripts_interface'
|
4
|
+
# require 'morpheus/api/image_builder_boot_scripts_interface'
|
5
5
|
|
6
6
|
class Morpheus::ImageBuilderInterface < Morpheus::APIClient
|
7
7
|
|
@@ -318,6 +318,31 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
318
318
|
execute(opts)
|
319
319
|
end
|
320
320
|
|
321
|
+
def list_schedules(id, params={}, headers={})
|
322
|
+
validate_id!(id)
|
323
|
+
execute(method: :get, url: "#{base_path}/#{id}/schedules", params: params, headers: headers)
|
324
|
+
end
|
325
|
+
|
326
|
+
def get_schedule(id, schedule_id, params={}, headers={})
|
327
|
+
validate_id!(id) && validate_id!(schedule_id, 'schedule_id')
|
328
|
+
execute(method: :get, url: "#{base_path}/#{id}/schedules/#{schedule_id}", params: params, headers: headers)
|
329
|
+
end
|
330
|
+
|
331
|
+
def create_schedule(id, payload, params={}, headers={})
|
332
|
+
validate_id!(id)
|
333
|
+
execute(method: :post, url: "#{base_path}/#{id}/schedules", params: params, payload: payload, headers: headers)
|
334
|
+
end
|
335
|
+
|
336
|
+
def update_schedule(id, schedule_id, payload, params={}, headers={})
|
337
|
+
validate_id!(id) && validate_id!(schedule_id, 'schedule_id')
|
338
|
+
execute(method: :put, url: "#{base_path}/#{id}/schedules/#{schedule_id}", params: params, payload: payload, headers: headers)
|
339
|
+
end
|
340
|
+
|
341
|
+
def destroy_schedule(id, schedule_id, params = {}, headers={})
|
342
|
+
validate_id!(id) && validate_id!(schedule_id, 'schedule_id')
|
343
|
+
execute(method: :delete, url: "#{base_path}/#{id}/schedules/#{schedule_id}", params: params, headers: headers)
|
344
|
+
end
|
345
|
+
|
321
346
|
def update_load_balancer(id, payload)
|
322
347
|
url = "#{@base_url}/api/instances/#{id}/load-balancer"
|
323
348
|
headers = {authorization: "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
@@ -4,7 +4,6 @@ class Morpheus::LogsInterface < Morpheus::APIClient
|
|
4
4
|
|
5
5
|
def list(params={})
|
6
6
|
url = "#{@base_url}/api/logs"
|
7
|
-
# old versions expected containers[]
|
8
7
|
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
9
8
|
execute({method: :get, url: url, headers: headers})
|
10
9
|
end
|
@@ -12,14 +11,13 @@ class Morpheus::LogsInterface < Morpheus::APIClient
|
|
12
11
|
def container_logs(containers=[], params={})
|
13
12
|
url = "#{@base_url}/api/logs"
|
14
13
|
# old versions expected containers[]
|
15
|
-
headers = { params: {'containers' => containers
|
14
|
+
headers = { params: {'containers' => containers}.merge(params), authorization: "Bearer #{@access_token}" }
|
16
15
|
execute({method: :get, url: url, headers: headers})
|
17
16
|
end
|
18
17
|
|
19
18
|
def server_logs(servers=[], params={})
|
20
19
|
url = "#{@base_url}/api/logs"
|
21
|
-
|
22
|
-
headers = { params: {'servers' => servers, 'servers[]' => servers}.merge(params), authorization: "Bearer #{@access_token}" }
|
20
|
+
headers = { params: {'servers' => servers}.merge(params), authorization: "Bearer #{@access_token}" }
|
23
21
|
execute({method: :get, url: url, headers: headers})
|
24
22
|
end
|
25
23
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'morpheus/api/api_client'
|
2
|
-
require 'morpheus/api/monitoring_checks_interface'
|
3
|
-
require 'morpheus/api/monitoring_groups_interface'
|
4
|
-
require 'morpheus/api/monitoring_apps_interface'
|
5
|
-
require 'morpheus/api/monitoring_incidents_interface'
|
6
|
-
require 'morpheus/api/monitoring_contacts_interface'
|
7
|
-
require 'morpheus/api/monitoring_alerts_interface'
|
2
|
+
# require 'morpheus/api/monitoring_checks_interface'
|
3
|
+
# require 'morpheus/api/monitoring_groups_interface'
|
4
|
+
# require 'morpheus/api/monitoring_apps_interface'
|
5
|
+
# require 'morpheus/api/monitoring_incidents_interface'
|
6
|
+
# require 'morpheus/api/monitoring_contacts_interface'
|
7
|
+
# require 'morpheus/api/monitoring_alerts_interface'
|
8
8
|
|
9
9
|
class Morpheus::MonitoringInterface < Morpheus::APIClient
|
10
10
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'morpheus/api/api_client'
|
2
|
+
|
3
|
+
class Morpheus::MonitoringSettingsInterface < Morpheus::APIClient
|
4
|
+
|
5
|
+
def base_path
|
6
|
+
"/api/monitoring-settings"
|
7
|
+
end
|
8
|
+
|
9
|
+
def get(params={}, headers={})
|
10
|
+
execute(method: :get, url: "#{base_path}", params: params, headers: headers)
|
11
|
+
end
|
12
|
+
|
13
|
+
def update(payload, params={}, headers={})
|
14
|
+
execute(method: :put, url: "#{base_path}", payload: payload, params: params, headers: headers)
|
15
|
+
end
|
16
|
+
|
17
|
+
def update_service_now(payload, params={}, headers={})
|
18
|
+
execute(method: :put, url: "#{base_path}/service-now", payload: payload, params: params, headers: headers)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update_new_relic(payload, params={}, headers={})
|
22
|
+
execute(method: :put, url: "#{base_path}/new-relic", payload: payload, params: params, headers: headers)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|