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,67 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Clone a server
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#servers__server_id__clone_post]
|
10
|
+
##
|
11
|
+
def clone_server(server_id: nil, name: nil, datacenter_id: nil)
|
12
|
+
|
13
|
+
# Build PUT body
|
14
|
+
clone_specs = {
|
15
|
+
'name' => name,
|
16
|
+
'datacenter_id' => datacenter_id
|
17
|
+
}
|
18
|
+
|
19
|
+
# Stringify the PUT body
|
20
|
+
string_body = Fog::JSON.encode(clone_specs)
|
21
|
+
|
22
|
+
# Request
|
23
|
+
params = {
|
24
|
+
'method' => :post,
|
25
|
+
'endpoint' => "/servers/#{server_id}/clone",
|
26
|
+
'body' => string_body
|
27
|
+
}
|
28
|
+
|
29
|
+
request(params)
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end # Real
|
34
|
+
|
35
|
+
|
36
|
+
class Mock
|
37
|
+
|
38
|
+
def clone_server(server_id: nil, name: nil, datacenter_id: nil)
|
39
|
+
|
40
|
+
# Search for server
|
41
|
+
if server = self.data[:servers].find {
|
42
|
+
|hash| hash['id'] == server_id
|
43
|
+
}
|
44
|
+
else
|
45
|
+
raise Fog::Errors::NotFound.new('The requested resource could
|
46
|
+
not be found.')
|
47
|
+
end
|
48
|
+
|
49
|
+
# Clone server and save to servers list
|
50
|
+
clone = server.dup
|
51
|
+
clone['id'] = Fog::UUID.uuid
|
52
|
+
clone['name'] = name
|
53
|
+
self.data[:servers] << clone
|
54
|
+
|
55
|
+
# Return Response Object to User
|
56
|
+
response = Excon::Response.new
|
57
|
+
response.status = 202
|
58
|
+
response.body = clone
|
59
|
+
response
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end # Mock
|
64
|
+
|
65
|
+
end # OneAndOne
|
66
|
+
end # Compute
|
67
|
+
end # Fog
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Creates a new firewall policy
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#firewall_policies_post]
|
10
|
+
##
|
11
|
+
def create_firewall(name: nil, description: nil, rules: nil)
|
12
|
+
|
13
|
+
# Build POST body
|
14
|
+
new_firewall = {
|
15
|
+
'name' => name,
|
16
|
+
'description' => description,
|
17
|
+
'rules' => rules
|
18
|
+
}
|
19
|
+
|
20
|
+
# Clean out null values from POST body
|
21
|
+
body = clean_hash(new_firewall)
|
22
|
+
|
23
|
+
# Stringify the POST body
|
24
|
+
string_body = Fog::JSON.encode(body)
|
25
|
+
|
26
|
+
# Request
|
27
|
+
params = {
|
28
|
+
'method' => :post,
|
29
|
+
'endpoint' => '/firewall_policies',
|
30
|
+
'body' => string_body
|
31
|
+
}
|
32
|
+
|
33
|
+
request(params)
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end # Real
|
38
|
+
|
39
|
+
|
40
|
+
class Mock
|
41
|
+
|
42
|
+
def create_firewall(name: nil, description: nil, rules: nil)
|
43
|
+
|
44
|
+
# Add UUID to rules being passed in
|
45
|
+
rules.each do |rule|
|
46
|
+
rule['id'] = Fog::UUID.uuid
|
47
|
+
end
|
48
|
+
|
49
|
+
# Create mock firewall hash
|
50
|
+
mock_firewall = {
|
51
|
+
"id" => Fog::UUID.uuid,
|
52
|
+
"name" => name,
|
53
|
+
"description" => description,
|
54
|
+
"state" => "ACTIVE",
|
55
|
+
"creation_date" => "2015-04-29T10:43:11+00:00",
|
56
|
+
"default" => 0,
|
57
|
+
"rules" => rules,
|
58
|
+
"server_ips" => [],
|
59
|
+
"cloudpanel_id" => "FW99AA4_7"
|
60
|
+
}
|
61
|
+
|
62
|
+
# Save mock firewall to list
|
63
|
+
self.data[:firewalls] << mock_firewall
|
64
|
+
|
65
|
+
# Return mock response to user
|
66
|
+
response = Excon::Response.new
|
67
|
+
response.status = 202
|
68
|
+
response.body = mock_firewall
|
69
|
+
|
70
|
+
response
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end # Mock
|
75
|
+
|
76
|
+
end # OneAndOne
|
77
|
+
end # Compute
|
78
|
+
end # Fog
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Creates a new image
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#images_post]
|
10
|
+
##
|
11
|
+
def create_image(server_id: nil, name: nil, description: nil,
|
12
|
+
frequency: nil, num_images: nil)
|
13
|
+
|
14
|
+
# Build POST body
|
15
|
+
new_image = {
|
16
|
+
'server_id' => server_id,
|
17
|
+
'name' => name,
|
18
|
+
'description' => description,
|
19
|
+
'frequency' => frequency,
|
20
|
+
'num_images' => num_images
|
21
|
+
}
|
22
|
+
|
23
|
+
# Clean out null values from POST body
|
24
|
+
body = clean_hash(new_image)
|
25
|
+
|
26
|
+
# Stringify the POST body
|
27
|
+
string_body = Fog::JSON.encode(body)
|
28
|
+
|
29
|
+
# Request
|
30
|
+
params = {
|
31
|
+
'method' => :post,
|
32
|
+
'endpoint' => '/images',
|
33
|
+
'body' => string_body
|
34
|
+
}
|
35
|
+
|
36
|
+
request(params)
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end # Real
|
41
|
+
|
42
|
+
|
43
|
+
class Mock
|
44
|
+
|
45
|
+
def create_image(server_id: nil, name: nil, description: nil,
|
46
|
+
frequency: nil, num_images: nil)
|
47
|
+
|
48
|
+
# Create mock image hash
|
49
|
+
mock_image = {
|
50
|
+
"id" => Fog::UUID.uuid,
|
51
|
+
"name" => name,
|
52
|
+
"datacenter" => {
|
53
|
+
"id" => "D0F6D8C8ED29D3036F94C27BBB7BAD36",
|
54
|
+
"location" => "USA",
|
55
|
+
"country_code" => "US"
|
56
|
+
},
|
57
|
+
"os_family" => "Windows",
|
58
|
+
"os" => "WindowsDatacenter",
|
59
|
+
"os_version" => "Windows2012R2",
|
60
|
+
"architecture" => 64,
|
61
|
+
"os_image_type" => "Personal",
|
62
|
+
"type" => "MY_IMAGE",
|
63
|
+
"min_hdd_size" => 40,
|
64
|
+
"licenses" => [
|
65
|
+
{
|
66
|
+
"name" => "Windows 2012 Standard"
|
67
|
+
}
|
68
|
+
],
|
69
|
+
"cloudpanel_id" => "ap8962D_253",
|
70
|
+
"state" => "ENABLED",
|
71
|
+
"description" => description,
|
72
|
+
"hdds" => [
|
73
|
+
{
|
74
|
+
"id" => "D0289C1FDF48628FE53335470EEC05DB",
|
75
|
+
"size" => 40,
|
76
|
+
"is_main" => true
|
77
|
+
}
|
78
|
+
],
|
79
|
+
"server_id" => server_id,
|
80
|
+
"frequency" => frequency,
|
81
|
+
"num_images" => num_images,
|
82
|
+
"creation_date" => "2015-05-06T08:04:41+00:00"
|
83
|
+
}
|
84
|
+
|
85
|
+
# Save mock image to images list
|
86
|
+
self.data[:images] << mock_image
|
87
|
+
|
88
|
+
# Return mock response to user
|
89
|
+
response = Excon::Response.new
|
90
|
+
response.status = 202
|
91
|
+
response.body = mock_image
|
92
|
+
|
93
|
+
response
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end # Mock
|
98
|
+
|
99
|
+
end # OneAndOne
|
100
|
+
end # Compute
|
101
|
+
end # Fog
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Create a new load balancer
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#load_balancers_post]
|
10
|
+
##
|
11
|
+
def create_load_balancer(name: nil, description: nil,
|
12
|
+
health_check_test: nil, health_check_interval: nil, persistence: nil,
|
13
|
+
persistence_time: nil, method: nil, rules: nil,
|
14
|
+
health_check_path: nil, health_check_parse: nil, datacenter_id: nil)
|
15
|
+
|
16
|
+
# Build POST body
|
17
|
+
new_load_balancer = {
|
18
|
+
'name' => name,
|
19
|
+
'description' => description,
|
20
|
+
'health_check_test' => health_check_test,
|
21
|
+
'health_check_interval' => health_check_interval,
|
22
|
+
'persistence' => persistence,
|
23
|
+
'persistence_time' => persistence_time,
|
24
|
+
'method' => method,
|
25
|
+
'rules' => rules,
|
26
|
+
'health_check_path' => health_check_path,
|
27
|
+
'health_check_parse' => health_check_parse,
|
28
|
+
'datacenter_id' => datacenter_id
|
29
|
+
}
|
30
|
+
|
31
|
+
# Clean out null keys in POST body
|
32
|
+
body = clean_hash(new_load_balancer)
|
33
|
+
|
34
|
+
# Stringify the POST body
|
35
|
+
string_body = Fog::JSON.encode(body)
|
36
|
+
|
37
|
+
# Request
|
38
|
+
params = {
|
39
|
+
'method' => :post,
|
40
|
+
'endpoint' => '/load_balancers',
|
41
|
+
'body' => string_body
|
42
|
+
}
|
43
|
+
|
44
|
+
request(params)
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Real
|
49
|
+
|
50
|
+
|
51
|
+
class Mock
|
52
|
+
|
53
|
+
def create_load_balancer(name: nil, description: nil,
|
54
|
+
health_check_test: nil, health_check_interval: nil, persistence: nil,
|
55
|
+
persistence_time: nil, method: nil, rules: nil,
|
56
|
+
health_check_path: nil, health_check_parse: nil, datacenter_id: nil)
|
57
|
+
|
58
|
+
# Add UUID to rules being passed in
|
59
|
+
rules.each do |rule|
|
60
|
+
rule['id'] = Fog::UUID.uuid
|
61
|
+
end
|
62
|
+
|
63
|
+
# Create mock load balancer hash
|
64
|
+
mock_load_balancer = {
|
65
|
+
"id" => Fog::UUID.uuid,
|
66
|
+
"name" => name,
|
67
|
+
"state" => "ACTIVE",
|
68
|
+
"creation_date" => "2015-05-04T07:26:24+00:00",
|
69
|
+
"description" => description,
|
70
|
+
"ip" => nil,
|
71
|
+
"health_check_test" => health_check_test,
|
72
|
+
"health_check_interval" => health_check_interval,
|
73
|
+
"health_check_path" => health_check_path,
|
74
|
+
"health_check_path_parser" => health_check_parse,
|
75
|
+
"persistence" => persistence,
|
76
|
+
"persistence_time" => persistence_time,
|
77
|
+
"method" => method,
|
78
|
+
"datacenter" => {
|
79
|
+
"id" => datacenter_id,
|
80
|
+
"location" => "USA",
|
81
|
+
"country_code" => "US"
|
82
|
+
},
|
83
|
+
"rules" => rules,
|
84
|
+
"server_ips" => [],
|
85
|
+
"cloudpanel_id" => "LB99AA4_1"
|
86
|
+
}
|
87
|
+
|
88
|
+
# Save mock load balancer to list
|
89
|
+
self.data[:load_balancers] << mock_load_balancer
|
90
|
+
|
91
|
+
# Return mock response to user
|
92
|
+
response = Excon::Response.new
|
93
|
+
response.status = 202
|
94
|
+
response.body = mock_load_balancer
|
95
|
+
|
96
|
+
response
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end # Mock
|
101
|
+
|
102
|
+
end # OneAndOne
|
103
|
+
end # Compute
|
104
|
+
end # Fog
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Creates a new monitoring policy
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#monitoring_policies_post]
|
10
|
+
##
|
11
|
+
def create_monitoring_policy(name: nil, description: nil, email: nil,
|
12
|
+
agent: nil, thresholds: nil, ports: nil, processes: nil)
|
13
|
+
|
14
|
+
# Build POST body
|
15
|
+
new_monitoring_policy = {
|
16
|
+
'name' => name,
|
17
|
+
'description' => description,
|
18
|
+
'email' => email,
|
19
|
+
'agent' => agent,
|
20
|
+
'thresholds' => thresholds,
|
21
|
+
'ports' => ports,
|
22
|
+
'processes' => processes
|
23
|
+
}
|
24
|
+
|
25
|
+
# Clean out null keys in POST body
|
26
|
+
body = clean_hash(new_monitoring_policy)
|
27
|
+
|
28
|
+
# Stringify the POST body
|
29
|
+
string_body = Fog::JSON.encode(body)
|
30
|
+
|
31
|
+
# Request
|
32
|
+
params = {
|
33
|
+
'method' => :post,
|
34
|
+
'endpoint' => '/monitoring_policies',
|
35
|
+
'body' => string_body
|
36
|
+
}
|
37
|
+
|
38
|
+
request(params)
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end # Real
|
43
|
+
|
44
|
+
|
45
|
+
class Mock
|
46
|
+
|
47
|
+
def create_monitoring_policy(name: nil, description: nil, email: nil,
|
48
|
+
agent: nil, thresholds: nil, ports: nil, processes: nil)
|
49
|
+
|
50
|
+
# Add UUID to ports being passed in
|
51
|
+
ports.each do |port|
|
52
|
+
port['id'] = Fog::UUID.uuid
|
53
|
+
end
|
54
|
+
|
55
|
+
# Add UUID to processes being passed in
|
56
|
+
processes.each do |process|
|
57
|
+
process['id'] = Fog::UUID.uuid
|
58
|
+
end
|
59
|
+
|
60
|
+
# Create mock monitoring policy hash
|
61
|
+
mock_monitoring_policy = {
|
62
|
+
"id" => Fog::UUID.uuid,
|
63
|
+
"name" => name,
|
64
|
+
"description" => description,
|
65
|
+
"default" => 0,
|
66
|
+
"state" => "ACTIVE",
|
67
|
+
"creation_date" => "2015-05-07T07:34:41+00:00",
|
68
|
+
"email" => email,
|
69
|
+
"agent" => agent,
|
70
|
+
"servers" => [],
|
71
|
+
"thresholds" => thresholds,
|
72
|
+
"ports" => ports,
|
73
|
+
"processes" => processes,
|
74
|
+
"cloudpanel_id" => "mo8962D_3"
|
75
|
+
}
|
76
|
+
|
77
|
+
# Save mock monitoring policy to list
|
78
|
+
self.data[:monitoring_policies] << mock_monitoring_policy
|
79
|
+
|
80
|
+
# Return mock response to user
|
81
|
+
response = Excon::Response.new
|
82
|
+
response.status = 202
|
83
|
+
response.body = mock_monitoring_policy
|
84
|
+
|
85
|
+
response
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end # Mock
|
90
|
+
|
91
|
+
end # OneAndOne
|
92
|
+
end # Compute
|
93
|
+
end # Fog
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Create a new private network
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#private_networks_post]
|
10
|
+
##
|
11
|
+
def create_private_network(name: nil, description: nil,
|
12
|
+
network_address: nil, subnet_mask: nil, datacenter_id: nil)
|
13
|
+
|
14
|
+
# Build POST body
|
15
|
+
new_private_network = {
|
16
|
+
'name' => name,
|
17
|
+
'description' => description,
|
18
|
+
'network_address' => network_address,
|
19
|
+
'subnet_mask' => subnet_mask,
|
20
|
+
'datacenter_id' => datacenter_id
|
21
|
+
}
|
22
|
+
|
23
|
+
# Clean out null keys in POST body
|
24
|
+
body = clean_hash(new_private_network)
|
25
|
+
|
26
|
+
# Stringify the POST body
|
27
|
+
string_body = Fog::JSON.encode(body)
|
28
|
+
|
29
|
+
# Request
|
30
|
+
params = {
|
31
|
+
'method' => :post,
|
32
|
+
'endpoint' => '/private_networks',
|
33
|
+
'body' => string_body
|
34
|
+
}
|
35
|
+
|
36
|
+
request(params)
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end # Real
|
41
|
+
|
42
|
+
|
43
|
+
class Mock
|
44
|
+
|
45
|
+
def create_private_network(name: nil, description: nil,
|
46
|
+
network_address: nil, subnet_mask: nil, datacenter_id: nil)
|
47
|
+
|
48
|
+
# Create mock private network hash
|
49
|
+
mock_private_network = {
|
50
|
+
"id" => Fog::UUID.uuid,
|
51
|
+
"name" => name,
|
52
|
+
"description" => description,
|
53
|
+
"datacenter" => {
|
54
|
+
"id" => datacenter_id,
|
55
|
+
"location" => "USA",
|
56
|
+
"country_code" => "US"
|
57
|
+
},
|
58
|
+
"network_address" => network_address,
|
59
|
+
"subnet_mask" => subnet_mask,
|
60
|
+
"state" => "ACTIVE",
|
61
|
+
"creation_date" => "2015-05-04T08:35:12+00:00",
|
62
|
+
"servers" => [],
|
63
|
+
"cloudpanel_id" => "pn99AA4_2"
|
64
|
+
}
|
65
|
+
|
66
|
+
# Save mock private network to list
|
67
|
+
self.data[:private_networks] << mock_private_network
|
68
|
+
|
69
|
+
# Return mock response to user
|
70
|
+
response = Excon::Response.new
|
71
|
+
response.status = 202
|
72
|
+
response.body = mock_private_network
|
73
|
+
|
74
|
+
response
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end # Mock
|
79
|
+
|
80
|
+
end # OneAndOne
|
81
|
+
end # Compute
|
82
|
+
end # Fog
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OneAndOne
|
4
|
+
|
5
|
+
class Real
|
6
|
+
|
7
|
+
##
|
8
|
+
# Create a new public IP
|
9
|
+
# URL: [https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html#public_ips_post]
|
10
|
+
##
|
11
|
+
def create_public_ip(reverse_dns: nil, type: nil, datacenter_id: nil)
|
12
|
+
|
13
|
+
# Build POST body
|
14
|
+
new_ip = {
|
15
|
+
'reverse_dns' => reverse_dns,
|
16
|
+
'type' => type,
|
17
|
+
'datacenter_id' => datacenter_id
|
18
|
+
}
|
19
|
+
|
20
|
+
# Clean out null keys in POST body
|
21
|
+
body = clean_hash(new_ip)
|
22
|
+
|
23
|
+
# Stringify the POST body
|
24
|
+
string_body = Fog::JSON.encode(body)
|
25
|
+
|
26
|
+
# Request
|
27
|
+
params = {
|
28
|
+
'method' => :post,
|
29
|
+
'endpoint' => '/public_ips',
|
30
|
+
'body' => string_body
|
31
|
+
}
|
32
|
+
|
33
|
+
request(params)
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end # Real
|
38
|
+
|
39
|
+
|
40
|
+
class Mock
|
41
|
+
|
42
|
+
def create_public_ip(reverse_dns: nil, type: nil, datacenter_id: nil)
|
43
|
+
|
44
|
+
# Create mock public ip hash
|
45
|
+
mock_public_ip = {
|
46
|
+
"id" => Fog::UUID.uuid,
|
47
|
+
"ip" => "10.4.140.155",
|
48
|
+
"type" => type,
|
49
|
+
"datacenter" => {
|
50
|
+
"id" => datacenter_id,
|
51
|
+
"location" => "USA",
|
52
|
+
"country_code" => "US"
|
53
|
+
},
|
54
|
+
"assigned_to" => nil,
|
55
|
+
"reverse_dns" => reverse_dns,
|
56
|
+
"is_dhcp" => false,
|
57
|
+
"state" => "ACTIVE",
|
58
|
+
"creation_date" => "2015-05-06T08:17:33+00:00"
|
59
|
+
}
|
60
|
+
|
61
|
+
# Save mock public ip to list
|
62
|
+
self.data[:public_ips] << mock_public_ip
|
63
|
+
|
64
|
+
# Return mock response to user
|
65
|
+
response = Excon::Response.new
|
66
|
+
response.status = 202
|
67
|
+
response.body = mock_public_ip
|
68
|
+
|
69
|
+
response
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end # Mock
|
74
|
+
|
75
|
+
end # OneAndOne
|
76
|
+
end # Compute
|
77
|
+
end # Fog
|