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,68 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Add rules to a load balancer
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#load_balancers__load_balancer_id__rules_post]
|
10
|
+
##
|
11
|
+
def add_load_balancer_rules(load_balancer_id: nil, rules: nil)
|
12
|
+
|
13
|
+
# Build POST body
|
14
|
+
new_rules = {
|
15
|
+
'rules' => rules
|
16
|
+
}
|
17
|
+
|
18
|
+
# Clean out null keys in POST body
|
19
|
+
body = clean_hash(new_rules)
|
20
|
+
|
21
|
+
# Stringify the POST body
|
22
|
+
string_body = Fog::JSON.encode(body)
|
23
|
+
|
24
|
+
# Request
|
25
|
+
params = {
|
26
|
+
'method' => :post,
|
27
|
+
'endpoint' => "/load_balancers/#{load_balancer_id}/rules",
|
28
|
+
'body' => string_body
|
29
|
+
}
|
30
|
+
|
31
|
+
request(params)
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end # Real
|
36
|
+
|
37
|
+
|
38
|
+
class Mock
|
39
|
+
|
40
|
+
def add_load_balancer_rules(load_balancer_id: nil, rules: nil)
|
41
|
+
|
42
|
+
# Search for load balancer to return
|
43
|
+
if load_balancer = self.data[:load_balancers].find {
|
44
|
+
|hash| hash['id'] == load_balancer_id
|
45
|
+
}
|
46
|
+
# Add rules
|
47
|
+
rules.each do |rule|
|
48
|
+
rule['id'] = Fog::UUID.uuid
|
49
|
+
load_balancer['rules'] << rule
|
50
|
+
end
|
51
|
+
else
|
52
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
53
|
+
not be found.')
|
54
|
+
end
|
55
|
+
|
56
|
+
# Return Response Object to User
|
57
|
+
response = Excon::Response.new
|
58
|
+
response.status = 202
|
59
|
+
response.body = load_balancer
|
60
|
+
response
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end # Mock
|
65
|
+
|
66
|
+
end # OneAndOne
|
67
|
+
end # Compute
|
68
|
+
end # Fog
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Add servers to a monitoring policy
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#monitoring_policies__monitoring_policy_id__servers_post]
|
10
|
+
##
|
11
|
+
def add_mp_servers(monitoring_policy_id: nil, servers: nil)
|
12
|
+
|
13
|
+
# Build POST body
|
14
|
+
new_servers = {
|
15
|
+
'servers' => servers
|
16
|
+
}
|
17
|
+
|
18
|
+
# Stringify the POST body
|
19
|
+
string_body = Fog::JSON.encode(new_servers)
|
20
|
+
|
21
|
+
# Request
|
22
|
+
params = {
|
23
|
+
'method' => :post,
|
24
|
+
'endpoint' => "/monitoring_policies/#{monitoring_policy_id}/servers",
|
25
|
+
'body' => string_body
|
26
|
+
}
|
27
|
+
|
28
|
+
request(params)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end # Real
|
33
|
+
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
|
37
|
+
def add_mp_servers(monitoring_policy_id: nil, servers: nil)
|
38
|
+
|
39
|
+
# Search for MP to return
|
40
|
+
if monitoring_policy = self.data[:monitoring_policies].find {
|
41
|
+
|hash| hash['id'] == monitoring_policy_id
|
42
|
+
}
|
43
|
+
# Add servers
|
44
|
+
servers.each do |server|
|
45
|
+
monitoring_policy['servers'] << server
|
46
|
+
end
|
47
|
+
else
|
48
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
49
|
+
not be found.')
|
50
|
+
end
|
51
|
+
|
52
|
+
# Return Response Object to User
|
53
|
+
response = Excon::Response.new
|
54
|
+
response.status = 202
|
55
|
+
response.body = monitoring_policy
|
56
|
+
response
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end # Mock
|
61
|
+
|
62
|
+
end # OneAndOne
|
63
|
+
end # Compute
|
64
|
+
end # Fog
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Add new ports to a monitoring policy
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#monitoring_policies__monitoring_policy_id__ports_post]
|
10
|
+
##
|
11
|
+
def add_ports(monitoring_policy_id: nil, ports: nil)
|
12
|
+
|
13
|
+
# Build POST body
|
14
|
+
new_ports = {
|
15
|
+
'ports' => ports
|
16
|
+
}
|
17
|
+
|
18
|
+
# Stringify the POST body
|
19
|
+
string_body = Fog::JSON.encode(body)
|
20
|
+
|
21
|
+
# Request
|
22
|
+
params = {
|
23
|
+
'method' => :post,
|
24
|
+
'endpoint' => "/monitoring_policies/#{monitoring_policy_id}/ports",
|
25
|
+
'body' => string_body
|
26
|
+
}
|
27
|
+
|
28
|
+
request(params)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end # Real
|
33
|
+
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
|
37
|
+
def add_ports(monitoring_policy_id: nil, ports: nil)
|
38
|
+
|
39
|
+
# Search for MP to return
|
40
|
+
if monitoring_policy = self.data[:monitoring_policies].find {
|
41
|
+
|hash| hash['id'] == monitoring_policy_id
|
42
|
+
}
|
43
|
+
# Add ports
|
44
|
+
ports.each do |port|
|
45
|
+
port['id'] = Fog::UUID.uuid
|
46
|
+
monitoring_policy['ports'] << port
|
47
|
+
end
|
48
|
+
else
|
49
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
50
|
+
not be found.')
|
51
|
+
end
|
52
|
+
|
53
|
+
# Return Response Object to User
|
54
|
+
response = Excon::Response.new
|
55
|
+
response.status = 202
|
56
|
+
response.body = monitoring_policy
|
57
|
+
response
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end # Mock
|
62
|
+
|
63
|
+
end # OneAndOne
|
64
|
+
end # Compute
|
65
|
+
end # Fog
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Assigns a private network to the server
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__private_networks_post]
|
10
|
+
##
|
11
|
+
def add_private_network(server_id: nil, private_network_id: nil)
|
12
|
+
|
13
|
+
# Build PUT body
|
14
|
+
private_network_specs = {
|
15
|
+
'id' => private_network_id
|
16
|
+
}
|
17
|
+
|
18
|
+
# Stringify the PUT body
|
19
|
+
string_body = Fog::JSON.encode(private_network_specs)
|
20
|
+
|
21
|
+
# Request
|
22
|
+
params = {
|
23
|
+
'method' => :post,
|
24
|
+
'endpoint' => "/servers/#{server_id}/private_networks",
|
25
|
+
'body' => string_body
|
26
|
+
}
|
27
|
+
|
28
|
+
request(params)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end # Real
|
33
|
+
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
|
37
|
+
def add_private_network(server_id: nil, private_network_id: nil)
|
38
|
+
|
39
|
+
# Search for server
|
40
|
+
if server = self.data[:servers].find {
|
41
|
+
|hash| hash['id'] == server_id
|
42
|
+
}
|
43
|
+
private_network = {
|
44
|
+
'id' => private_network_id
|
45
|
+
}
|
46
|
+
|
47
|
+
server['private_networks'] << private_network
|
48
|
+
else
|
49
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
50
|
+
not be found.')
|
51
|
+
end
|
52
|
+
|
53
|
+
# Return Response Object to User
|
54
|
+
response = Excon::Response.new
|
55
|
+
response.status = 202
|
56
|
+
response.body = server
|
57
|
+
response
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end # Mock
|
62
|
+
|
63
|
+
end # OneAndOne
|
64
|
+
end # Compute
|
65
|
+
end # Fog
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Add servers to a private network
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#private_networks__private_network_id__servers_post]
|
10
|
+
##
|
11
|
+
def add_private_network_servers(private_network_id: nil, servers: nil)
|
12
|
+
|
13
|
+
# Build POST body
|
14
|
+
new_servers = {
|
15
|
+
'servers' => servers
|
16
|
+
}
|
17
|
+
|
18
|
+
# Clean out null keys in POST body
|
19
|
+
body = clean_hash(new_servers)
|
20
|
+
|
21
|
+
# Stringify the POST body
|
22
|
+
string_body = Fog::JSON.encode(body)
|
23
|
+
|
24
|
+
# Request
|
25
|
+
params = {
|
26
|
+
'method' => :post,
|
27
|
+
'endpoint' => "/private_networks/#{private_network_id}/servers",
|
28
|
+
'body' => string_body
|
29
|
+
}
|
30
|
+
|
31
|
+
request(params)
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end # Real
|
36
|
+
|
37
|
+
|
38
|
+
class Mock
|
39
|
+
|
40
|
+
def add_private_network_servers(private_network_id: nil, servers: nil)
|
41
|
+
|
42
|
+
# Search for private network to return
|
43
|
+
if private_network = self.data[:private_networks].find {
|
44
|
+
|hash| hash['id'] == private_network_id
|
45
|
+
}
|
46
|
+
# Add servers
|
47
|
+
servers.each do |server|
|
48
|
+
private_network['servers'] << server
|
49
|
+
end
|
50
|
+
else
|
51
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
52
|
+
not be found.')
|
53
|
+
end
|
54
|
+
|
55
|
+
# Return Response Object to User
|
56
|
+
response = Excon::Response.new
|
57
|
+
response.status = 202
|
58
|
+
response.body = private_network
|
59
|
+
response
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end # Mock
|
64
|
+
|
65
|
+
end # OneAndOne
|
66
|
+
end # Compute
|
67
|
+
end # Fog
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Add new processes to a monitoring policy
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#monitoring_policies__monitoring_policy_id__processes_post]
|
10
|
+
##
|
11
|
+
def add_processes(monitoring_policy_id: nil, processes: nil)
|
12
|
+
|
13
|
+
# Build POST body
|
14
|
+
new_processes = {
|
15
|
+
'processes' => processes
|
16
|
+
}
|
17
|
+
|
18
|
+
# Stringify the POST body
|
19
|
+
string_body = Fog::JSON.encode(new_processes)
|
20
|
+
|
21
|
+
# Request
|
22
|
+
params = {
|
23
|
+
'method' => :post,
|
24
|
+
'endpoint' => "/monitoring_policies/#{monitoring_policy_id}/processes",
|
25
|
+
'body' => string_body
|
26
|
+
}
|
27
|
+
|
28
|
+
request(params)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end # Real
|
33
|
+
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
|
37
|
+
def add_processes(monitoring_policy_id: nil, processes: nil)
|
38
|
+
|
39
|
+
# Search for MP to return
|
40
|
+
if monitoring_policy = self.data[:monitoring_policies].find {
|
41
|
+
|hash| hash['id'] == monitoring_policy_id
|
42
|
+
}
|
43
|
+
# Add processes
|
44
|
+
processes.each do |process|
|
45
|
+
process['id'] = Fog::UUID.uuid
|
46
|
+
monitoring_policy['processes'] << process
|
47
|
+
end
|
48
|
+
else
|
49
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
50
|
+
not be found.')
|
51
|
+
end
|
52
|
+
|
53
|
+
# Return Response Object to User
|
54
|
+
response = Excon::Response.new
|
55
|
+
response.status = 202
|
56
|
+
response.body = monitoring_policy
|
57
|
+
response
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end # Mock
|
62
|
+
|
63
|
+
end # OneAndOne
|
64
|
+
end # Compute
|
65
|
+
end # Fog
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Add a new IP to the server
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__ips_post]
|
10
|
+
##
|
11
|
+
def add_server_ip(server_id: nil, type: nil)
|
12
|
+
|
13
|
+
# Build POST body
|
14
|
+
ip_specs = {
|
15
|
+
'type' => type
|
16
|
+
}
|
17
|
+
|
18
|
+
# Clean out null keys in POST body
|
19
|
+
body = clean_hash(ip_specs)
|
20
|
+
|
21
|
+
# Stringify the POST body
|
22
|
+
string_body = Fog::JSON.encode(body)
|
23
|
+
|
24
|
+
# Request
|
25
|
+
params = {
|
26
|
+
'method' => :post,
|
27
|
+
'endpoint' => "/servers/#{server_id}/ips",
|
28
|
+
'body' => string_body
|
29
|
+
}
|
30
|
+
|
31
|
+
request(params)
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end # Real
|
36
|
+
|
37
|
+
|
38
|
+
class Mock
|
39
|
+
|
40
|
+
def add_server_ip(server_id: nil, type: nil)
|
41
|
+
|
42
|
+
# Search for server to return
|
43
|
+
if server = self.data[:servers].find {
|
44
|
+
|hash| hash['id'] == server_id
|
45
|
+
}
|
46
|
+
# Add IP
|
47
|
+
new_ip = {
|
48
|
+
'id' => Fog::UUID.uuid,
|
49
|
+
'type' => type,
|
50
|
+
'firewall_policy' => {},
|
51
|
+
'load_balancers' => []
|
52
|
+
}
|
53
|
+
|
54
|
+
server['ips'] << new_ip
|
55
|
+
else
|
56
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
57
|
+
not be found.')
|
58
|
+
end
|
59
|
+
|
60
|
+
# Return Response Object to User
|
61
|
+
response = Excon::Response.new
|
62
|
+
response.status = 202
|
63
|
+
response.body = server
|
64
|
+
response
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end # Mock
|
69
|
+
|
70
|
+
end # OneAndOne
|
71
|
+
end # Compute
|
72
|
+
end # Fog
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Add servers to a shared storage
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#shared_storages__shared_storage_id__servers_post]
|
10
|
+
##
|
11
|
+
def add_shared_storage_servers(shared_storage_id: nil, servers: nil)
|
12
|
+
|
13
|
+
# Build POST body
|
14
|
+
add_servers = {
|
15
|
+
'servers' => servers
|
16
|
+
}
|
17
|
+
|
18
|
+
# Stringify the POST body
|
19
|
+
string_body = Fog::JSON.encode(add_servers)
|
20
|
+
|
21
|
+
# Request
|
22
|
+
params = {
|
23
|
+
'method' => :post,
|
24
|
+
'endpoint' => "/shared_storages/#{shared_storage_id}/servers",
|
25
|
+
'body' => string_body
|
26
|
+
}
|
27
|
+
|
28
|
+
request(params)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end # Real
|
33
|
+
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
|
37
|
+
def add_shared_storage_servers(shared_storage_id: nil, servers: nil)
|
38
|
+
|
39
|
+
# Search for shared storage to return
|
40
|
+
if shared_storage = self.data[:shared_storages].find {
|
41
|
+
|hash| hash['id'] == shared_storage_id
|
42
|
+
}
|
43
|
+
# Add servers
|
44
|
+
servers.each do |server|
|
45
|
+
shared_storage['servers'] << server
|
46
|
+
end
|
47
|
+
else
|
48
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
49
|
+
not be found.')
|
50
|
+
end
|
51
|
+
|
52
|
+
# Return Response Object to User
|
53
|
+
response = Excon::Response.new
|
54
|
+
response.status = 202
|
55
|
+
response.body = shared_storage
|
56
|
+
response
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end # Mock
|
61
|
+
|
62
|
+
end # OneAndOne
|
63
|
+
end # Compute
|
64
|
+
end # Fog
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Returns the credentials for accessing the shared storages
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#shared_storages_access_get]
|
10
|
+
##
|
11
|
+
def change_password(password)
|
12
|
+
|
13
|
+
# Create PUT body
|
14
|
+
new_password = {
|
15
|
+
'password' => password
|
16
|
+
}
|
17
|
+
|
18
|
+
# Stringify the PUT body
|
19
|
+
string_body = Fog::JSON.encode(new_password)
|
20
|
+
|
21
|
+
# Request
|
22
|
+
params = {
|
23
|
+
'method' => :put,
|
24
|
+
'endpoint' => '/shared_storages/access',
|
25
|
+
'body' => string_body
|
26
|
+
}
|
27
|
+
|
28
|
+
request(params)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end # Real
|
33
|
+
|
34
|
+
|
35
|
+
class Mock
|
36
|
+
|
37
|
+
def change_password(password)
|
38
|
+
Fog::Mock.not_implemented
|
39
|
+
end
|
40
|
+
|
41
|
+
end # Mock
|
42
|
+
|
43
|
+
end # OneAndOne
|
44
|
+
end # Compute
|
45
|
+
end # Fog
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Change a server's status
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__status_action_put]
|
10
|
+
##
|
11
|
+
def change_status(server_id: nil, action: nil, method: nil)
|
12
|
+
|
13
|
+
# Build PUT body
|
14
|
+
status_specs = {
|
15
|
+
'action' => action,
|
16
|
+
'method' => method
|
17
|
+
}
|
18
|
+
|
19
|
+
# Stringify the PUT body
|
20
|
+
string_body = Fog::JSON.encode(status_specs)
|
21
|
+
|
22
|
+
# Request
|
23
|
+
params = {
|
24
|
+
'method' => :put,
|
25
|
+
'endpoint' => "/servers/#{server_id}/status/action",
|
26
|
+
'body' => string_body
|
27
|
+
}
|
28
|
+
|
29
|
+
request(params)
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end # Real
|
34
|
+
|
35
|
+
|
36
|
+
class Mock
|
37
|
+
|
38
|
+
def change_status(server_id: nil, action: nil, method: nil)
|
39
|
+
|
40
|
+
# Search for server
|
41
|
+
if server = self.data[:servers].find {
|
42
|
+
|hash| hash['id'] == server_id
|
43
|
+
}
|
44
|
+
if action == 'POWER_ON'
|
45
|
+
server['status']['state'] = 'POWERED_ON'
|
46
|
+
elsif action == 'POWER_OFF'
|
47
|
+
server['status']['state'] = 'POWERED_OFF'
|
48
|
+
elsif action == 'REBOOT'
|
49
|
+
sleep 3
|
50
|
+
server['status']['state'] = 'POWERED_ON'
|
51
|
+
end
|
52
|
+
else
|
53
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
54
|
+
not be found.')
|
55
|
+
end
|
56
|
+
|
57
|
+
# Return Response Object to User
|
58
|
+
response = Excon::Response.new
|
59
|
+
response.status = 202
|
60
|
+
response.body = server
|
61
|
+
response
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end # Mock
|
66
|
+
|
67
|
+
end # OneAndOne
|
68
|
+
end # Compute
|
69
|
+
end # Fog
|