fog-oneandone 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +36 -0
  3. data/CONTRIBUTING.md +276 -0
  4. data/CONTRIBUTORS.md +1 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.md +20 -0
  7. data/README.md +317 -0
  8. data/bin/fog +78 -0
  9. data/examples/example_app.rb +80 -0
  10. data/fog-oneandone.gemspec +22 -0
  11. data/gemfiles/Gemfile-edge +7 -0
  12. data/lib/fog-oneandone.rb +10 -0
  13. data/lib/oneandone/compute.rb +713 -0
  14. data/lib/oneandone/core.rb +11 -0
  15. data/lib/oneandone/models/compute/firewall.rb +128 -0
  16. data/lib/oneandone/models/compute/firewalls.rb +24 -0
  17. data/lib/oneandone/models/compute/image.rb +72 -0
  18. data/lib/oneandone/models/compute/images.rb +24 -0
  19. data/lib/oneandone/models/compute/load_balancer.rb +149 -0
  20. data/lib/oneandone/models/compute/load_balancers.rb +24 -0
  21. data/lib/oneandone/models/compute/monitoring_policies.rb +24 -0
  22. data/lib/oneandone/models/compute/monitoring_policy.rb +196 -0
  23. data/lib/oneandone/models/compute/private_network.rb +105 -0
  24. data/lib/oneandone/models/compute/private_networks.rb +24 -0
  25. data/lib/oneandone/models/compute/public_ip.rb +68 -0
  26. data/lib/oneandone/models/compute/public_ips.rb +24 -0
  27. data/lib/oneandone/models/compute/server.rb +434 -0
  28. data/lib/oneandone/models/compute/servers.rb +24 -0
  29. data/lib/oneandone/models/compute/shared_storage.rb +101 -0
  30. data/lib/oneandone/models/compute/shared_storages.rb +24 -0
  31. data/lib/oneandone/models/compute/vpn.rb +70 -0
  32. data/lib/oneandone/models/compute/vpns.rb +24 -0
  33. data/lib/oneandone/requests/compute/access.rb +35 -0
  34. data/lib/oneandone/requests/compute/add_firewall.rb +70 -0
  35. data/lib/oneandone/requests/compute/add_firewall_ips.rb +67 -0
  36. data/lib/oneandone/requests/compute/add_firewall_rules.rb +68 -0
  37. data/lib/oneandone/requests/compute/add_hdds.rb +65 -0
  38. data/lib/oneandone/requests/compute/add_load_balancer.rb +76 -0
  39. data/lib/oneandone/requests/compute/add_load_balancer_ips.rb +67 -0
  40. data/lib/oneandone/requests/compute/add_load_balancer_rules.rb +68 -0
  41. data/lib/oneandone/requests/compute/add_mp_servers.rb +64 -0
  42. data/lib/oneandone/requests/compute/add_ports.rb +65 -0
  43. data/lib/oneandone/requests/compute/add_private_network.rb +65 -0
  44. data/lib/oneandone/requests/compute/add_private_network_servers.rb +67 -0
  45. data/lib/oneandone/requests/compute/add_processes.rb +65 -0
  46. data/lib/oneandone/requests/compute/add_server_ip.rb +72 -0
  47. data/lib/oneandone/requests/compute/add_shared_storage_servers.rb +64 -0
  48. data/lib/oneandone/requests/compute/change_password.rb +45 -0
  49. data/lib/oneandone/requests/compute/change_status.rb +69 -0
  50. data/lib/oneandone/requests/compute/clone_server.rb +67 -0
  51. data/lib/oneandone/requests/compute/create_firewall.rb +78 -0
  52. data/lib/oneandone/requests/compute/create_image.rb +101 -0
  53. data/lib/oneandone/requests/compute/create_load_balancer.rb +104 -0
  54. data/lib/oneandone/requests/compute/create_monitoring_policy.rb +93 -0
  55. data/lib/oneandone/requests/compute/create_private_network.rb +82 -0
  56. data/lib/oneandone/requests/compute/create_public_ip.rb +77 -0
  57. data/lib/oneandone/requests/compute/create_server.rb +139 -0
  58. data/lib/oneandone/requests/compute/create_shared_storage.rb +83 -0
  59. data/lib/oneandone/requests/compute/create_snapshot.rb +51 -0
  60. data/lib/oneandone/requests/compute/create_vpn.rb +80 -0
  61. data/lib/oneandone/requests/compute/delete_firewall.rb +51 -0
  62. data/lib/oneandone/requests/compute/delete_firewall_rule.rb +60 -0
  63. data/lib/oneandone/requests/compute/delete_hdd.rb +61 -0
  64. data/lib/oneandone/requests/compute/delete_image.rb +51 -0
  65. data/lib/oneandone/requests/compute/delete_load_balancer.rb +51 -0
  66. data/lib/oneandone/requests/compute/delete_load_balancer_rule.rb +60 -0
  67. data/lib/oneandone/requests/compute/delete_monitoring_policy.rb +51 -0
  68. data/lib/oneandone/requests/compute/delete_port.rb +60 -0
  69. data/lib/oneandone/requests/compute/delete_private_network.rb +51 -0
  70. data/lib/oneandone/requests/compute/delete_process.rb +60 -0
  71. data/lib/oneandone/requests/compute/delete_public_ip.rb +51 -0
  72. data/lib/oneandone/requests/compute/delete_server.rb +51 -0
  73. data/lib/oneandone/requests/compute/delete_server_ip.rb +60 -0
  74. data/lib/oneandone/requests/compute/delete_shared_storage.rb +51 -0
  75. data/lib/oneandone/requests/compute/delete_snapshot.rb +51 -0
  76. data/lib/oneandone/requests/compute/delete_vpn.rb +51 -0
  77. data/lib/oneandone/requests/compute/eject_dvd.rb +51 -0
  78. data/lib/oneandone/requests/compute/get_datacenter.rb +50 -0
  79. data/lib/oneandone/requests/compute/get_dvd.rb +50 -0
  80. data/lib/oneandone/requests/compute/get_dvd_iso.rb +50 -0
  81. data/lib/oneandone/requests/compute/get_firewall.rb +50 -0
  82. data/lib/oneandone/requests/compute/get_firewall_ip.rb +59 -0
  83. data/lib/oneandone/requests/compute/get_firewall_rule.rb +59 -0
  84. data/lib/oneandone/requests/compute/get_fixed_server.rb +50 -0
  85. data/lib/oneandone/requests/compute/get_hardware.rb +50 -0
  86. data/lib/oneandone/requests/compute/get_hdd.rb +60 -0
  87. data/lib/oneandone/requests/compute/get_hdds.rb +50 -0
  88. data/lib/oneandone/requests/compute/get_image.rb +50 -0
  89. data/lib/oneandone/requests/compute/get_load_balancer.rb +50 -0
  90. data/lib/oneandone/requests/compute/get_load_balancer_ip.rb +59 -0
  91. data/lib/oneandone/requests/compute/get_load_balancer_rule.rb +59 -0
  92. data/lib/oneandone/requests/compute/get_log.rb +51 -0
  93. data/lib/oneandone/requests/compute/get_monitored_server.rb +49 -0
  94. data/lib/oneandone/requests/compute/get_monitoring_policy.rb +50 -0
  95. data/lib/oneandone/requests/compute/get_mp_server.rb +59 -0
  96. data/lib/oneandone/requests/compute/get_port.rb +59 -0
  97. data/lib/oneandone/requests/compute/get_private_network.rb +50 -0
  98. data/lib/oneandone/requests/compute/get_private_network_server.rb +59 -0
  99. data/lib/oneandone/requests/compute/get_process.rb +59 -0
  100. data/lib/oneandone/requests/compute/get_public_ip.rb +50 -0
  101. data/lib/oneandone/requests/compute/get_server.rb +50 -0
  102. data/lib/oneandone/requests/compute/get_server_appliance.rb +50 -0
  103. data/lib/oneandone/requests/compute/get_server_image.rb +50 -0
  104. data/lib/oneandone/requests/compute/get_server_ip.rb +59 -0
  105. data/lib/oneandone/requests/compute/get_server_private_network.rb +59 -0
  106. data/lib/oneandone/requests/compute/get_shared_storage.rb +50 -0
  107. data/lib/oneandone/requests/compute/get_shared_storage_server.rb +59 -0
  108. data/lib/oneandone/requests/compute/get_snapshot.rb +50 -0
  109. data/lib/oneandone/requests/compute/get_vpn.rb +50 -0
  110. data/lib/oneandone/requests/compute/install_server_image.rb +72 -0
  111. data/lib/oneandone/requests/compute/list_datacenters.rb +56 -0
  112. data/lib/oneandone/requests/compute/list_dvds.rb +56 -0
  113. data/lib/oneandone/requests/compute/list_firewall_ips.rb +50 -0
  114. data/lib/oneandone/requests/compute/list_firewall_rules.rb +50 -0
  115. data/lib/oneandone/requests/compute/list_firewalls.rb +56 -0
  116. data/lib/oneandone/requests/compute/list_fixed_servers.rb +40 -0
  117. data/lib/oneandone/requests/compute/list_images.rb +56 -0
  118. data/lib/oneandone/requests/compute/list_ip_firewalls.rb +59 -0
  119. data/lib/oneandone/requests/compute/list_ip_load_balancers.rb +59 -0
  120. data/lib/oneandone/requests/compute/list_load_balancer_ips.rb +50 -0
  121. data/lib/oneandone/requests/compute/list_load_balancer_rules.rb +50 -0
  122. data/lib/oneandone/requests/compute/list_load_balancers.rb +56 -0
  123. data/lib/oneandone/requests/compute/list_logs.rb +59 -0
  124. data/lib/oneandone/requests/compute/list_monitored_servers.rb +51 -0
  125. data/lib/oneandone/requests/compute/list_monitoring_policies.rb +56 -0
  126. data/lib/oneandone/requests/compute/list_mp_servers.rb +50 -0
  127. data/lib/oneandone/requests/compute/list_ports.rb +51 -0
  128. data/lib/oneandone/requests/compute/list_private_network_servers.rb +50 -0
  129. data/lib/oneandone/requests/compute/list_private_networks.rb +56 -0
  130. data/lib/oneandone/requests/compute/list_processes.rb +51 -0
  131. data/lib/oneandone/requests/compute/list_public_ips.rb +56 -0
  132. data/lib/oneandone/requests/compute/list_server_appliances.rb +56 -0
  133. data/lib/oneandone/requests/compute/list_server_ips.rb +50 -0
  134. data/lib/oneandone/requests/compute/list_server_private_networks.rb +50 -0
  135. data/lib/oneandone/requests/compute/list_servers.rb +56 -0
  136. data/lib/oneandone/requests/compute/list_shared_storage_servers.rb +50 -0
  137. data/lib/oneandone/requests/compute/list_shared_storages.rb +56 -0
  138. data/lib/oneandone/requests/compute/list_usages.rb +54 -0
  139. data/lib/oneandone/requests/compute/list_vpns.rb +56 -0
  140. data/lib/oneandone/requests/compute/load_dvd.rb +65 -0
  141. data/lib/oneandone/requests/compute/ping.rb +38 -0
  142. data/lib/oneandone/requests/compute/ping_auth.rb +38 -0
  143. data/lib/oneandone/requests/compute/remove_firewall.rb +60 -0
  144. data/lib/oneandone/requests/compute/remove_firewall_ip.rb +60 -0
  145. data/lib/oneandone/requests/compute/remove_load_balancer.rb +71 -0
  146. data/lib/oneandone/requests/compute/remove_load_balancer_ip.rb +60 -0
  147. data/lib/oneandone/requests/compute/remove_mp_server.rb +60 -0
  148. data/lib/oneandone/requests/compute/remove_private_network.rb +60 -0
  149. data/lib/oneandone/requests/compute/remove_private_network_server.rb +60 -0
  150. data/lib/oneandone/requests/compute/remove_shared_storage_server.rb +60 -0
  151. data/lib/oneandone/requests/compute/restore_snapshot.rb +35 -0
  152. data/lib/oneandone/requests/compute/status.rb +50 -0
  153. data/lib/oneandone/requests/compute/update_firewall.rb +76 -0
  154. data/lib/oneandone/requests/compute/update_hardware.rb +82 -0
  155. data/lib/oneandone/requests/compute/update_hdd.rb +71 -0
  156. data/lib/oneandone/requests/compute/update_image.rb +80 -0
  157. data/lib/oneandone/requests/compute/update_load_balancer.rb +96 -0
  158. data/lib/oneandone/requests/compute/update_monitoring_policy.rb +82 -0
  159. data/lib/oneandone/requests/compute/update_port.rb +74 -0
  160. data/lib/oneandone/requests/compute/update_private_network.rb +82 -0
  161. data/lib/oneandone/requests/compute/update_process.rb +76 -0
  162. data/lib/oneandone/requests/compute/update_public_ip.rb +71 -0
  163. data/lib/oneandone/requests/compute/update_server.rb +76 -0
  164. data/lib/oneandone/requests/compute/update_shared_storage.rb +80 -0
  165. data/lib/oneandone/requests/compute/update_vpn.rb +76 -0
  166. data/tests/oneandone/test_firewalls.rb +188 -0
  167. data/tests/oneandone/test_images.rb +79 -0
  168. data/tests/oneandone/test_load_balancers.rb +192 -0
  169. data/tests/oneandone/test_monitoring_policies.rb +342 -0
  170. data/tests/oneandone/test_private_networks.rb +123 -0
  171. data/tests/oneandone/test_public_ips.rb +75 -0
  172. data/tests/oneandone/test_servers.rb +465 -0
  173. data/tests/oneandone/test_shared_storages.rb +131 -0
  174. 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,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Shared components
4
+ gem "fog-core", :github => "fog/fog-core"
5
+ gem "fog-json", :github => "fog/fog-json"
6
+
7
+ gemspec :path => "../"
@@ -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'