solusvm 1.1.0.beta2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/solusvm.rb +0 -2
- data/lib/solusvm/base.rb +47 -20
- data/lib/solusvm/general.rb +13 -10
- data/lib/solusvm/node.rb +8 -6
- data/lib/solusvm/version.rb +1 -1
- data/test/solusvm/test_base.rb +20 -22
- data/test/solusvm/test_general.rb +3 -15
- data/test/solusvm/test_node.rb +10 -14
- metadata +11 -83
- data/lib/solusvm/exceptions.rb +0 -4
- data/lib/solusvm/solusvm_errors.rb +0 -22
data/lib/solusvm.rb
CHANGED
data/lib/solusvm/base.rb
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
Faraday.register_middleware :response, :solusvm_errors => Solusvm::SolusvmErrors
|
|
2
|
-
|
|
3
1
|
module Solusvm
|
|
4
2
|
# Solusvm::Base is the main class for mapping API resources as subclasses.
|
|
5
3
|
class Base
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
VALID_SERVER_TYPES = ["openvz", "xen", "xen hvm"]
|
|
5
|
+
|
|
6
|
+
attr_reader :returned_parameters
|
|
8
7
|
|
|
9
8
|
# Prepares and sends the API request to the URL specificed in Solusvm.config
|
|
10
9
|
#
|
|
11
10
|
# class MyClass < Base
|
|
12
11
|
# def create_server(name)
|
|
13
|
-
# perform_request(:action =>
|
|
12
|
+
# perform_request(:action => "name", :id => 1)
|
|
14
13
|
# end
|
|
15
14
|
# end
|
|
16
15
|
#
|
|
@@ -20,14 +19,15 @@ module Solusvm
|
|
|
20
19
|
#
|
|
21
20
|
# <tt>force_array</tt> - see parse_response
|
|
22
21
|
def perform_request(options = {}, force_array = false)
|
|
23
|
-
ca_path = File.join(File.dirname(__FILE__),
|
|
22
|
+
ca_path = File.join(File.dirname(__FILE__), "..", "cacert.pem")
|
|
24
23
|
ssl = {:verify => true, :ca_file => File.expand_path(ca_path)}
|
|
24
|
+
|
|
25
25
|
response = Faraday.new(:url => api_endpoint, :ssl => ssl) do |c|
|
|
26
26
|
c.params = options.merge(api_login)
|
|
27
|
-
c.response :solusvm_errors
|
|
28
27
|
c.adapter :net_http
|
|
29
28
|
end.get
|
|
30
|
-
|
|
29
|
+
|
|
30
|
+
@returned_parameters = parse_response(response.status, response.body, force_array)
|
|
31
31
|
log_messages(options)
|
|
32
32
|
successful?
|
|
33
33
|
end
|
|
@@ -36,26 +36,45 @@ module Solusvm
|
|
|
36
36
|
#
|
|
37
37
|
# <tt>force_array</tt> - Parses the xml element as an array; can be a string with the element name
|
|
38
38
|
# or an array with element names
|
|
39
|
-
def parse_response(body, force_array = false)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
def parse_response(status, body, force_array = false)
|
|
40
|
+
parse_error(status, body) || begin
|
|
41
|
+
force_array = Array(force_array) if force_array
|
|
42
|
+
body = "<solusrequest>#{body}</solusrequest>"
|
|
43
|
+
XmlSimple.xml_in(body, "ForceArray" => force_array)
|
|
44
|
+
end
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
# Parses a returned_parameters value as a list, if present.
|
|
46
48
|
def parse_returned_params_as_list(attribute)
|
|
47
49
|
if returned_parameters[attribute] && !returned_parameters[attribute].empty?
|
|
48
|
-
returned_parameters[attribute].to_s.split(
|
|
50
|
+
returned_parameters[attribute].to_s.split(",")
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Parses error responses.
|
|
55
|
+
def parse_error(status, body)
|
|
56
|
+
if (200..299).include?(status)
|
|
57
|
+
# Checks for application errors
|
|
58
|
+
case body.downcase
|
|
59
|
+
when /invalid ipaddress/i
|
|
60
|
+
{ "status" => "error", "statusmsg" => "This IP is not authorized to use the API" }
|
|
61
|
+
when /Invalid id or key/i
|
|
62
|
+
{ "status" => "error", "statusmsg" => "Invalid ID or key" }
|
|
63
|
+
when /Node not found/i
|
|
64
|
+
{ "status" => "error", "statusmsg" => "Node does not exist" }
|
|
65
|
+
end
|
|
66
|
+
else
|
|
67
|
+
{ "status" => "error", "statusmsg" => "Bad HTTP Status: #{status}" }
|
|
49
68
|
end
|
|
50
69
|
end
|
|
51
70
|
|
|
52
71
|
# Returns true when a request has been successful
|
|
53
72
|
#
|
|
54
73
|
# my_class = MyClass.new
|
|
55
|
-
# my_class.create_server(
|
|
74
|
+
# my_class.create_server("example.com")
|
|
56
75
|
# my_class.successful? # => true
|
|
57
76
|
def successful?
|
|
58
|
-
returned_parameters[
|
|
77
|
+
returned_parameters["status"] == "success"
|
|
59
78
|
end
|
|
60
79
|
|
|
61
80
|
# URI parsed API URL
|
|
@@ -81,14 +100,22 @@ module Solusvm
|
|
|
81
100
|
|
|
82
101
|
# API response message
|
|
83
102
|
def statusmsg
|
|
84
|
-
returned_parameters[
|
|
103
|
+
returned_parameters["statusmsg"]
|
|
85
104
|
end
|
|
86
105
|
|
|
87
|
-
#
|
|
88
|
-
def validate_server_type
|
|
106
|
+
# Validates the server type.
|
|
107
|
+
def validate_server_type(type, &block)
|
|
89
108
|
type = type.strip
|
|
90
|
-
|
|
91
|
-
|
|
109
|
+
|
|
110
|
+
if valid = VALID_SERVER_TYPES.include?(type)
|
|
111
|
+
yield
|
|
112
|
+
else
|
|
113
|
+
@returned_parameters = {
|
|
114
|
+
"status" => "error",
|
|
115
|
+
"statusmsg" => "Invalid Virtual Server type: #{type}"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
false
|
|
92
119
|
end
|
|
93
120
|
end
|
|
94
121
|
end
|
data/lib/solusvm/general.rb
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
module Solusvm
|
|
2
2
|
# Solusvm::General is the class for retrieving general information.
|
|
3
3
|
class General < Base
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
# Lists available templates.
|
|
6
6
|
#
|
|
7
7
|
# Parameters:
|
|
8
8
|
#
|
|
9
9
|
# * +type+ - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]
|
|
10
10
|
def templates(type)
|
|
11
|
-
validate_server_type
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
validate_server_type(type) do
|
|
12
|
+
perform_request(:action => 'listtemplates', :type => type)
|
|
13
|
+
parse_returned_params_as_list('templates')
|
|
14
|
+
end
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
# Lists available plans.
|
|
@@ -19,9 +20,10 @@ module Solusvm
|
|
|
19
20
|
#
|
|
20
21
|
# * +type+ - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]
|
|
21
22
|
def plans(type)
|
|
22
|
-
validate_server_type
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
validate_server_type(type) do
|
|
24
|
+
perform_request(:action => 'listplans', :type => type)
|
|
25
|
+
parse_returned_params_as_list('plans')
|
|
26
|
+
end
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
# Lists available isos.
|
|
@@ -30,9 +32,10 @@ module Solusvm
|
|
|
30
32
|
#
|
|
31
33
|
# * +type+ - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]
|
|
32
34
|
def isos(type)
|
|
33
|
-
validate_server_type
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
validate_server_type(type) do
|
|
36
|
+
perform_request(:action => 'listiso', :type => type)
|
|
37
|
+
parse_returned_params_as_list('iso')
|
|
38
|
+
end
|
|
36
39
|
end
|
|
37
40
|
end
|
|
38
41
|
end
|
data/lib/solusvm/node.rb
CHANGED
|
@@ -8,9 +8,10 @@ module Solusvm
|
|
|
8
8
|
#
|
|
9
9
|
# * +type+ - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]
|
|
10
10
|
def list(type)
|
|
11
|
-
validate_server_type
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
validate_server_type(type) do
|
|
12
|
+
perform_request(:action => 'listnodes', :type => type)
|
|
13
|
+
parse_returned_params_as_list('nodes')
|
|
14
|
+
end
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
# Lists existing nodes ids of a given type.
|
|
@@ -19,9 +20,10 @@ module Solusvm
|
|
|
19
20
|
#
|
|
20
21
|
# * +type+ - a valid virtualization type; e.g: [openvz|xen|xen hvm|kvm]
|
|
21
22
|
def ids(type)
|
|
22
|
-
validate_server_type
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
validate_server_type(type) do
|
|
24
|
+
perform_request(:action => 'node-idlist', :type => type)
|
|
25
|
+
returned_parameters['nodes'].split(',')
|
|
26
|
+
end
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
# Retrieves statistics from a specific node.
|
data/lib/solusvm/version.rb
CHANGED
data/test/solusvm/test_base.rb
CHANGED
|
@@ -55,49 +55,47 @@ class TestBase < Test::Unit::TestCase
|
|
|
55
55
|
|
|
56
56
|
def test_validate_server_type
|
|
57
57
|
Solusvm::Base::VALID_SERVER_TYPES.each do |type|
|
|
58
|
-
|
|
59
|
-
@base.validate_server_type!(type)
|
|
60
|
-
end
|
|
58
|
+
assert @base.validate_server_type(type) { true }
|
|
61
59
|
end
|
|
62
60
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
rescue Solusvm::SolusvmError => e
|
|
67
|
-
assert_equal 'Invalid Virtual Server type: bob', e.message
|
|
68
|
-
end
|
|
61
|
+
assert !@base.validate_server_type('bob') { true }
|
|
62
|
+
assert !@base.successful?
|
|
63
|
+
assert_equal "Invalid Virtual Server type: bob", @base.statusmsg
|
|
69
64
|
end
|
|
70
65
|
|
|
71
66
|
def test_unautorized_ip
|
|
72
67
|
VCR.use_cassette "base/unauthorized_ip" do
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
@base.perform_request(:action => 'unauthorized')
|
|
69
|
+
|
|
70
|
+
assert !@base.successful?
|
|
71
|
+
assert_equal "This IP is not authorized to use the API", @base.statusmsg
|
|
76
72
|
end
|
|
77
73
|
end
|
|
78
74
|
|
|
79
75
|
def test_invalid_key_or_id
|
|
80
76
|
VCR.use_cassette "base/invalid_key" do
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
@base.perform_request(:action => 'badkey')
|
|
78
|
+
|
|
79
|
+
assert !@base.successful?
|
|
80
|
+
assert_equal "Invalid ID or key", @base.statusmsg
|
|
84
81
|
end
|
|
85
82
|
end
|
|
86
83
|
|
|
87
84
|
def test_node_does_not_exist
|
|
88
85
|
VCR.use_cassette "base/nonexistent_node" do
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
@base.perform_request(:action => 'nodeexist')
|
|
87
|
+
|
|
88
|
+
assert !@base.successful?
|
|
89
|
+
assert_equal "Node does not exist", @base.statusmsg
|
|
92
90
|
end
|
|
93
91
|
end
|
|
94
92
|
|
|
95
93
|
def test_invalid_http_status
|
|
96
94
|
VCR.use_cassette "base/invalid_status" do
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
@base.perform_request(:action => 'httperror')
|
|
96
|
+
|
|
97
|
+
assert !@base.successful?
|
|
98
|
+
assert_equal "Bad HTTP Status: 404", @base.statusmsg
|
|
100
99
|
end
|
|
101
|
-
|
|
102
100
|
end
|
|
103
101
|
end
|
|
@@ -20,11 +20,7 @@ class TestGeneral < Test::Unit::TestCase
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def test_templates_with_invalid_type
|
|
23
|
-
|
|
24
|
-
assert_raise Solusvm::SolusvmError do
|
|
25
|
-
@general.templates('badserver')
|
|
26
|
-
end
|
|
27
|
-
end
|
|
23
|
+
assert !@general.templates('badserver')
|
|
28
24
|
end
|
|
29
25
|
|
|
30
26
|
def test_plans
|
|
@@ -40,11 +36,7 @@ class TestGeneral < Test::Unit::TestCase
|
|
|
40
36
|
end
|
|
41
37
|
|
|
42
38
|
def test_plans_with_invalid_type
|
|
43
|
-
|
|
44
|
-
assert_raise Solusvm::SolusvmError do
|
|
45
|
-
@general.plans('whatever')
|
|
46
|
-
end
|
|
47
|
-
end
|
|
39
|
+
assert !@general.plans('whatever')
|
|
48
40
|
end
|
|
49
41
|
|
|
50
42
|
def test_isos
|
|
@@ -60,10 +52,6 @@ class TestGeneral < Test::Unit::TestCase
|
|
|
60
52
|
end
|
|
61
53
|
|
|
62
54
|
def test_isos_with_invalid_type
|
|
63
|
-
|
|
64
|
-
assert_raise Solusvm::SolusvmError do
|
|
65
|
-
@general.isos('whatever')
|
|
66
|
-
end
|
|
67
|
-
end
|
|
55
|
+
assert !@general.isos('whatever')
|
|
68
56
|
end
|
|
69
57
|
end
|
data/test/solusvm/test_node.rb
CHANGED
|
@@ -13,24 +13,22 @@ class TestNode < Test::Unit::TestCase
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def test_list_empty
|
|
16
|
-
VCR.use_cassette "node/list" do
|
|
16
|
+
VCR.use_cassette "node/list" do
|
|
17
17
|
assert !@nodes.list('openvz')
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def test_nodes_with_invalid_type
|
|
22
|
-
|
|
23
|
-
@nodes.list('whatever')
|
|
24
|
-
end
|
|
22
|
+
assert !@nodes.list('whatever')
|
|
25
23
|
end
|
|
26
24
|
|
|
27
25
|
def test_statistics
|
|
28
26
|
VCR.use_cassette "node/statistics" do
|
|
29
27
|
@nodes.statistics(1)
|
|
30
28
|
end
|
|
31
|
-
|
|
29
|
+
|
|
32
30
|
node_statistics = @nodes.returned_parameters
|
|
33
|
-
|
|
31
|
+
|
|
34
32
|
assert_equal '1000', node_statistics['freedisk']
|
|
35
33
|
assert_equal '22', node_statistics['sshport']
|
|
36
34
|
assert_equal 'city', node_statistics['city']
|
|
@@ -49,7 +47,7 @@ class TestNode < Test::Unit::TestCase
|
|
|
49
47
|
def test_list_all_ips_available
|
|
50
48
|
Solusvm.config("api_id1", api_login[:key], :url => 'http://www.example.com/api')
|
|
51
49
|
VCR.use_cassette "node/available_ips" do
|
|
52
|
-
assert_equal %w(123.123.123.123 124.124.124.124 125.125.125.125).sort, @nodes.available_ips(1).sort
|
|
50
|
+
assert_equal %w(123.123.123.123 124.124.124.124 125.125.125.125).sort, @nodes.available_ips(1).sort
|
|
53
51
|
end
|
|
54
52
|
end
|
|
55
53
|
|
|
@@ -67,9 +65,7 @@ class TestNode < Test::Unit::TestCase
|
|
|
67
65
|
end
|
|
68
66
|
|
|
69
67
|
def test_nodes_ids_error
|
|
70
|
-
|
|
71
|
-
@nodes.ids('whatever')
|
|
72
|
-
end
|
|
68
|
+
assert !@nodes.ids('whatever')
|
|
73
69
|
end
|
|
74
70
|
|
|
75
71
|
def test_virtualservers
|
|
@@ -77,9 +73,9 @@ class TestNode < Test::Unit::TestCase
|
|
|
77
73
|
VCR.use_cassette "node/virtualservers" do
|
|
78
74
|
@nodes.virtualservers(1)
|
|
79
75
|
end
|
|
80
|
-
|
|
76
|
+
|
|
81
77
|
server = @nodes.returned_parameters["virtualservers"]["virtualserver"].first
|
|
82
|
-
|
|
78
|
+
|
|
83
79
|
assert_equal "theid", server["vserverid"]
|
|
84
80
|
assert_equal "thexid", server["ctid-xid"]
|
|
85
81
|
assert_equal "theclientid", server["clientid"]
|
|
@@ -111,9 +107,9 @@ class TestNode < Test::Unit::TestCase
|
|
|
111
107
|
VCR.use_cassette "node/xenresources" do
|
|
112
108
|
@nodes.xenresources(1)
|
|
113
109
|
end
|
|
114
|
-
|
|
110
|
+
|
|
115
111
|
node_resources = @nodes.returned_parameters
|
|
116
|
-
|
|
112
|
+
|
|
117
113
|
assert_equal 'thefreememory', node_resources['freememory']
|
|
118
114
|
assert_equal 'thefreehdd', node_resources['freehdd']
|
|
119
115
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solusvm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 1.2.0
|
|
5
|
+
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
8
|
- Justin Mazzi
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-08-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: xml-simple
|
|
@@ -182,13 +182,11 @@ files:
|
|
|
182
182
|
- lib/solusvm/cli/reseller_cli.rb
|
|
183
183
|
- lib/solusvm/cli/server_cli.rb
|
|
184
184
|
- lib/solusvm/client.rb
|
|
185
|
-
- lib/solusvm/exceptions.rb
|
|
186
185
|
- lib/solusvm/general.rb
|
|
187
186
|
- lib/solusvm/hash.rb
|
|
188
187
|
- lib/solusvm/node.rb
|
|
189
188
|
- lib/solusvm/reseller.rb
|
|
190
189
|
- lib/solusvm/server.rb
|
|
191
|
-
- lib/solusvm/solusvm_errors.rb
|
|
192
190
|
- lib/solusvm/version.rb
|
|
193
191
|
- solusvm.gemspec
|
|
194
192
|
- test/cli/test_base_cli.rb
|
|
@@ -278,90 +276,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
278
276
|
version: '0'
|
|
279
277
|
segments:
|
|
280
278
|
- 0
|
|
281
|
-
hash: -
|
|
279
|
+
hash: -2927450006008360826
|
|
282
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
283
281
|
none: false
|
|
284
282
|
requirements:
|
|
285
|
-
- - ! '
|
|
283
|
+
- - ! '>='
|
|
286
284
|
- !ruby/object:Gem::Version
|
|
287
|
-
version:
|
|
285
|
+
version: '0'
|
|
286
|
+
segments:
|
|
287
|
+
- 0
|
|
288
|
+
hash: -2927450006008360826
|
|
288
289
|
requirements: []
|
|
289
290
|
rubyforge_project: solusvm
|
|
290
|
-
rubygems_version: 1.8.
|
|
291
|
+
rubygems_version: 1.8.23
|
|
291
292
|
signing_key:
|
|
292
293
|
specification_version: 3
|
|
293
294
|
summary: Wrapper for the SolusVM Admin::API
|
|
294
|
-
test_files:
|
|
295
|
-
- test/cli/test_base_cli.rb
|
|
296
|
-
- test/cli/test_client_cli.rb
|
|
297
|
-
- test/cli/test_general_cli.rb
|
|
298
|
-
- test/cli/test_node_cli.rb
|
|
299
|
-
- test/cli/test_reseller_cli.rb
|
|
300
|
-
- test/cli/test_server_cli.rb
|
|
301
|
-
- test/solusvm/test_base.rb
|
|
302
|
-
- test/solusvm/test_cli.rb
|
|
303
|
-
- test/solusvm/test_client.rb
|
|
304
|
-
- test/solusvm/test_general.rb
|
|
305
|
-
- test/solusvm/test_hash.rb
|
|
306
|
-
- test/solusvm/test_node.rb
|
|
307
|
-
- test/solusvm/test_reseller.rb
|
|
308
|
-
- test/solusvm/test_server.rb
|
|
309
|
-
- test/test_helper.rb
|
|
310
|
-
- test/test_solusvm.rb
|
|
311
|
-
- test/vcr_cassettes/base/invalid_key.yml
|
|
312
|
-
- test/vcr_cassettes/base/invalid_status.yml
|
|
313
|
-
- test/vcr_cassettes/base/nonexistent_node.yml
|
|
314
|
-
- test/vcr_cassettes/base/parse_response.yml
|
|
315
|
-
- test/vcr_cassettes/base/statusmsg.yml
|
|
316
|
-
- test/vcr_cassettes/base/successful.yml
|
|
317
|
-
- test/vcr_cassettes/base/unauthorized_ip.yml
|
|
318
|
-
- test/vcr_cassettes/client/authenticate.yml
|
|
319
|
-
- test/vcr_cassettes/client/change_password.yml
|
|
320
|
-
- test/vcr_cassettes/client/create.yml
|
|
321
|
-
- test/vcr_cassettes/client/delete.yml
|
|
322
|
-
- test/vcr_cassettes/client/exists.yml
|
|
323
|
-
- test/vcr_cassettes/client/list.yml
|
|
324
|
-
- test/vcr_cassettes/general/isos.yml
|
|
325
|
-
- test/vcr_cassettes/general/plans.yml
|
|
326
|
-
- test/vcr_cassettes/general/templates.yml
|
|
327
|
-
- test/vcr_cassettes/node/available_ips.yml
|
|
328
|
-
- test/vcr_cassettes/node/ids.yml
|
|
329
|
-
- test/vcr_cassettes/node/list.yml
|
|
330
|
-
- test/vcr_cassettes/node/statistics.yml
|
|
331
|
-
- test/vcr_cassettes/node/virtualservers.yml
|
|
332
|
-
- test/vcr_cassettes/node/xenresources.yml
|
|
333
|
-
- test/vcr_cassettes/reseller/change_resources.yml
|
|
334
|
-
- test/vcr_cassettes/reseller/create.yml
|
|
335
|
-
- test/vcr_cassettes/reseller/delete.yml
|
|
336
|
-
- test/vcr_cassettes/reseller/info.yml
|
|
337
|
-
- test/vcr_cassettes/reseller/list.yml
|
|
338
|
-
- test/vcr_cassettes/server/.yml
|
|
339
|
-
- test/vcr_cassettes/server/boot.yml
|
|
340
|
-
- test/vcr_cassettes/server/change_bootorder.yml
|
|
341
|
-
- test/vcr_cassettes/server/change_consolepass.yml
|
|
342
|
-
- test/vcr_cassettes/server/change_hostname.yml
|
|
343
|
-
- test/vcr_cassettes/server/change_owner.yml
|
|
344
|
-
- test/vcr_cassettes/server/change_plan.yml
|
|
345
|
-
- test/vcr_cassettes/server/change_rootpassword.yml
|
|
346
|
-
- test/vcr_cassettes/server/change_vncpass.yml
|
|
347
|
-
- test/vcr_cassettes/server/console.yml
|
|
348
|
-
- test/vcr_cassettes/server/create.yml
|
|
349
|
-
- test/vcr_cassettes/server/exists.yml
|
|
350
|
-
- test/vcr_cassettes/server/info.yml
|
|
351
|
-
- test/vcr_cassettes/server/info_all.yml
|
|
352
|
-
- test/vcr_cassettes/server/mountiso.yml
|
|
353
|
-
- test/vcr_cassettes/server/network_disable.yml
|
|
354
|
-
- test/vcr_cassettes/server/network_enable.yml
|
|
355
|
-
- test/vcr_cassettes/server/pae_disable.yml
|
|
356
|
-
- test/vcr_cassettes/server/pae_enable.yml
|
|
357
|
-
- test/vcr_cassettes/server/reboot.yml
|
|
358
|
-
- test/vcr_cassettes/server/rebuild.yml
|
|
359
|
-
- test/vcr_cassettes/server/resume.yml
|
|
360
|
-
- test/vcr_cassettes/server/shutdown.yml
|
|
361
|
-
- test/vcr_cassettes/server/status.yml
|
|
362
|
-
- test/vcr_cassettes/server/suspend.yml
|
|
363
|
-
- test/vcr_cassettes/server/terminate.yml
|
|
364
|
-
- test/vcr_cassettes/server/tun_disable.yml
|
|
365
|
-
- test/vcr_cassettes/server/tun_enable.yml
|
|
366
|
-
- test/vcr_cassettes/server/unmountiso.yml
|
|
367
|
-
- test/vcr_cassettes/server/vnc.yml
|
|
295
|
+
test_files: []
|
data/lib/solusvm/exceptions.rb
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Solusvm
|
|
2
|
-
class SolusvmErrors < Faraday::Response::Middleware
|
|
3
|
-
|
|
4
|
-
def on_complete(env)
|
|
5
|
-
if (200..299).include? env[:status]
|
|
6
|
-
# Checks for application errors
|
|
7
|
-
case env[:body].downcase
|
|
8
|
-
when /invalid ipaddress/i
|
|
9
|
-
raise "This IP is not authorized to use the API"
|
|
10
|
-
when /Invalid id or key/i
|
|
11
|
-
raise "Invalid ID or key"
|
|
12
|
-
when /Node not found/i
|
|
13
|
-
raise "Node does not exist"
|
|
14
|
-
end
|
|
15
|
-
else
|
|
16
|
-
raise SolusvmError, "Bad HTTP Status: #{env[:status]}"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
|
22
|
-
end
|