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,71 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Modify a public IP
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#public_ips__ip_id__put]
|
10
|
+
##
|
11
|
+
def update_public_ip(ip_id: nil, reverse_dns: nil)
|
12
|
+
|
13
|
+
# Build PUT body
|
14
|
+
update_ip = {
|
15
|
+
'reverse_dns' => reverse_dns
|
16
|
+
}
|
17
|
+
|
18
|
+
# Stringify the PUT body
|
19
|
+
string_body = Fog::JSON.encode(update_ip)
|
20
|
+
|
21
|
+
# Request
|
22
|
+
params = {
|
23
|
+
'method' => :put,
|
24
|
+
'endpoint' => "/public_ips/#{ip_id}",
|
25
|
+
'body' => string_body
|
26
|
+
}
|
27
|
+
|
28
|
+
request(params)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end # Real
|
33
|
+
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
|
37
|
+
def update_public_ip(ip_id: nil, reverse_dns: nil)
|
38
|
+
|
39
|
+
# Search for IP to update
|
40
|
+
if ip = self.data[:public_ips].find {
|
41
|
+
|hash| hash['id'] == ip_id
|
42
|
+
}
|
43
|
+
# Create parameter hash
|
44
|
+
params = {
|
45
|
+
'reverse_dns' => reverse_dns
|
46
|
+
}
|
47
|
+
|
48
|
+
# Update the IP we found with new values
|
49
|
+
params.each do |key, value|
|
50
|
+
if value
|
51
|
+
ip[key] = value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
else
|
55
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
56
|
+
not be found.')
|
57
|
+
end
|
58
|
+
|
59
|
+
# Return Response Object to User
|
60
|
+
response = Excon::Response.new
|
61
|
+
response.status = 202
|
62
|
+
response.body = ip
|
63
|
+
response
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end # Mock
|
68
|
+
|
69
|
+
end # OneAndOne
|
70
|
+
end # Compute
|
71
|
+
end # Fog
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Update a server's specs
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__put]
|
10
|
+
##
|
11
|
+
def update_server(server_id: nil, name: nil, description: nil)
|
12
|
+
|
13
|
+
# Build PUT body
|
14
|
+
server_specs = {
|
15
|
+
'name' => name,
|
16
|
+
'description' => description
|
17
|
+
}
|
18
|
+
|
19
|
+
# Clean out null keys in PUT body
|
20
|
+
body = clean_hash(server_specs)
|
21
|
+
|
22
|
+
# Stringify the PUT body
|
23
|
+
string_body = Fog::JSON.encode(body)
|
24
|
+
|
25
|
+
# Request
|
26
|
+
params = {
|
27
|
+
'method' => :put,
|
28
|
+
'endpoint' => "/servers/#{server_id}",
|
29
|
+
'body' => string_body
|
30
|
+
}
|
31
|
+
|
32
|
+
request(params)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end # Real
|
37
|
+
|
38
|
+
|
39
|
+
class Mock
|
40
|
+
|
41
|
+
def update_server(server_id: nil, name: nil, description: nil)
|
42
|
+
|
43
|
+
# Search for server to update
|
44
|
+
if server = self.data[:servers].find {
|
45
|
+
|hash| hash['id'] == server_id
|
46
|
+
}
|
47
|
+
# Create parameter hash
|
48
|
+
params = {
|
49
|
+
'name' => name,
|
50
|
+
'description' => description
|
51
|
+
}
|
52
|
+
|
53
|
+
# Update the server we found with new values
|
54
|
+
params.each do |key, value|
|
55
|
+
if value
|
56
|
+
server[key] = value
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
61
|
+
not be found.')
|
62
|
+
end
|
63
|
+
|
64
|
+
# Return Response Object to User
|
65
|
+
response = Excon::Response.new
|
66
|
+
response.status = 202
|
67
|
+
response.body = server
|
68
|
+
response
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end # Mock
|
73
|
+
|
74
|
+
end # OneAndOne
|
75
|
+
end # Compute
|
76
|
+
end # Fog
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Modify a shared storage
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#shared_storages__shared_storage_id__put]
|
10
|
+
##
|
11
|
+
def update_shared_storage(shared_storage_id: nil, name: nil,
|
12
|
+
description: nil, size: nil)
|
13
|
+
|
14
|
+
# Build PUT body
|
15
|
+
new_shared_storage = {
|
16
|
+
'name' => name,
|
17
|
+
'description' => description,
|
18
|
+
'size' => size
|
19
|
+
}
|
20
|
+
|
21
|
+
# Clean out null values from PUT body
|
22
|
+
body = clean_hash(new_shared_storage)
|
23
|
+
|
24
|
+
# Stringify the PUT body
|
25
|
+
string_body = Fog::JSON.encode(body)
|
26
|
+
|
27
|
+
# Request
|
28
|
+
params = {
|
29
|
+
'method' => :put,
|
30
|
+
'endpoint' => "/shared_storages/#{shared_storage_id}",
|
31
|
+
'body' => string_body
|
32
|
+
}
|
33
|
+
|
34
|
+
request(params)
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end # Real
|
39
|
+
|
40
|
+
|
41
|
+
class Mock
|
42
|
+
|
43
|
+
def update_shared_storage(shared_storage_id: nil, name: nil,
|
44
|
+
description: nil, size: nil)
|
45
|
+
|
46
|
+
# Search for shared storage to update
|
47
|
+
if shared_storage = self.data[:shared_storages].find {
|
48
|
+
|hash| hash['id'] == shared_storage_id
|
49
|
+
}
|
50
|
+
# Create parameter hash
|
51
|
+
params = {
|
52
|
+
'name' => name,
|
53
|
+
'description' => description,
|
54
|
+
'size' => size
|
55
|
+
}
|
56
|
+
|
57
|
+
# Update the shared storage we found with new values
|
58
|
+
params.each do |key, value|
|
59
|
+
if value
|
60
|
+
shared_storage[key] = value
|
61
|
+
end
|
62
|
+
end
|
63
|
+
else
|
64
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
65
|
+
not be found.')
|
66
|
+
end
|
67
|
+
|
68
|
+
# Return Response Object to User
|
69
|
+
response = Excon::Response.new
|
70
|
+
response.status = 202
|
71
|
+
response.body = shared_storage
|
72
|
+
response
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end # Mock
|
77
|
+
|
78
|
+
end # OneAndOne
|
79
|
+
end # Compute
|
80
|
+
end # Fog
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Modify a VPN
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#vpns__vpn_id__put]
|
10
|
+
##
|
11
|
+
def update_vpn(vpn_id: nil, name: nil, description: nil)
|
12
|
+
|
13
|
+
# Build PUT body
|
14
|
+
new_vpn = {
|
15
|
+
'name' => name,
|
16
|
+
'description' => description
|
17
|
+
}
|
18
|
+
|
19
|
+
# Clean out null values from PUT body
|
20
|
+
body = clean_hash(new_vpn)
|
21
|
+
|
22
|
+
# Stringify the PUT body
|
23
|
+
string_body = Fog::JSON.encode(body)
|
24
|
+
|
25
|
+
# Request
|
26
|
+
params = {
|
27
|
+
'method' => :put,
|
28
|
+
'endpoint' => "/vpns/#{vpn_id}",
|
29
|
+
'body' => string_body
|
30
|
+
}
|
31
|
+
|
32
|
+
request(params)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end # Real
|
37
|
+
|
38
|
+
|
39
|
+
class Mock
|
40
|
+
|
41
|
+
def update_vpn(vpn_id: nil, name: nil, description: nil)
|
42
|
+
|
43
|
+
# Search for VPN to update
|
44
|
+
if vpn = self.data[:vpns].find {
|
45
|
+
|hash| hash['id'] == vpn_id
|
46
|
+
}
|
47
|
+
# Create parameter hash
|
48
|
+
params = {
|
49
|
+
'name' => name,
|
50
|
+
'description' => description
|
51
|
+
}
|
52
|
+
|
53
|
+
# Update the VPN we found with new values
|
54
|
+
params.each do |key, value|
|
55
|
+
if value
|
56
|
+
vpn[key] = value
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
61
|
+
not be found.')
|
62
|
+
end
|
63
|
+
|
64
|
+
# Return Response Object to User
|
65
|
+
response = Excon::Response.new
|
66
|
+
response.status = 202
|
67
|
+
response.body = vpn
|
68
|
+
response
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end # Mock
|
73
|
+
|
74
|
+
end # OneAndOne
|
75
|
+
end # Compute
|
76
|
+
end # Fog
|
@@ -0,0 +1,188 @@
|
|
1
|
+
require_relative '../../lib/fog-oneandone'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
Fog.mock!
|
5
|
+
|
6
|
+
class TestFirewall < 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_firewall
|
23
|
+
|
24
|
+
# Perform Request
|
25
|
+
rule1 = {
|
26
|
+
'protocol' => 'TCP',
|
27
|
+
'port_from' => 80,
|
28
|
+
'port_to' => 80,
|
29
|
+
'source' => '0.0.0.0'
|
30
|
+
}
|
31
|
+
|
32
|
+
rules = [rule1]
|
33
|
+
|
34
|
+
response = @compute.create_firewall(name: 'Test Firewall',
|
35
|
+
description: 'Example Desc', rules: rules)
|
36
|
+
|
37
|
+
@@firewall_id = response.body['id']
|
38
|
+
|
39
|
+
# Assertions
|
40
|
+
assert_equal response.body['name'], 'Test Firewall'
|
41
|
+
assert_equal response.body['description'], 'Example Desc'
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_b_list_firewalls
|
46
|
+
|
47
|
+
# Perform Request
|
48
|
+
response = @compute.list_firewalls
|
49
|
+
|
50
|
+
# Assertions
|
51
|
+
assert_equal response.body.length, 1
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_c_update_firewall
|
56
|
+
|
57
|
+
# Perform Request
|
58
|
+
response = @compute.update_firewall(firewall_id: @@firewall_id,
|
59
|
+
name: 'New Name', description: 'New Desc')
|
60
|
+
|
61
|
+
# Assertions
|
62
|
+
assert_equal response.body['name'], 'New Name'
|
63
|
+
assert_equal response.body['description'], 'New Desc'
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_d_get_firewall
|
68
|
+
|
69
|
+
# Perform Request
|
70
|
+
response = @compute.get_firewall(@@firewall_id)
|
71
|
+
|
72
|
+
# Assertions
|
73
|
+
assert_equal response.body['id'], @@firewall_id
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_e_add_firewall_ips
|
78
|
+
|
79
|
+
# Perform Request
|
80
|
+
ip1 = '<IP-ID>'
|
81
|
+
|
82
|
+
ips = [ip1]
|
83
|
+
|
84
|
+
response = @compute.add_firewall_ips(firewall_id: @@firewall_id,
|
85
|
+
ips: ips)
|
86
|
+
|
87
|
+
# Assertions
|
88
|
+
assert_equal response.body['server_ips'][0], '<IP-ID>'
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_f_list_firewall_ips
|
93
|
+
|
94
|
+
# Perform Request
|
95
|
+
response = @compute.list_firewall_ips(@@firewall_id)
|
96
|
+
|
97
|
+
# Assertions
|
98
|
+
assert_equal response.body.length, 1
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_g_get_firewall_ip
|
103
|
+
|
104
|
+
# Perform Request
|
105
|
+
response = @compute.get_firewall_ip(firewall_id: @@firewall_id,
|
106
|
+
ip_id: '<IP-ID>')
|
107
|
+
|
108
|
+
# Assertions
|
109
|
+
assert_equal response.body, '<IP-ID>'
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_h_remove_firewall_ip
|
114
|
+
|
115
|
+
# Perform Request
|
116
|
+
response = @compute.remove_firewall_ip(firewall_id: @@firewall_id,
|
117
|
+
ip_id: '<IP-ID>')
|
118
|
+
|
119
|
+
# Assertions
|
120
|
+
assert_equal response.body['server_ips'].length, 0
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_i_add_firewall_rules
|
125
|
+
|
126
|
+
# Perform Request
|
127
|
+
rule2 = {
|
128
|
+
'protocol' => 'TCP',
|
129
|
+
'port_from' => 90,
|
130
|
+
'port_to' => 90,
|
131
|
+
'source' => '0.0.0.0'
|
132
|
+
}
|
133
|
+
|
134
|
+
rules = [rule2]
|
135
|
+
|
136
|
+
response = @compute.add_firewall_rules(firewall_id: @@firewall_id,
|
137
|
+
rules: rules)
|
138
|
+
|
139
|
+
@@rule2_id = response.body['rules'][1]['id']
|
140
|
+
|
141
|
+
# Assertions
|
142
|
+
assert_equal response.body['rules'][1]['port_from'], 90
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_j_list_firewall_rules
|
147
|
+
|
148
|
+
# Perform Request
|
149
|
+
response = @compute.list_firewall_rules(@@firewall_id)
|
150
|
+
|
151
|
+
# Assertions
|
152
|
+
assert_equal response.body.length, 2
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_k_get_firewall_rule
|
157
|
+
|
158
|
+
# Perform Request
|
159
|
+
response = @compute.get_firewall_rule(firewall_id: @@firewall_id,
|
160
|
+
rule_id: @@rule2_id)
|
161
|
+
|
162
|
+
# Assertions
|
163
|
+
assert_equal response.body['id'], @@rule2_id
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_l_delete_firewall_rule
|
168
|
+
|
169
|
+
# Perform Request
|
170
|
+
response = @compute.delete_firewall_rule(firewall_id: @@firewall_id,
|
171
|
+
rule_id: @@rule2_id)
|
172
|
+
|
173
|
+
# Assertions
|
174
|
+
assert_equal response.body['rules'].length, 1
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_m_delete_firewall
|
179
|
+
|
180
|
+
# Perform Request
|
181
|
+
response = @compute.delete_firewall(@@firewall_id)
|
182
|
+
|
183
|
+
# Assertions
|
184
|
+
assert_equal response.body, 'The requested firewall has been deleted.'
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative '../../lib/fog-oneandone'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
Fog.mock!
|
5
|
+
|
6
|
+
class TestImage < 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_image
|
23
|
+
|
24
|
+
# Perform Request
|
25
|
+
response = @compute.create_image(server_id: 'ServerID',
|
26
|
+
name: 'Test Image', frequency: 'ONCE', num_images: 1)
|
27
|
+
|
28
|
+
@@image_id = response.body['id']
|
29
|
+
|
30
|
+
# Assertions
|
31
|
+
assert_equal response.body['name'], 'Test Image'
|
32
|
+
assert_equal response.body['frequency'], 'ONCE'
|
33
|
+
assert_equal response.body['num_images'], 1
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_b_list_images
|
38
|
+
|
39
|
+
# Perform Request
|
40
|
+
response = @compute.list_images
|
41
|
+
|
42
|
+
# Assertions
|
43
|
+
assert_equal response.body.length, 1
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_c_update_image
|
48
|
+
|
49
|
+
# Perform Request
|
50
|
+
response = @compute.update_image(image_id: @@image_id,
|
51
|
+
name: 'New Name', frequency: 'WEEKLY')
|
52
|
+
|
53
|
+
# Assertions
|
54
|
+
assert_equal response.body['name'], 'New Name'
|
55
|
+
assert_equal response.body['frequency'], 'WEEKLY'
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_d_get_image
|
60
|
+
|
61
|
+
# Perform Request
|
62
|
+
response = @compute.get_image(@@image_id)
|
63
|
+
|
64
|
+
# Assertions
|
65
|
+
assert_equal response.body['id'], @@image_id
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_e_delete_image
|
70
|
+
|
71
|
+
# Perform Request
|
72
|
+
response = @compute.delete_image(@@image_id)
|
73
|
+
|
74
|
+
# Assertions
|
75
|
+
assert_equal response.body, 'The requested image has been deleted.'
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|