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
@@ -0,0 +1,52 @@
1
+ Shindo.tests('Fog::Compute[:profitbricks] | request request', ['profitbricks', 'compute']) do
2
+
3
+ @requests_schema = {
4
+ 'id' => String,
5
+ 'type' => String,
6
+ 'href' => String,
7
+ 'items' => Array
8
+ }
9
+
10
+ @request_schema = {
11
+ 'id' => String,
12
+ 'type' => String,
13
+ 'href' => String,
14
+ 'metadata' => Hash,
15
+ 'properties' => Hash
16
+ }
17
+
18
+ service = Fog::Compute[:profitbricks]
19
+
20
+ tests('success') do
21
+
22
+ Excon.defaults[:connection_timeout] = 500
23
+
24
+ tests('#get_all_requests').data_matches_schema(@requests_schema) do
25
+ data = service.get_all_requests
26
+
27
+ @request_id = data.body['items'][0]['id']
28
+
29
+ data.body
30
+ end
31
+
32
+ tests('#get_request').data_matches_schema(@request_schema) do
33
+ data = service.get_request(@request_id)
34
+ data.body
35
+ end
36
+
37
+ tests('#get_request_status').data_matches_schema(@request_schema) do
38
+ data = service.get_request(@request_id)
39
+ data.body
40
+ end
41
+ end
42
+
43
+ tests('failure') do
44
+ tests('#get_location').raises(ArgumentError) do
45
+ service.get_request
46
+ end
47
+
48
+ tests('#get_location_status').raises(ArgumentError) do
49
+ service.get_request_status
50
+ end
51
+ end
52
+ end
@@ -1,46 +1,18 @@
1
1
  Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'compute']) do
2
2
 
