solusvm 1.4.0 → 2.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/LICENSE +1 -1
- data/README.markdown +159 -116
- data/Rakefile +3 -33
- data/bin/solusvm +3 -4
- data/lib/solusvm.rb +1 -3
- data/lib/solusvm/base.rb +101 -46
- data/lib/solusvm/cli.rb +8 -8
- data/lib/solusvm/cli/base_cli.rb +3 -3
- data/lib/solusvm/cli/client_cli.rb +3 -5
- data/lib/solusvm/cli/general_cli.rb +3 -5
- data/lib/solusvm/cli/node_cli.rb +3 -5
- data/lib/solusvm/cli/reseller_cli.rb +3 -5
- data/lib/solusvm/cli/server_cli.rb +4 -6
- data/lib/solusvm/client.rb +45 -27
- data/lib/solusvm/errors.rb +3 -0
- data/lib/solusvm/general.rb +11 -12
- data/lib/solusvm/hash.rb +1 -11
- data/lib/solusvm/node.rb +33 -21
- data/lib/solusvm/reseller.rb +53 -49
- data/lib/solusvm/server.rb +188 -52
- data/lib/solusvm/version.rb +2 -2
- data/test/cli/test_base_cli.rb +14 -4
- data/test/cli/test_client_cli.rb +13 -13
- data/test/cli/test_general_cli.rb +7 -7
- data/test/cli/test_node_cli.rb +13 -13
- data/test/cli/test_reseller_cli.rb +11 -11
- data/test/cli/test_server_cli.rb +61 -61
- data/test/sham_rack_stubs/base/parse-response.json +4 -0
- data/test/sham_rack_stubs/client/authenticate.json +4 -0
- data/test/sham_rack_stubs/client/change-password.json +6 -0
- data/test/sham_rack_stubs/client/create.json +9 -0
- data/test/sham_rack_stubs/client/delete.json +4 -0
- data/test/sham_rack_stubs/client/exists.json +4 -0
- data/test/sham_rack_stubs/client/list-empty.json +5 -0
- data/test/sham_rack_stubs/client/list.json +30 -0
- data/test/sham_rack_stubs/general/isos-empty.json +5 -0
- data/test/sham_rack_stubs/general/isos.json +5 -0
- data/test/sham_rack_stubs/general/plans-empty.json +5 -0
- data/test/sham_rack_stubs/general/plans.json +5 -0
- data/test/sham_rack_stubs/general/templates-empty.json +7 -0
- data/test/sham_rack_stubs/general/templates.json +7 -0
- data/test/sham_rack_stubs/generic/error.json +4 -0
- data/test/sham_rack_stubs/node/available-ips-empty.json +6 -0
- data/test/sham_rack_stubs/node/available-ips.json +6 -0
- data/test/sham_rack_stubs/node/ids.json +5 -0
- data/test/sham_rack_stubs/node/list-empty.json +5 -0
- data/test/sham_rack_stubs/node/list-groups.json +5 -0
- data/test/sham_rack_stubs/node/list.json +5 -0
- data/test/sham_rack_stubs/node/statistics.json +21 -0
- data/test/sham_rack_stubs/node/virtualservers-empty.json +5 -0
- data/test/sham_rack_stubs/node/virtualservers.json +19 -0
- data/test/sham_rack_stubs/node/xenresources.json +6 -0
- data/test/sham_rack_stubs/reseller/change-resources.json +18 -0
- data/test/sham_rack_stubs/reseller/create.json +25 -0
- data/test/sham_rack_stubs/reseller/delete.json +4 -0
- data/test/sham_rack_stubs/reseller/info.json +24 -0
- data/test/sham_rack_stubs/reseller/list-empty.json +5 -0
- data/test/sham_rack_stubs/reseller/list.json +5 -0
- data/test/sham_rack_stubs/server/add-ip.json +5 -0
- data/test/sham_rack_stubs/server/boot.json +4 -0
- data/test/sham_rack_stubs/server/change-bootorder.json +4 -0
- data/test/sham_rack_stubs/server/change-hostname.json +5 -0
- data/test/sham_rack_stubs/server/change-owner.json +4 -0
- data/test/sham_rack_stubs/server/change-plan.json +4 -0
- data/test/sham_rack_stubs/server/change-rootpassword.json +5 -0
- data/test/sham_rack_stubs/server/change-vncpass.json +5 -0
- data/test/sham_rack_stubs/server/console.json +13 -0
- data/test/sham_rack_stubs/server/create.json +13 -0
- data/test/sham_rack_stubs/server/del-ip.json +4 -0
- data/test/sham_rack_stubs/server/exists.json +4 -0
- data/test/sham_rack_stubs/server/info-all.json +16 -0
- data/test/sham_rack_stubs/server/info.json +15 -0
- data/test/sham_rack_stubs/server/mountiso.json +4 -0
- data/test/sham_rack_stubs/server/network-disable.json +4 -0
- data/test/sham_rack_stubs/server/network-enable.json +4 -0
- data/test/sham_rack_stubs/server/pae-disable.json +4 -0
- data/test/sham_rack_stubs/server/pae-enable.json +4 -0
- data/test/sham_rack_stubs/server/reboot.json +4 -0
- data/test/sham_rack_stubs/server/rebuild.json +4 -0
- data/test/sham_rack_stubs/server/resume.json +4 -0
- data/test/sham_rack_stubs/server/shutdown.json +4 -0
- data/test/sham_rack_stubs/server/status.json +4 -0
- data/test/sham_rack_stubs/server/suspend.json +4 -0
- data/test/sham_rack_stubs/server/terminate.json +4 -0
- data/test/sham_rack_stubs/server/tun-disable.json +4 -0
- data/test/sham_rack_stubs/server/tun-enable.json +4 -0
- data/test/sham_rack_stubs/server/unmountiso.json +4 -0
- data/test/sham_rack_stubs/server/vnc.json +8 -0
- data/test/solusvm/test_base.rb +34 -56
- data/test/solusvm/test_cli.rb +3 -3
- data/test/solusvm/test_client.rb +56 -66
- data/test/solusvm/test_general.rb +34 -19
- data/test/solusvm/test_hash.rb +0 -9
- data/test/solusvm/test_node.rb +66 -72
- data/test/solusvm/test_reseller.rb +47 -58
- data/test/solusvm/test_server.rb +149 -164
- data/test/test_helper.rb +43 -31
- metadata +173 -189
- data/.document +0 -5
- data/.gitignore +0 -25
- data/.travis.yml +0 -12
- data/solusvm.gemspec +0 -33
- data/test/vcr_cassettes/base/invalid_key.yml +0 -19
- data/test/vcr_cassettes/base/invalid_status.yml +0 -19
- data/test/vcr_cassettes/base/nonexistent_node.yml +0 -19
- data/test/vcr_cassettes/base/parse_response.yml +0 -28
- data/test/vcr_cassettes/base/statusmsg.yml +0 -28
- data/test/vcr_cassettes/base/successful.yml +0 -68
- data/test/vcr_cassettes/base/successful_instance_config.yml +0 -28
- data/test/vcr_cassettes/base/unauthorized_ip.yml +0 -19
- data/test/vcr_cassettes/client/authenticate.yml +0 -37
- data/test/vcr_cassettes/client/change_password.yml +0 -39
- data/test/vcr_cassettes/client/create.yml +0 -42
- data/test/vcr_cassettes/client/delete.yml +0 -37
- data/test/vcr_cassettes/client/exists.yml +0 -20
- data/test/vcr_cassettes/client/list.yml +0 -66
- data/test/vcr_cassettes/general/isos.yml +0 -38
- data/test/vcr_cassettes/general/plans.yml +0 -38
- data/test/vcr_cassettes/general/templates.yml +0 -38
- data/test/vcr_cassettes/node/available_ips.yml +0 -41
- data/test/vcr_cassettes/node/ids.yml +0 -21
- data/test/vcr_cassettes/node/list.yml +0 -38
- data/test/vcr_cassettes/node/list_groups.yml +0 -20
- data/test/vcr_cassettes/node/statistics.yml +0 -32
- data/test/vcr_cassettes/node/virtualservers.yml +0 -67
- data/test/vcr_cassettes/node/xenresources.yml +0 -22
- data/test/vcr_cassettes/reseller/change_resources.yml +0 -27
- data/test/vcr_cassettes/reseller/create.yml +0 -27
- data/test/vcr_cassettes/reseller/delete.yml +0 -15
- data/test/vcr_cassettes/reseller/info.yml +0 -27
- data/test/vcr_cassettes/reseller/list.yml +0 -27
- data/test/vcr_cassettes/server/.yml +0 -1017
- data/test/vcr_cassettes/server/add_ip.yml +0 -15
- data/test/vcr_cassettes/server/boot.yml +0 -15
- data/test/vcr_cassettes/server/change_bootorder.yml +0 -15
- data/test/vcr_cassettes/server/change_consolepass.yml +0 -16
- data/test/vcr_cassettes/server/change_hostname.yml +0 -15
- data/test/vcr_cassettes/server/change_owner.yml +0 -15
- data/test/vcr_cassettes/server/change_plan.yml +0 -15
- data/test/vcr_cassettes/server/change_rootpassword.yml +0 -15
- data/test/vcr_cassettes/server/change_vncpass.yml +0 -15
- data/test/vcr_cassettes/server/console.yml +0 -28
- data/test/vcr_cassettes/server/create.yml +0 -27
- data/test/vcr_cassettes/server/del_ip.yml +0 -15
- data/test/vcr_cassettes/server/exists.yml +0 -15
- data/test/vcr_cassettes/server/info.yml +0 -27
- data/test/vcr_cassettes/server/info_all.yml +0 -15
- data/test/vcr_cassettes/server/mountiso.yml +0 -15
- data/test/vcr_cassettes/server/network_disable.yml +0 -15
- data/test/vcr_cassettes/server/network_enable.yml +0 -15
- data/test/vcr_cassettes/server/pae_disable.yml +0 -15
- data/test/vcr_cassettes/server/pae_enable.yml +0 -15
- data/test/vcr_cassettes/server/reboot.yml +0 -15
- data/test/vcr_cassettes/server/rebuild.yml +0 -15
- data/test/vcr_cassettes/server/resume.yml +0 -15
- data/test/vcr_cassettes/server/shutdown.yml +0 -15
- data/test/vcr_cassettes/server/status.yml +0 -15
- data/test/vcr_cassettes/server/suspend.yml +0 -15
- data/test/vcr_cassettes/server/terminate.yml +0 -27
- data/test/vcr_cassettes/server/tun_disable.yml +0 -15
- data/test/vcr_cassettes/server/tun_enable.yml +0 -15
- data/test/vcr_cassettes/server/unmountiso.yml +0 -15
- data/test/vcr_cassettes/server/vnc.yml +0 -15
data/test/solusvm/test_hash.rb
CHANGED
@@ -15,13 +15,4 @@ class TestHash < Test::Unit::TestCase
|
|
15
15
|
assert_equal expected, merged.reverse_merge!(defaults)
|
16
16
|
assert_equal expected, merged
|
17
17
|
end
|
18
|
-
|
19
|
-
def test_to_query
|
20
|
-
defaults = { a: "x", b: "y", c: 10 }
|
21
|
-
expected = "a=x&b=y&c=10".split('&').sort
|
22
|
-
actual = defaults.to_query.split('&').sort
|
23
|
-
|
24
|
-
assert defaults.to_query.is_a?(String)
|
25
|
-
assert_equal expected, actual
|
26
|
-
end
|
27
18
|
end
|
data/test/solusvm/test_node.rb
CHANGED
@@ -2,120 +2,114 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class TestNode < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@nodes =
|
5
|
+
@nodes = SolusVM::Node.new(solusvm_params)
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_list
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
stub_response 'node/list'
|
10
|
+
|
11
|
+
list = @nodes.list('xen')
|
12
|
+
|
13
|
+
assert @nodes.successful?
|
14
|
+
assert list.is_a? Array
|
15
|
+
assert_not_empty list
|
12
16
|
end
|
13
17
|
|
14
18
|
def test_list_empty
|
15
|
-
|
16
|
-
|
17
|
-
|
19
|
+
stub_response 'node/list-empty'
|
20
|
+
|
21
|
+
assert !@nodes.list('openvz')
|
22
|
+
assert @nodes.successful?
|
18
23
|
end
|
19
24
|
|
20
25
|
def test_nodes_with_invalid_type
|
21
26
|
assert !@nodes.list('whatever')
|
27
|
+
assert !@nodes.successful?
|
22
28
|
end
|
23
29
|
|
24
30
|
def test_list_groups
|
25
|
-
|
26
|
-
|
27
|
-
|
31
|
+
stub_response 'node/list-groups'
|
32
|
+
|
33
|
+
list = @nodes.list_groups
|
34
|
+
|
35
|
+
assert @nodes.successful?
|
36
|
+
assert list.is_a? Array
|
37
|
+
assert_not_empty list
|
28
38
|
end
|
29
39
|
|
30
40
|
def test_statistics
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
assert_equal '22', node_statistics['sshport']
|
39
|
-
assert_equal 'city', node_statistics['city']
|
40
|
-
assert_equal 'name', node_statistics['name']
|
41
|
-
assert_equal '0', node_statistics['freeips']
|
42
|
-
assert_equal 'country', node_statistics['country']
|
43
|
-
assert_equal 'x86_64', node_statistics['arch']
|
44
|
-
assert_equal '1', node_statistics['id']
|
45
|
-
assert_equal '10', node_statistics['freememory']
|
46
|
-
assert_equal '2', node_statistics['virtualservers']
|
47
|
-
assert_equal '127.0.0.1', node_statistics['ip']
|
48
|
-
assert_equal 'hostname.com', node_statistics['hostname']
|
49
|
-
assert_equal 'success', node_statistics['status']
|
41
|
+
stub_response 'node/statistics'
|
42
|
+
|
43
|
+
stats = @nodes.statistics(1)
|
44
|
+
|
45
|
+
assert @nodes.successful?
|
46
|
+
assert stats.is_a? Hash
|
47
|
+
assert_not_empty stats
|
50
48
|
end
|
51
49
|
|
52
50
|
def test_list_all_ips_available
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
stub_response 'node/available-ips'
|
52
|
+
|
53
|
+
list = @nodes.available_ips(1)
|
54
|
+
|
55
|
+
assert @nodes.successful?
|
56
|
+
assert list.is_a? Array
|
57
|
+
assert_not_empty list
|
57
58
|
end
|
58
59
|
|
59
60
|
def test_list_all_ips_not_available
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
stub_response 'node/available-ips-empty'
|
62
|
+
|
63
|
+
assert_empty @nodes.available_ips(1)
|
64
|
+
assert @nodes.successful?
|
64
65
|
end
|
65
66
|
|
66
67
|
def test_ids
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
stub_response 'node/ids'
|
69
|
+
|
70
|
+
list = @nodes.ids('xen')
|
71
|
+
|
72
|
+
assert @nodes.successful?
|
73
|
+
assert list.is_a? Array
|
74
|
+
assert_not_empty list
|
70
75
|
end
|
71
76
|
|
72
77
|
def test_nodes_ids_error
|
73
78
|
assert !@nodes.ids('whatever')
|
79
|
+
assert !@nodes.successful?
|
74
80
|
end
|
75
81
|
|
76
82
|
def test_virtualservers
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
assert_equal "theid", server["vserverid"]
|
85
|
-
assert_equal "thexid", server["ctid-xid"]
|
86
|
-
assert_equal "theclientid", server["clientid"]
|
87
|
-
assert_equal "theip", server["ipaddress"]
|
88
|
-
assert_equal "thehostname", server["hostname"]
|
89
|
-
assert_equal "thetemplate", server["template"]
|
90
|
-
assert_equal "thediskspace", server["hdd"]
|
91
|
-
assert_equal "thememory", server["memory"]
|
92
|
-
assert_equal "theswap", server["swap-burst"]
|
93
|
-
assert_equal "thetype", server["type"]
|
94
|
-
assert_equal "themac", server["mac"]
|
83
|
+
stub_response 'node/virtualservers'
|
84
|
+
|
85
|
+
servers = @nodes.virtualservers(1)
|
86
|
+
|
87
|
+
assert @nodes.successful?
|
88
|
+
assert servers.is_a? Array
|
89
|
+
assert servers.all? { |s| s.is_a? Hash }
|
95
90
|
end
|
96
91
|
|
97
92
|
def test_virtualservers_empty
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
93
|
+
stub_response 'node/virtualservers-empty'
|
94
|
+
|
95
|
+
assert_empty @nodes.virtualservers(1)
|
96
|
+
assert @nodes.successful?
|
102
97
|
end
|
103
98
|
|
104
99
|
def test_virtualservers_fail
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
100
|
+
stub_response 'generic/error'
|
101
|
+
|
102
|
+
assert_nil @nodes.virtualservers(1)
|
103
|
+
assert !@nodes.successful?
|
109
104
|
end
|
110
105
|
|
111
106
|
def test_xenresources
|
112
|
-
|
113
|
-
@nodes.xenresources(1)
|
114
|
-
end
|
107
|
+
stub_response 'node/xenresources'
|
115
108
|
|
116
|
-
node_resources = @nodes.
|
109
|
+
node_resources = @nodes.xenresources(1)
|
117
110
|
|
118
|
-
|
119
|
-
|
111
|
+
assert @nodes.successful?
|
112
|
+
assert node_resources.is_a? Hash
|
113
|
+
assert_not_empty node_resources
|
120
114
|
end
|
121
115
|
end
|
@@ -1,92 +1,81 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class TestReseller < Test::Unit::TestCase
|
4
|
-
|
5
4
|
def setup
|
6
|
-
@reseller =
|
5
|
+
@reseller = SolusVM::Reseller.new(solusvm_params)
|
7
6
|
end
|
8
7
|
|
9
8
|
def test_create
|
10
|
-
options = {
|
11
|
-
|
12
|
-
|
13
|
-
@
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
assert_equal options[:password], params['password']
|
23
|
-
assert_equal options[:email], params['email']
|
9
|
+
options = {
|
10
|
+
username: 'apitest3',
|
11
|
+
password: '123456',
|
12
|
+
email: 'email@address.com',
|
13
|
+
firstname: 'Phill',
|
14
|
+
lastname: 'Smith'
|
15
|
+
}
|
16
|
+
|
17
|
+
stub_response 'reseller/create'
|
18
|
+
|
19
|
+
assert @reseller.create(options).is_a? Hash
|
20
|
+
assert @reseller.successful?
|
24
21
|
end
|
25
22
|
|
26
23
|
def test_create_fail
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
stub_response 'generic/error'
|
25
|
+
|
26
|
+
assert !@reseller.create
|
27
|
+
assert !@reseller.successful?
|
31
28
|
end
|
32
29
|
|
33
30
|
def test_change_resources
|
34
|
-
|
35
|
-
VCR.use_cassette "reseller/change_resources" do
|
36
|
-
@reseller.change_resources("vps123", options)
|
37
|
-
end
|
38
|
-
|
39
|
-
params = @reseller.returned_parameters
|
31
|
+
stub_response 'reseller/change-resources'
|
40
32
|
|
41
|
-
assert
|
42
|
-
assert
|
33
|
+
assert @reseller.change_resources("vps123", maxvps: 10).is_a? Hash
|
34
|
+
assert @reseller.successful?
|
43
35
|
end
|
44
36
|
|
45
37
|
def test_change_resources_fail
|
46
|
-
|
47
|
-
|
48
|
-
|
38
|
+
stub_response 'generic/error'
|
39
|
+
|
40
|
+
assert !@reseller.change_resources("vps13")
|
41
|
+
assert !@reseller.successful?
|
49
42
|
end
|
50
43
|
|
51
44
|
def test_info
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
params = @reseller.returned_parameters
|
57
|
-
|
58
|
-
assert params
|
59
|
-
assert_equal "reseller123", params['username']
|
60
|
-
assert_equal "Phill", params['firstname']
|
61
|
-
assert_equal "Smith", params['lastname']
|
62
|
-
assert_equal "123456", params['password']
|
63
|
-
assert_equal "reseller3@email.com", params['email']
|
45
|
+
stub_response 'reseller/info'
|
46
|
+
|
47
|
+
assert @reseller.info("vps123").is_a? Hash
|
48
|
+
assert @reseller.successful?
|
64
49
|
end
|
65
50
|
|
66
51
|
def test_info_fail
|
67
|
-
|
68
|
-
|
69
|
-
|
52
|
+
stub_response 'generic/error'
|
53
|
+
|
54
|
+
assert !@reseller.info("vps13")
|
55
|
+
assert !@reseller.successful?
|
70
56
|
end
|
71
57
|
|
72
58
|
def test_list
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
59
|
+
stub_response 'reseller/list'
|
60
|
+
|
61
|
+
list = @reseller.list
|
62
|
+
|
63
|
+
assert list.is_a? Array
|
64
|
+
assert_not_empty list
|
65
|
+
assert @reseller.successful?
|
77
66
|
end
|
78
67
|
|
79
68
|
def test_list_empty
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
69
|
+
stub_response 'reseller/list-empty'
|
70
|
+
|
71
|
+
assert !@reseller.list
|
72
|
+
assert @reseller.successful?
|
84
73
|
end
|
85
74
|
|
86
75
|
def test_delete
|
87
|
-
|
88
|
-
assert @reseller.delete("vps123")
|
89
|
-
end
|
90
|
-
end
|
76
|
+
stub_response 'reseller/delete'
|
91
77
|
|
78
|
+
assert @reseller.delete("vps123")
|
79
|
+
assert @reseller.successful?
|
80
|
+
end
|
92
81
|
end
|
data/test/solusvm/test_server.rb
CHANGED
@@ -2,267 +2,252 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class TestServer < Test::Unit::TestCase
|
4
4
|
def setup
|
5
|
-
@server =
|
5
|
+
@server = SolusVM::Server.new(solusvm_params)
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_create
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
9
|
+
stub_response 'server/create'
|
10
|
+
|
11
|
+
options = {
|
12
|
+
type: 'xen',
|
13
|
+
username: 'bob',
|
14
|
+
node: 'node1',
|
15
|
+
plan: 'plan1',
|
16
|
+
template: 'mytpl',
|
17
|
+
ips: 1
|
18
|
+
}
|
19
|
+
|
20
|
+
hostname = 'test.com'
|
21
|
+
password = '123456'
|
22
|
+
|
23
|
+
assert @server.create(hostname, password, options).is_a? Hash
|
24
|
+
assert @server.successful?
|
24
25
|
end
|
25
26
|
|
26
27
|
def test_create_error
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
assert
|
28
|
+
stub_response 'generic/error'
|
29
|
+
|
30
|
+
assert !@server.create('', '')
|
31
|
+
assert !@server.successful?
|
31
32
|
end
|
32
33
|
|
33
34
|
def test_rebuild
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
stub_response 'server/rebuild'
|
36
|
+
|
37
|
+
assert @server.rebuild(1, "mytpl")
|
38
|
+
assert @server.successful?
|
38
39
|
end
|
39
40
|
|
40
41
|
def test_boot
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
stub_response 'server/boot'
|
43
|
+
|
44
|
+
assert @server.boot(1)
|
45
|
+
assert @server.successful?
|
45
46
|
end
|
46
47
|
|
47
48
|
def test_reboot
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
stub_response 'server/reboot'
|
50
|
+
|
51
|
+
assert @server.reboot(1)
|
52
|
+
assert @server.successful?
|
52
53
|
end
|
53
54
|
|
54
55
|
def test_suspend
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
stub_response 'server/suspend'
|
57
|
+
|
58
|
+
assert @server.suspend(1)
|
59
|
+
assert @server.successful?
|
59
60
|
end
|
60
61
|
|
61
62
|
def test_resume
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
stub_response 'server/resume'
|
64
|
+
|
65
|
+
assert @server.resume(1)
|
66
|
+
assert @server.successful?
|
66
67
|
end
|
67
68
|
|
68
69
|
def test_shutdown
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
stub_response 'server/shutdown'
|
71
|
+
|
72
|
+
assert @server.shutdown(1)
|
73
|
+
assert @server.successful?
|
73
74
|
end
|
74
75
|
|
75
76
|
def test_terminate
|
76
|
-
|
77
|
-
assert @server.terminate(1)
|
78
|
-
assert_equal 'Virtual server terminated', @server.statusmsg
|
77
|
+
stub_response "server/terminate"
|
79
78
|
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
assert @server.terminate(1)
|
80
|
+
assert @server.successful?
|
81
|
+
|
82
|
+
assert @server.terminate(1, true)
|
83
|
+
assert @server.successful?
|
83
84
|
end
|
84
85
|
|
85
86
|
def test_tun_enable
|
86
|
-
|
87
|
-
|
88
|
-
|
87
|
+
stub_response 'server/tun-enable'
|
88
|
+
|
89
|
+
assert @server.tun_enable(1)
|
90
|
+
assert @server.successful?
|
89
91
|
end
|
90
92
|
|
91
93
|
def test_tun_disable
|
92
|
-
|
93
|
-
|
94
|
-
|
94
|
+
stub_response 'server/tun-disable'
|
95
|
+
|
96
|
+
assert @server.tun_disable(1)
|
97
|
+
assert @server.successful?
|
95
98
|
end
|
96
99
|
|
97
100
|
def test_network_enable
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
+
stub_response 'server/network-enable'
|
102
|
+
|
103
|
+
assert @server.network_enable(1)
|
104
|
+
assert @server.successful?
|
101
105
|
end
|
102
106
|
|
103
107
|
def test_network_disable
|
104
|
-
|
105
|
-
|
106
|
-
|
108
|
+
stub_response 'server/network-disable'
|
109
|
+
|
110
|
+
assert @server.network_disable(1)
|
111
|
+
assert @server.successful?
|
107
112
|
end
|
108
113
|
|
109
114
|
def test_pae_enable
|
110
|
-
|
111
|
-
|
112
|
-
|
115
|
+
stub_response 'server/pae-enable'
|
116
|
+
|
117
|
+
assert @server.pae_enable(1)
|
118
|
+
assert @server.successful?
|
113
119
|
end
|
114
120
|
|
115
121
|
def test_pae_disable
|
116
|
-
|
117
|
-
|
118
|
-
|
122
|
+
stub_response 'server/pae-disable'
|
123
|
+
|
124
|
+
assert @server.pae_disable(1)
|
125
|
+
assert @server.successful?
|
119
126
|
end
|
120
127
|
|
121
128
|
def test_exists
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
129
|
+
stub_response 'server/exists'
|
130
|
+
|
131
|
+
assert @server.exists?(1)
|
132
|
+
assert @server.successful?
|
126
133
|
end
|
127
134
|
|
128
135
|
def test_status
|
129
|
-
|
130
|
-
|
131
|
-
|
136
|
+
stub_response 'server/status'
|
137
|
+
|
138
|
+
assert_equal 'online', @server.status(1)
|
139
|
+
assert @server.successful?
|
132
140
|
end
|
133
141
|
|
134
142
|
def test_add_ip
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
143
|
+
stub_response 'server/add-ip'
|
144
|
+
|
145
|
+
assert_equal '123.123.123.123', @server.add_ip(1)
|
146
|
+
assert @server.successful?
|
139
147
|
end
|
140
148
|
|
141
149
|
def test_del_ip
|
142
|
-
|
143
|
-
|
144
|
-
|
150
|
+
stub_response 'server/del-ip'
|
151
|
+
|
152
|
+
assert @server.del_ip(1, '123.123.123.123')
|
153
|
+
assert @server.successful?
|
145
154
|
end
|
146
155
|
|
147
156
|
def test_change_plan
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
157
|
+
stub_response 'server/change-plan'
|
158
|
+
|
159
|
+
assert @server.change_plan(1, 'newplan')
|
160
|
+
assert @server.successful?
|
152
161
|
end
|
153
162
|
|
154
163
|
def test_change_owner
|
155
|
-
|
156
|
-
|
157
|
-
|
164
|
+
stub_response 'server/change-owner'
|
165
|
+
|
166
|
+
assert @server.change_owner(1, 2)
|
167
|
+
assert @server.successful?
|
158
168
|
end
|
159
169
|
|
160
170
|
def test_change_consolepass
|
161
|
-
|
162
|
-
|
171
|
+
pend do
|
172
|
+
stub_response 'server/change-consolepass'
|
173
|
+
|
174
|
+
assert @server.change_consolepass(1, 'thepassword')
|
163
175
|
end
|
164
176
|
end
|
165
177
|
|
166
178
|
def test_change_vncpass
|
167
|
-
|
168
|
-
|
169
|
-
|
179
|
+
stub_response 'server/change-vncpass'
|
180
|
+
|
181
|
+
assert @server.change_vncpass(1, "vncpassword")
|
182
|
+
assert @server.successful?
|
170
183
|
end
|
171
184
|
|
172
185
|
def test_change_rootpassword
|
173
|
-
|
174
|
-
|
175
|
-
|
186
|
+
stub_response 'server/change-rootpassword'
|
187
|
+
|
188
|
+
assert @server.change_rootpassword(1, "rootpassword")
|
189
|
+
assert @server.successful?
|
176
190
|
end
|
177
191
|
|
178
192
|
def test_change_bootorder
|
179
|
-
|
180
|
-
|
181
|
-
|
193
|
+
stub_response 'server/change-bootorder'
|
194
|
+
|
195
|
+
assert @server.change_bootorder(1, :c)
|
196
|
+
assert @server.successful?
|
182
197
|
end
|
183
198
|
|
184
199
|
def test_change_hostname
|
185
|
-
|
186
|
-
|
187
|
-
|
200
|
+
stub_response 'server/change-hostname'
|
201
|
+
|
202
|
+
assert @server.change_hostname(1, 'hostname')
|
203
|
+
assert @server.successful?
|
188
204
|
end
|
189
205
|
|
190
206
|
def test_info
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
assert_equal '1', info['vserverid']
|
199
|
-
assert_equal '1', info['ctid-xid']
|
200
|
-
assert_equal '1', info['clientid']
|
201
|
-
assert_equal 'host.example.com', info['hostname']
|
202
|
-
assert_equal '123.123.123.123', info['ipaddress']
|
203
|
-
assert_equal 'vps1', info['template']
|
204
|
-
assert_equal '123456', info['hdd']
|
205
|
-
assert_equal '123456', info['memory']
|
206
|
-
assert_equal 'swp', info['swap-burst']
|
207
|
-
assert_equal 'xenhvm', info['type']
|
207
|
+
stub_response 'server/info'
|
208
|
+
|
209
|
+
assert @server.info(1, true).is_a? Hash
|
210
|
+
assert @server.successful?
|
211
|
+
|
212
|
+
assert @server.info(1).is_a? Hash
|
213
|
+
assert @server.successful?
|
208
214
|
end
|
209
215
|
|
210
216
|
def test_vnc
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
assert_equal 'thetype', info['type']
|
216
|
-
assert_equal 'thevncip', info['vncip']
|
217
|
-
assert_equal 'thevncport', info['vncport']
|
218
|
-
assert_equal 'thevncpassword', info['vncpassword']
|
217
|
+
stub_response 'server/vnc'
|
218
|
+
|
219
|
+
assert @server.vnc(1).is_a? Hash
|
220
|
+
assert @server.successful?
|
219
221
|
end
|
220
222
|
|
221
223
|
def test_console
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
assert_equal 'theconsolepassword', info['consolepassword']
|
230
|
-
assert_equal 'theconsoleusername', info['consoleusername']
|
231
|
-
|
232
|
-
# with the optional parameters
|
233
|
-
VCR.use_cassette "server/console" do
|
234
|
-
@server.console(1, access: "admin", time: 1)
|
235
|
-
end
|
236
|
-
# a check to see if it returned a expected parameter even with the optional parameter
|
237
|
-
assert_equal 'thetype', @server.returned_parameters['type']
|
224
|
+
stub_response 'server/console'
|
225
|
+
|
226
|
+
assert @server.console(1).is_a? Hash
|
227
|
+
assert @server.successful?
|
228
|
+
|
229
|
+
assert @server.console(1, access: "admin", time: 1).is_a? Hash
|
230
|
+
assert @server.successful?
|
238
231
|
end
|
239
232
|
|
240
233
|
def test_info_all
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
assert_equal "success", info["status"]
|
246
|
-
assert_equal "123.123.123.123", info["mainipaddress"]
|
247
|
-
assert_equal "tydeus", info["node"]
|
248
|
-
assert_equal "openvz", info["type"]
|
249
|
-
assert_equal "16106127360000,5370261749139,10735865610861,33", info["bandwidth"]
|
250
|
-
assert_equal "1073741824,187097088,886644736,17", info["memory"]
|
251
|
-
assert_equal "236223201280,103640707072,132582494208,44", info["hdd"]
|
252
|
-
assert_equal "/graphs/9/214/214-8f7daef90bc75037489af4217af674a67df545ba05c8a6bcd5341d5894f2f905bf23976f52c0104415c1694135d51f204ddfd7b11bbe87c195a5de4a-86400.png", info["trafficgraph"]
|
253
|
-
assert_equal "/graphs/9/214/214-load-8f7daef90bc75037489af4217af674a67df545ba05c8a6bcd5341d5894f2f905bf23976f52c0104415c1694135d51f204ddfd7b11bbe87c195a5de4a-86400.png", info["loadgraph"]
|
254
|
-
assert_equal "/graphs/9/214/214-mem-8f7daef90bc75037489af4217af674a67df545ba05c8a6bcd5341d5894f2f905bf23976f52c0104415c1694135d51f204ddfd7b11bbe87c195a5de4a-86400.png", info["memorygraph"]
|
234
|
+
stub_response 'server/info-all'
|
235
|
+
|
236
|
+
assert @server.info_all(1).is_a? Hash
|
237
|
+
assert @server.successful?
|
255
238
|
end
|
256
239
|
|
257
240
|
def test_mountiso
|
258
|
-
|
259
|
-
|
260
|
-
|
241
|
+
stub_response 'server/mountiso'
|
242
|
+
|
243
|
+
assert @server.mountiso(1, "theiso")
|
244
|
+
assert @server.successful?
|
261
245
|
end
|
262
246
|
|
263
247
|
def test_unmountiso
|
264
|
-
|
265
|
-
|
266
|
-
|
248
|
+
stub_response 'server/unmountiso'
|
249
|
+
|
250
|
+
assert @server.unmountiso(1)
|
251
|
+
assert @server.successful?
|
267
252
|
end
|
268
253
|
end
|