fog-profitbricks 0.0.5 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.md +1465 -4
  4. data/Rakefile +3 -0
  5. data/examples/pb_demo.rb +83 -35
  6. data/fog-profitbricks.gemspec +10 -10
  7. data/gemfiles/Gemfile.1.8.7 +0 -1
  8. data/lib/fog/profitbricks.rb +4 -23
  9. data/lib/fog/profitbricks/compute.rb +1082 -1
  10. data/lib/fog/profitbricks/helpers/compute/data_helper.rb +12 -0
  11. data/lib/fog/profitbricks/models/base.rb +37 -0
  12. data/lib/fog/profitbricks/models/compute/datacenter.rb +64 -0
  13. data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/datacenters.rb +9 -4
  14. data/lib/fog/profitbricks/models/compute/firewall_rule.rb +101 -0
  15. data/lib/fog/profitbricks/models/compute/firewall_rules.rb +40 -0
  16. data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/flavor.rb +0 -0
  17. data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/flavors.rb +0 -0
  18. data/lib/fog/profitbricks/models/compute/image.rb +72 -0
  19. data/lib/fog/profitbricks/models/compute/images.rb +28 -0
  20. data/lib/fog/profitbricks/models/compute/ip_block.rb +58 -0
  21. data/lib/fog/profitbricks/models/compute/ip_blocks.rb +30 -0
  22. data/lib/fog/profitbricks/models/compute/lan.rb +89 -0
  23. data/lib/fog/profitbricks/models/compute/lans.rb +36 -0
  24. data/lib/fog/profitbricks/models/compute/load_balancer.rb +126 -0
  25. data/lib/fog/profitbricks/models/compute/load_balancers.rb +34 -0
  26. data/lib/fog/profitbricks/models/compute/location.rb +18 -0
  27. data/lib/fog/profitbricks/models/compute/locations.rb +28 -0
  28. data/lib/fog/profitbricks/models/compute/nic.rb +111 -0
  29. data/lib/fog/profitbricks/models/compute/nics.rb +38 -0
  30. data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/region.rb +0 -0
  31. data/lib/fog/{compute/profit_bricks/models → profitbricks/models/compute}/regions.rb +0 -0
  32. data/lib/fog/profitbricks/models/compute/request.rb +24 -0
  33. data/lib/fog/profitbricks/models/compute/requests.rb +37 -0
  34. data/lib/fog/profitbricks/models/compute/server.rb +263 -0
  35. data/lib/fog/profitbricks/models/compute/servers.rb +32 -0
  36. data/lib/fog/profitbricks/models/compute/snapshot.rb +81 -0
  37. data/lib/fog/profitbricks/models/compute/snapshots.rb +28 -0
  38. data/lib/fog/profitbricks/models/compute/volume.rb +123 -0
  39. data/lib/fog/profitbricks/models/compute/volumes.rb +33 -0
  40. data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +104 -0
  41. data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +88 -0
  42. data/lib/fog/profitbricks/requests/compute/attach_volume.rb +89 -0
  43. data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +89 -0
  44. data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +103 -0
  45. data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/create_flavor.rb +0 -0
  46. data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +81 -0
  47. data/lib/fog/profitbricks/requests/compute/create_lan.rb +160 -0
  48. data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +87 -0
  49. data/lib/fog/profitbricks/requests/compute/create_nic.rb +124 -0
  50. data/lib/fog/profitbricks/requests/compute/create_server.rb +257 -0
  51. data/lib/fog/profitbricks/requests/compute/create_volume.rb +133 -0
  52. data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +113 -0
  53. data/lib/fog/profitbricks/requests/compute/delete_datacenter.rb +43 -0
  54. data/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb +47 -0
  55. data/lib/fog/profitbricks/requests/compute/delete_image.rb +43 -0
  56. data/lib/fog/profitbricks/requests/compute/delete_ip_block.rb +43 -0
  57. data/lib/fog/profitbricks/requests/compute/delete_lan.rb +44 -0
  58. data/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb +44 -0
  59. data/lib/fog/profitbricks/requests/compute/delete_nic.rb +46 -0
  60. data/lib/fog/profitbricks/requests/compute/delete_server.rb +48 -0
  61. data/lib/fog/profitbricks/requests/compute/delete_snapshot.rb +43 -0
  62. data/lib/fog/profitbricks/requests/compute/delete_volume.rb +44 -0
  63. data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +52 -0
  64. data/lib/fog/profitbricks/requests/compute/detach_volume.rb +53 -0
  65. data/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb +59 -0
  66. data/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb +76 -0
  67. data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/get_all_flavors.rb +0 -0
  68. data/lib/fog/profitbricks/requests/compute/get_all_images.rb +66 -0
  69. data/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb +56 -0
  70. data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +120 -0
  71. data/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb +100 -0
  72. data/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb +117 -0
  73. data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +44 -0
  74. data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +102 -0
  75. data/lib/fog/profitbricks/requests/compute/get_all_requests.rb +43 -0
  76. data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +134 -0
  77. data/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb +66 -0
  78. data/lib/fog/profitbricks/requests/compute/get_all_volumes.rb +78 -0
  79. data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +78 -0
  80. data/lib/fog/profitbricks/requests/compute/get_attached_volume.rb +79 -0
  81. data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +65 -0
  82. data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +71 -0
  83. data/lib/fog/{compute/profit_bricks/requests → profitbricks/requests/compute}/get_flavor.rb +0 -0
  84. data/lib/fog/profitbricks/requests/compute/get_image.rb +71 -0
  85. data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +58 -0
  86. data/lib/fog/profitbricks/requests/compute/get_lan.rb +120 -0
  87. data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +99 -0
  88. data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +116 -0
  89. data/lib/fog/profitbricks/requests/compute/get_location.rb +49 -0
  90. data/lib/fog/profitbricks/requests/compute/get_nic.rb +98 -0
  91. data/lib/fog/profitbricks/requests/compute/get_request.rb +61 -0
  92. data/lib/fog/profitbricks/requests/compute/get_request_status.rb +50 -0
  93. data/lib/fog/profitbricks/requests/compute/get_server.rb +133 -0
  94. data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +70 -0
  95. data/lib/fog/profitbricks/requests/compute/get_volume.rb +73 -0
  96. data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +74 -0
  97. data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +75 -0
  98. data/lib/fog/profitbricks/requests/compute/reboot_server.rb +47 -0
  99. data/lib/fog/profitbricks/requests/compute/remove_nic_association.rb +44 -0
  100. data/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb +61 -0
  101. data/lib/fog/profitbricks/requests/compute/start_server.rb +49 -0
  102. data/lib/fog/profitbricks/requests/compute/stop_server.rb +50 -0
  103. data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +73 -0
  104. data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +87 -0
  105. data/lib/fog/profitbricks/requests/compute/update_image.rb +90 -0
  106. data/lib/fog/profitbricks/requests/compute/update_lan.rb +126 -0
  107. data/lib/fog/profitbricks/requests/compute/update_load_balancer.rb +70 -0
  108. data/lib/fog/profitbricks/requests/compute/update_nic.rb +107 -0
  109. data/lib/fog/profitbricks/requests/compute/update_server.rb +147 -0
  110. data/lib/fog/profitbricks/requests/compute/update_snapshot.rb +90 -0
  111. data/lib/fog/profitbricks/requests/compute/update_volume.rb +82 -0
  112. data/lib/fog/profitbricks/version.rb +1 -1
  113. data/tests/profitbricks/requests/compute/composite_create_tests.rb +241 -0
  114. data/tests/profitbricks/requests/compute/location_tests.rb +24 -12
  115. data/tests/profitbricks/requests/compute/nic_tests.rb +290 -0
  116. data/tests/profitbricks/requests/compute/request_tests.rb +52 -0
  117. data/tests/profitbricks/requests/compute/server_tests.rb +398 -175
  118. metadata +140 -133
  119. data/lib/fog/compute/profit_bricks.rb +0 -217
  120. data/lib/fog/compute/profit_bricks/models/datacenter.rb +0 -60
  121. data/lib/fog/compute/profit_bricks/models/image.rb +0 -27
  122. data/lib/fog/compute/profit_bricks/models/images.rb +0 -22
  123. data/lib/fog/compute/profit_bricks/models/interface.rb +0 -61
  124. data/lib/fog/compute/profit_bricks/models/interfaces.rb +0 -23
  125. data/lib/fog/compute/profit_bricks/models/server.rb +0 -104
  126. data/lib/fog/compute/profit_bricks/models/servers.rb +0 -22
  127. data/lib/fog/compute/profit_bricks/models/volume.rb +0 -71
  128. data/lib/fog/compute/profit_bricks/models/volumes.rb +0 -23
  129. data/lib/fog/compute/profit_bricks/requests/clear_data_center.rb +0 -51
  130. data/lib/fog/compute/profit_bricks/requests/connect_storage_to_server.rb +0 -83
  131. data/lib/fog/compute/profit_bricks/requests/create_data_center.rb +0 -62
  132. data/lib/fog/compute/profit_bricks/requests/create_nic.rb +0 -79
  133. data/lib/fog/compute/profit_bricks/requests/create_server.rb +0 -105
  134. data/lib/fog/compute/profit_bricks/requests/create_storage.rb +0 -96
  135. data/lib/fog/compute/profit_bricks/requests/delete_data_center.rb +0 -60
  136. data/lib/fog/compute/profit_bricks/requests/delete_nic.rb +0 -64
  137. data/lib/fog/compute/profit_bricks/requests/delete_server.rb +0 -64
  138. data/lib/fog/compute/profit_bricks/requests/delete_storage.rb +0 -64
  139. data/lib/fog/compute/profit_bricks/requests/disconnect_storage_from_server.rb +0 -76
  140. data/lib/fog/compute/profit_bricks/requests/get_all_data_centers.rb +0 -31
  141. data/lib/fog/compute/profit_bricks/requests/get_all_images.rb +0 -65
  142. data/lib/fog/compute/profit_bricks/requests/get_all_locations.rb +0 -44
  143. data/lib/fog/compute/profit_bricks/requests/get_all_nic.rb +0 -53
  144. data/lib/fog/compute/profit_bricks/requests/get_all_servers.rb +0 -57
  145. data/lib/fog/compute/profit_bricks/requests/get_all_storages.rb +0 -56
  146. data/lib/fog/compute/profit_bricks/requests/get_data_center.rb +0 -38
  147. data/lib/fog/compute/profit_bricks/requests/get_data_center_state.rb +0 -42
  148. data/lib/fog/compute/profit_bricks/requests/get_image.rb +0 -69
  149. data/lib/fog/compute/profit_bricks/requests/get_location.rb +0 -48
  150. data/lib/fog/compute/profit_bricks/requests/get_nic.rb +0 -63
  151. data/lib/fog/compute/profit_bricks/requests/get_server.rb +0 -98
  152. data/lib/fog/compute/profit_bricks/requests/get_storage.rb +0 -63
  153. data/lib/fog/compute/profit_bricks/requests/reset_server.rb +0 -49
  154. data/lib/fog/compute/profit_bricks/requests/set_internet_access.rb +0 -59
  155. data/lib/fog/compute/profit_bricks/requests/start_server.rb +0 -58
  156. data/lib/fog/compute/profit_bricks/requests/stop_server.rb +0 -58
  157. data/lib/fog/compute/profit_bricks/requests/update_data_center.rb +0 -54
  158. data/lib/fog/compute/profit_bricks/requests/update_nic.rb +0 -74
  159. data/lib/fog/compute/profit_bricks/requests/update_server.rb +0 -79
  160. data/lib/fog/compute/profit_bricks/requests/update_storage.rb +0 -73
  161. data/lib/fog/models/profit_bricks/base.rb +0 -11
  162. data/lib/fog/parsers/compute.rb +0 -37
  163. data/lib/fog/parsers/compute/profit_bricks/base.rb +0 -51
  164. data/lib/fog/parsers/compute/profit_bricks/clear_data_center.rb +0 -22
  165. data/lib/fog/parsers/compute/profit_bricks/connect_storage_to_server.rb +0 -22
  166. data/lib/fog/parsers/compute/profit_bricks/create_data_center.rb +0 -22
  167. data/lib/fog/parsers/compute/profit_bricks/create_nic.rb +0 -22
  168. data/lib/fog/parsers/compute/profit_bricks/create_server.rb +0 -22
  169. data/lib/fog/parsers/compute/profit_bricks/create_storage.rb +0 -22
  170. data/lib/fog/parsers/compute/profit_bricks/delete_data_center.rb +0 -20
  171. data/lib/fog/parsers/compute/profit_bricks/delete_nic.rb +0 -22
  172. data/lib/fog/parsers/compute/profit_bricks/delete_server.rb +0 -22
  173. data/lib/fog/parsers/compute/profit_bricks/delete_storage.rb +0 -22
  174. data/lib/fog/parsers/compute/profit_bricks/disconnect_storage_from_server.rb +0 -22
  175. data/lib/fog/parsers/compute/profit_bricks/get_all_data_centers.rb +0 -26
  176. data/lib/fog/parsers/compute/profit_bricks/get_all_images.rb +0 -30
  177. data/lib/fog/parsers/compute/profit_bricks/get_all_nic.rb +0 -30
  178. data/lib/fog/parsers/compute/profit_bricks/get_all_servers.rb +0 -57
  179. data/lib/fog/parsers/compute/profit_bricks/get_all_storages.rb +0 -33
  180. data/lib/fog/parsers/compute/profit_bricks/get_data_center.rb +0 -23
  181. data/lib/fog/parsers/compute/profit_bricks/get_data_center_state.rb +0 -20
  182. data/lib/fog/parsers/compute/profit_bricks/get_image.rb +0 -26
  183. data/lib/fog/parsers/compute/profit_bricks/get_nic.rb +0 -27
  184. data/lib/fog/parsers/compute/profit_bricks/get_server.rb +0 -57
  185. data/lib/fog/parsers/compute/profit_bricks/get_storage.rb +0 -30
  186. data/lib/fog/parsers/compute/profit_bricks/reset_server.rb +0 -20
  187. data/lib/fog/parsers/compute/profit_bricks/set_internet_access.rb +0 -22
  188. data/lib/fog/parsers/compute/profit_bricks/update_data_center.rb +0 -22
  189. data/lib/fog/parsers/compute/profit_bricks/update_nic.rb +0 -22
  190. data/lib/fog/parsers/compute/profit_bricks/update_server.rb +0 -22
  191. data/lib/fog/parsers/compute/profit_bricks/update_storage.rb +0 -22
  192. data/lib/fog/profitbricks/storage.rb +0 -1
  193. data/tests/profitbricks/requests/compute/image_tests.rb +0 -50
  194. data/tests/profitbricks/requests/compute/interface_tests.rb +0 -101
