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
data/bin/fog
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog'))
|
4
|
+
require 'optparse'
|
5
|
+
require 'irb'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
options = OptionParser.new do |opts|
|
9
|
+
opts.banner = 'usage: fog [options] CREDENTIAL'
|
10
|
+
|
11
|
+
opts.on('-C', '--credentials-path FILE', 'Path to the credentials file') do |file|
|
12
|
+
Fog.credentials_path = file
|
13
|
+
end
|
14
|
+
|
15
|
+
opts.on_tail('-v', '--version', 'Prints the version') do
|
16
|
+
puts Fog::VERSION
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
|
20
|
+
opts.on_tail('-h', '--help', 'Prints this message') do
|
21
|
+
puts opts
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
end
|
25
|
+
options.parse!
|
26
|
+
|
27
|
+
Fog.credential = ARGV.first ? ARGV.first.to_sym : nil
|
28
|
+
Fog.mock! if ENV['FOG_MOCK']
|
29
|
+
if Fog.credentials.empty?
|
30
|
+
begin
|
31
|
+
Fog::Errors.missing_credentials
|
32
|
+
rescue Fog::Errors::LoadError => error
|
33
|
+
abort error.message
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
require 'fog/bin'
|
38
|
+
|
39
|
+
providers = Fog.available_providers
|
40
|
+
providers = if providers.length > 1
|
41
|
+
providers[0...-1].join(', ') << ' and ' << providers[-1]
|
42
|
+
else
|
43
|
+
providers.first
|
44
|
+
end
|
45
|
+
|
46
|
+
if ARGV.length > 1
|
47
|
+
|
48
|
+
result = instance_eval(ARGV[1..-1].join(' '))
|
49
|
+
puts(Fog::JSON.encode(result))
|
50
|
+
|
51
|
+
else
|
52
|
+
|
53
|
+
ARGV.clear # Avoid passing args to IRB
|
54
|
+
IRB.setup(nil)
|
55
|
+
@irb = IRB::Irb.new(nil)
|
56
|
+
IRB.conf[:MAIN_CONTEXT] = @irb.context
|
57
|
+
IRB.conf[:PROMPT][:FOG] = IRB.conf[:PROMPT][:SIMPLE].dup
|
58
|
+
IRB.conf[:PROMPT][:FOG][:RETURN] = "%s\n"
|
59
|
+
@irb.context.prompt_mode = :FOG
|
60
|
+
@irb.context.workspace = IRB::WorkSpace.new(binding)
|
61
|
+
|
62
|
+
trap 'INT' do
|
63
|
+
@irb.signal_handle
|
64
|
+
end
|
65
|
+
|
66
|
+
Fog::Formatador.display_line('Welcome to fog interactive!')
|
67
|
+
Fog::Formatador.display_line(":#{Fog.credential} provides #{providers}")
|
68
|
+
providers = Fog.providers
|
69
|
+
|
70
|
+
# FIXME: hacks until we can `include Fog` in bin
|
71
|
+
CDN = Fog::CDN
|
72
|
+
Compute = Fog::Compute
|
73
|
+
DNS = Fog::DNS
|
74
|
+
Storage = Fog::Storage
|
75
|
+
|
76
|
+
catch(:IRB_EXIT) { @irb.eval_input }
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require_relative '../lib/fog-oneandone'
|
2
|
+
|
3
|
+
compute = Fog::Compute::OneAndOne.new({
|
4
|
+
:oneandone_api_key => '<API-TOKEN>'
|
5
|
+
})
|
6
|
+
|
7
|
+
# Create Server
|
8
|
+
my_server = compute.servers.create(name: 'Example App Server',
|
9
|
+
fixed_instance_id: '65929629F35BBFBA63022008F773F3EB',
|
10
|
+
appliance_id: '6C902E5899CC6F7ED18595EBEB542EE1',
|
11
|
+
datacenter_id: '5091F6D8CBFEF9C26ACE957C652D5D49')
|
12
|
+
|
13
|
+
puts 'Creating server...'
|
14
|
+
puts my_server.wait_for { ready? }
|
15
|
+
|
16
|
+
|
17
|
+
# Create Firewall
|
18
|
+
puts "----------"
|
19
|
+
rule1 = {
|
20
|
+
'protocol' => 'TCP',
|
21
|
+
'port_from' => 80,
|
22
|
+
'port_to' => 80,
|
23
|
+
'source' => '0.0.0.0'
|
24
|
+
}
|
25
|
+
|
26
|
+
rules = [rule1]
|
27
|
+
|
28
|
+
my_firewall = compute.firewalls.create(name: 'Example App Firewall',
|
29
|
+
rules: rules)
|
30
|
+
puts 'Creating Firewall...'
|
31
|
+
puts my_firewall.wait_for { ready? }
|
32
|
+
|
33
|
+
|
34
|
+
# Create Load Balancer
|
35
|
+
puts "----------"
|
36
|
+
rule1 = {
|
37
|
+
'protocol' => 'TCP',
|
38
|
+
'port_balancer' => 80,
|
39
|
+
'port_server' => 80,
|
40
|
+
'source' => '0.0.0.0'
|
41
|
+
}
|
42
|
+
|
43
|
+
rules = [rule1]
|
44
|
+
|
45
|
+
my_load_balancer = compute.load_balancers.create(name: 'Example App LB',
|
46
|
+
rules: rules, health_check_test: 'TCP', health_check_interval: 40,
|
47
|
+
persistence: true, persistence_time: 1200, method: 'ROUND_ROBIN',
|
48
|
+
datacenter_id: '5091F6D8CBFEF9C26ACE957C652D5D49')
|
49
|
+
puts 'Creating Load Balancer...'
|
50
|
+
puts my_load_balancer.wait_for { ready? }
|
51
|
+
|
52
|
+
|
53
|
+
# Add Firewall to Server
|
54
|
+
puts "----------"
|
55
|
+
puts 'Adding Firewall to server IP...'
|
56
|
+
my_server.add_firewall(ip_id: my_server.ips[0]['id'],
|
57
|
+
firewall_id: my_firewall.id)
|
58
|
+
puts my_server.wait_for { ready? }
|
59
|
+
|
60
|
+
|
61
|
+
# Add LB to Server
|
62
|
+
puts "----------"
|
63
|
+
puts 'Adding Load Balancer to server IP...'
|
64
|
+
my_server.add_load_balancer(ip_id: my_server.ips[0]['id'],
|
65
|
+
load_balancer_id: my_load_balancer.id)
|
66
|
+
puts my_server.wait_for { ready? }
|
67
|
+
|
68
|
+
|
69
|
+
# Cleanup
|
70
|
+
puts "----------"
|
71
|
+
puts 'Destroying server...'
|
72
|
+
puts my_server.destroy
|
73
|
+
|
74
|
+
puts "----------"
|
75
|
+
puts 'Destroying load balancer...'
|
76
|
+
puts my_load_balancer.destroy
|
77
|
+
|
78
|
+
puts "----------"
|
79
|
+
puts 'Destroying firewall...'
|
80
|
+
puts my_firewall.destroy
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "fog-oneandone"
|
7
|
+
spec.version = "1.0"
|
8
|
+
spec.authors = ["Tyler Burkhardt (stackpointcloud.com)"]
|
9
|
+
spec.email = "tyler@stackpointcloud.com"
|
10
|
+
spec.summary = "Module for the 'fog' gem to support 1and1."
|
11
|
+
spec.description = "This library can be used as a module for 'fog' or as
|
12
|
+
a standalone 1and1 provider."
|
13
|
+
spec.homepage = "https://github.com/1and1/fog-oneandone"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_runtime_dependency "fog-core"
|
20
|
+
spec.add_runtime_dependency "fog-json"
|
21
|
+
spec.add_development_dependency "minitest"
|
22
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# necessary when requiring fog without rubygems while also
|
2
|
+
# maintaining ruby 1.8.7 support (can't use require_relative)
|
3
|
+
__LIB_DIR__ = File.expand_path(File.dirname(__FILE__))
|
4
|
+
$LOAD_PATH.unshift __LIB_DIR__ unless $LOAD_PATH.include?(__LIB_DIR__)
|
5
|
+
|
6
|
+
# Fog-OneAndOne Core Dependencies
|
7
|
+
require 'fog/core'
|
8
|
+
require 'fog/json'
|
9
|
+
|
10
|
+
require_relative 'oneandone/compute'
|