morpheus-cli 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bin/morpheus +24 -16
- data/lib/morpheus/api/api_client.rb +8 -0
- data/lib/morpheus/api/apps_interface.rb +50 -17
- data/lib/morpheus/api/deploy_interface.rb +7 -7
- data/lib/morpheus/api/groups_interface.rb +5 -5
- data/lib/morpheus/api/instance_types_interface.rb +4 -4
- data/lib/morpheus/api/instances_interface.rb +46 -12
- data/lib/morpheus/api/security_group_rules_interface.rb +45 -0
- data/lib/morpheus/api/security_groups_interface.rb +59 -0
- data/lib/morpheus/api/servers_interface.rb +4 -4
- data/lib/morpheus/api/zones_interface.rb +38 -5
- data/lib/morpheus/cli.rb +5 -0
- data/lib/morpheus/cli/apps.rb +153 -7
- data/lib/morpheus/cli/cli_command.rb +20 -0
- data/lib/morpheus/cli/cli_registry.rb +75 -0
- data/lib/morpheus/cli/credentials.rb +4 -3
- data/lib/morpheus/cli/deploys.rb +7 -2
- data/lib/morpheus/cli/groups.rb +4 -2
- data/lib/morpheus/cli/instance_types.rb +3 -1
- data/lib/morpheus/cli/instances.rb +151 -2
- data/lib/morpheus/cli/remote.rb +2 -1
- data/lib/morpheus/cli/security_group_rules.rb +243 -0
- data/lib/morpheus/cli/security_groups.rb +192 -0
- data/lib/morpheus/cli/servers.rb +4 -1
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/zones.rb +152 -4
- data/lib/morpheus/rest_client.rb +50 -0
- data/morpheus-cli.gemspec +2 -2
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 155f7945ae237b102b407e7e7f0558f390db806f
|
4
|
+
data.tar.gz: a42d7f42f2c04b8793ec463c5f54832ab8630138
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15b5d574772c270cd79ba16aca4b5474e1baefe66c508ac943811c1be61f5aef72fc7a1d309d568f5d5134b9436f6fd8583c37588a8331c49c5714cb7814e484
|
7
|
+
data.tar.gz: 834ee86b5021746dcd9fefa488e933434cc08b5ad8606894123281ffad98a98890cd992ace753d7afb6d552e4953ed2d612156dfd672d7ffaa5a2b8e6e0d4f64
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Morpheus::Cli
|
2
2
|
|
3
|
-
|
3
|
+
Provides a command line interface for interacting with the Morpheus Cloud Platform. Easily provision servers, containers, and manage deployments.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,7 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
Please check out the [Wiki](https://github.com/gomorpheus/morpheus-cli/wiki) for usage instructions.
|
22
22
|
|
23
23
|
## Contributing
|
24
24
|
|
data/bin/morpheus
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'morpheus/cli'
|
3
|
+
require 'morpheus/rest_client'
|
4
|
+
require 'morpheus/cli/cli_registry'
|
3
5
|
|
4
6
|
remote_handler = Morpheus::Cli::Remote.new()
|
5
7
|
|
8
|
+
# parse args to handle global issues
|
9
|
+
if ARGV.find {|arg| arg == '--insecure'}
|
10
|
+
Morpheus::RestClient.enable_ssl_verification = false
|
11
|
+
end
|
12
|
+
|
13
|
+
filtered_args = ARGV.find_all {|arg| arg != '--insecure'}
|
14
|
+
|
15
|
+
if Morpheus::Cli::CliRegistry.has_command?(ARGV[0])
|
16
|
+
Morpheus::Cli::CliRegistry.exec(ARGV[0], filtered_args[1..-1])
|
17
|
+
exit 0
|
18
|
+
end
|
19
|
+
|
6
20
|
case ARGV[0]
|
7
21
|
when 'remote'
|
8
|
-
remote_handler.handle(
|
22
|
+
remote_handler.handle(filtered_args[1..-1])
|
9
23
|
when 'login'
|
10
24
|
appliance_name, appliance_url = Morpheus::Cli::Remote.active_appliance
|
11
25
|
Morpheus::Cli::Credentials.new(appliance_name,appliance_url).login()
|
12
|
-
when 'groups'
|
13
|
-
Morpheus::Cli::Groups.new().handle(ARGV[1..-1])
|
14
|
-
when 'zones'
|
15
|
-
Morpheus::Cli::Zones.new().handle(ARGV[1..-1])
|
16
|
-
when 'servers'
|
17
|
-
Morpheus::Cli::Servers.new().handle(ARGV[1..-1])
|
18
|
-
when 'instances'
|
19
|
-
Morpheus::Cli::Instances.new().handle(ARGV[1..-1])
|
20
|
-
when 'instance-types'
|
21
|
-
Morpheus::Cli::InstanceTypes.new().handle(ARGV[1..-1])
|
22
|
-
when 'apps'
|
23
|
-
Morpheus::Cli::Apps.new().handle(ARGV[1..-1])
|
24
|
-
when 'deploy'
|
25
|
-
Morpheus::Cli::Deploys.new().handle(ARGV[1..-1])
|
26
26
|
when 'logout'
|
27
27
|
appliance_name, appliance_url = Morpheus::Cli::Remote.active_appliance
|
28
28
|
creds = Morpheus::Cli::Credentials.new(appliance_name,appliance_url).load_saved_credentials()
|
@@ -33,4 +33,12 @@ case ARGV[0]
|
|
33
33
|
end
|
34
34
|
else
|
35
35
|
puts "\nUsage: morpheus [command] [options]\n"
|
36
|
-
|
36
|
+
puts "\nCommands:\n"
|
37
|
+
puts "\tremote"
|
38
|
+
puts "\tlogin"
|
39
|
+
puts "\tlogout"
|
40
|
+
Morpheus::Cli::CliRegistry.all.each {|cmd,klass|
|
41
|
+
puts "\t#{cmd.to_s}"
|
42
|
+
}
|
43
|
+
puts ""
|
44
|
+
end
|
@@ -38,4 +38,12 @@ class Morpheus::APIClient
|
|
38
38
|
def deploy
|
39
39
|
Morpheus::DeployInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
40
40
|
end
|
41
|
+
|
42
|
+
def security_groups
|
43
|
+
Morpheus::SecurityGroupsInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
44
|
+
end
|
45
|
+
|
46
|
+
def security_group_rules
|
47
|
+
Morpheus::SecurityGroupRulesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
|
48
|
+
end
|
41
49
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
-
require '
|
2
|
+
require 'morpheus/rest_client'
|
3
3
|
|
4
4
|
class Morpheus::AppsInterface < Morpheus::APIClient
|
5
5
|
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
@@ -21,7 +21,7 @@ class Morpheus::AppsInterface < Morpheus::APIClient
|
|
21
21
|
elsif options.is_a?(String)
|
22
22
|
headers[:params]['name'] = options
|
23
23
|
end
|
24
|
-
response = RestClient
|
24
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
25
25
|
timeout: 10, headers: headers)
|
26
26
|
JSON.parse(response.to_s)
|
27
27
|
end
|
@@ -29,8 +29,8 @@ class Morpheus::AppsInterface < Morpheus::APIClient
|
|
29
29
|
def get_envs(id, options=nil)
|
30
30
|
url = "#{@base_url}/api/apps/#{id}/envs"
|
31
31
|
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
32
|
-
response = RestClient
|
33
|
-
|
32
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
33
|
+
timeout: 10, headers: headers)
|
34
34
|
JSON.parse(response.to_s)
|
35
35
|
end
|
36
36
|
|
@@ -39,7 +39,7 @@ class Morpheus::AppsInterface < Morpheus::APIClient
|
|
39
39
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
40
40
|
|
41
41
|
payload = {envs: options}
|
42
|
-
response = RestClient
|
42
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
43
43
|
timeout: 10, headers: headers, payload: payload.to_json)
|
44
44
|
JSON.parse(response.to_s)
|
45
45
|
end
|
@@ -48,8 +48,8 @@ class Morpheus::AppsInterface < Morpheus::APIClient
|
|
48
48
|
url = "#{@base_url}/api/apps/#{id}/envs/#{name}"
|
49
49
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
50
50
|
|
51
|
-
response = RestClient
|
52
|
-
|
51
|
+
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
52
|
+
timeout: 10, headers: headers)
|
53
53
|
JSON.parse(response.to_s)
|
54
54
|
end
|
55
55
|
|
@@ -59,40 +59,73 @@ class Morpheus::AppsInterface < Morpheus::APIClient
|
|
59
59
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
60
60
|
|
61
61
|
payload = options
|
62
|
-
response = RestClient
|
63
|
-
|
62
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
63
|
+
timeout: 10, headers: headers, payload: payload.to_json)
|
64
64
|
JSON.parse(response.to_s)
|
65
65
|
end
|
66
66
|
|
67
67
|
def destroy(id)
|
68
68
|
url = "#{@base_url}/api/apps/#{id}"
|
69
69
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
70
|
-
response = RestClient
|
71
|
-
|
70
|
+
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
71
|
+
timeout: 10, headers: headers)
|
72
72
|
JSON.parse(response.to_s)
|
73
73
|
end
|
74
74
|
|
75
75
|
def stop(id)
|
76
76
|
url = "#{@base_url}/api/apps/#{id}/stop"
|
77
77
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
78
|
-
response = RestClient
|
79
|
-
|
78
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
79
|
+
timeout: 10, headers: headers)
|
80
80
|
JSON.parse(response.to_s)
|
81
81
|
end
|
82
82
|
|
83
83
|
def start(id)
|
84
84
|
url = "#{@base_url}/api/apps/#{id}/start"
|
85
85
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
86
|
-
response = RestClient
|
87
|
-
|
86
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
87
|
+
timeout: 10, headers: headers)
|
88
88
|
JSON.parse(response.to_s)
|
89
89
|
end
|
90
90
|
|
91
91
|
def restart(id)
|
92
92
|
url = "#{@base_url}/api/apps/#{id}/restart"
|
93
93
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
94
|
-
response = RestClient
|
94
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
95
|
+
timeout: 10, headers: headers)
|
96
|
+
JSON.parse(response.to_s)
|
97
|
+
end
|
98
|
+
|
99
|
+
def firewall_disable(id)
|
100
|
+
url = "#{@base_url}/api/apps/#{id}/security-groups/disable"
|
101
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
102
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
103
|
+
timeout: 10, headers: headers)
|
104
|
+
JSON.parse(response.to_s)
|
105
|
+
end
|
106
|
+
|
107
|
+
def firewall_enable(id)
|
108
|
+
url = "#{@base_url}/api/apps/#{id}/security-groups/enable"
|
109
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
110
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
111
|
+
timeout: 10, headers: headers)
|
112
|
+
JSON.parse(response.to_s)
|
113
|
+
end
|
114
|
+
|
115
|
+
def security_groups(id)
|
116
|
+
url = "#{@base_url}/api/apps/#{id}/security-groups"
|
117
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
118
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
95
119
|
timeout: 10, headers: headers)
|
96
120
|
JSON.parse(response.to_s)
|
97
121
|
end
|
98
|
-
|
122
|
+
|
123
|
+
def apply_security_groups(id, options)
|
124
|
+
url = "#{@base_url}/api/apps/#{id}/security-groups"
|
125
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
126
|
+
payload = options
|
127
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
128
|
+
timeout: 10, headers: headers, payload: payload.to_json)
|
129
|
+
JSON.parse(response.to_s)
|
130
|
+
end
|
131
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'json'
|
2
|
-
require 'rest-client'
|
3
2
|
require 'net/http/post/multipart'
|
4
3
|
require 'mime/types'
|
4
|
+
require 'morpheus/rest_client'
|
5
5
|
|
6
6
|
class Morpheus::DeployInterface < Morpheus::APIClient
|
7
7
|
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
@@ -21,7 +21,7 @@ class Morpheus::DeployInterface < Morpheus::APIClient
|
|
21
21
|
elsif options.is_a?(String)
|
22
22
|
headers[:params]['name'] = options
|
23
23
|
end
|
24
|
-
response = RestClient
|
24
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
25
25
|
timeout: 10, headers: headers)
|
26
26
|
JSON.parse(response.to_s)
|
27
27
|
end
|
@@ -32,7 +32,7 @@ class Morpheus::DeployInterface < Morpheus::APIClient
|
|
32
32
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
33
33
|
|
34
34
|
payload = options || {}
|
35
|
-
response = RestClient
|
35
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
36
36
|
timeout: 10, headers: headers, payload: payload.to_json)
|
37
37
|
JSON.parse(response.to_s)
|
38
38
|
end
|
@@ -42,7 +42,7 @@ class Morpheus::DeployInterface < Morpheus::APIClient
|
|
42
42
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
43
43
|
|
44
44
|
payload = options
|
45
|
-
response = RestClient
|
45
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
46
46
|
timeout: 10, headers: headers)
|
47
47
|
JSON.parse(response.to_s)
|
48
48
|
end
|
@@ -68,7 +68,7 @@ class Morpheus::DeployInterface < Morpheus::APIClient
|
|
68
68
|
def destroy(id)
|
69
69
|
url = "#{@base_url}/api/deploy/#{id}"
|
70
70
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
71
|
-
response = RestClient
|
71
|
+
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
72
72
|
timeout: 10, headers: headers)
|
73
73
|
JSON.parse(response.to_s)
|
74
74
|
end
|
@@ -82,7 +82,7 @@ class Morpheus::DeployInterface < Morpheus::APIClient
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
85
|
-
response = RestClient
|
85
|
+
response = Morpheus::RestClient.execute(method: :post, url: url, headers: headers, timeout: nil, payload: payload.to_json)
|
86
86
|
JSON.parse(response.to_s)
|
87
87
|
end
|
88
|
-
end
|
88
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
-
require '
|
2
|
+
require 'morpheus/rest_client'
|
3
3
|
|
4
4
|
class Morpheus::GroupsInterface < Morpheus::APIClient
|
5
5
|
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
@@ -21,7 +21,7 @@ class Morpheus::GroupsInterface < Morpheus::APIClient
|
|
21
21
|
elsif options.is_a?(String)
|
22
22
|
headers[:params]['name'] = options
|
23
23
|
end
|
24
|
-
response = RestClient
|
24
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
25
25
|
timeout: 10, headers: headers)
|
26
26
|
JSON.parse(response.to_s)
|
27
27
|
end
|
@@ -32,7 +32,7 @@ class Morpheus::GroupsInterface < Morpheus::APIClient
|
|
32
32
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
33
33
|
|
34
34
|
payload = {group: options}
|
35
|
-
response = RestClient
|
35
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
36
36
|
timeout: 10, headers: headers, payload: payload.to_json)
|
37
37
|
JSON.parse(response.to_s)
|
38
38
|
end
|
@@ -40,8 +40,8 @@ class Morpheus::GroupsInterface < Morpheus::APIClient
|
|
40
40
|
def destroy(id)
|
41
41
|
url = "#{@base_url}/api/groups/#{id}"
|
42
42
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
43
|
-
response = RestClient
|
43
|
+
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
44
44
|
timeout: 10, headers: headers)
|
45
45
|
JSON.parse(response.to_s)
|
46
46
|
end
|
47
|
-
end
|
47
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
-
require '
|
2
|
+
require 'morpheus/rest_client'
|
3
3
|
|
4
4
|
class Morpheus::InstanceTypesInterface < Morpheus::APIClient
|
5
5
|
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
@@ -21,7 +21,7 @@ class Morpheus::InstanceTypesInterface < Morpheus::APIClient
|
|
21
21
|
elsif options.is_a?(String)
|
22
22
|
headers[:params]['name'] = options
|
23
23
|
end
|
24
|
-
response = RestClient
|
24
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
25
25
|
timeout: 10, headers: headers)
|
26
26
|
JSON.parse(response.to_s)
|
27
27
|
end
|
@@ -33,10 +33,10 @@ class Morpheus::InstanceTypesInterface < Morpheus::APIClient
|
|
33
33
|
if !name.nil?
|
34
34
|
headers[:params][:name] = name
|
35
35
|
end
|
36
|
-
response = RestClient
|
36
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
37
37
|
timeout: 10, headers: headers)
|
38
38
|
JSON.parse(response.to_s)
|
39
39
|
end
|
40
40
|
|
41
41
|
|
42
|
-
end
|
42
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
-
require '
|
2
|
+
require 'morpheus/rest_client'
|
3
3
|
|
4
4
|
class Morpheus::InstancesInterface < Morpheus::APIClient
|
5
5
|
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
@@ -9,7 +9,6 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
9
9
|
@expires_at = expires_at
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
12
|
def get(options=nil)
|
14
13
|
url = "#{@base_url}/api/instances"
|
15
14
|
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
@@ -21,7 +20,7 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
21
20
|
elsif options.is_a?(String)
|
22
21
|
headers[:params]['name'] = options
|
23
22
|
end
|
24
|
-
response = RestClient
|
23
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
25
24
|
timeout: 10, headers: headers)
|
26
25
|
JSON.parse(response.to_s)
|
27
26
|
end
|
@@ -29,7 +28,7 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
29
28
|
def get_envs(id, options=nil)
|
30
29
|
url = "#{@base_url}/api/instances/#{id}/envs"
|
31
30
|
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
32
|
-
response = RestClient
|
31
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
33
32
|
timeout: 10, headers: headers)
|
34
33
|
JSON.parse(response.to_s)
|
35
34
|
end
|
@@ -39,7 +38,7 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
39
38
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
40
39
|
|
41
40
|
payload = {envs: options}
|
42
|
-
response = RestClient
|
41
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
43
42
|
timeout: 10, headers: headers, payload: payload.to_json)
|
44
43
|
JSON.parse(response.to_s)
|
45
44
|
end
|
@@ -48,7 +47,7 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
48
47
|
url = "#{@base_url}/api/instances/#{id}/envs/#{name}"
|
49
48
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
50
49
|
|
51
|
-
response = RestClient
|
50
|
+
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
52
51
|
timeout: 10, headers: headers)
|
53
52
|
JSON.parse(response.to_s)
|
54
53
|
end
|
@@ -59,7 +58,7 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
59
58
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
60
59
|
|
61
60
|
payload = options
|
62
|
-
response = RestClient
|
61
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
63
62
|
timeout: 10, headers: headers, payload: payload.to_json)
|
64
63
|
JSON.parse(response.to_s)
|
65
64
|
end
|
@@ -67,7 +66,7 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
67
66
|
def destroy(id)
|
68
67
|
url = "#{@base_url}/api/instances/#{id}"
|
69
68
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
70
|
-
response = RestClient
|
69
|
+
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
71
70
|
timeout: 10, headers: headers)
|
72
71
|
JSON.parse(response.to_s)
|
73
72
|
end
|
@@ -75,7 +74,7 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
75
74
|
def stop(id)
|
76
75
|
url = "#{@base_url}/api/instances/#{id}/stop"
|
77
76
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
78
|
-
response = RestClient
|
77
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
79
78
|
timeout: 10, headers: headers)
|
80
79
|
JSON.parse(response.to_s)
|
81
80
|
end
|
@@ -83,7 +82,7 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
83
82
|
def start(id)
|
84
83
|
url = "#{@base_url}/api/instances/#{id}/start"
|
85
84
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
86
|
-
response = RestClient
|
85
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
87
86
|
timeout: 10, headers: headers)
|
88
87
|
JSON.parse(response.to_s)
|
89
88
|
end
|
@@ -91,8 +90,43 @@ class Morpheus::InstancesInterface < Morpheus::APIClient
|
|
91
90
|
def restart(id)
|
92
91
|
url = "#{@base_url}/api/instances/#{id}/restart"
|
93
92
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
94
|
-
response = RestClient
|
93
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
94
|
+
timeout: 10, headers: headers)
|
95
|
+
JSON.parse(response.to_s)
|
96
|
+
end
|
97
|
+
|
98
|
+
def firewall_disable(id)
|
99
|
+
url = "#{@base_url}/api/instances/#{id}/security-groups/disable"
|
100
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
101
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
102
|
+
timeout: 10, headers: headers)
|
103
|
+
JSON.parse(response.to_s)
|
104
|
+
end
|
105
|
+
|
106
|
+
def firewall_enable(id)
|
107
|
+
url = "#{@base_url}/api/instances/#{id}/security-groups/enable"
|
108
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
109
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
95
110
|
timeout: 10, headers: headers)
|
96
111
|
JSON.parse(response.to_s)
|
97
112
|
end
|
98
|
-
|
113
|
+
|
114
|
+
def security_groups(id)
|
115
|
+
url = "#{@base_url}/api/instances/#{id}/security-groups"
|
116
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
117
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
118
|
+
timeout: 10, headers: headers)
|
119
|
+
JSON.parse(response.to_s)
|
120
|
+
end
|
121
|
+
|
122
|
+
def apply_security_groups(id, options)
|
123
|
+
url = "#{@base_url}/api/instances/#{id}/security-groups"
|
124
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
125
|
+
payload = options
|
126
|
+
puts "payload #{payload}"
|
127
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
128
|
+
timeout: 10, headers: headers, payload: payload.to_json)
|
129
|
+
JSON.parse(response.to_s)
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|