data/Rakefile CHANGED
@@ -3,6 +3,9 @@ require "rake/testtask"
3
3
 
4
4
  task :default => :travis
5
5
  task :travis => ["test", "test:travis"]
6
+ task :console do
7
+ exec "pry -r fog/profitbricks -I ./lib"
8
+ end
6
9
 
7
10
  Rake::TestTask.new do |t|
8
11
  t.libs.push %w(spec)
@@ -1,53 +1,101 @@
1
- require 'fog'
1
+ require 'fog/profitbricks'
2
2
 
3
3
  Excon.defaults[:connection_timeout] = 200
4
4
 
5
5
  compute = Fog::Compute.new(:provider => 'ProfitBricks')
6
6
 
7
- # Create data center
8
- datacenter = compute.datacenters.create(:name => 'MyDataCenter', :region => 'us/las')
7
+ # Find the Ubuntu 16 image in North America.
8
+ image = compute.images.all.find do |image|
9
+ image.name =~ /Ubuntu-16/ &&
10
+ image.location == 'us/las'
11
+ end
12
+
13
+ # Create datacenter.
14
+ datacenter = compute.datacenters.create(name: 'fog-demo',
15
+ location: 'us/las',
16
+ description: 'fog-profitbricks demo')
9
17
  datacenter.wait_for { ready? }
10
18
 
11
- # Get the data center
12
- compute.datacenters.get(datacenter.id)
19
+ # Rename datacenter.
20
+ datacenter.name = 'rename fog-demo'
21
+ datacenter.update
13
22
 
14
- # List all data centers
15
- compute.datacenters.all
23
+ # Create public LAN.
24
+ lan = compute.lans.create(datacenter_id: datacenter.id,
25
+ name: 'public',
26
+ public: true)
16
27
 
17
- # Update the data center
18
- datacenter.options = { :dataCenterName => 'TestDataCenter'}
19
- datacenter.update
20
- datacenter.wait_for { ready? }
28
+ # Define system volume.
29
+ system_volume = {
30
+ name: 'system',
31
+ size: 5,
32
+ image: image.id,
33
+ image_password: 'volume2016',
34
+ ssh_keys: ['ssh-rsa AAAAB3NzaC1yc2EAAAADA=='],
35
+ type: 'HDD'
36
+ }
21
37
 
22
- # Refresh data center properties
23
- datacenter.reload
38
+ # Define public firewall rules.
39
+ fw1 = { name: 'Allow SSH', protocol: 'TCP', port_range_start: 22, port_range_end: 22 }
40
+ fw2 = { name: 'Allow Ping', protocol: 'ICMP', icmp_type: 8, icmp_code: 0 }
24
41
 
