fog-oneandone 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/CONTRIBUTING.md +276 -0
- data/CONTRIBUTORS.md +1 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +317 -0
- data/bin/fog +78 -0
- data/examples/example_app.rb +80 -0
- data/fog-oneandone.gemspec +22 -0
- data/gemfiles/Gemfile-edge +7 -0
- data/lib/fog-oneandone.rb +10 -0
- data/lib/oneandone/compute.rb +713 -0
- data/lib/oneandone/core.rb +11 -0
- data/lib/oneandone/models/compute/firewall.rb +128 -0
- data/lib/oneandone/models/compute/firewalls.rb +24 -0
- data/lib/oneandone/models/compute/image.rb +72 -0
- data/lib/oneandone/models/compute/images.rb +24 -0
- data/lib/oneandone/models/compute/load_balancer.rb +149 -0
- data/lib/oneandone/models/compute/load_balancers.rb +24 -0
- data/lib/oneandone/models/compute/monitoring_policies.rb +24 -0
- data/lib/oneandone/models/compute/monitoring_policy.rb +196 -0
- data/lib/oneandone/models/compute/private_network.rb +105 -0
- data/lib/oneandone/models/compute/private_networks.rb +24 -0
- data/lib/oneandone/models/compute/public_ip.rb +68 -0
- data/lib/oneandone/models/compute/public_ips.rb +24 -0
- data/lib/oneandone/models/compute/server.rb +434 -0
- data/lib/oneandone/models/compute/servers.rb +24 -0
- data/lib/oneandone/models/compute/shared_storage.rb +101 -0
- data/lib/oneandone/models/compute/shared_storages.rb +24 -0
- data/lib/oneandone/models/compute/vpn.rb +70 -0
- data/lib/oneandone/models/compute/vpns.rb +24 -0
- data/lib/oneandone/requests/compute/access.rb +35 -0
- data/lib/oneandone/requests/compute/add_firewall.rb +70 -0
- data/lib/oneandone/requests/compute/add_firewall_ips.rb +67 -0
- data/lib/oneandone/requests/compute/add_firewall_rules.rb +68 -0
- data/lib/oneandone/requests/compute/add_hdds.rb +65 -0
- data/lib/oneandone/requests/compute/add_load_balancer.rb +76 -0
- data/lib/oneandone/requests/compute/add_load_balancer_ips.rb +67 -0
- data/lib/oneandone/requests/compute/add_load_balancer_rules.rb +68 -0
- data/lib/oneandone/requests/compute/add_mp_servers.rb +64 -0
- data/lib/oneandone/requests/compute/add_ports.rb +65 -0
- data/lib/oneandone/requests/compute/add_private_network.rb +65 -0
- data/lib/oneandone/requests/compute/add_private_network_servers.rb +67 -0
- data/lib/oneandone/requests/compute/add_processes.rb +65 -0
- data/lib/oneandone/requests/compute/add_server_ip.rb +72 -0
- data/lib/oneandone/requests/compute/add_shared_storage_servers.rb +64 -0
- data/lib/oneandone/requests/compute/change_password.rb +45 -0
- data/lib/oneandone/requests/compute/change_status.rb +69 -0
- data/lib/oneandone/requests/compute/clone_server.rb +67 -0
- data/lib/oneandone/requests/compute/create_firewall.rb +78 -0
- data/lib/oneandone/requests/compute/create_image.rb +101 -0
- data/lib/oneandone/requests/compute/create_load_balancer.rb +104 -0
- data/lib/oneandone/requests/compute/create_monitoring_policy.rb +93 -0
- data/lib/oneandone/requests/compute/create_private_network.rb +82 -0
- data/lib/oneandone/requests/compute/create_public_ip.rb +77 -0
- data/lib/oneandone/requests/compute/create_server.rb +139 -0
- data/lib/oneandone/requests/compute/create_shared_storage.rb +83 -0
- data/lib/oneandone/requests/compute/create_snapshot.rb +51 -0
- data/lib/oneandone/requests/compute/create_vpn.rb +80 -0
- data/lib/oneandone/requests/compute/delete_firewall.rb +51 -0
- data/lib/oneandone/requests/compute/delete_firewall_rule.rb +60 -0
- data/lib/oneandone/requests/compute/delete_hdd.rb +61 -0
- data/lib/oneandone/requests/compute/delete_image.rb +51 -0
- data/lib/oneandone/requests/compute/delete_load_balancer.rb +51 -0
- data/lib/oneandone/requests/compute/delete_load_balancer_rule.rb +60 -0
- data/lib/oneandone/requests/compute/delete_monitoring_policy.rb +51 -0
- data/lib/oneandone/requests/compute/delete_port.rb +60 -0
- data/lib/oneandone/requests/compute/delete_private_network.rb +51 -0
- data/lib/oneandone/requests/compute/delete_process.rb +60 -0
- data/lib/oneandone/requests/compute/delete_public_ip.rb +51 -0
- data/lib/oneandone/requests/compute/delete_server.rb +51 -0
- data/lib/oneandone/requests/compute/delete_server_ip.rb +60 -0
- data/lib/oneandone/requests/compute/delete_shared_storage.rb +51 -0
- data/lib/oneandone/requests/compute/delete_snapshot.rb +51 -0
- data/lib/oneandone/requests/compute/delete_vpn.rb +51 -0
- data/lib/oneandone/requests/compute/eject_dvd.rb +51 -0
- data/lib/oneandone/requests/compute/get_datacenter.rb +50 -0
- data/lib/oneandone/requests/compute/get_dvd.rb +50 -0
- data/lib/oneandone/requests/compute/get_dvd_iso.rb +50 -0
- data/lib/oneandone/requests/compute/get_firewall.rb +50 -0
- data/lib/oneandone/requests/compute/get_firewall_ip.rb +59 -0
- data/lib/oneandone/requests/compute/get_firewall_rule.rb +59 -0
- data/lib/oneandone/requests/compute/get_fixed_server.rb +50 -0
- data/lib/oneandone/requests/compute/get_hardware.rb +50 -0
- data/lib/oneandone/requests/compute/get_hdd.rb +60 -0
- data/lib/oneandone/requests/compute/get_hdds.rb +50 -0
- data/lib/oneandone/requests/compute/get_image.rb +50 -0
- data/lib/oneandone/requests/compute/get_load_balancer.rb +50 -0
- data/lib/oneandone/requests/compute/get_load_balancer_ip.rb +59 -0
- data/lib/oneandone/requests/compute/get_load_balancer_rule.rb +59 -0
- data/lib/oneandone/requests/compute/get_log.rb +51 -0
- data/lib/oneandone/requests/compute/get_monitored_server.rb +49 -0
- data/lib/oneandone/requests/compute/get_monitoring_policy.rb +50 -0
- data/lib/oneandone/requests/compute/get_mp_server.rb +59 -0
- data/lib/oneandone/requests/compute/get_port.rb +59 -0
- data/lib/oneandone/requests/compute/get_private_network.rb +50 -0
- data/lib/oneandone/requests/compute/get_private_network_server.rb +59 -0
- data/lib/oneandone/requests/compute/get_process.rb +59 -0
- data/lib/oneandone/requests/compute/get_public_ip.rb +50 -0
- data/lib/oneandone/requests/compute/get_server.rb +50 -0
- data/lib/oneandone/requests/compute/get_server_appliance.rb +50 -0
- data/lib/oneandone/requests/compute/get_server_image.rb +50 -0
- data/lib/oneandone/requests/compute/get_server_ip.rb +59 -0
- data/lib/oneandone/requests/compute/get_server_private_network.rb +59 -0
- data/lib/oneandone/requests/compute/get_shared_storage.rb +50 -0
- data/lib/oneandone/requests/compute/get_shared_storage_server.rb +59 -0
- data/lib/oneandone/requests/compute/get_snapshot.rb +50 -0
- data/lib/oneandone/requests/compute/get_vpn.rb +50 -0
- data/lib/oneandone/requests/compute/install_server_image.rb +72 -0
- data/lib/oneandone/requests/compute/list_datacenters.rb +56 -0
- data/lib/oneandone/requests/compute/list_dvds.rb +56 -0
- data/lib/oneandone/requests/compute/list_firewall_ips.rb +50 -0
- data/lib/oneandone/requests/compute/list_firewall_rules.rb +50 -0
- data/lib/oneandone/requests/compute/list_firewalls.rb +56 -0
- data/lib/oneandone/requests/compute/list_fixed_servers.rb +40 -0
- data/lib/oneandone/requests/compute/list_images.rb +56 -0
- data/lib/oneandone/requests/compute/list_ip_firewalls.rb +59 -0
- data/lib/oneandone/requests/compute/list_ip_load_balancers.rb +59 -0
- data/lib/oneandone/requests/compute/list_load_balancer_ips.rb +50 -0
- data/lib/oneandone/requests/compute/list_load_balancer_rules.rb +50 -0
- data/lib/oneandone/requests/compute/list_load_balancers.rb +56 -0
- data/lib/oneandone/requests/compute/list_logs.rb +59 -0
- data/lib/oneandone/requests/compute/list_monitored_servers.rb +51 -0
- data/lib/oneandone/requests/compute/list_monitoring_policies.rb +56 -0
- data/lib/oneandone/requests/compute/list_mp_servers.rb +50 -0
- data/lib/oneandone/requests/compute/list_ports.rb +51 -0
- data/lib/oneandone/requests/compute/list_private_network_servers.rb +50 -0
- data/lib/oneandone/requests/compute/list_private_networks.rb +56 -0
- data/lib/oneandone/requests/compute/list_processes.rb +51 -0
- data/lib/oneandone/requests/compute/list_public_ips.rb +56 -0
- data/lib/oneandone/requests/compute/list_server_appliances.rb +56 -0
- data/lib/oneandone/requests/compute/list_server_ips.rb +50 -0
- data/lib/oneandone/requests/compute/list_server_private_networks.rb +50 -0
- data/lib/oneandone/requests/compute/list_servers.rb +56 -0
- data/lib/oneandone/requests/compute/list_shared_storage_servers.rb +50 -0
- data/lib/oneandone/requests/compute/list_shared_storages.rb +56 -0
- data/lib/oneandone/requests/compute/list_usages.rb +54 -0
- data/lib/oneandone/requests/compute/list_vpns.rb +56 -0
- data/lib/oneandone/requests/compute/load_dvd.rb +65 -0
- data/lib/oneandone/requests/compute/ping.rb +38 -0
- data/lib/oneandone/requests/compute/ping_auth.rb +38 -0
- data/lib/oneandone/requests/compute/remove_firewall.rb +60 -0
- data/lib/oneandone/requests/compute/remove_firewall_ip.rb +60 -0
- data/lib/oneandone/requests/compute/remove_load_balancer.rb +71 -0
- data/lib/oneandone/requests/compute/remove_load_balancer_ip.rb +60 -0
- data/lib/oneandone/requests/compute/remove_mp_server.rb +60 -0
- data/lib/oneandone/requests/compute/remove_private_network.rb +60 -0
- data/lib/oneandone/requests/compute/remove_private_network_server.rb +60 -0
- data/lib/oneandone/requests/compute/remove_shared_storage_server.rb +60 -0
- data/lib/oneandone/requests/compute/restore_snapshot.rb +35 -0
- data/lib/oneandone/requests/compute/status.rb +50 -0
- data/lib/oneandone/requests/compute/update_firewall.rb +76 -0
- data/lib/oneandone/requests/compute/update_hardware.rb +82 -0
- data/lib/oneandone/requests/compute/update_hdd.rb +71 -0
- data/lib/oneandone/requests/compute/update_image.rb +80 -0
- data/lib/oneandone/requests/compute/update_load_balancer.rb +96 -0
- data/lib/oneandone/requests/compute/update_monitoring_policy.rb +82 -0
- data/lib/oneandone/requests/compute/update_port.rb +74 -0
- data/lib/oneandone/requests/compute/update_private_network.rb +82 -0
- data/lib/oneandone/requests/compute/update_process.rb +76 -0
- data/lib/oneandone/requests/compute/update_public_ip.rb +71 -0
- data/lib/oneandone/requests/compute/update_server.rb +76 -0
- data/lib/oneandone/requests/compute/update_shared_storage.rb +80 -0
- data/lib/oneandone/requests/compute/update_vpn.rb +76 -0
- data/tests/oneandone/test_firewalls.rb +188 -0
- data/tests/oneandone/test_images.rb +79 -0
- data/tests/oneandone/test_load_balancers.rb +192 -0
- data/tests/oneandone/test_monitoring_policies.rb +342 -0
- data/tests/oneandone/test_private_networks.rb +123 -0
- data/tests/oneandone/test_public_ips.rb +75 -0
- data/tests/oneandone/test_servers.rb +465 -0
- data/tests/oneandone/test_shared_storages.rb +131 -0
- metadata +259 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
require_relative '../../lib/fog-oneandone'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
Fog.mock!
|
5
|
+
|
6
|
+
class TestPublicIP < Minitest::Test
|
7
|
+
|
8
|
+
def self.test_order
|
9
|
+
:alpha
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup
|
13
|
+
|
14
|
+
# Establish Connection
|
15
|
+
@compute = Fog::Compute::OneAndOne.new({
|
16
|
+
:oneandone_api_key => 'APIKEY'
|
17
|
+
})
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def test_a_create_public_ip
|
23
|
+
|
24
|
+
# Perform Request
|
25
|
+
response = @compute.create_public_ip
|
26
|
+
|
27
|
+
@@ip_id = response.body['id']
|
28
|
+
|
29
|
+
# Assertions
|
30
|
+
assert_equal response.body['state'], 'ACTIVE'
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_b_list_public_ips
|
35
|
+
|
36
|
+
# Perform Request
|
37
|
+
response = @compute.list_public_ips
|
38
|
+
|
39
|
+
# Assertions
|
40
|
+
assert_equal response.body.length, 1
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_c_update_public_ip
|
45
|
+
|
46
|
+
# Perform Request
|
47
|
+
response = @compute.update_public_ip(ip_id: @@ip_id,
|
48
|
+
reverse_dns: 'example.com')
|
49
|
+
|
50
|
+
# Assertions
|
51
|
+
assert_equal response.body['reverse_dns'], 'example.com'
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_d_get_public_ip
|
56
|
+
|
57
|
+
# Perform Request
|
58
|
+
response = @compute.get_public_ip(@@ip_id)
|
59
|
+
|
60
|
+
# Assertions
|
61
|
+
assert_equal response.body['id'], @@ip_id
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_e_delete_public_ip
|
66
|
+
|
67
|
+
# Perform Request
|
68
|
+
response = @compute.delete_public_ip(@@ip_id)
|
69
|
+
|
70
|
+
# Assertions
|
71
|
+
assert_equal response.body, 'The requested public IP has been deleted.'
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
@@ -0,0 +1,465 @@
|
|
1
|
+
require_relative '../../lib/fog-oneandone'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
Fog.mock!
|
5
|
+
|
6
|
+
class TestServer < Minitest::Test
|
7
|
+
|
8
|
+
def self.test_order
|
9
|
+
:alpha
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup
|
13
|
+
|
14
|
+
# Establish Connection
|
15
|
+
@compute = Fog::Compute::OneAndOne.new({
|
16
|
+
:oneandone_api_key => 'APIKEY'
|
17
|
+
})
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def test_a_create_server
|
23
|
+
|
24
|
+
# Perform Request
|
25
|
+
hdd1 = {
|
26
|
+
'size' => 120,
|
27
|
+
'is_main' => true
|
28
|
+
}
|
29
|
+
|
30
|
+
hdds = [hdd1]
|
31
|
+
|
32
|
+
response = @compute.create_server(name: 'Test Server', vcore: 1,
|
33
|
+
cores_per_processor: 1, ram: 1, appliance_id: '<IMAGE-ID>', hdds: hdds)
|
34
|
+
|
35
|
+
@@server_id = response.body['id']
|
36
|
+
@@ip1_id = response.body['ips'][0]['id']
|
37
|
+
|
38
|
+
# Assertions
|
39
|
+
assert_equal response.body['name'], 'Test Server'
|
40
|
+
assert_equal response.body['hardware']['vcore'], 1
|
41
|
+
assert_equal response.body['hardware']['cores_per_processor'], 1
|
42
|
+
assert_equal response.body['hardware']['ram'], 1
|
43
|
+
assert_equal response.body['image']['id'], '<IMAGE-ID>'
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_b_list_servers
|
48
|
+
|
49
|
+
# Perform Request
|
50
|
+
response = @compute.list_servers
|
51
|
+
|
52
|
+
# Assertions
|
53
|
+
assert_equal response.body.length, 1
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_c_update_server
|
58
|
+
|
59
|
+
# Perform Request
|
60
|
+
response = @compute.update_server(server_id: @@server_id,
|
61
|
+
name: 'New Name')
|
62
|
+
|
63
|
+
# Assertions
|
64
|
+
assert_equal response.body['name'], 'New Name'
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_d_get_server
|
69
|
+
|
70
|
+
# Perform Request
|
71
|
+
response = @compute.get_server(@@server_id)
|
72
|
+
|
73
|
+
# Assertions
|
74
|
+
assert_equal response.body['id'], @@server_id
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_e_list_fixed_servers
|
79
|
+
|
80
|
+
# Perform Request
|
81
|
+
response = @compute.list_fixed_servers
|
82
|
+
|
83
|
+
@@fixed_server_id = response.body[0]['id']
|
84
|
+
|
85
|
+
# Assertions
|
86
|
+
assert_equal response.body.length, 4
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_f_get_fixed_server
|
91
|
+
|
92
|
+
# Perform Request
|
93
|
+
response = @compute.get_fixed_server(@@fixed_server_id)
|
94
|
+
|
95
|
+
# Assertions
|
96
|
+
assert_equal response.body['id'], @@fixed_server_id
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_g_get_hardware
|
101
|
+
|
102
|
+
# Perform Request
|
103
|
+
response = @compute.get_hardware(@@server_id)
|
104
|
+
|
105
|
+
# Assertions
|
106
|
+
assert_equal response.body['vcore'], 1
|
107
|
+
assert_equal response.body['cores_per_processor'], 1
|
108
|
+
assert_equal response.body['ram'], 1
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_h_update_hardware
|
113
|
+
|
114
|
+
# Perform Request
|
115
|
+
response = @compute.update_hardware(server_id: @@server_id, vcore: 2, ram: 4)
|
116
|
+
|
117
|
+
# Assertions
|
118
|
+
assert_equal response.body['hardware']['vcore'], 2
|
119
|
+
assert_equal response.body['hardware']['ram'], 4
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_i_get_hdds
|
124
|
+
|
125
|
+
# Perform Request
|
126
|
+
response = @compute.get_hdds(@@server_id)
|
127
|
+
|
128
|
+
# Assertions
|
129
|
+
assert_equal response.body.length, 1
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_j_add_hdds
|
134
|
+
|
135
|
+
# Perform Request
|
136
|
+
hdd2 = {
|
137
|
+
'size' => 100,
|
138
|
+
'is_main' => false
|
139
|
+
}
|
140
|
+
|
141
|
+
hdds = [hdd2]
|
142
|
+
|
143
|
+
response = @compute.add_hdds(server_id: @@server_id, hdds: hdds)
|
144
|
+
|
145
|
+
@@hdd2_id = response.body['hardware']['hdds'][1]['id']
|
146
|
+
|
147
|
+
# Assertions
|
148
|
+
assert_equal response.body['hardware']['hdds'][1]['size'], 100
|
149
|
+
assert_equal response.body['hardware']['hdds'][1]['is_main'], false
|
150
|
+
assert_equal response.body['hardware']['hdds'].length, 2
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_k_get_hdd
|
155
|
+
|
156
|
+
# Perform Request
|
157
|
+
response = @compute.get_hdd(server_id: @@server_id, hdd_id: @@hdd2_id)
|
158
|
+
|
159
|
+
# Assertions
|
160
|
+
assert_equal response.body['id'], @@hdd2_id
|
161
|
+
assert_equal response.body['size'], 100
|
162
|
+
assert_equal response.body['is_main'], false
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_l_update_hdd
|
167
|
+
|
168
|
+
# Perform Request
|
169
|
+
response = @compute.update_hdd(server_id: @@server_id, hdd_id: @@hdd2_id,
|
170
|
+
size: 200)
|
171
|
+
|
172
|
+
# Assertions
|
173
|
+
assert_equal response.body['hardware']['hdds'][1]['size'], 200
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_m_delete_hdd
|
178
|
+
|
179
|
+
# Perform Request
|
180
|
+
response = @compute.delete_hdd(server_id: @@server_id, hdd_id: @@hdd2_id)
|
181
|
+
|
182
|
+
# Assertions
|
183
|
+
assert_equal response.body['hardware']['hdds'].length, 1
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_n_get_server_image
|
188
|
+
|
189
|
+
# Perform Request
|
190
|
+
response = @compute.get_server_image(@@server_id)
|
191
|
+
|
192
|
+
# Assertions
|
193
|
+
assert_equal response.body['id'], '<IMAGE-ID>'
|
194
|
+
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_o_install_server_image
|
198
|
+
|
199
|
+
# Perform Request
|
200
|
+
response = @compute.install_server_image(server_id: @@server_id,
|
201
|
+
image_id: 'NEW-ID')
|
202
|
+
|
203
|
+
# Assertions
|
204
|
+
assert_equal response.body['image']['id'], 'NEW-ID'
|
205
|
+
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_p_add_server_ip
|
209
|
+
|
210
|
+
# Perform Request
|
211
|
+
response = @compute.add_server_ip(server_id: @@server_id)
|
212
|
+
|
213
|
+
@@ip2_id = response.body['ips'][1]['id']
|
214
|
+
|
215
|
+
# Assertions
|
216
|
+
assert_equal response.body['ips'].length, 2
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_q_list_server_ips
|
221
|
+
|
222
|
+
# Perform Request
|
223
|
+
response = @compute.list_server_ips(@@server_id)
|
224
|
+
|
225
|
+
# Assertions
|
226
|
+
assert_equal response.body.length, 2
|
227
|
+
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_r_get_server_ip
|
231
|
+
|
232
|
+
# Perform Request
|
233
|
+
response = @compute.get_server_ip(server_id: @@server_id,
|
234
|
+
ip_id: @@ip2_id)
|
235
|
+
|
236
|
+
# Assertions
|
237
|
+
assert_equal response.body['id'], @@ip2_id
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_s_delete_server_ip
|
242
|
+
|
243
|
+
# Perform Request
|
244
|
+
response = @compute.delete_server_ip(server_id: @@server_id,
|
245
|
+
ip_id: @@ip2_id)
|
246
|
+
|
247
|
+
# Assertions
|
248
|
+
assert_equal response.body['ips'].length, 1
|
249
|
+
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_t_list_ip_firewalls
|
253
|
+
|
254
|
+
# Perform Request
|
255
|
+
response = @compute.list_ip_firewalls(server_id: @@server_id,
|
256
|
+
ip_id: @@ip1_id)
|
257
|
+
|
258
|
+
# Assertions
|
259
|
+
assert_equal response.body, {}
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_u_add_firewall
|
264
|
+
|
265
|
+
# Perform Request
|
266
|
+
response = @compute.add_firewall(server_id: @@server_id,
|
267
|
+
ip_id: @@ip1_id, firewall_id:'FIREWALL1')
|
268
|
+
|
269
|
+
# Assertions
|
270
|
+
assert_equal response.body['ips'][0]['firewall_policy']['id'], 'FIREWALL1'
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_v_remove_firewall
|
275
|
+
|
276
|
+
# Perform Request
|
277
|
+
response = @compute.remove_firewall(server_id: @@server_id, ip_id: @@ip1_id)
|
278
|
+
|
279
|
+
# Assertions
|
280
|
+
assert_equal response.body['ips'][0]['firewall_policy'], {}
|
281
|
+
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_w_list_ip_load_balancers
|
285
|
+
|
286
|
+
# Perform Request
|
287
|
+
response = @compute.list_ip_load_balancers(server_id: @@server_id,
|
288
|
+
ip_id: @@ip1_id)
|
289
|
+
|
290
|
+
# Assertions
|
291
|
+
assert_equal response.body, []
|
292
|
+
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_x_add_load_balancer
|
296
|
+
|
297
|
+
# Perform Request
|
298
|
+
response = @compute.add_load_balancer(server_id: @@server_id,
|
299
|
+
ip_id: @@ip1_id, load_balancer_id: 'LB1')
|
300
|
+
|
301
|
+
# Assertions
|
302
|
+
assert_equal response.body['ips'][0]['load_balancers'][0]['id'], 'LB1'
|
303
|
+
|
304
|
+
end
|
305
|
+
|
306
|
+
def test_y_remove_load_balancer
|
307
|
+
|
308
|
+
# Perform Request
|
309
|
+
response = @compute.remove_load_balancer(server_id: @@server_id,
|
310
|
+
ip_id: @@ip1_id, load_balancer_id: 'LB1')
|
311
|
+
|
312
|
+
# Assertions
|
313
|
+
assert_equal response.body['ips'][0]['load_balancers'].length, 0
|
314
|
+
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_z_status
|
318
|
+
|
319
|
+
# Perform Request
|
320
|
+
response = @compute.status(@@server_id)
|
321
|
+
|
322
|
+
# Assertions
|
323
|
+
assert_equal response.body['state'], 'POWERED_ON'
|
324
|
+
|
325
|
+
end
|
326
|
+
|
327
|
+
def test_za_change_status
|
328
|
+
|
329
|
+
# Perform Request
|
330
|
+
response = @compute.change_status(server_id: @@server_id,
|
331
|
+
action: 'POWER_OFF', method: 'SOFTWARE')
|
332
|
+
|
333
|
+
# Assertions
|
334
|
+
assert_equal response.body['status']['state'], 'POWERED_OFF'
|
335
|
+
|
336
|
+
end
|
337
|
+
|
338
|
+
def test_zb_load_dvd
|
339
|
+
|
340
|
+
# Perform Request
|
341
|
+
response = @compute.load_dvd(server_id: @@server_id, dvd_id: 'DVD1')
|
342
|
+
|
343
|
+
# Assertions
|
344
|
+
assert_equal response.body['dvd']['id'], 'DVD1'
|
345
|
+
|
346
|
+
end
|
347
|
+
|
348
|
+
def test_zc_get_dvd
|
349
|
+
|
350
|
+
# Perform Request
|
351
|
+
response = @compute.get_dvd(@@server_id)
|
352
|
+
|
353
|
+
# Assertions
|
354
|
+
assert_equal response.body['id'], 'DVD1'
|
355
|
+
|
356
|
+
end
|
357
|
+
|
358
|
+
def test_zd_eject_dvd
|
359
|
+
|
360
|
+
# Perform Request
|
361
|
+
response = @compute.eject_dvd(@@server_id)
|
362
|
+
|
363
|
+
# Assertions
|
364
|
+
assert_equal response.body['dvd'], {}
|
365
|
+
|
366
|
+
end
|
367
|
+
|
368
|
+
def test_ze_add_private_network
|
369
|
+
|
370
|
+
# Perform Request
|
371
|
+
response = @compute.add_private_network(server_id: @@server_id,
|
372
|
+
private_network_id: 'PN1')
|
373
|
+
|
374
|
+
# Assertions
|
375
|
+
assert_equal response.body['private_networks'].length, 1
|
376
|
+
|
377
|
+
end
|
378
|
+
|
379
|
+
def test_zf_list_server_private_networks
|
380
|
+
|
381
|
+
# Perform Request
|
382
|
+
response = @compute.list_server_private_networks(@@server_id)
|
383
|
+
|
384
|
+
# Assertions
|
385
|
+
assert_equal response.body.length, 1
|
386
|
+
|
387
|
+
end
|
388
|
+
|
389
|
+
def test_zg_get_server_private_network
|
390
|
+
|
391
|
+
# Perform Request
|
392
|
+
response = @compute.get_server_private_network(server_id: @@server_id,
|
393
|
+
private_network_id: 'PN1')
|
394
|
+
|
395
|
+
# Assertions
|
396
|
+
assert_equal response.body['id'], 'PN1'
|
397
|
+
|
398
|
+
end
|
399
|
+
|
400
|
+
def test_zh_remove_private_network
|
401
|
+
|
402
|
+
# Perform Request
|
403
|
+
response = @compute.remove_private_network(server_id: @@server_id,
|
404
|
+
private_network_id: 'PN1')
|
405
|
+
|
406
|
+
# Assertions
|
407
|
+
assert_equal response.body['private_networks'].length, 0
|
408
|
+
|
409
|
+
end
|
410
|
+
|
411
|
+
def test_zi_create_snapshot
|
412
|
+
|
413
|
+
# Perform Request
|
414
|
+
response = @compute.create_snapshot(@@server_id)
|
415
|
+
|
416
|
+
@@snapshot_id = response.body['snapshot']['id']
|
417
|
+
|
418
|
+
# Assertions
|
419
|
+
assert_equal response.body['snapshot']['id'], @@snapshot_id
|
420
|
+
|
421
|
+
end
|
422
|
+
|
423
|
+
def test_zj_get_snapshot
|
424
|
+
|
425
|
+
# Perform Request
|
426
|
+
response = @compute.get_snapshot(@@server_id)
|
427
|
+
|
428
|
+
# Assertions
|
429
|
+
assert_equal response.body['id'], @@snapshot_id
|
430
|
+
|
431
|
+
end
|
432
|
+
|
433
|
+
def test_zk_delete_snapshot
|
434
|
+
|
435
|
+
# Perform Request
|
436
|
+
response = @compute.delete_snapshot(server_id: @@server_id,
|
437
|
+
snapshot_id: @@snapshot_id)
|
438
|
+
|
439
|
+
# Assertions
|
440
|
+
assert_equal response.body['snapshot'], {}
|
441
|
+
|
442
|
+
end
|
443
|
+
|
444
|
+
def test_zl_clone_server
|
445
|
+
|
446
|
+
# Perform Request
|
447
|
+
response = @compute.clone_server(server_id: @@server_id,
|
448
|
+
name: 'Mini Me')
|
449
|
+
|
450
|
+
# Assertions
|
451
|
+
assert_equal response.body['name'], 'Mini Me'
|
452
|
+
|
453
|
+
end
|
454
|
+
|
455
|
+
def test_zm_delete_server
|
456
|
+
|
457
|
+
# Perform Request
|
458
|
+
response = @compute.delete_server(@@server_id)
|
459
|
+
|
460
|
+
# Assertions
|
461
|
+
assert_equal response.body, 'The requested server has been deleted.'
|
462
|
+
|
463
|
+
end
|
464
|
+
|
465
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require_relative '../../lib/fog-oneandone'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
Fog.mock!
|
5
|
+
|
6
|
+
class TestSharedStorage < Minitest::Test
|
7
|
+
|
8
|
+
def self.test_order
|
9
|
+
:alpha
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup
|
13
|
+
|
14
|
+
# Establish Connection
|
15
|
+
@compute = Fog::Compute::OneAndOne.new({
|
16
|
+
:oneandone_api_key => 'APIKEY'
|
17
|
+
})
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def test_a_create_shared_storage
|
23
|
+
|
24
|
+
# Perform Request
|
25
|
+
response = @compute.create_shared_storage(name: 'Test SS',
|
26
|
+
description: 'Example Desc', size: 200)
|
27
|
+
|
28
|
+
@@shared_storage_id = response.body['id']
|
29
|
+
|
30
|
+
# Assertions
|
31
|
+
assert_equal response.body['name'], 'Test SS'
|
32
|
+
assert_equal response.body['description'], 'Example Desc'
|
33
|
+
assert_equal response.body['size'], 200
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_b_list_shared_storages
|
38
|
+
|
39
|
+
# Perform Request
|
40
|
+
response = @compute.list_shared_storages
|
41
|
+
|
42
|
+
# Assertions
|
43
|
+
assert_equal response.body.length, 1
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_c_update_shared_storage
|
48
|
+
|
49
|
+
# Perform Request
|
50
|
+
response = @compute.update_shared_storage(shared_storage_id: @@shared_storage_id,
|
51
|
+
name: 'New Name', description: 'New Desc')
|
52
|
+
|
53
|
+
# Assertions
|
54
|
+
assert_equal response.body['name'], 'New Name'
|
55
|
+
assert_equal response.body['description'], 'New Desc'
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_d_get_shared_storage
|
60
|
+
|
61
|
+
# Perform Request
|
62
|
+
response = @compute.get_shared_storage(@@shared_storage_id)
|
63
|
+
|
64
|
+
# Assertions
|
65
|
+
assert_equal response.body['id'], @@shared_storage_id
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_e_add_shared_storage_servers
|
70
|
+
|
71
|
+
# Perform Request
|
72
|
+
server1 = {
|
73
|
+
'id' => '<SERVER-ID>',
|
74
|
+
'rights' => 'RW'
|
75
|
+
}
|
76
|
+
|
77
|
+
servers = [server1]
|
78
|
+
|
79
|
+
response = @compute.add_shared_storage_servers(shared_storage_id: @@shared_storage_id,
|
80
|
+
servers: servers)
|
81
|
+
|
82
|
+
@@server1 = response.body['servers'][0]['id']
|
83
|
+
|
84
|
+
# Assertions
|
85
|
+
assert_equal response.body['servers'].length, 1
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_f_list_shared_storage_servers
|
90
|
+
|
91
|
+
# Perform Request
|
92
|
+
response = @compute.list_shared_storage_servers(@@shared_storage_id)
|
93
|
+
|
94
|
+
# Assertions
|
95
|
+
assert_equal response.body.length, 1
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_g_get_shared_storage_server
|
100
|
+
|
101
|
+
# Perform Request
|
102
|
+
response = @compute.get_shared_storage_server(shared_storage_id: @@shared_storage_id,
|
103
|
+
server_id: @@server1)
|
104
|
+
|
105
|
+
# Assertions
|
106
|
+
assert_equal response.body['id'], @@server1
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_h_remove_shared_storage_server
|
111
|
+
|
112
|
+
# Perform Request
|
113
|
+
response = @compute.remove_shared_storage_server(shared_storage_id: @@shared_storage_id,
|
114
|
+
server_id: @@server1)
|
115
|
+
|
116
|
+
# Assertions
|
117
|
+
assert_equal response.body['servers'].length, 0
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_i_delete_shared_storage
|
122
|
+
|
123
|
+
# Perform Request
|
124
|
+
response = @compute.delete_shared_storage(@@shared_storage_id)
|
125
|
+
|
126
|
+
# Assertions
|
127
|
+
assert_equal response.body, 'The requested shared storage has been deleted.'
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|