3
- @data_center_format = {
4
- 'requestId' => String,
5
- 'dataCenterId' => String,
6
- 'dataCenterName' => String,
7
- 'dataCenterVersion' => Integer,
8
- 'provisioningState' => 'AVAILABLE',
9
- 'location' => String
3
+ @resource_schema = {
4
+ 'id' => String,
5
+ 'type' => String,
6
+ 'href' => String,
7
+ 'metadata' => Hash,
8
+ 'properties' => Hash
10
9
  }
11
10
 
12
- @server_format = {
13
- 'serverId' => String,
14
- 'serverName' => 'FogServer',
15
- 'cores' => Integer,
16
- 'ram' => Integer,
17
- 'internetAccess' => String,
18
- 'connectedStorages' => Fog::Nullable::Array,
19
- 'nics' => Fog::Nullable::Array,
20
- 'provisioningState' => 'AVAILABLE',
21
- 'virtualMachineState' => 'RUNNING',
22
- 'creationTime' => Time,
23
- 'lastModificationTime' => Time,
24
- 'osType' => String,
25
- 'availabilityZone' => 'AUTO' || 'ZONE_1' || 'ZONE_2',
26
- }
27
-
28
- @storage_format = {
29
- 'dataCenterId' => String,
30
- 'dataCenterVersion' => Integer,
31
- 'storageId' => String,
32
- 'size' => Integer,
33
- 'storageName' => String,
34
- 'mountImage' => Hash,
35
- 'provisioningState' => 'AVAILABLE',
36
- 'creationTime' => Time,
37
- 'lastModificationTime' => Time
38
- }
39
-
40
- @minimal_format = {
41
- 'requestId' => String,
42
- 'dataCenterId' => String,
43
- 'dataCenterVersion' => Integer
11
+ @minimal_schema_with_items = {
12
+ 'id' => String,
13
+ 'type' => String,
14
+ 'href' => String,
15
+ 'items' => Array
44
16
  }
45
17
 
46
18
  service = Fog::Compute[:profitbricks]
@@ -49,201 +21,452 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
49
21
 
50
22
  Excon.defaults[:connection_timeout] = 500
51
23
 
52
- tests('#create_data_center').formats(@minimal_format.merge('location' => String)) do
53
- # puts '#create_data_center'
54
- data = service.create_data_center('FogDataCenter', 'us/las')
55
- @data_center_id = data.body['createDataCenterResponse']['dataCenterId']
56
- service.datacenters.get(@data_center_id).wait_for { ready? }
57
- data.body['createDataCenterResponse']
58
- end
59
-
60
- tests('#get_data_center').formats(@data_center_format) do
61
- # puts '#get_data_center'
62
- data = service.get_data_center(@data_center_id)
63
- data.body['getDataCenterResponse']
64
- end
65
-
66
- tests('#get_all_data_centers').formats({
67
- 'dataCenterId' => String,
68
- 'dataCenterName' => String,
69
- 'dataCenterVersion' => Integer
70
- }) do
71
- # puts '#get_all_data_centers'
72
- data = service.get_all_data_centers
73
- data.body['getAllDataCentersResponse'].find { |dc|
74
- dc['dataCenterId'] == @data_center_id
75
- }
24
+ tests('#create_datacenter').data_matches_schema(@resource_schema) do
25
+ options = {}
26
+ options[:name] = 'FogDataCenter'
27
+ options[:location] = 'us/las'
28
+ options[:description] = 'Part of server tests suite'
29
+
30
+ createDatacenterResponse = service.create_datacenter(options)
31
+ @datacenter_id = createDatacenterResponse.body['id']
32
+
33
+ if ENV["FOG_MOCK"] != "true"
34
+ service.datacenters.get(@datacenter_id).wait_for { ready? }
35
+ end
36
+
37
+ createDatacenterResponse.body
38
+ end
39
+
40
+ tests('#get_datacenter').data_matches_schema(@resource_schema) do
41
+ getDatacenterResponse = service.get_datacenter(@datacenter_id)
42
+ getDatacenterResponse.body
76
43
  end
77
44
 
78
- tests('#update_data_center').formats(@minimal_format) do
79
- # puts '#update_data_center'
80
- data = service.update_data_center(
81
- @data_center_id, { 'dataCenterName' => 'FogDataCenterRename' }
45
+ tests('#get_all_datacenters').data_matches_schema(@minimal_schema_with_items) do
46
+ getAllDatacentersResponse = service.get_all_datacenters
47
+ getAllDatacentersResponse.body
48
+ end
49
+
50
+ tests('#update_datacenter').data_matches_schema(@resource_schema) do
51
+ options = {}
52
+ options[:name] = 'FogDataCenterRename'
53
+ options[:description] = 'FogDataCenterDescriptionUpdated'
54
+
55
+ updateDatacenterResponse = service.update_datacenter(
56
+ @datacenter_id, options
82
57
  )
83
- data.body['updateDataCenterResponse']
58
+
59
+ if ENV["FOG_MOCK"] != "true"
60
+ service.datacenters.get(@datacenter_id).wait_for { ready? }
61
+ end
62
+
63
+ updateDatacenterResponse.body
84
64
  end
85
65
 
86
- tests('#get_all_images') do
87
- # puts '#get_all_images'
88
- data = service.get_all_images.body['getAllImagesResponse'].find { |image|
89
- image['location'] == 'us/las' &&
90
- image['imageType'] == 'HDD' &&
91
- image['osType'] == 'LINUX'
66
+ tests('#get_all_images').data_matches_schema(@minimal_schema_with_items) do
67
+ getAllImagesResponse = service.get_all_images
68
+ data = service.get_all_images.body['items'].find { |image|
69
+ image['properties']['location'] == 'us/las' &&
70
+ image['properties']['imageType'] == 'CDROM' &&
71
+ image['properties']['licenceType'] == 'LINUX'
92
72
  }
93
- @image_id = data['imageId']
73
+ @image_id = data['id']
74
+ getAllImagesResponse.body
94
75
  end
95
76
 
96
- tests('#create_storage') do
97
- # puts '#create_storage'
98
- data = service.create_storage(
99
- @data_center_id, 5, {
100
- 'storageName' => 'FogVolume',
101
- 'mountImageId' => @image_id
102
- }
103
- )
104
- @storage_id = data.body['createStorageResponse']['storageId']
105
- service.volumes.get(@storage_id).wait_for { ready? }
106
- data.body['createStorageResponse']
77
+ tests('#get_image').data_matches_schema(@resource_schema) do
78
+ getImageResponse = service.get_image(@image_id)
79
+ getImageResponse.body
107
80
  end
108
81
 
109
- tests('#get_storage').formats(@storage_format) do
110
- # puts '#get_storage'
111
- data = service.get_storage(@storage_id).body['getStorageResponse']
82
+ if ENV["FOG_MOCK"] == "true"
83
+ tests('#update_image').data_matches_schema(@resource_schema) do
84
+ options = {}
85
+ options[:name] = 'FogImageRename'
86
+ options[:description] = 'FogImageDescriptionUpdated'
87
+
88
+ updateImageResponse = service.update_image(
89
+ @image_id, options
90
+ )
91
+
92
+ updateImageResponse.body
93
+ end
112
94
  end
113
95
 
114
- tests('#get_all_storages').formats(@storage_format) do
115
- # puts '#get_all_storages'
116
- data = service.get_all_storages
117
- data.body['getAllStoragesResponse'].find {
118
- |storage| storage['storageId'] == @storage_id
96
+ tests('#get_all_volumes').data_matches_schema(@minimal_schema_with_items) do
97
+ if dc = service.get_all_datacenters.body["items"].find {
98
+ |datacenter| datacenter["id"] == @datacenter_id
119
99
  }
100
+ else
101
+ raise Fog::Errors::NotFound.new("The requested resource could not be found")
102
+ end
103
+
104
+ getAllVolumesResponse = service.get_all_volumes(dc['id'])
105
+ getAllVolumesResponse.body
120
106
  end
121
107
 
122
- tests('#update_storage').formats(@minimal_format) do
123
- # puts '#update_storage'
124
- service.update_storage(@storage_id, { 'size' => 6 }).body['updateStorageResponse']
108
+ tests('#create_volume').data_matches_schema(@resource_schema) do
109
+ options = {}
110
+ options[:name] = 'FogRestTestVolume'
111
+ options[:size] = 5
112
+ options[:licenceType] = 'LINUX'
113
+ options[:type] = 'HDD'
114
+
115
+ createVolumeResponse = service.create_volume(@datacenter_id, options)
116
+ @volume_id = createVolumeResponse.body['id']
117
+
118
+ if ENV["FOG_MOCK"] != "true"
119
+ loop do
120
+ sleep(5)
121
+ vlm = service.volumes.get(@datacenter_id, @volume_id)
122
+ break unless !vlm.ready?
123
+ end
124
+ end
125
+
126
+ # Calling wait_for causes ArgumentError
127
+ # vlm.wait_for { ready? }
128
+
129
+ createVolumeResponse.body
125
130
  end
126
131
 
127
- tests('#create_server').formats(@minimal_format.merge('serverId' => String)) do
128
- # puts '#create_server'
129
- data = service.create_server(@data_center_id, 1, 512, {
130
- 'serverName' => 'FogServer',
131
- 'bootFromStorageId' => @storage_id
132
- })
133
- @server_id = data.body['createServerResponse']['serverId']
134
- service.servers.get(@server_id).wait_for { ready? }
135
- data.body['createServerResponse']
132
+ tests('#get_volume').data_matches_schema(@resource_schema) do
133
+ getVolumeResponse = service.get_volume(@datacenter_id, @volume_id)
134
+ getVolumeResponse.body
136
135
  end
137
136
 
138
- tests('#get_all_servers').formats(@server_format.merge(
139
- 'dataCenterId' => String, 'dataCenterVersion' => Integer
140
- )) do
141
- # puts '#get_all_servers'
142
- data = service.get_all_servers
143
- data.body['getAllServersResponse'].find {
144
- |server| server['serverId'] == @server_id
145
- }
137
+ tests('#create_volume_snapshot').data_matches_schema(@resource_schema) do
138
+ options = {}
139
+ options[:name] = 'FogRestTestSnapshot'
140
+ options[:description] = 'Testing fog create snapshot'
141
+
142
+ createVolumeSnapshotResponse = service.create_volume_snapshot(@datacenter_id, @volume_id, options)
143
+ @snapshot_id = createVolumeSnapshotResponse.body['id']
144
+
145
+ if ENV["FOG_MOCK"] != "true"
146
+ sleep(5)
147
+ snapshot = service.snapshots.get(@snapshot_id)
148
+ snapshot.wait_for { ready? }
149
+ end
150
+
151
+ createVolumeSnapshotResponse.body
152
+ end
153
+
154
+ tests('#update_volume').data_matches_schema(@resource_schema) do
155
+ options = {}
156
+ options[:name] = 'FogRestTestVolumeRenamed'
157
+ options[:size] = 6
158
+
159
+ updateVolumeResponse = service.update_volume(@datacenter_id, @volume_id, options)
160
+
161
+ if ENV["FOG_MOCK"] != "true"
162
+ loop do
163
+ sleep(1)
164
+ vlm = service.volumes.get(@datacenter_id, @volume_id)
165
+ break unless !vlm.ready?
166
+ end
167
+ end
168
+
169
+ # Calling wait_for causes ArgumentError
170
+ # vlm.wait_for { ready? }
171
+
172
+ updateVolumeResponse.body
173
+ end
174
+
175
+ tests('#update_snapshot').data_matches_schema(@resource_schema) do
176
+ options = {}
177
+ options[:name] = 'FogRestTestSnapshotRename'
178
+ options[:description] = 'Testing fog create snapshot - updated description'
179
+ options[:ramHotPlug] = true
180
+
181
+ updateSnapshotResponse = service.update_snapshot(@snapshot_id, options)
182
+
183
+ if ENV["FOG_MOCK"] != "true"
184
+ snapshot = service.snapshots.get(@snapshot_id)
185
+ snapshot.wait_for { ready? }
186
+ end
187
+ updateSnapshotResponse.body
188
+ end
189
+
190
+ tests('#get_snapshot').data_matches_schema(@resource_schema) do
191
+ getSnapshotResponse = service.get_snapshot(@snapshot_id)
192
+ getSnapshotResponse.body
193
+ end
194
+
195
+ tests('#restore_volume_snapshot').succeeds do
196
+ options = {}
197
+ options[:snapshot_id] = @snapshot_id
198
+
199
+ restoreVolumeSnapshotResponse = service.restore_volume_snapshot(@datacenter_id, @volume_id, options)
200
+ restoreVolumeSnapshotResponse.status == 202
201
+ end
202
+
203
+ tests('#get_all_snapshots').data_matches_schema(@minimal_schema_with_items) do
204
+ getAllSnapshotsResponse = service.get_all_snapshots
205
+ getAllSnapshotsResponse.body
206
+ end
207
+
208
+ tests('#create_server').data_matches_schema(@resource_schema) do
209
+ properties = {}
210
+ properties[:name] = 'FogTestServer_2'
211
+ properties[:cores] = 1
212
+ properties[:ram] = 1024
213
+ properties[:availabilityZone] = 'ZONE_1'
214
+ properties[:cpuFamily] = 'INTEL_XEON'
215
+
216
+ entities = {}
217
+ entities[:volumes] = {}
218
+ entities[:volumes]['items'] = [
219
+ {
220
+ 'id' => @volume_id
221
+ }
222
+ ]
223
+
224
+ createServerResponse = service.create_server(@datacenter_id, properties, entities)
225
+ @server_id = createServerResponse.body['id']
226
+
227
+ if ENV["FOG_MOCK"] != "true"
228
+ loop do
229
+ sleep(480)
230
+ server = service.servers.get(@datacenter_id, @server_id)
231
+ break unless !server.ready?
232
+ end
233
+ end
234
+
235
+ # Calling wait_for causes ArgumentError
236
+ # server.wait_for { ready? }
237
+
238
+ createServerResponse.body
146
239
  end
147
240
 
148
- tests('#get_server').formats(@server_format.merge(@minimal_format)) do
149
- # puts '#get_server'
150
- data = service.get_server(@server_id)
151
- data.body['getServerResponse']
241
+ tests('#get_server').data_matches_schema(@resource_schema) do
242
+ getServerResponse = service.get_server(@datacenter_id, @server_id)
243
+ getServerResponse.body
152
244
  end
153
245
 
154
- tests('#update_server').formats(@minimal_format) do
155
- # puts '#update_server'
156
- data = service.update_server(@server_id, { 'serverName' => 'FogServerRename' })
157
- service.servers.get(@server_id).wait_for { ready? }
158
- data.body['updateServerResponse']
246
+ tests('#list_attached_volumes').data_matches_schema(@minimal_schema_with_items) do
247
+ listAttachedVolumesResponse = service.list_attached_volumes(@datacenter_id, @server_id)
248
+ listAttachedVolumesResponse.body
159
249
  end
160
250
 
161
- tests('#connect_storage_to_server').formats(@minimal_format) do
162
- # puts '#connect_storage_to_server'
163
- service.connect_storage_to_server(@storage_id, @server_id).body['connectStorageToServerResponse']
251
+ tests('#attach_volume').data_matches_schema(@resource_schema) do
252
+ attachVolumeResponse = service.attach_volume(@datacenter_id, @server_id, @volume_id)
253
+
254
+ if ENV["FOG_MOCK"] != "true"
255
+ loop do
256
+ vlm = service.volumes.get(@datacenter_id, @volume_id)
257
+ sleep(1)
258
+ break unless !vlm.ready?
259
+ end
260
+ end
261
+
262
+ # Calling wait_for causes ArgumentError
263
+ # vlm.wait_for { ready? }
264
+
265
+ attachVolumeResponse.body
266
+ end
267
+
268
+ tests('#get_attached_volume').data_matches_schema(@resource_schema) do
269
+ getAttachedVolumeResponse = service.get_attached_volume(@datacenter_id, @server_id, @volume_id)
270
+ getAttachedVolumeResponse.body
271
+ end
272
+
273
+ tests('#detach_volume').succeeds do
274
+ detachVolumeResponse = service.detach_volume(@datacenter_id, @server_id, @volume_id)
275
+ detachVolumeResponse.status == 202
276
+ end
277
+
278
+ tests('#attach_cdrom').data_matches_schema(@resource_schema) do
279
+ attachCdromResponse = service.attach_cdrom(@datacenter_id, @server_id, @image_id)
280
+
281
+ if ENV["FOG_MOCK"] != "true"
282
+ cd = service.images.get(@image_id)
283
+ cd.wait_for { ready? }
284
+ end
285
+
286
+ @cdrom_id = attachCdromResponse.body['id']
287
+
288
+ attachCdromResponse.body
289
+ end
290
+
291
+ tests('#get_attached_cdrom').data_matches_schema(@resource_schema) do
292
+ if ENV["FOG_MOCK"] != "true"
293
+ sleep(240)
294
+ end
295
+ getAttachedVolumeResponse = service.get_attached_cdrom(@datacenter_id, @server_id, @cdrom_id)
296
+ getAttachedVolumeResponse.body
297
+ end
298
+
299
+ tests('#list_attached_cdroms').data_matches_schema(@minimal_schema_with_items) do
300
+ listAttachedCdromsResponse = service.list_attached_cdroms(@datacenter_id, @server_id)
301
+
302
+ listAttachedCdromsResponse.body
303
+ end
304
+
305
+ tests('#detach_cdrom').succeeds do
306
+ detachVolumeResponse = service.detach_cdrom(@datacenter_id, @server_id, @cdrom_id)
307
+ detachVolumeResponse.status == 202
308
+ end
309
+
310
+ tests('#update_server').data_matches_schema(@resource_schema) do
311
+ updateServerResponse = service.update_server(@datacenter_id, @server_id, { 'name' => 'FogServerRename' })
312
+
313
+ if ENV["FOG_MOCK"] != "true"
314
+ loop do
315
+ server = service.servers.get(@datacenter_id, @server_id)
316
+ sleep(1)
317
+ break unless !server.ready?
318
+ end
319
+ end
320
+
321
+ # Calling wait_for causes ArgumentError
322
+ # server.wait_for { ready? }
323
+
324
+ updateServerResponse.body
325
+ end
326
+
327
+ tests('#get_all_servers').data_matches_schema(@minimal_schema_with_items) do
328
+ getAllServersResponse = service.get_all_servers(@datacenter_id)
329
+
330
+ getAllServersResponse.body
164
331
  end
165
332
 
166
333
  tests('#stop_server').succeeds do
167
- # puts '#stop_server'
168
- service.stop_server(@server_id)
169
- service.servers.get(@server_id).wait_for { state == "INACTIVE" }
334
+ stopServerResponse = service.stop_server(@datacenter_id, @server_id)
335
+
336
+ if ENV["FOG_MOCK"] != "true"
337
+ loop do
338
+ server = service.servers.get(@datacenter_id, @server_id)
339
+ sleep(1)
340
+ break unless !server.shutoff?
341
+ end
342
+ end
343
+
344
+ # Calling wait_for causes ArgumentError
345
+ # server.wait_for { shutoff? }
346
+
347
+ stopServerResponse.status == 202
170
348
  end
171
349
 
172
350
  tests('#start_server').succeeds do
173
- # puts '#start_server'
174
- service.start_server(@server_id)
175
- service.servers.get(@server_id).wait_for { state == "AVAILABLE" }
351
+ startServerResponse = service.start_server(@datacenter_id, @server_id)
352
+
353
+ if ENV["FOG_MOCK"] != "true"
354
+ loop do
355
+ server = service.servers.get(@datacenter_id, @server_id)
356
+ sleep(1)
357
+ break unless !server.running?
358
+ end
359
+ end
360
+
361
+ # Calling wait_for causes ArgumentError
362
+ # server.wait_for { running? }
363
+
364
+ startServerResponse.status == 202
176
365
  end
177
366
 
178
- tests('#reset_server').succeeds do
179
- # puts '#reset_server'
180
- service.reset_server(@server_id)
181
- service.servers.get(@server_id).wait_for { state == "AVAILABLE" }
367
+ tests('#reboot_server').succeeds do
368
+ rebootServerResponse = service.reboot_server(@datacenter_id, @server_id)
369
+
370
+ if ENV["FOG_MOCK"] != "true"
371
+ loop do
372
+ server = service.servers.get(@datacenter_id, @server_id)
373
+ sleep(1)
374
+ break unless !server.running?
375
+ end
376
+ end
377
+
378
+ rebootServerResponse.status == 202
182
379
  end
183
380
 
184
- tests('#disconnect_storage_from_server').formats(@minimal_format) do
185
- # puts '#disconnect_storage_from_server'
186
- service.disconnect_storage_from_server(@storage_id, @server_id).body['disconnectStorageFromServerResponse']
381
+ tests('#delete_server').succeeds do
382
+ deleteServerResponse = service.delete_server(@datacenter_id, @server_id)
383
+ deleteServerResponse.status == 202
187
384
  end
188
385
 
189
- tests('#delete_storage').formats(@minimal_format) do
190
- # puts '#delete_storage'
191
- data = service.delete_storage(@storage_id)
192
- data.body['deleteStorageResponse']
386
+ tests('#delete_snapshot').succeeds do
387
+ deleteSnapshotResponse = service.delete_snapshot(@snapshot_id)
388
+ deleteSnapshotResponse.status == 202
193
389
  end
194
390
 
195
- tests('#delete_server').formats(@minimal_format) do
196
- # puts '#delete_server'
197
- data = service.delete_server(@server_id)
198
- data.body['deleteServerResponse']
391
+ tests('#delete_volume').succeeds do
392
+ deleteVolumeResponse = service.delete_volume(@datacenter_id, @volume_id)
393
+ deleteVolumeResponse.status == 202
199
394
  end
200
395
 
201
- tests('#clear_data_center').formats(@minimal_format) do
202
- data = service.clear_data_center(@data_center_id)
203
- data.body['clearDataCenterResponse']
396
+ if ENV["FOG_MOCK"] == "true"
397
+ tests('#delete_image').succeeds do
398
+ deleteImageResponse = service.delete_image(@image_id)
399
+ deleteImageResponse.status == 202
400
+ end
204
401
  end
205
402
 
206
- tests('#delete_data_center').formats({'requestId' => String}) do
207
- # puts '#delete_data_center'
208
- service.delete_data_center(@data_center_id).body['deleteDataCenterResponse']
403
+ tests('#delete_datacenter').succeeds do
404
+ deleteDatacenterResponse = service.delete_datacenter(@datacenter_id)
405
+ deleteDatacenterResponse.status == 202
209
406
  end
210
407
  end
211
408
 
212
409
  tests('failure') do
213
410
 
214
- tests('#get_data_center').raises(Fog::Errors::NotFound) do
215
- # puts '#get_data_center'
216
- service.get_data_center('00000000-0000-0000-0000-000000000000')
411
+ tests('#get_datacenter').raises(Fog::Errors::NotFound) do
412
+ service.get_datacenter('00000000-0000-0000-0000-000000000000')
413
+ end
414
+
415
+ tests('#update_datacenter').raises(Fog::Errors::NotFound) do
416
+ service.update_datacenter('00000000-0000-0000-0000-000000000000',
417
+ { 'name' => 'FogTestDCRename' })
418
+ end
419
+
420
+ tests('#delete_datacenter').raises(Fog::Errors::NotFound) do
421
+ service.delete_datacenter('00000000-0000-0000-0000-000000000000')
217
422
  end
218
423
 
219
- tests('#update_data_center').raises(Fog::Errors::NotFound) do
220
- # puts '#update_data_center'
221
- service.update_data_center('00000000-0000-0000-0000-000000000000',
222
- { 'dataCenterName' => 'FogTestDCRename' })
424
+ tests('#get_image').raises(Fog::Errors::NotFound) do
425
+ service.get_image('00000000-0000-0000-0000-000000000000')
223
426
  end
224
427
 
225
- tests('#delete_data_center').raises(Fog::Errors::NotFound) do
226
- # puts '#delete_data_center'
227
- service.delete_data_center('00000000-0000-0000-0000-000000000000')
428
+ tests('#update_image').raises(Fog::Errors::NotFound) do
429
+ service.update_image('00000000-0000-0000-0000-000000000000', {})
228
430
  end
229
- tests('#create_storage').raises(ArgumentError) do
230
- # puts '#create_storage'
231
- service.create_storage
431
+
432
+ tests('#create_volume').raises(ArgumentError) do
433
+ service.create_volume
434
+ end
435
+
436
+ tests('#create_volume_snapshot').raises(ArgumentError) do
437
+ service.create_volume_snapshot
438
+ end
439
+
440
+ tests('#create_volume_snapshot').raises(Fog::Errors::NotFound) do
441
+ service.create_volume_snapshot('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', {})
442
+ end
443
+
444
+ tests('#get_snapshot').raises(Fog::Errors::NotFound) do
445
+ service.get_snapshot('00000000-0000-0000-0000-000000000000')
446
+ end
447
+
448
+ tests('#get_snapshot').raises(ArgumentError) do
449
+ service.get_snapshot
450
+ end
451
+
452
+ tests('#restore_volume_snapshot').raises(ArgumentError) do
453
+ service.restore_volume_snapshot
454
+ end
455
+
456
+ tests('#restore_volume_snapshot').raises(Fog::Errors::NotFound) do
457
+ service.restore_volume_snapshot('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', {})
232
458
  end
233
459
 
234
- tests('#get_storage').raises(Fog::Errors::NotFound) do
235
- # puts '#get_storage'
236
- service.get_storage('00000000-0000-0000-0000-000000000000')
460
+ tests('#get_volume').raises(Fog::Errors::NotFound) do
461
+ service.get_volume('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000')
237
462
  end
238
463
 
239
- tests('#update_storage').raises(Fog::Errors::NotFound) do
240
- # puts '#update_storage'
241
- service.update_storage('00000000-0000-0000-0000-000000000000')
464
+ tests('#update_volume').raises(Fog::Errors::NotFound) do
465
+ service.update_volume('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000')
242
466
  end
243
467
 
244
- tests('#delete_storage').raises(Fog::Errors::NotFound) do
245
- # puts '#delete_storage'
246
- service.delete_storage('00000000-0000-0000-0000-000000000000')
468
+ tests('#delete_volume').raises(Fog::Errors::NotFound) do
469
+ service.delete_volume('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000')
247
470
  end
248
471
  end
249
472
  end