25
- # Find HDD image in North America running Linux
26
- image = compute.images.all.find do |image|
27
- image.region == 'us/las' &&
28
- image.type == 'HDD' &&
29
- image.os_type == 'LINUX'
30
- end
42
+ # Define public network interface.
43
+ public_nic = {
44
+ name: 'public',
45
+ lan: lan.id,
46
+ dhcp: true,
47
+ firewall_active: true,
48
+ firewall_rules: [fw1, fw2]
49
+ }
31
50
 
32
- # Create volume
33
- volume = compute.volumes.create(:data_center_id => datacenter.id, :size => 5, :options => { :storageName => 'MyVolume', :mountImageId => image.id })
34
- volume.wait_for { ready? }
51
+ # Create a server with the above system volume and public network interface.
52
+ server1 = compute.servers.create(datacenter_id: datacenter.id,
53
+ name: 'server1',
54
+ cores: 1,
55
+ cpu_family: 'AMD_OPTERON',
56
+ ram: 2048,
57
+ volumes: [system_volume],
58
+ nics: [public_nic])
59
+ server1.wait_for { ready? }
35
60
 
36
- # Create server
37
- server = compute.servers.create(:data_center_id => datacenter.id, :cores => 1, :ram => 1024, :options => { :serverName => 'MyServer' })
38
- server.wait_for { ready? }
61
+ # Change CPU family from AMD_OPTERON to INTEL_XEON.
62
+ server1.allow_reboot = true
63
+ server1.cpu_family = 'INTEL_XEON'
64
+ server1.update
39
65
 
40
- # Attach volume to server
41
- volume.attach(server.id)
66
+ # Create data volume.
67
+ data_volume = compute.volumes.create(datacenter_id: datacenter.id,
68
+ name: 'data',
69
+ size: 5,
70
+ licence_type: 'OTHER',
71
+ type: 'SSD')
72
+ data_volume.wait_for { ready? }
42
73
 
43
- # Create network interface and attach to server
44
- nic = compute.interfaces.create(:server_id => server.id, :lan_id => 1, :options => { :nicName => 'TestNic', :ip => '10.0.0.1', :dhcpActive => false })
74
+ # Attach data volume to server1.
75
+ server1.attach_volume(data_volume.id)
45
76
 
46
- # Enable LAN for public Internet access
47
- nic.set_internet_access(:data_center_id => datacenter.id, :lan_id => 1, :internet_access => true)
77
+ # Connect a second network interface to server1.
78
+ private_nic = compute.nics.create(datacenter_id: datacenter.id,
79
+ server_id: server1.id,
80
+ name: 'private',
81
+ dhcp: true,
82
+ lan: 2)
83
+ private_nic.wait_for { ready? }
48
84
 
49
- # Clear data center (WARNING - this will remove all items under a data center)
50
- datacenter.clear(true)
85
+ # Create a second server.
86
+ server2 = compute.servers.create(datacenter_id: datacenter.id,
87
+ name: 'server2',
88
+ cores: 1,
89
+ cpu_family: 'AMD_OPTERON',
90
+ ram: 2048,
91
+ volumes: [system_volume])
92
+ server2.wait_for { ready? }
51
93
 
52
- # Delete data center
53
- datacenter.destroy
94
+ # Connect a private network interface to server2 with SSH access.
95
+ private_nic = compute.nics.create(datacenter_id: datacenter.id,
96
+ server_id: server2.id,
97
+ name: 'private',
98
+ dhcp: true,
99
+ lan: 2,
100
+ firewall_rules: [fw1])
101
+ private_nic.wait_for { ready? }
@@ -19,14 +19,14 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_runtime_dependency "fog-core"
23
- spec.add_runtime_dependency "fog-xml"
24
- spec.add_runtime_dependency "nokogiri"
25
- spec.add_development_dependency "rake"
26
- spec.add_development_dependency "minitest"
27
- spec.add_development_dependency "shindo"
28
- spec.add_development_dependency "turn"
29
- spec.add_development_dependency "pry"
30
- spec.add_development_dependency "rubocop" if RUBY_VERSION >= "1.9.3"
31
- spec.add_development_dependency "coveralls" if RUBY_VERSION.to_f >= 1.9
22
+ spec.add_runtime_dependency "fog-core", "~> 1.42"
23
+ spec.add_runtime_dependency "fog-json", "~> 1.0"
24
+
25
+ spec.add_development_dependency "rake", "~> 10.4"
26
+ spec.add_development_dependency "minitest", "~> 4"
27
+ spec.add_development_dependency "shindo", "~> 0.3"
28
+ spec.add_development_dependency "turn", "~> 0.9"
29
+ spec.add_development_dependency "pry", "~> 0.10"
30
+ spec.add_development_dependency "rubocop", "~> 0" if RUBY_VERSION >= "1.9.3"
31
+ spec.add_development_dependency "coveralls", "~> 0" if RUBY_VERSION.to_f >= 1.9
32
32
  end
@@ -1,7 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'mime-types', '< 2.0'
4
- gem 'nokogiri', '< 1.6'
5
4
  gem 'rest-client', '~> 1.6.8'
6
5
 
7
6
  gemspec :path => '../'
@@ -1,41 +1,22 @@
1
1
  require "fog/core"
2
- require "fog/xml"
2
+ require "fog/json"
3
3
 
4
- require File.expand_path('../profitbricks/version', __FILE__)
4
+ require File.expand_path('profitbricks/version', __dir__)
5
5
 
6
6
  module Fog
7
7
  module Compute
8
- autoload :ProfitBricks, File.expand_path('../compute/profit_bricks', __FILE__)
8
+ autoload :ProfitBricks, File.expand_path('profitbricks/compute', __dir__)
9
9
  end
10
10
 
11
11
  module Models
12
12
  module ProfitBricks
13
- autoload :Base, File.expand_path('../models/profit_bricks/base', __FILE__)
13
+ autoload :Base, File.expand_path('profitbricks/models/base', __dir__)
14
14
  end
15
15
  end
16
16
 
17
- module Parsers
18
- autoload :Compute, File.expand_path('../parsers/compute', __FILE__)
19
- end
20
-
21
17
  module ProfitBricks
22
18
  extend Fog::Provider
23
19
 
24
20
  service(:compute, "Compute")
25
-
26
- def self.construct_envelope(&block)
27
- namespaces = {
28
- "xmlns" => "",
29
- "xmlns:soapenv" => "http://schemas.xmlsoap.org/soap/envelope/",
30
- "xmlns:ws" => "http://ws.api.profitbricks.com/"
31
- }
32
-
33
- Nokogiri::XML::Builder.new do |xml|
34
- xml[:soapenv].Envelope(namespaces) do
35
- xml[:soapenv].Header
36
- xml[:soapenv].Body(&block)
37
- end
38
- end
39
- end
40
21
  end
41
22
  end
