morpheus-cli 0.1.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/morpheus/api/accounts_interface.rb +55 -0
- data/lib/morpheus/api/api_client.rb +48 -3
- data/lib/morpheus/api/apps_interface.rb +13 -13
- data/lib/morpheus/api/{zones_interface.rb → clouds_interface.rb} +10 -10
- data/lib/morpheus/api/deploy_interface.rb +4 -4
- data/lib/morpheus/api/groups_interface.rb +3 -3
- data/lib/morpheus/api/instance_types_interface.rb +2 -2
- data/lib/morpheus/api/instances_interface.rb +35 -19
- data/lib/morpheus/api/key_pairs_interface.rb +60 -0
- data/lib/morpheus/api/license_interface.rb +29 -0
- data/lib/morpheus/api/load_balancers_interface.rb +72 -0
- data/lib/morpheus/api/logs_interface.rb +37 -0
- data/lib/morpheus/api/options_interface.rb +20 -0
- data/lib/morpheus/api/provision_types_interface.rb +27 -0
- data/lib/morpheus/api/roles_interface.rb +73 -0
- data/lib/morpheus/api/security_group_rules_interface.rb +3 -3
- data/lib/morpheus/api/security_groups_interface.rb +5 -5
- data/lib/morpheus/api/servers_interface.rb +67 -3
- data/lib/morpheus/api/task_sets_interface.rb +46 -0
- data/lib/morpheus/api/tasks_interface.rb +72 -0
- data/lib/morpheus/api/users_interface.rb +72 -0
- data/lib/morpheus/cli.rb +27 -4
- data/lib/morpheus/cli/accounts.rb +306 -0
- data/lib/morpheus/cli/apps.rb +58 -1
- data/lib/morpheus/cli/cli_command.rb +87 -0
- data/lib/morpheus/cli/cli_registry.rb +6 -1
- data/lib/morpheus/cli/{zones.rb → clouds.rb} +99 -70
- data/lib/morpheus/cli/credentials.rb +23 -11
- data/lib/morpheus/cli/error_handler.rb +31 -11
- data/lib/morpheus/cli/groups.rb +1 -0
- data/lib/morpheus/cli/hosts.rb +567 -0
- data/lib/morpheus/cli/instances.rb +588 -292
- data/lib/morpheus/cli/key_pairs.rb +393 -0
- data/lib/morpheus/cli/license.rb +118 -0
- data/lib/morpheus/cli/load_balancers.rb +366 -0
- data/lib/morpheus/cli/mixins/accounts_helper.rb +193 -0
- data/lib/morpheus/cli/option_types.rb +260 -0
- data/lib/morpheus/cli/roles.rb +164 -0
- data/lib/morpheus/cli/security_group_rules.rb +4 -9
- data/lib/morpheus/cli/shell.rb +108 -0
- data/lib/morpheus/cli/tasks.rb +370 -0
- data/lib/morpheus/cli/users.rb +325 -0
- data/lib/morpheus/cli/version.rb +1 -1
- data/lib/morpheus/cli/workflows.rb +100 -0
- data/lib/morpheus/formatters.rb +43 -0
- data/morpheus-cli.gemspec +1 -1
- metadata +33 -10
- data/lib/morpheus/cli/servers.rb +0 -265
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
class Morpheus::KeyPairsInterface < Morpheus::APIClient
|
5
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
6
|
+
@access_token = access_token
|
7
|
+
@refresh_token = refresh_token
|
8
|
+
@base_url = base_url
|
9
|
+
@expires_at = expires_at
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(account_id, id)
|
13
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
14
|
+
url = "#{@base_url}/api/key-pairs/#{id}"
|
15
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
16
|
+
headers[:params]['accountId'] = account_id if account_id
|
17
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
18
|
+
timeout: 10, headers: headers)
|
19
|
+
JSON.parse(response.to_s)
|
20
|
+
end
|
21
|
+
|
22
|
+
def list(account_id, options={})
|
23
|
+
url = "#{@base_url}/api/key-pairs"
|
24
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
25
|
+
headers[:params].merge!(options)
|
26
|
+
headers[:params]['accountId'] = account_id if account_id
|
27
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
28
|
+
timeout: 10, headers: headers)
|
29
|
+
JSON.parse(response.to_s)
|
30
|
+
end
|
31
|
+
|
32
|
+
def create(account_id, options)
|
33
|
+
url = "#{@base_url}/api/key-pairs"
|
34
|
+
headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
35
|
+
headers[:params]['accountId'] = account_id if account_id
|
36
|
+
payload = options
|
37
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
38
|
+
timeout: 10, headers: headers, payload: payload.to_json)
|
39
|
+
JSON.parse(response.to_s)
|
40
|
+
end
|
41
|
+
|
42
|
+
def update(account_id, id, options)
|
43
|
+
url = "#{@base_url}/api/key-pairs/#{id}"
|
44
|
+
headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
45
|
+
headers[:params]['accountId'] = account_id if account_id
|
46
|
+
payload = options
|
47
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
48
|
+
timeout: 10, headers: headers, payload: payload.to_json)
|
49
|
+
JSON.parse(response.to_s)
|
50
|
+
end
|
51
|
+
|
52
|
+
def destroy(account_id, id)
|
53
|
+
url = "#{@base_url}/api/key-pairs/#{id}"
|
54
|
+
headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
55
|
+
headers[:params]['accountId'] = account_id if account_id
|
56
|
+
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
57
|
+
timeout: 10, headers: headers)
|
58
|
+
JSON.parse(response.to_s)
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
class Morpheus::LicenseInterface < Morpheus::APIClient
|
5
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
6
|
+
@access_token = access_token
|
7
|
+
@refresh_token = refresh_token
|
8
|
+
@base_url = base_url
|
9
|
+
@expires_at = expires_at
|
10
|
+
end
|
11
|
+
|
12
|
+
def get()
|
13
|
+
url = "#{@base_url}/api/license"
|
14
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
15
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
16
|
+
timeout: 30, headers: headers, verify_ssl: false)
|
17
|
+
JSON.parse(response.to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
def apply(key)
|
21
|
+
url = "#{@base_url}/api/license"
|
22
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
23
|
+
payload = {license: key}
|
24
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
25
|
+
timeout: 30, headers: headers, payload: payload.to_json, verify_ssl: false)
|
26
|
+
JSON.parse(response.to_s)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
class Morpheus::LoadBalancersInterface < Morpheus::APIClient
|
5
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
6
|
+
@access_token = access_token
|
7
|
+
@refresh_token = refresh_token
|
8
|
+
@base_url = base_url
|
9
|
+
@expires_at = expires_at
|
10
|
+
end
|
11
|
+
|
12
|
+
def load_balancer_types(options={})
|
13
|
+
url = "#{@base_url}/api/load-balancer-types"
|
14
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
15
|
+
|
16
|
+
if options.is_a?(Hash)
|
17
|
+
headers[:params].merge!(options)
|
18
|
+
elsif options.is_a?(Numeric)
|
19
|
+
url = "#{@base_url}/api/load-balancer-types/#{options}"
|
20
|
+
elsif options.is_a?(String)
|
21
|
+
headers[:params]['name'] = options
|
22
|
+
end
|
23
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
24
|
+
timeout: 30, headers: headers, verify_ssl:false)
|
25
|
+
JSON.parse(response.to_s)
|
26
|
+
end
|
27
|
+
|
28
|
+
def get(options=nil)
|
29
|
+
url = "#{@base_url}/api/load-balancers"
|
30
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
31
|
+
|
32
|
+
if options.is_a?(Hash)
|
33
|
+
headers[:params].merge!(options)
|
34
|
+
elsif options.is_a?(Numeric)
|
35
|
+
url = "#{@base_url}/api/load-balancers/#{options}"
|
36
|
+
elsif options.is_a?(String)
|
37
|
+
headers[:params]['name'] = options
|
38
|
+
end
|
39
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
40
|
+
timeout: 30, headers: headers, verify_ssl:false)
|
41
|
+
JSON.parse(response.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
def update(id, options)
|
45
|
+
url = "#{@base_url}/api/load-balancers/#{id}"
|
46
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
47
|
+
|
48
|
+
payload = options
|
49
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
50
|
+
timeout: 10, headers: headers, payload: payload.to_json)
|
51
|
+
JSON.parse(response.to_s)
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def create(options)
|
56
|
+
url = "#{@base_url}/api/load-balancers"
|
57
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
58
|
+
|
59
|
+
payload = options
|
60
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
61
|
+
timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
|
62
|
+
JSON.parse(response.to_s)
|
63
|
+
end
|
64
|
+
|
65
|
+
def destroy(id)
|
66
|
+
url = "#{@base_url}/api/load-balancers/#{id}"
|
67
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
68
|
+
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
69
|
+
timeout: 30, headers: headers, verify_ssl:false)
|
70
|
+
JSON.parse(response.to_s)
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
class Morpheus::LogsInterface < Morpheus::APIClient
|
5
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
6
|
+
@access_token = access_token
|
7
|
+
@refresh_token = refresh_token
|
8
|
+
@base_url = base_url
|
9
|
+
@expires_at = expires_at
|
10
|
+
end
|
11
|
+
|
12
|
+
def container_logs(containers=[], options={})
|
13
|
+
url = "#{@base_url}/api/logs"
|
14
|
+
headers = { params: {'containers': containers}.merge(options), authorization: "Bearer #{@access_token}" }
|
15
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
16
|
+
timeout: 30, headers: headers, verify_ssl: false)
|
17
|
+
JSON.parse(response.to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
def server_logs(servers=[], options={})
|
21
|
+
url = "#{@base_url}/api/logs"
|
22
|
+
headers = { params: {'servers': servers}.merge(options), authorization: "Bearer #{@access_token}" }
|
23
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
24
|
+
timeout: 30, headers: headers, verify_ssl: false)
|
25
|
+
JSON.parse(response.to_s)
|
26
|
+
end
|
27
|
+
|
28
|
+
def stats()
|
29
|
+
url = "#{@base_url}/api/logs/log-stats"
|
30
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
31
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
32
|
+
timeout: 30, headers: headers, verify_ssl: false)
|
33
|
+
JSON.parse(response.to_s)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
class Morpheus::OptionsInterface < Morpheus::APIClient
|
5
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
6
|
+
@access_token = access_token
|
7
|
+
@refresh_token = refresh_token
|
8
|
+
@base_url = base_url
|
9
|
+
@expires_at = expires_at
|
10
|
+
end
|
11
|
+
|
12
|
+
def options_for_source(source,params = {})
|
13
|
+
url = "#{@base_url}/api/options/#{source}"
|
14
|
+
headers = { params: params, authorization: "Bearer #{@access_token}" }
|
15
|
+
|
16
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
17
|
+
timeout: 30, headers: headers,verify_ssl: false)
|
18
|
+
JSON.parse(response.to_s)
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'morpheus/rest_client'
|
3
|
+
|
4
|
+
class Morpheus::ProvisionTypesInterface < Morpheus::APIClient
|
5
|
+
def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
|
6
|
+
@access_token = access_token
|
7
|
+
@refresh_token = refresh_token
|
8
|
+
@base_url = base_url
|
9
|
+
@expires_at = expires_at
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(options=nil)
|
13
|
+
url = "#{@base_url}/api/provision-types"
|
14
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
15
|
+
|
16
|
+
if options.is_a?(Hash)
|
17
|
+
headers[:params].merge!(options)
|
18
|
+
elsif options.is_a?(Numeric)
|
19
|
+
url = "#{@base_url}/api/provision-types/#{options}"
|
20
|
+
elsif options.is_a?(String)
|
21
|
+
headers[:params]['name'] = options
|
22
|
+
end
|
23
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
24
|
+
timeout: 30, headers: headers, verify_ssl:false)
|
25
|
+
JSON.parse(response.to_s)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
class Morpheus::RolesInterface < Morpheus::APIClient
|
5
|
+
|
6
|
+
def initialize(access_token, refresh_token, expires_at = nil, base_url=nil)
|
7
|
+
@access_token = access_token
|
8
|
+
@refresh_token = refresh_token
|
9
|
+
@base_url = base_url
|
10
|
+
@expires_at = expires_at
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(account_id, id)
|
14
|
+
raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
|
15
|
+
url = build_url(account_id, id)
|
16
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
17
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
18
|
+
timeout: 10, headers: headers)
|
19
|
+
JSON.parse(response.to_s)
|
20
|
+
end
|
21
|
+
|
22
|
+
def list(account_id, options={})
|
23
|
+
url = build_url(account_id)
|
24
|
+
headers = { params: {}, authorization: "Bearer #{@access_token}" }
|
25
|
+
headers[:params].merge!(options)
|
26
|
+
response = Morpheus::RestClient.execute(method: :get, url: url,
|
27
|
+
timeout: 10, headers: headers)
|
28
|
+
JSON.parse(response.to_s)
|
29
|
+
end
|
30
|
+
|
31
|
+
def create(account_id, options)
|
32
|
+
url = build_url(account_id)
|
33
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
34
|
+
payload = options
|
35
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
36
|
+
timeout: 10, headers: headers, payload: payload.to_json)
|
37
|
+
JSON.parse(response.to_s)
|
38
|
+
end
|
39
|
+
|
40
|
+
def update(account_id, id, options)
|
41
|
+
url = build_url(account_id, id)
|
42
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
43
|
+
payload = options
|
44
|
+
response = Morpheus::RestClient.execute(method: :post, url: url,
|
45
|
+
timeout: 10, headers: headers, payload: payload.to_json)
|
46
|
+
JSON.parse(response.to_s)
|
47
|
+
end
|
48
|
+
|
49
|
+
def destroy(account_id, id)
|
50
|
+
url = build_url(account_id, id)
|
51
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
52
|
+
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
53
|
+
timeout: 10, headers: headers)
|
54
|
+
JSON.parse(response.to_s)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def build_url(account_id=nil, role_id=nil)
|
60
|
+
url = "#{@base_url}/api"
|
61
|
+
if account_id
|
62
|
+
#url += "/accounts/#{account_id}/roles"
|
63
|
+
url += "/roles"
|
64
|
+
else
|
65
|
+
url += "/roles"
|
66
|
+
end
|
67
|
+
if role_id
|
68
|
+
url += "/#{role_id}"
|
69
|
+
end
|
70
|
+
url
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -20,7 +20,7 @@ class Morpheus::SecurityGroupRulesInterface < Morpheus::APIClient
|
|
20
20
|
url = "#{@base_url}/api/security-groups/#{security_group_id}/rules/#{options}"
|
21
21
|
end
|
22
22
|
response = Morpheus::RestClient.execute(method: :get, url: url,
|
23
|
-
timeout:
|
23
|
+
timeout: 30, headers: headers)
|
24
24
|
JSON.parse(response.to_s)
|
25
25
|
end
|
26
26
|
|
@@ -30,7 +30,7 @@ class Morpheus::SecurityGroupRulesInterface < Morpheus::APIClient
|
|
30
30
|
|
31
31
|
payload = options
|
32
32
|
response = Morpheus::RestClient.execute(method: :post, url: url,
|
33
|
-
timeout:
|
33
|
+
timeout: 30, headers: headers, payload: payload.to_json)
|
34
34
|
JSON.parse(response.to_s)
|
35
35
|
end
|
36
36
|
|
@@ -39,7 +39,7 @@ class Morpheus::SecurityGroupRulesInterface < Morpheus::APIClient
|
|
39
39
|
print "url #{url}"
|
40
40
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
41
41
|
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
42
|
-
timeout:
|
42
|
+
timeout: 30, headers: headers)
|
43
43
|
JSON.parse(response.to_s)
|
44
44
|
end
|
45
45
|
end
|
@@ -16,7 +16,7 @@ class Morpheus::SecurityGroupsInterface < Morpheus::APIClient
|
|
16
16
|
headers[:params].merge!(options)
|
17
17
|
end
|
18
18
|
response = Morpheus::RestClient.execute(method: :get, url: url,
|
19
|
-
timeout:
|
19
|
+
timeout: 30, headers: headers, verify_ssl: false)
|
20
20
|
JSON.parse(response.to_s)
|
21
21
|
end
|
22
22
|
|
@@ -27,7 +27,7 @@ class Morpheus::SecurityGroupsInterface < Morpheus::APIClient
|
|
27
27
|
headers[:params].merge!(options)
|
28
28
|
end
|
29
29
|
response = Morpheus::RestClient.execute(method: :get, url: url,
|
30
|
-
timeout:
|
30
|
+
timeout: 30, headers: headers, verify_ssl: false)
|
31
31
|
JSON.parse(response.to_s)
|
32
32
|
end
|
33
33
|
|
@@ -37,7 +37,7 @@ class Morpheus::SecurityGroupsInterface < Morpheus::APIClient
|
|
37
37
|
|
38
38
|
payload = options
|
39
39
|
response = Morpheus::RestClient.execute(method: :post, url: url,
|
40
|
-
timeout:
|
40
|
+
timeout: 30, headers: headers, verify_ssl: false, payload: payload.to_json)
|
41
41
|
JSON.parse(response.to_s)
|
42
42
|
end
|
43
43
|
|
@@ -45,7 +45,7 @@ class Morpheus::SecurityGroupsInterface < Morpheus::APIClient
|
|
45
45
|
url = "#{@base_url}/api/security-groups/#{id}"
|
46
46
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
47
47
|
response = Morpheus::RestClient.execute(method: :put, url: url,
|
48
|
-
timeout:
|
48
|
+
timeout: 30, headers: headers, verify_ssl: false)
|
49
49
|
JSON.parse(response.to_s)
|
50
50
|
end
|
51
51
|
|
@@ -53,7 +53,7 @@ class Morpheus::SecurityGroupsInterface < Morpheus::APIClient
|
|
53
53
|
url = "#{@base_url}/api/security-groups/#{id}"
|
54
54
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
55
55
|
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
56
|
-
timeout:
|
56
|
+
timeout: 30, headers: headers, verify_ssl: false)
|
57
57
|
JSON.parse(response.to_s)
|
58
58
|
end
|
59
59
|
end
|
@@ -21,7 +21,7 @@ class Morpheus::ServersInterface < Morpheus::APIClient
|
|
21
21
|
headers[:params]['name'] = options
|
22
22
|
end
|
23
23
|
response = Morpheus::RestClient.execute(method: :get, url: url,
|
24
|
-
timeout:
|
24
|
+
timeout: 30, headers: headers, verify_ssl:false)
|
25
25
|
JSON.parse(response.to_s)
|
26
26
|
end
|
27
27
|
|
@@ -32,7 +32,71 @@ class Morpheus::ServersInterface < Morpheus::APIClient
|
|
32
32
|
|
33
33
|
payload = options
|
34
34
|
response = Morpheus::RestClient.execute(method: :post, url: url,
|
35
|
-
timeout:
|
35
|
+
timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
|
36
|
+
JSON.parse(response.to_s)
|
37
|
+
end
|
38
|
+
|
39
|
+
def stop(serverId,payload = {})
|
40
|
+
url = "#{@base_url}/api/servers/#{serverId}/stop"
|
41
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
42
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
43
|
+
timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
|
44
|
+
JSON.parse(response.to_s)
|
45
|
+
end
|
46
|
+
|
47
|
+
def start(serverId,payload = {})
|
48
|
+
url = "#{@base_url}/api/servers/#{serverId}/start"
|
49
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
50
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
51
|
+
timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
|
52
|
+
JSON.parse(response.to_s)
|
53
|
+
end
|
54
|
+
|
55
|
+
def install_agent(serverId,payload = {})
|
56
|
+
url = "#{@base_url}/api/servers/#{serverId}/install-agent"
|
57
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
58
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
59
|
+
timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
|
60
|
+
JSON.parse(response.to_s)
|
61
|
+
end
|
62
|
+
|
63
|
+
def upgrade(serverId,payload = {})
|
64
|
+
url = "#{@base_url}/api/servers/#{serverId}/upgrade"
|
65
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
66
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
67
|
+
timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
|
68
|
+
JSON.parse(response.to_s)
|
69
|
+
end
|
70
|
+
|
71
|
+
def reprovision(serverId,payload = {})
|
72
|
+
url = "#{@base_url}/api/servers/#{serverId}/reprovision"
|
73
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
74
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
75
|
+
timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
|
76
|
+
JSON.parse(response.to_s)
|
77
|
+
end
|
78
|
+
|
79
|
+
def reinitialize(serverId,payload = {})
|
80
|
+
url = "#{@base_url}/api/servers/#{serverId}/reinitialize"
|
81
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
82
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
83
|
+
timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
|
84
|
+
JSON.parse(response.to_s)
|
85
|
+
end
|
86
|
+
|
87
|
+
def assign_account(serverId,payload = {})
|
88
|
+
url = "#{@base_url}/api/servers/#{serverId}/assign-account"
|
89
|
+
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
90
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
91
|
+
timeout: 30, headers: headers, verify_ssl:false, payload: payload.to_json)
|
92
|
+
JSON.parse(response.to_s)
|
93
|
+
end
|
94
|
+
|
95
|
+
def workflow(id,task_set_id,payload)
|
96
|
+
url = "#{@base_url}/api/servers/#{id}/workflow"
|
97
|
+
headers = { :params => {:taskSetId => task_set_id},:authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
98
|
+
response = Morpheus::RestClient.execute(method: :put, url: url,
|
99
|
+
timeout: 30, headers: headers,verify_ssl: false,payload: payload.to_json)
|
36
100
|
JSON.parse(response.to_s)
|
37
101
|
end
|
38
102
|
|
@@ -40,7 +104,7 @@ class Morpheus::ServersInterface < Morpheus::APIClient
|
|
40
104
|
url = "#{@base_url}/api/servers/#{id}"
|
41
105
|
headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
|
42
106
|
response = Morpheus::RestClient.execute(method: :delete, url: url,
|
43
|
-
timeout:
|
107
|
+
timeout: 30, headers: headers, verify_ssl:false)
|
44
108
|
JSON.parse(response.to_s)
|
45
109
|
end
|
46
110
|
end
|