@@ -1 +1,1082 @@
1
- # This file is intentionally left blank
1
+ module Fog
2
+ module Compute
3
+ class ProfitBricks < Fog::Service
4
+ API_VERSION = 'v2'
5
+
6
+ autoload :Base, File.expand_path('models/base', __dir__)
7
+
8
+ requires :profitbricks_username, :profitbricks_password
9
+ recognizes :profitbricks_url
10
+
11
+ # Models
12
+ model_path 'fog/profitbricks/models/compute'
13
+ model :server
14
+ collection :servers
15
+ model :datacenter
16
+ collection :datacenters
17
+ model :region
18
+ collection :regions
19
+ model :image
20
+ collection :images
21
+ model :flavor
22
+ collection :flavors
23
+ model :volume
24
+ collection :volumes
25
+ model :lan
26
+ collection :lans
27
+ model :nic
28
+ collection :nics
29
+ model :location
30
+ collection :locations
31
+ model :snapshot
32
+ collection :snapshots
33
+ model :request
34
+ collection :requests
35
+ model :ip_block
36
+ collection :ip_blocks
37
+ model :firewall_rule
38
+ collection :firewall_rules
39
+ model :load_balancer
40
+ collection :load_balancers
41
+
42
+ # Requests
43
+ request_path 'fog/profitbricks/requests/compute'
44
+ request :create_server # createServer
45
+ request :delete_server # deleteServer
46
+ request :update_server # updateServer
47
+ request :get_all_servers # getAllServers
48
+ request :get_server # getServer
49
+ request :list_attached_volumes # listAttachedVolumes
50
+ request :attach_volume # attachVolume
51
+ request :get_attached_volume # getAttachedVolume
52
+ request :detach_volume # detachVolume
53
+ request :list_attached_cdroms # listAttachedCdroms
54
+ request :attach_cdrom # attachCdrom
55
+ request :get_attached_cdrom # getAttachedCdrom
56
+ request :detach_cdrom # detachCdrom
57
+ request :reboot_server # rebootServer
58
+ request :start_server # startServer
59
+ request :stop_server # stopServer
60
+
61
+ request :create_datacenter # createDataCenter
62
+ request :delete_datacenter # deleteDataCenter
63
+ request :update_datacenter # updateDataCenter
64
+ request :get_all_datacenters # getAllDataCenters
65
+ request :get_datacenter # getDataCenter
66
+
67
+ request :get_all_locations # getAllLocations
68
+ request :get_location # getLocation
69
+
70
+ request :get_all_images # getAllImages
71
+ request :get_image # getImage
72
+ request :update_image # updateImage
73
+ request :delete_image # deleteImage
74
+
75
+ request :get_all_flavors # getAllFlavors
76
+ request :get_flavor # getFlavor
77
+ request :create_flavor # createFlavor
78
+
79
+ request :create_volume # createVolume
80
+ request :delete_volume # deleteVolume
81
+ request :update_volume # updateVolume
82
+ request :get_all_volumes # getAllVolumes
83
+ request :get_volume # getVolume
84
+ request :create_volume_snapshot # createVolumeSnapshot
85
+ request :restore_volume_snapshot # restoreVolumeSnapshot
86
+
87
+ request :get_all_lans # getAllLans
88
+ request :get_lan # getLans
89
+ request :create_lan # createLan
90
+ request :update_lan # updateLan
91
+ request :delete_lan # deleteLan
92
+
93
+ request :create_nic # createNic
94
+ request :delete_nic # deleteNic
95
+ request :update_nic # updateNic
96
+ request :get_all_nic # getAllNic
97
+ request :get_nic # getNic
98
+
99
+ request :delete_snapshot # deleteSnapshot
100
+ request :update_snapshot # updateSnapshot
101
+ request :get_all_snapshots # getAllSnapshots
102
+ request :get_snapshot # getSnapshot
103
+
104
+ request :get_all_requests # getAllRequests
105
+ request :get_request # getRequest
106
+ request :get_request_status # getRequestStatus
107
+
108
+ request :get_all_ip_blocks # getAllIpBlocks
109
+ request :get_ip_block # getIpBlock
110
+ request :create_ip_block # createIpBlock
111
+ request :delete_ip_block # deleteIpBlock
112
+
113
+ request :get_all_firewall_rules # getAllFireWallRules
114
+ request :get_firewall_rule # getFirewallRule
115
+ request :create_firewall_rule # createFirewallRule
116
+ request :update_firewall_rule # updateFirewallRule
117
+ request :delete_firewall_rule # deleteFirewallRule
118
+
119
+ request :get_all_load_balancers # getAllLoadBalancers
120
+ request :get_load_balancer # getLoadBalancer
121
+ request :create_load_balancer # createLoadBalancer
122
+ request :delete_load_balancer # deleteLoadBalancer
123
+ request :update_load_balancer # deleteLoadBalancer
124
+ request :get_all_load_balanced_nics # getAllLoadBalancedNics
125
+ request :get_load_balanced_nic # getLoadBalancedNic
126
+ request :associate_nic_to_load_balancer # associateNicToLoadBalancer
127
+ request :remove_nic_association # associateNicToLoadBalancer
128
+
129
+ class Real
130
+ def initialize(options={})
131
+ @profitbricks_username = options[:profitbricks_username]
132
+ @profitbricks_password = options[:profitbricks_password]
133
+ @profitbricks_url = options[:profitbricks_url] || "https://api.profitbricks.com"
134
+
135
+ connection_options = options[:connection_options] || {}
136
+ connection_options[:headers] ||= {}
137
+ connection_options[:headers]["User-Agent"] = "#{Fog::Core::Connection.user_agents}"
138
+ connection_options[:omit_default_port] = true
139
+ connection_options[:path_prefix] = "/rest/#{API_VERSION}"
140
+
141
+ @connection = Fog::Core::Connection.new(@profitbricks_url, false, connection_options)
142
+ end
143
+
144
+ def request(params)
145
+ params[:headers] ||= {}
146
+ params[:headers].merge!("Authorization" => "Basic #{auth_header}")
147
+ params[:path_style] = false
148
+
149
+ begin
150
+ response = @connection.request(params)
151
+ rescue Excon::Errors::Unauthorized => error
152
+ raise error, Fog::JSON.decode(error.response.body)['messages']
153
+ rescue Excon::Errors::HTTPStatusError => error
154
+ raise error, Fog::JSON.decode(error.response.body)['messages']
155
+ rescue Excon::Errors::InternalServerError => error
156
+ raise error, Fog::JSON.decode(error.response.body)['messages']
157
+ rescue Fog::Errors::NotFound => error
158
+ raise error, Fog::JSON.decode(error.response.body)['messages']
159
+ end
160
+
161
+ unless response.body.empty?
162
+ response.body = Fog::JSON.decode(response.body)
163
+ response.body['requestId'] = get_request_id(response.headers)
164
+ end
165
+ response
166
+ end
167
+
168
+ private
169
+
170
+ def auth_header
171
+ return Base64.strict_encode64(
172
+ "#{@profitbricks_username}:#{@profitbricks_password}"
173
+ )
174
+ end
175
+
176
+ def get_request_id(headers)
177
+ location = headers['Location']
178
+ location.match(/requests\/([-a-f0-9]+)/i)[1] unless location.nil?
179
+ end
180
+ end
181
+
182
+ class Mock
183
+ def self.data
184
+ dc_1_id = Fog::UUID.uuid
185
+ dc_2_id = Fog::UUID.uuid
186
+ serv_1_id = Fog::UUID.uuid
187
+ vol_1_id = Fog::UUID.uuid
188
+ vol_2_id = Fog::UUID.uuid
189
+ req_1_id = Fog::UUID.uuid
190
+ req_2_id = Fog::UUID.uuid
191
+ nic_1_id = Fog::UUID.uuid
192
+ nic_2_id = Fog::UUID.uuid
193
+ ipb_1_id = Fog::UUID.uuid
194
+ ipb_2_id = Fog::UUID.uuid
195
+ fwr_1_id = Fog::UUID.uuid
196
+ fwr_2_id = Fog::UUID.uuid
197
+ lb_1_id = Fog::UUID.uuid
198
+ lb_2_id = Fog::UUID.uuid
199
+
200
+ @data ||= Hash.new do |hash, key|
201
+ hash[key] = {
202
+ :datacenters => {
203
+ "id" => "datacenters",
204
+ "type" => "collection",
205
+ "href" => "https://api.profitbricks.com/rest/v2/datacenters",
206
+ "items" =>
207
+ [
208
+ {
209
+ 'id' => dc_1_id,
210
+ 'type' => 'datacenter',
211
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}",
212
+ 'metadata' => {
213
+ 'createdDate' => '2016-07-31T15:41:27Z',
214
+ 'createdBy' => 'test@stackpointcloud.com',
215
+ 'etag' => '5b91832ee85a758568d4523a86bd8702',
216
+ 'lastModifiedDate' => '2016-07-31T15:41:27Z',
217
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
218
+ 'state' => 'AVAILABLE'
219
+ },
220
+ 'properties' => {
221
+ 'name' => 'dc_1',
222
+ 'description' => 'testing fog rest implementation',
223
+ 'location' => 'us/las',
224
+ 'version' => 1,
225
+ 'features' => ["SSD", "MULTIPLE_CPU"]
226
+ }
227
+ },
228
+ {
229
+ 'id' => dc_2_id,
230
+ 'type' => 'datacenter',
231
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_2_id}",
232
+ 'metadata' => {
233
+ 'createdDate' => '2016-07-31T15:41:27Z',
234
+ 'createdBy' => 'test@stackpointcloud.com',
235
+ 'etag' => '5b91832ee85a758568d4523a86bd8702',
236
+ 'lastModifiedDate' => '2016-07-31T15:41:27Z',
237
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
238
+ 'state' => 'AVAILABLE'
239
+ },
240
+ 'properties' =>{
241
+ 'name' => 'dc_2',
242
+ 'description' => 'testing fog rest implementation',
243
+ 'location' => 'de/fkb',
244
+ 'version' => 1,
245
+ 'features' => ["SSD", "MULTIPLE_CPU"]
246
+ }
247
+ }
248
+ ]
249
+ },
250
+ :servers => {
251
+ 'id' => 'servers',
252
+ 'type' => 'collection',
253
+ "href" => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers",
254
+ 'items' =>
255
+ [
256
+ {
257
+ 'id' => serv_1_id,
258
+ 'type' => 'server',
259
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}",
260
+ 'metadata' => {
261
+ 'createdDate' => '2014-10-20T21:20:46Z',
262
+ 'createdBy' => 'test@stackpointcloud.com',
263
+ 'etag' => '0018832d7a7ba455db74ac41ae9f11fe',
264
+ 'lastModifiedDate' => '2015-03-18T21:31:10Z',
265
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
266
+ 'state' => 'AVAILABLE'
267
+ },
268
+ 'properties' => {
269
+ 'name' => 'FogTestServer_1',
270
+ 'cores' => 1,
271
+ 'ram' => 1024,
272
+ 'availabilityZone' => 'AUTO',
273
+ 'vmState' => 'RUNNING',
274
+ 'bootVolume' => {
275
+ 'id' => 'c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1',
276
+ 'type' => 'volume',
277
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/volumes/c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1",
278
+ 'metadata' => {
279
+ 'createdDate' => '2014-10-20T21:20:46Z',
280
+ 'createdBy' => 'test@stackpointcloud.com',
281
+ 'etag' => '7a539b539d8ca9e08c5ac5e63c9c4c8f',
282
+ 'lastModifiedDate' => '2014-10-20T21:20:46Z',
283
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
284
+ 'state' => 'AVAILABLE'
285
+ },
286
+ 'properties' => {
287
+ 'name' => 'Storage',
288
+ 'type' => 'HDD',
289
+ 'size' => 50,
290
+ 'image' => '4f363db0-4955-11e4-b362-52540066fee9',
291
+ 'bus' => 'VIRTIO',
292
+ 'licenceType' => 'LINUX',
293
+ 'cpuHotPlug' => 'true',
294
+ 'cpuHotUnplug' => 'false',
295
+ 'ramHotPlug' => 'true',
296
+ 'ramHotUnplug' => 'false',
297
+ 'nicHotPlug' => 'true',
298
+ 'nicHotUnplug' => 'true',
299
+ 'discVirtioHotPlug' => 'true',
300
+ 'discVirtioHotUnplug' => 'true',
301
+ 'discScsiHotPlug' => 'false',
302
+ 'discScsiHotUnplug' => 'false',
303
+ 'deviceNumber' => 1
304
+ }
305
+ },
306
+ 'cpuFamily' => 'AMD_OPTERON'
307
+ },
308
+ 'entities' => {
309
+ 'cdroms' => {
310
+ 'id' => "#{serv_1_id}/cdroms",
311
+ 'type' => 'collection',
312
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/cdroms",
313
+ 'items' => [ ]
314
+ },
315
+ 'volumes' => {
316
+ 'id' => "#{serv_1_id}/volumes",
317
+ 'type' => 'collection',
318
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/volumes",
319
+ 'items' =>
320
+ [
321
+ {
322
+ 'id' => 'c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1',
323
+ 'type' => 'volume',
324
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/volumes/c04a2198-7e60-4bc0-b869-6e9c9dbcb8e1",
325
+ 'metadata' => {
326
+ 'createdDate' => '2014-10-20T21:20:46Z',
327
+ 'createdBy' => 'test@stackpointcloud.com',
328
+ 'etag' => '7a539b539d8ca9e08c5ac5e63c9c4c8f',
329
+ 'lastModifiedDate' => '2014-10-20T21:20:46Z',
330
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
331
+ 'state' => 'AVAILABLE'
332
+ },
333
+ 'properties' => {
334
+ 'name' => 'Storage',
335
+ 'type' => 'HDD',
336
+ 'size' => 50,
337
+ 'image' => '4f363db0-4955-11e4-b362-52540066fee9',
338
+ 'bus' => 'VIRTIO',
339
+ 'licenceType' => 'LINUX',
340
+ 'cpuHotPlug' => 'true',
341
+ 'cpuHotUnplug' => 'false',
342
+ 'ramHotPlug' => 'true',
343
+ 'ramHotUnplug' => 'false',
344
+ 'nicHotPlug' => 'true',
345
+ 'nicHotUnplug' => 'true',
346
+ 'discVirtioHotPlug' => 'true',
347
+ 'discVirtioHotUnplug' => 'true',
348
+ 'discScsiHotPlug' => 'false',
349
+ 'discScsiHotUnplug' => 'false',
350
+ 'deviceNumber' => 1
351
+ }
352
+ },
353
+ {
354
+ 'id' => '5c4d37ca-d620-4546-8b24-f92e3c608c2c',
355
+ 'type' => 'volume',
356
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/volumes/5c4d37ca-d620-4546-8b24-f92e3c608c2c",
357
+ 'metadata' => {
358
+ 'createdDate' => '2015-03-18T21:31:10Z',
359
+ 'createdBy' => 'test@stackpointcloud.com',
360
+ 'etag' => '0018832d7a7ba455db74ac41ae9f11fe',
361
+ 'lastModifiedDate' => '2015-03-18T21:31:10Z',
362
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
363
+ 'state' => 'AVAILABLE'
364
+ },
365
+ 'properties' => {
366
+ 'name' => 'Docker Registry Volume',
367
+ 'type' => 'HDD',
368
+ 'size' => 50,
369
+ 'bus' => 'VIRTIO',
370
+ 'licenceType' => 'OTHER',
371
+ 'cpuHotPlug' => 'false',
372
+ 'cpuHotUnplug' => 'false',
373
+ 'ramHotPlug' => 'false',
374
+ 'ramHotUnplug' => 'false',
375
+ 'nicHotPlug' => 'false',
376
+ 'nicHotUnplug' => 'false',
377
+ 'discVirtioHotPlug' => 'false',
378
+ 'discVirtioHotUnplug' => 'false',
379
+ 'discScsiHotPlug' => 'false',
380
+ 'discScsiHotUnplug' => 'false',
381
+ 'deviceNumber' => 2
382
+ }
383
+ }
384
+ ]
385
+ },
386
+ 'nics' => {
387
+ 'id' => "#{serv_1_id}/nics",
388
+ 'type' => 'collection',
389
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics",
390
+ 'items' =>
391
+ [
392
+ {
393
+ 'id' => '01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d',
394
+ 'type' => 'nic',
395
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics/01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d",
396
+ 'metadata' => {
397
+ 'createdDate' => '2015-02-09T22:46:38Z',
398
+ 'createdBy' => 'test@stackpointcloud.com',
399
+ 'etag' => 'b4854a82738079d2c7f43b5324bd92e3',
400
+ 'lastModifiedDate' => '2015-02-09T22:46:38Z',
401
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
402
+ 'state' => 'AVAILABLE'
403
+ },
404
+ 'properties' => {
405
+ 'mac' => '00:02:94:9e:f4:b0',
406
+ 'ips' => [ '210.94.35.77' ],
407
+ 'dhcp' => 'true',
408
+ 'lan' => 1,
409
+ 'firewallActive' => 'false'
410
+ },
411
+ 'entities' => {
412
+ 'firewallrules' => {
413
+ 'id' => '01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d/firewallrules',
414
+ 'type' => 'collection',
415
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/664f0f1c-7384-462b-8f0c-cfc4c3f6e2a3/nics/01ea3bd9-047c-4941-85cf-ed6b7a2d1d7d/firewallrules",
416
+ 'items' => [ ]
417
+ }
418
+ }
419
+ }
420
+ ]
421
+ }
422
+ },
423
+ 'datacenter_id' => dc_1_id
424
+ }
425
+ ]
426
+ },
427
+ :locations => {
428
+ "id" => "locations",
429
+ "type" => "collection",
430
+ "href" => "https://api.profitbricks.com/rest/v2/locations",
431
+ "items" =>
432
+ [
433
+ {
434
+ 'id' => 'de/fkb',
435
+ 'type' => 'location',
436
+ 'href' => 'https://api.profitbricks.com/rest/v2/locations/de/fkb',
437
+ 'properties' => {
438
+ 'name' => 'karlsruhe',
439
+ 'features' => [ "SSD", "MULTIPLE_CPU" ]
440
+ }
441
+ },
442
+ {
443
+ 'id' => 'de/fra',
444
+ 'type' => 'location',
445
+ 'href' => 'https://api.profitbricks.com/rest/v2/locations/de/fra',
446
+ 'properties' => {
447
+ 'name' => 'frankfurt',
448
+ 'features' => [ "SSD", "MULTIPLE_CPU" ]
449
+ }
450
+ },
451
+ {
452
+ 'id' => 'us/las',
453
+ 'type' => 'location',
454
+ 'href' => 'https://api.profitbricks.com/rest/v2/locations/us/las',
455
+ 'properties' => {
456
+ 'name' => 'lasvegas',
457
+ 'features' => [ "SSD", "MULTIPLE_CPU" ]
458
+ }
459
+ }
460
+ ]
461
+ },
462
+ :images =>
463
+ {
464
+ "id" => "images",
465
+ "type" => "collection",
466
+ "href" => "https://api.profitbricks.com/rest/v2/images",
467
+ "items" =>
468
+ [
469
+ {
470
+ 'id' => 'dfcb40db-28b5-11e6-9336-52540005ab80',
471
+ 'type' => 'image',
472
+ 'href' => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80',
473
+ 'metadata' => {
474
+ 'createdDate' => '2016-06-02T11:33:49Z',
475
+ 'createdBy' => 'System',
476
+ 'etag' => '9909709d99655c6f31aca789998d7d89',
477
+ 'lastModifiedDate' => '2016-06-02T11:33:49Z',
478
+ 'lastModifiedBy' => 'System',
479
+ 'state' => 'AVAILABLE'
480
+ },
481
+ 'properties' => {
482
+ 'name' => 'CentOS-6.8-x86_64-netinstall.iso',
483
+ 'description' => '',
484
+ 'location' => 'us/las',
485
+ 'size' => 0.23,
486
+ 'cpuHotPlug' => 'true',
487
+ 'cpuHotUnplug' => 'false',
488
+ 'ramHotPlug' => 'true',
489
+ 'ramHotUnplug' => 'false',
490
+ 'nicHotPlug' => 'true',
491
+ 'nicHotUnplug' => 'true',
492
+ 'discVirtioHotPlug' => 'true',
493
+ 'discVirtioHotUnplug' => 'true',
494
+ 'discScsiHotPlug' => 'false',
495
+ 'discScsiHotUnplug' => 'false',
496
+ 'licenceType' => 'LINUX',
497
+ 'imageType' => 'CDROM',
498
+ 'public' => 'true'
499
+ }
500
+ },
501
+ {
502
+ 'id' => '05cadf29-6c12-11e4-beeb-52540066fee9',
503
+ 'type' => 'image',
504
+ 'href' => 'https=>//api.profitbricks.com/rest/v2/images/05cadf29-6c12-11e4-beeb-52540066fee9',
505
+ 'metadata' => {
506
+ 'createdDate' => '2014-11-14T15:22:19Z',
507
+ 'createdBy' => 'System',
508
+ 'etag' => '957e0eac7456fa7554e73bf0d18860eb',
509
+ 'lastModifiedDate' => '2014-11-14T15=>22=>19Z',
510
+ 'lastModifiedBy' => 'System',
511
+ 'state' => 'AVAILABLE'
512
+ },
513
+ 'properties' => {
514
+ 'name' => 'Microsoft-SQL-2012-Full-trial-english.iso',
515
+ 'description' => '',
516
+ 'location' => 'us/las',
517
+ 'size' => 4,
518
+ 'cpuHotPlug' => 'false',
519
+ 'cpuHotUnplug' => 'false',
520
+ 'ramHotPlug' => 'false',
521
+ 'ramHotUnplug' => 'false',
522
+ 'nicHotPlug' => 'false',
523
+ 'nicHotUnplug' => 'false',
524
+ 'discVirtioHotPlug' => 'false',
525
+ 'discVirtioHotUnplug' => 'false',
526
+ 'discScsiHotPlug' => 'false',
527
+ 'discScsiHotUnplug' => 'false',
528
+ 'licenceType' => 'OTHER',
529
+ 'imageType' => 'CDROM',
530
+ 'public' => 'true'
531
+ }
532
+ }
533
+ ]
534
+ },
535
+ :flavors =>
536
+ [
537
+ {
538
+ 'flavorId' => Fog::UUID.uuid,
539
+ 'flavorName' => 'Micro',
540
+ 'ram' => 1024,
541
+ 'disk' => 50,
542
+ 'cores' => 1
543
+ },
544
+ {
545
+ 'flavorId' => Fog::UUID.uuid,
546
+ 'flavorName' => 'Small',
547
+ 'ram' => 2048,
548
+ 'disk' => 50,
549
+ 'cores' => 1
550
+ }
551
+ ],
552
+ :volumes => {
553
+ "id" => "#{dc_1_id}/volumes",
554
+ "type" => 'collection',
555
+ "href" => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/volumes",
556
+ "items" =>
557
+ [
558
+ {
559
+ 'id' => vol_1_id,
560
+ 'type' => 'volume',
561
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/volumes/#{vol_1_id}",
562
+ 'metadata' => {
563
+ 'createdDate' => '2015-03-18T19:00:51Z',
564
+ 'createdBy' => 'test@stackpointcloud.com',
565
+ 'etag' => 'c4a2fde6ba91a038ff953b939cc21efe',
566
+ 'lastModifiedDate' => '2015-03-18T19=>00=>51Z',
567
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
568
+ 'state' => 'AVAILABLE'
569
+ },
570
+ 'properties' => {
571
+ 'name' => 'master 1 Storage',
572
+ 'type' => 'HDD',
573
+ 'size' => 50,
574
+ 'image' => '681673e7-bfc2-11e4-850c-52540066fee9',
575
+ 'bus' => 'VIRTIO',
576
+ 'licenceType' => 'OTHER',
577
+ 'cpuHotPlug' => 'true',
578
+ 'cpuHotUnplug' => 'false',
579
+ 'ramHotPlug' => 'false',
580
+ 'ramHotUnplug' => 'false',
581
+ 'nicHotPlug' => 'true',
582
+ 'nicHotUnplug' => 'true',
583
+ 'discVirtioHotPlug' => 'true',
584
+ 'discVirtioHotUnplug' => 'true',
585
+ 'discScsiHotPlug' => 'false',
586
+ 'discScsiHotUnplug' => 'false',
587
+ 'deviceNumber' => 1
588
+ },
589
+ 'datacenter_id' => dc_1_id
590
+ },
591
+ {
592
+ 'id' => vol_2_id,
593
+ 'type' => 'volume',
594
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/volumes/#{vol_2_id}",
595
+ 'metadata' => {
596
+ 'createdDate' => '2015-03-18T21:31:10Z',
597
+ 'createdBy' => 'test@stackpointcloud.com',
598
+ 'etag' => '0018832d7a7ba455db74ac41ae9f11fe',
599
+ 'lastModifiedDate' => '2015-03-18T21:31:10Z',
600
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
601
+ 'state' => 'AVAILABLE'
602
+ },
603
+ 'properties' => {
604
+ 'name' => 'Docker Registry Volume',
605
+ 'type' => 'HDD',
606
+ 'size' => 50,
607
+ 'bus' => 'VIRTIO',
608
+ 'licenceType' => 'OTHER',
609
+ 'cpuHotPlug' => 'false',
610
+ 'cpuHotUnplug' => 'false',
611
+ 'ramHotPlug' => 'false',
612
+ 'ramHotUnplug' => 'false',
613
+ 'nicHotPlug' => 'false',
614
+ 'nicHotUnplug' => 'false',
615
+ 'discVirtioHotPlug' => 'false',
616
+ 'discVirtioHotUnplug' => 'false',
617
+ 'discScsiHotPlug' => 'false',
618
+ 'discScsiHotUnplug' => 'false',
619
+ 'deviceNumber' => 2
620
+ },
621
+ 'datacenter_id' => dc_1_id
622
+ }
623
+ ]
624
+ },
625
+ :lans => {
626
+ 'id' => "#{dc_1_id}/lans",
627
+ 'type' => 'collection',
628
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/lans",
629
+ 'items' =>
630
+ [
631
+ {
632
+ 'id' => '9',
633
+ 'type' => 'nic',
634
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/lans/9",
635
+ 'metadata' => {
636
+ 'createdDate' => '2015-03-18T19:00:51Z',
637
+ 'createdBy' => 'test@stackpointcloud.com',
638
+ 'etag' => 'faa67fbacb1c0e2e02cf9650657251f1',
639
+ 'lastModifiedDate' => '2015-03-18T19:00:51Z',
640
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
641
+ 'state' => 'AVAILABLE'
642
+ },
643
+ 'properties' => {
644
+ 'name' => 'FogTestLAN_1',
645
+ 'public' => 'true'
646
+ },
647
+ 'entities' => {
648
+ 'nics' => {
649
+ 'id' => '9/nics',
650
+ 'type' => 'collection',
651
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/lans/9/nics",
652
+ 'items' => [ ]
653
+ }
654
+ },
655
+ 'datacenter_id' => dc_1_id
656
+ }
657
+ ]
658
+ },
659
+ :nics => {
660
+ 'id' => "#{serv_1_id}/nics",
661
+ 'type' => 'collection',
662
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics",
663
+ 'items' =>
664
+ [
665
+ {
666
+ 'id' => nic_1_id,
667
+ 'type' => 'nic',
668
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics/#{nic_1_id}",
669
+ 'metadata' => {
670
+ 'createdDate' => '2015-03-18T19:00:51Z',
671
+ 'createdBy' => 'test@stackpointcloud.com',
672
+ 'etag' => 'faa67fbacb1c0e2e02cf9650657251f1',
673
+ 'lastModifiedDate' => '2015-03-18T19:00:51Z',
674
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
675
+ 'state' => 'AVAILABLE'
676
+ },
677
+ 'properties' => {
678
+ 'name' => 'FogTestNIC_1',
679
+ 'mac' => '02:01:36:5f:09:da',
680
+ 'ips' => [ '10.9.194.12'],
681
+ 'dhcp' => 'true',
682
+ 'lan' => 2,
683
+ 'firewallActive' => 'false'
684
+ },
685
+ 'entities' => {
686
+ 'firewallrules' => {
687
+ 'id' => "#{nic_1_id}/firewallrules",
688
+ 'type' => 'collection',
689
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics/#{nic_1_id}/firewallrules",
690
+ 'items' => [ ]
691
+ }
692
+ },
693
+ 'datacenter_id' => dc_1_id
694
+ },
695
+ {
696
+ 'id' => nic_2_id,
697
+ 'type' => 'nic',
698
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics/#{nic_2_id}",
699
+ 'metadata' => {
700
+ 'createdDate' => '2015-03-18T19:00:51Z',
701
+ 'createdBy' => 'test@stackpointcloud.com',
702
+ 'etag' => 'faa67fbacb1c0e2e02cf9650657251f1',
703
+ 'lastModifiedDate' => '2015-03-18T19:00:51Z',
704
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
705
+ 'state' => 'AVAILABLE'
706
+ },
707
+ 'properties' => {
708
+ 'name' => 'FogTestNIC_2',
709
+ 'mac' => '03:01:60:bf:d4:8a',
710
+ 'ips' => [ '192.96.159.188' ],
711
+ 'dhcp' => 'true',
712
+ 'lan' => 1,
713
+ 'firewallActive' => 'false'
714
+ },
715
+ 'entities'=> {
716
+ 'firewallrules'=> {
717
+ 'id'=> 'cf6d01d3-295d-48bd-8d07-568cce63cbbc/firewallrules',
718
+ 'type'=> 'collection',
719
+ 'href'=> "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics/#{nic_2_id}/firewallrules",
720
+ 'items'=> [ ]
721
+ }
722
+ },
723
+ 'datacenter_id' => dc_1_id
724
+ }
725
+ ]
726
+ },
727
+ :snapshots => {
728
+ 'id' => 'snapshots',
729
+ 'type' => 'collection',
730
+ 'href' => 'https =>//api.profitbricks.com/rest/v2/snapshots',
731
+ 'items' =>
732
+ [
733
+ {
734
+ 'id' => '3d52b13d-bec4-49de-ad05-fd2f8c687be6',
735
+ 'type' => 'snapshot',
736
+ 'href' => 'https =>//api.profitbricks.com/rest/v2/snapshots/3d52b13d-bec4-49de-ad05-fd2f8c687be6',
737
+ 'metadata' => {
738
+ 'createdDate' => '2016-08-07T22:28:38Z',
739
+ 'createdBy' => 'test@stackpointcloud.com',
740
+ 'etag' => '83ad78a4757ab0d9bdeaebc3a6485dcf',
741
+ 'lastModifiedDate' => '2016-08-07T22:28:38Z',
742
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
743
+ 'state' => 'AVAILABLE'
744
+ },
745
+ 'properties' => {
746
+ 'name' => 'FogTestSnapshot',
747
+ 'description' => 'Testing fog create volume snapshot',
748
+ 'location' => 'de/fkb',
749
+ 'size' => 5,
750
+ 'cpuHotPlug' => 'false',
751
+ 'cpuHotUnplug' => 'false',
752
+ 'ramHotPlug' => 'false',
753
+ 'ramHotUnplug' => 'false',
754
+ 'nicHotPlug' => 'false',
755
+ 'nicHotUnplug' => 'false',
756
+ 'discVirtioHotPlug' => 'false',
757
+ 'discVirtioHotUnplug' => 'false',
758
+ 'discScsiHotPlug' => 'false',
759
+ 'discScsiHotUnplug' => 'false',
760
+ 'licenceType' => 'LINUX'
761
+ }
762
+ }
763
+ ]
764
+ },
765
+ :requests => {
766
+ 'id' => 'requests',
767
+ 'type' => 'collection',
768
+ 'href' => 'https=>//api.profitbricks.com/rest/v2/requests',
769
+ 'items' =>
770
+ [
771
+ {
772
+ 'id' => req_1_id,
773
+ 'type' => 'request',
774
+ 'href' => "https=>//api.profitbricks.com/rest/v2/requests/#{req_1_id}",
775
+ 'metadata' => {
776
+ 'createdDate' => '2016-08-07T23:32:17Z',
777
+ 'createdBy' => 'test@stackpointcloud.com',
778
+ 'etag' => '37a6259cc0c1dae299a7866489dff0bd',
779
+ 'requestStatus' => {
780
+ 'id' => "#{req_1_id}/status",
781
+ 'type' => 'request-status',
782
+ 'href' => "https://api.profitbricks.com/rest/v2/requests/#{req_1_id}/status"
783
+ }
784
+ },
785
+ 'properties' => {
786
+ 'method' => 'POST',
787
+ 'headers' => {
788
+ 'content-type' => 'application/x-www-form-urlencoded',
789
+ 'connection' => 'Keep-Alive',
790
+ 'host' => 'api.profitbricks.com',
791
+ 'x-forwarded-for' => '100.00.00.01',
792
+ 'content-length' => '47',
793
+ 'x-forwarded-host' => 'api.profitbricks.com',
794
+ 'x-reseller' => 'pb.domain',
795
+ 'user-agent' => 'fog-core/1.42.0',
796
+ 'x-forwarded-server' => 'my.profitbricks.com'
797
+ },
798
+ 'body' => '{\'snapshotId\': \'3d52b13d-bec4-49de-ad05-fd2f8c687be6\'}',
799
+ 'url' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/volumes/#{vol_1_id}/restore-snapshot"
800
+ }
801
+ },
802
+ {
803
+ 'id' => req_2_id,
804
+ 'type' => 'request',
805
+ 'href' => "https=>//api.profitbricks.com/rest/v2/requests/#{req_2_id}",
806
+ 'metadata' => {
807
+ 'createdDate' => '2016-08-07T23:32:17Z',
808
+ 'createdBy' => 'test@stackpointcloud.com',
809
+ 'etag' => '37a6259cc0c1dae299a7866489dff0bd',
810
+ 'requestStatus' => {
811
+ 'id' => "#{req_2_id}/status",
812
+ 'type' => 'request-status',
813
+ 'href' => "https://api.profitbricks.com/rest/v2/requests/#{req_2_id}/status"
814
+ }
815
+ },
816
+ 'properties' => {
817
+ 'method' => 'POST',
818
+ 'headers' => {
819
+ 'content-type' => 'application/x-www-form-urlencoded',
820
+ 'connection' => 'Keep-Alive',
821
+ 'host' => 'api.profitbricks.com',
822
+ 'x-forwarded-for' => '100.00.00.01',
823
+ 'content-length' => '47',
824
+ 'x-forwarded-host' => 'api.profitbricks.com',
825
+ 'x-reseller' => 'pb.domain',
826
+ 'user-agent' => 'fog-core/1.42.0',
827
+ 'x-forwarded-server' => 'my.profitbricks.com'
828
+ },
829
+ 'body' => '{\'snapshotId\': \'3d52b13d-bec4-49de-ad05-fd2f8c687be6\'}',
830
+ 'url' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/volumes/#{vol_2_id}/restore-snapshot"
831
+ }
832
+ }
833
+ ]
834
+ },
835
+ :request_status => {
836
+ 'id' => "#{req_1_id}/status",
837
+ 'type' => 'request-status',
838
+ 'href' => "https=>//api.profitbricks.com/rest/v2/requests/#{req_1_id}/status",
839
+ 'metadata' => {
840
+ 'status' => 'DONE',
841
+ 'message' => 'Request has been successfully executed',
842
+ 'etag' => '2ba22e58ca17bb728d522bba36cf8350',
843
+ 'targets' =>
844
+ [
845
+ {
846
+ 'target' => {
847
+ 'id' => '752df03a-b9a6-48ee-b9f5-58433184aa1a',
848
+ 'type' => 'volume',
849
+ 'href' => 'TO_BE_INJECTED'
850
+ },
851
+ 'status' => 'DONE'
852
+ }
853
+ ]
854
+ }
855
+ },
856
+ :ip_blocks => {
857
+ 'id' => 'ipblocks',
858
+ 'type' => 'collection',
859
+ 'href' => 'https://api.profitbricks.com/rest/v2/ipblocks',
860
+ 'items' =>
861
+ [
862
+ {
863
+ 'id' => ipb_1_id,
864
+ 'type' => 'ipblock',
865
+ 'href' => "https://api.profitbricks.com/rest/v2/ipblocks/#{ipb_1_id}",
866
+ 'metadata' => {
867
+ 'createdDate' => '2016-07-31T15:41:27Z',
868
+ 'createdBy' => 'test@stackpointcloud.com',
869
+ 'etag' => '5b91832ee85a758568d4523a86bd8702',
870
+ 'lastModifiedDate' => '2016-07-31T15:41:27Z',
871
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
872
+ 'state' => 'AVAILABLE'
873
+ },
874
+ 'properties' => {
875
+ 'ips' => ["111.111.111.111", "222.222.222.222"],
876
+ 'location' => 'us/las',
877
+ 'size' => 2,
878
+ 'name' => 'Fog test IP Block 1'
879
+ }
880
+ },
881
+ {
882
+ 'id' => ipb_2_id,
883
+ 'type' => 'ipblock',
884
+ 'href' => "https://api.profitbricks.com/rest/v2/ipblocks/#{ipb_2_id}",
885
+ 'metadata' => {
886
+ 'createdDate' => '2016-07-31T15:41:27Z',
887
+ 'createdBy' => 'test@stackpointcloud.com',
888
+ 'etag' => '5b91832ee85a758568d4523a86bd8702',
889
+ 'lastModifiedDate' => '2016-07-31T15:41:27Z',
890
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
891
+ 'state' => 'AVAILABLE'
892
+ },
893
+ 'properties' => {
894
+ 'ips' => ["333.333.333.333"],
895
+ 'location' => 'us/las',
896
+ 'size' => 1,
897
+ 'name' => 'Fog test IP Block 2'
898
+ }
899
+ }
900
+ ]
901
+ },
902
+ :firewall_rules => {
903
+ 'id' => "#{nic_1_id}/firewallrules",
904
+ 'type' => 'collection',
905
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics/#{nic_1_id}/firewallrules",
906
+ 'items' =>
907
+ [
908
+ {
909
+ 'id' => fwr_1_id,
910
+ 'type' => 'firewall-rule',
911
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics/#{nic_1_id}/firewallrules/#{fwr_1_id}",
912
+ 'metadata' => {
913
+ 'createdDate' => '2016-07-31T15:41:27Z',
914
+ 'createdBy' => 'test@stackpointcloud.com',
915
+ 'etag' => '5b91832ee85a758568d4523a86bd8703',
916
+ 'lastModifiedDate' => '2016-07-31T15:41:27Z',
917
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
918
+ 'state' => 'AVAILABLE'
919
+ },
920
+ 'properties' => {
921
+ 'name' => 'Fog test Firewall Rule 1',
922
+ 'protocol' => 'TCP',
923
+ 'sourceMac' => 'null',
924
+ 'sourceIp' => 'null',
925
+ 'targetIp' => 'null',
926
+ 'icmpCode' => 'null',
927
+ 'icmpType' => 'null',
928
+ 'portRangeStart' => 22,
929
+ 'portRangeEnd' => 22
930
+ },
931
+ 'datacenter_id' => dc_1_id,
932
+ 'server_id' => serv_1_id,
933
+ 'nic_id' => nic_1_id
934
+ },
935
+ {
936
+ 'id' => fwr_2_id,
937
+ 'type' => 'firewall-rule',
938
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics/#{nic_1_id}/firewallrules/#{fwr_2_id}",
939
+ 'metadata' => {
940
+ 'createdDate' => '2016-07-31T15:41:27Z',
941
+ 'createdBy' => 'test@stackpointcloud.com',
942
+ 'etag' => '5b91832ee85a758568d4523a86bd8701',
943
+ 'lastModifiedDate' => '2016-07-31T15:41:27Z',
944
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
945
+ 'state' => 'AVAILABLE'
946
+ },
947
+ 'properties' => {
948
+ 'name' => 'Fog test Firewall Rule 2',
949
+ 'protocol' => 'TCP',
950
+ 'sourceMac' => 'null',
951
+ 'sourceIp' => 'null',
952
+ 'targetIp' => 'null',
953
+ 'icmpCode' => 'null',
954
+ 'icmpType' => 'null',
955
+ 'portRangeStart' => 24,
956
+ 'portRangeEnd' => 25
957
+ },
958
+ 'datacenter_id' => dc_1_id,
959
+ 'server_id' => serv_1_id,
960
+ 'nic_id' => nic_1_id
961
+ }
962
+ ]
963
+ },
964
+ :load_balancers => {
965
+ 'id' => "#{dc_1_id}/loadbalancers",
966
+ 'type' => 'collection',
967
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/loadbalancers",
968
+ 'items' =>
969
+ [
970
+ {
971
+ 'id' => lb_1_id,
972
+ 'type' => 'loadbalancer',
973
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/loadbalancers/#{lb_1_id}",
974
+ 'metadata' => {
975
+ 'createdDate' => '2016-07-31T15:41:27Z',
976
+ 'createdBy' => 'test@stackpointcloud.com',
977
+ 'etag' => '5b91832ee85a758568d4523a86bd8723',
978
+ 'lastModifiedDate' => '2016-07-31T15:41:27Z',
979
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
980
+ 'state' => 'AVAILABLE'
981
+ },
982
+ 'properties' => {
983
+ 'name' => 'Fog test Load Balancer 1',
984
+ 'ip' => 'null',
985
+ 'dhcp' => 'true'
986
+ },
987
+ 'entities' => {
988
+ 'balancednics' => {
989
+ 'id' => "#{lb_1_id}/balancednics",
990
+ 'type' => 'collection',
991
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/loadbalancers/#{lb_1_id}/balancednics",
992
+ 'items' =>
993
+ [
994
+ {
995
+ 'id' => nic_1_id,
996
+ 'type' => 'nic',
997
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics/#{nic_1_id}",
998
+ 'metadata' => {
999
+ 'createdDate' => '2015-03-18T19:00:51Z',
1000
+ 'createdBy' => 'test@stackpointcloud.com',
1001
+ 'etag' => 'faa67fbacb1c0e2e02cf9650657251f1',
1002
+ 'lastModifiedDate' => '2015-03-18T19:00:51Z',
1003
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
1004
+ 'state' => 'AVAILABLE'
1005
+ },
1006
+ 'properties' => {
1007
+ 'name' => 'FogTestLoadBalancedNIC_1',
1008
+ 'mac' => '02:01:36:5f:09:da',
1009
+ 'ips' => [ '10.9.194.12'],
1010
+ 'dhcp' => 'true',
1011
+ 'lan' => 2,
1012
+ 'firewallActive' => 'false'
1013
+ },
1014
+ 'entities' => {
1015
+ 'firewallrules' => {
1016
+ 'id' => "#{nic_1_id}/firewallrules",
1017
+ 'type' => 'collection',
1018
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/servers/#{serv_1_id}/nics/#{nic_1_id}/firewallrules",
1019
+ 'items' => [ ]
1020
+ }
1021
+ },
1022
+ 'datacenter_id' => dc_1_id,
1023
+ 'load_balancer_id' => lb_1_id
1024
+ }
1025
+ ]
1026
+ }
1027
+ },
1028
+ 'datacenter_id' => dc_1_id
1029
+ },
1030
+ {
1031
+ 'id' => lb_2_id,
1032
+ 'type' => 'loadbalancer',
1033
+ 'href' => "https://api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/loadbalancers/#{lb_2_id}",
1034
+ 'metadata' => {
1035
+ 'createdDate' => '2016-07-31T15:41:27Z',
1036
+ 'createdBy' => 'test@stackpointcloud.com',
1037
+ 'etag' => '5b91832ee85a758568d4523a86bd8721',
1038
+ 'lastModifiedDate' => '2016-07-31T15:41:27Z',
1039
+ 'lastModifiedBy' => 'test@stackpointcloud.com',
1040
+ 'state' => 'INACTIVE'
1041
+ },
1042
+ 'properties' => {
1043
+ 'name' => 'Fog test Load Balancer 2',
1044
+ 'ip' => 'null',
1045
+ 'dhcp' => 'false'
1046
+ },
1047
+ 'entities' => {
1048
+ 'balancednics' => {
1049
+ 'id' => "#{lb_2_id}/balancednics",
1050
+ 'type' => 'collection',
1051
+ 'href' => "https=>//api.profitbricks.com/rest/v2/datacenters/#{dc_1_id}/loadbalancers/#{lb_2_id}/balancednics",
1052
+ 'items' => [ ]
1053
+ }
1054
+ },
1055
+ 'datacenter_id' => dc_1_id
1056
+ }
1057
+ ]
1058
+ }
1059
+ }
1060
+ end
1061
+ end
1062
+
1063
+ def self.reset
1064
+ @data = nil
1065
+ end
1066
+
1067
+ def initialize(options={})
1068
+ @profitbricks_username = options[:profitbricks_username]
1069
+ @profitbricks_password = options[:profitbricks_password]
1070
+ end
1071
+
1072
+ def data
1073
+ self.class.data[@profitbricks_username]
1074
+ end
1075
+
1076
+ def reset_data
1077
+ self.class.data.delete(@profitbricks_username)
1078
+ end
1079
+ end
1080
+ end
1081
+ end
1082
+ end