fog-profitbricks 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/.travis.yml +11 -4
  4. data/README.md +8 -5
  5. data/Rakefile +1 -1
  6. data/examples/pb_demo.rb +49 -49
  7. data/fog-profitbricks.gemspec +4 -5
  8. data/gemfiles/Gemfile.1.9.2+ +1 -0
  9. data/lib/fog/bin/profitbricks.rb +5 -5
  10. data/lib/fog/profitbricks.rb +3 -3
  11. data/lib/fog/profitbricks/compute.rb +209 -204
  12. data/lib/fog/profitbricks/helpers/compute/data_helper.rb +1 -1
  13. data/lib/fog/profitbricks/models/compute/datacenter.rb +1 -1
  14. data/lib/fog/profitbricks/models/compute/datacenters.rb +6 -7
  15. data/lib/fog/profitbricks/models/compute/firewall_rule.rb +2 -2
  16. data/lib/fog/profitbricks/models/compute/firewall_rules.rb +5 -8
  17. data/lib/fog/profitbricks/models/compute/flavors.rb +1 -4
  18. data/lib/fog/profitbricks/models/compute/image.rb +4 -0
  19. data/lib/fog/profitbricks/models/compute/images.rb +2 -5
  20. data/lib/fog/profitbricks/models/compute/ip_block.rb +1 -1
  21. data/lib/fog/profitbricks/models/compute/ip_blocks.rb +3 -8
  22. data/lib/fog/profitbricks/models/compute/lan.rb +1 -1
  23. data/lib/fog/profitbricks/models/compute/lans.rb +4 -7
  24. data/lib/fog/profitbricks/models/compute/load_balancer.rb +6 -7
  25. data/lib/fog/profitbricks/models/compute/load_balancers.rb +5 -9
  26. data/lib/fog/profitbricks/models/compute/locations.rb +2 -5
  27. data/lib/fog/profitbricks/models/compute/nic.rb +6 -3
  28. data/lib/fog/profitbricks/models/compute/nics.rb +2 -5
  29. data/lib/fog/profitbricks/models/compute/regions.rb +1 -4
  30. data/lib/fog/profitbricks/models/compute/request.rb +0 -1
  31. data/lib/fog/profitbricks/models/compute/requests.rb +2 -4
  32. data/lib/fog/profitbricks/models/compute/server.rb +10 -13
  33. data/lib/fog/profitbricks/models/compute/servers.rb +3 -6
  34. data/lib/fog/profitbricks/models/compute/snapshot.rb +2 -2
  35. data/lib/fog/profitbricks/models/compute/snapshots.rb +3 -6
  36. data/lib/fog/profitbricks/models/compute/volume.rb +11 -9
  37. data/lib/fog/profitbricks/models/compute/volumes.rb +3 -6
  38. data/lib/fog/profitbricks/requests/compute/associate_nic_to_load_balancer.rb +26 -13
  39. data/lib/fog/profitbricks/requests/compute/attach_cdrom.rb +25 -16
  40. data/lib/fog/profitbricks/requests/compute/attach_volume.rb +25 -16
  41. data/lib/fog/profitbricks/requests/compute/create_datacenter.rb +22 -23
  42. data/lib/fog/profitbricks/requests/compute/create_firewall_rule.rb +24 -26
  43. data/lib/fog/profitbricks/requests/compute/create_flavor.rb +34 -34
  44. data/lib/fog/profitbricks/requests/compute/create_ip_block.rb +18 -20
  45. data/lib/fog/profitbricks/requests/compute/create_lan.rb +151 -150
  46. data/lib/fog/profitbricks/requests/compute/create_load_balancer.rb +67 -26
  47. data/lib/fog/profitbricks/requests/compute/create_nic.rb +24 -26
  48. data/lib/fog/profitbricks/requests/compute/create_server.rb +70 -61
  49. data/lib/fog/profitbricks/requests/compute/create_volume.rb +122 -122
  50. data/lib/fog/profitbricks/requests/compute/create_volume_snapshot.rb +42 -45
  51. data/lib/fog/profitbricks/requests/compute/delete_datacenter.rb +34 -36
  52. data/lib/fog/profitbricks/requests/compute/delete_firewall_rule.rb +8 -11
  53. data/lib/fog/profitbricks/requests/compute/delete_image.rb +7 -9
  54. data/lib/fog/profitbricks/requests/compute/delete_ip_block.rb +8 -10
  55. data/lib/fog/profitbricks/requests/compute/delete_lan.rb +7 -9
  56. data/lib/fog/profitbricks/requests/compute/delete_load_balancer.rb +8 -10
  57. data/lib/fog/profitbricks/requests/compute/delete_nic.rb +7 -10
  58. data/lib/fog/profitbricks/requests/compute/delete_server.rb +6 -10
  59. data/lib/fog/profitbricks/requests/compute/delete_snapshot.rb +7 -10
  60. data/lib/fog/profitbricks/requests/compute/delete_volume.rb +36 -38
  61. data/lib/fog/profitbricks/requests/compute/detach_cdrom.rb +11 -13
  62. data/lib/fog/profitbricks/requests/compute/detach_volume.rb +16 -13
  63. data/lib/fog/profitbricks/requests/compute/get_all_datacenters.rb +1 -1
  64. data/lib/fog/profitbricks/requests/compute/get_all_firewall_rules.rb +6 -7
  65. data/lib/fog/profitbricks/requests/compute/get_all_flavors.rb +72 -72
  66. data/lib/fog/profitbricks/requests/compute/get_all_images.rb +62 -62
  67. data/lib/fog/profitbricks/requests/compute/get_all_ip_blocks.rb +5 -5
  68. data/lib/fog/profitbricks/requests/compute/get_all_lans.rb +113 -113
  69. data/lib/fog/profitbricks/requests/compute/get_all_load_balanced_nics.rb +15 -9
  70. data/lib/fog/profitbricks/requests/compute/get_all_load_balancers.rb +9 -9
  71. data/lib/fog/profitbricks/requests/compute/get_all_locations.rb +6 -6
  72. data/lib/fog/profitbricks/requests/compute/get_all_nic.rb +94 -94
  73. data/lib/fog/profitbricks/requests/compute/get_all_requests.rb +38 -38
  74. data/lib/fog/profitbricks/requests/compute/get_all_servers.rb +8 -9
  75. data/lib/fog/profitbricks/requests/compute/get_all_snapshots.rb +4 -4
  76. data/lib/fog/profitbricks/requests/compute/get_all_volumes.rb +71 -71
  77. data/lib/fog/profitbricks/requests/compute/get_attached_cdrom.rb +11 -11
  78. data/lib/fog/profitbricks/requests/compute/get_attached_volume.rb +16 -11
  79. data/lib/fog/profitbricks/requests/compute/get_datacenter.rb +4 -6
  80. data/lib/fog/profitbricks/requests/compute/get_firewall_rule.rb +8 -11
  81. data/lib/fog/profitbricks/requests/compute/get_flavor.rb +9 -9
  82. data/lib/fog/profitbricks/requests/compute/get_image.rb +7 -9
  83. data/lib/fog/profitbricks/requests/compute/get_ip_block.rb +8 -10
  84. data/lib/fog/profitbricks/requests/compute/get_lan.rb +7 -10
  85. data/lib/fog/profitbricks/requests/compute/get_load_balanced_nic.rb +16 -12
  86. data/lib/fog/profitbricks/requests/compute/get_load_balancer.rb +7 -9
  87. data/lib/fog/profitbricks/requests/compute/get_location.rb +7 -9
  88. data/lib/fog/profitbricks/requests/compute/get_nic.rb +8 -11
  89. data/lib/fog/profitbricks/requests/compute/get_request.rb +55 -57
  90. data/lib/fog/profitbricks/requests/compute/get_request_status.rb +44 -46
  91. data/lib/fog/profitbricks/requests/compute/get_server.rb +7 -10
  92. data/lib/fog/profitbricks/requests/compute/get_snapshot.rb +7 -9
  93. data/lib/fog/profitbricks/requests/compute/get_volume.rb +7 -9
  94. data/lib/fog/profitbricks/requests/compute/list_attached_cdroms.rb +8 -8
  95. data/lib/fog/profitbricks/requests/compute/list_attached_volumes.rb +18 -8
  96. data/lib/fog/profitbricks/requests/compute/reboot_server.rb +7 -11
  97. data/lib/fog/profitbricks/requests/compute/remove_nic_association.rb +9 -11
  98. data/lib/fog/profitbricks/requests/compute/restore_volume_snapshot.rb +15 -17
  99. data/lib/fog/profitbricks/requests/compute/start_server.rb +7 -11
  100. data/lib/fog/profitbricks/requests/compute/stop_server.rb +7 -11
  101. data/lib/fog/profitbricks/requests/compute/update_datacenter.rb +20 -15
  102. data/lib/fog/profitbricks/requests/compute/update_firewall_rule.rb +9 -11
  103. data/lib/fog/profitbricks/requests/compute/update_image.rb +15 -15
  104. data/lib/fog/profitbricks/requests/compute/update_lan.rb +6 -8
  105. data/lib/fog/profitbricks/requests/compute/update_load_balancer.rb +10 -12
  106. data/lib/fog/profitbricks/requests/compute/update_nic.rb +10 -12
  107. data/lib/fog/profitbricks/requests/compute/update_server.rb +10 -13
  108. data/lib/fog/profitbricks/requests/compute/update_snapshot.rb +10 -13
  109. data/lib/fog/profitbricks/requests/compute/update_volume.rb +10 -13
  110. data/lib/fog/profitbricks/version.rb +1 -1
  111. data/spec/minitest_helper.rb +1 -3
  112. data/tests/helpers/formats_helper.rb +8 -8
  113. data/tests/profitbricks/models/compute/compute_tests.rb +529 -0
  114. data/tests/profitbricks/requests/compute/composite_create_tests.rb +16 -83
  115. data/tests/profitbricks/requests/compute/flavor_tests.rb +1 -4
  116. data/tests/profitbricks/requests/compute/location_tests.rb +14 -17
  117. data/tests/profitbricks/requests/compute/nic_tests.rb +60 -70
  118. data/tests/profitbricks/requests/compute/request_tests.rb +1 -3
  119. data/tests/profitbricks/requests/compute/server_tests.rb +163 -161
  120. metadata +5 -18
@@ -1,5 +1,4 @@
1
- Shindo.tests('Fog::Compute[:profitbricks] | request request', ['profitbricks', 'compute']) do
2
-
1
+ Shindo.tests('Fog::Compute[:profitbricks] | request request', %w(profitbricks compute)) do
3
2
  @requests_schema = {
4
3
  'id' => String,
5
4
  'type' => String,
@@ -18,7 +17,6 @@ Shindo.tests('Fog::Compute[:profitbricks] | request request', ['profitbricks', '
18
17
  service = Fog::Compute[:profitbricks]
19
18
 
20
19
  tests('success') do
21
-
22
20
  Excon.defaults[:connection_timeout] = 500
23
21
 
24
22
  tests('#get_all_requests').data_matches_schema(@requests_schema) do
@@ -1,24 +1,77 @@
1
- Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'compute']) do
2
-
1
+ Shindo.tests('Fog::Compute[:profitbricks] | server request', %w(profitbricks compute)) do
3
2
  @resource_schema = {
4
- 'id' => String,
5
- 'type' => String,
6
- 'href' => String,
7
- 'metadata' => Hash,
8
- 'properties' => Hash
3
+ 'id' => String,
4
+ 'type' => String,
5
+ 'href' => String,
6
+ 'metadata' => Hash,
7
+ 'properties' => Hash
9
8
  }
10
9
 
11
10
  @minimal_schema_with_items = {
12
- 'id' => String,
13
- 'type' => String,
14
- 'href' => String,
15
- 'items' => Array
11
+ 'id' => String,
12
+ 'type' => String,
13
+ 'href' => String,
14
+ 'items' => Array
15
+ }
16
+
17
+ @volume_schema = {
18
+ "id" => String,
19
+ "type" => String,
20
+ "href" => String,
21
+ "name" => String,
22
+ "description" => String,
23
+ "location" => String,
24
+ "size" => Float,
25
+ "cpuHotPlug" => String,
26
+ "cpuHotUnplug" => String,
27
+ "ramHotPlug" => String,
28
+ "ramHotUnplug" => String,
29
+ "nicHotPlug" => String,
30
+ "nicHotUnplug" => String,
31
+ "discVirtioHotUnplug" => String,
32
+ "discScsiHotPlug" => String,
33
+ "discScsiHotUnplug" => String,
34
+ "licenceType" => String,
35
+ "imageType" => String,
36
+ "public" => String,
37
+ "createdDate" => String,
38
+ "createdBy" => String,
39
+ "etag" => String,
40
+ "lastModifiedDate" => String,
41
+ "lastModifiedBy" => String,
42
+ "state" => String
43
+ }
44
+
45
+ @image_schema = {
46
+ "id" => String,
47
+ "type" => String,
48
+ "href" => String,
49
+ "name" => String,
50
+ "description" => String,
51
+ "location" => String,
52
+ "size" => Float,
53
+ "cpuHotPlug" => String,
54
+ "cpuHotUnplug" => String,
55
+ "ramHotPlug" => String,
56
+ "ramHotUnplug" => String,
57
+ "nicHotPlug" => String,
58
+ "nicHotUnplug" => String,
59
+ "discVirtioHotUnplug" => String,
60
+ "discScsiHotPlug" => String,
61
+ "discScsiHotUnplug" => String,
62
+ "imageType" => String,
63
+ "public" => String,
64
+ "createdDate" => String,
65
+ "createdBy" => String,
66
+ "etag" => String,
67
+ "lastModifiedDate" => String,
68
+ "lastModifiedBy" => String,
69
+ "state" => String
16
70
  }
17
71
 
18
72
  service = Fog::Compute[:profitbricks]
19
73
 
20
74
  tests('success') do
21
-
22
75
  Excon.defaults[:connection_timeout] = 500
23
76
 
24
77
  tests('#create_datacenter').data_matches_schema(@resource_schema) do
@@ -30,10 +83,6 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
30
83
  createDatacenterResponse = service.create_datacenter(options)
31
84
  @datacenter_id = createDatacenterResponse.body['id']
32
85
 
33
- if ENV["FOG_MOCK"] != "true"
34
- service.datacenters.get(@datacenter_id).wait_for { ready? }
35
- end
36
-
37
86
  createDatacenterResponse.body
38
87
  end
39
88
 
@@ -56,37 +105,62 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
56
105
  @datacenter_id, options
57
106
  )
58
107
 
59
- if ENV["FOG_MOCK"] != "true"
60
- service.datacenters.get(@datacenter_id).wait_for { ready? }
61
- end
62
-
63
108
  updateDatacenterResponse.body
64
109
  end
65
110
 
66
111
  tests('#get_all_images').data_matches_schema(@minimal_schema_with_items) do
67
112
  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'
72
- }
113
+
114
+ data = getAllImagesResponse.body['items'].find do |image|
115
+ if ENV["FOG_MOCK"] != "true"
116
+ if image['properties']
117
+ image['properties']['location'] == 'us/las' &&
118
+ image['properties']['imageType'] == 'CDROM' &&
119
+ image['properties']['licenceType'] == 'LINUX'
120
+ else
121
+ image['location'] == 'us/las' &&
122
+ image['imageType'] == 'CDROM' &&
123
+ image['licenceType'] == 'LINUX'
124
+ end
125
+ else
126
+ if image['properties']
127
+ image['properties']['location'] == 'us/las' &&
128
+ image['properties']['imageType'] == 'CDROM' &&
129
+ image['properties']['licenceType'] == 'UNKNOWN'
130
+ else
131
+ image['location'] == 'us/las' &&
132
+ image['imageType'] == 'CDROM' &&
133
+ image['licenceType'] == 'UNKNOWN'
134
+ end
135
+ end
136
+ end
137
+
73
138
  @image_id = data['id']
74
139
  getAllImagesResponse.body
75
140
  end
76
141
 
77
- tests('#get_image').data_matches_schema(@resource_schema) do
78
- getImageResponse = service.get_image(@image_id)
79
- getImageResponse.body
142
+ if Fog.mock?
143
+ tests('#get_image').data_matches_schema(@volume_schema) do
144
+ getImageResponse = service.get_image(@image_id)
145
+ getImageResponse.body
146
+ end
80
147
  end
81
148
 
82
- if ENV["FOG_MOCK"] == "true"
83
- tests('#update_image').data_matches_schema(@resource_schema) do
149
+ unless Fog.mock?
150
+ tests('#get_image').data_matches_schema(@resource_schema) do
151
+ getImageResponse = service.get_image(@image_id)
152
+ getImageResponse.body
153
+ end
154
+ end
155
+
156
+ if Fog.mock?
157
+ tests('#update_image').data_matches_schema(@image_schema) do
84
158
  options = {}
85
159
  options[:name] = 'FogImageRename'
86
160
  options[:description] = 'FogImageDescriptionUpdated'
87
161
 
88
162
  updateImageResponse = service.update_image(
89
- @image_id, options
163
+ @image_id, options
90
164
  )
91
165
 
92
166
  updateImageResponse.body
@@ -94,11 +168,11 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
94
168
  end
95
169
 
96
170
  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
99
- }
171
+ if dc = service.get_all_datacenters.body["items"].find do |datacenter|
172
+ datacenter["id"] == @datacenter_id
173
+ end
100
174
  else
101
- raise Fog::Errors::NotFound.new("The requested resource could not be found")
175
+ raise Fog::Errors::NotFound, "The requested resource could not be found"
102
176
  end
103
177
 
104
178
  getAllVolumesResponse = service.get_all_volumes(dc['id'])
@@ -107,24 +181,16 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
107
181
 
108
182
  tests('#create_volume').data_matches_schema(@resource_schema) do
109
183
  options = {}
110
- options[:name] = 'FogRestTestVolume'
111
- options[:size] = 5
112
- options[:licenceType] = 'LINUX'
113
- options[:type] = 'HDD'
184
+ options[:name] = 'FogRestTestVolume'
185
+ options[:size] = 5
186
+ options[:licenceType] = 'LINUX'
187
+ options[:type] = 'HDD'
188
+ options[:availabilityZone] = 'AUTO'
114
189
 
115
190
  createVolumeResponse = service.create_volume(@datacenter_id, options)
116
191
  @volume_id = createVolumeResponse.body['id']
117
192
 
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? }
193
+ sleep(5) if ENV["FOG_MOCK"] != "true"
128
194
 
129
195
  createVolumeResponse.body
130
196
  end
@@ -139,15 +205,11 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
139
205
  options[:name] = 'FogRestTestSnapshot'
140
206
  options[:description] = 'Testing fog create snapshot'
141
207
 
208
+ sleep(15) if ENV["FOG_MOCK"] != "true"
209
+
142
210
  createVolumeSnapshotResponse = service.create_volume_snapshot(@datacenter_id, @volume_id, options)
143
211
  @snapshot_id = createVolumeSnapshotResponse.body['id']
144
212
 
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
213
  createVolumeSnapshotResponse.body
152
214
  end
153
215
 
@@ -158,17 +220,6 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
158
220
 
159
221
  updateVolumeResponse = service.update_volume(@datacenter_id, @volume_id, options)
160
222
 
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
223
  updateVolumeResponse.body
173
224
  end
174
225
 
@@ -180,10 +231,6 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
180
231
 
181
232
  updateSnapshotResponse = service.update_snapshot(@snapshot_id, options)
182
233
 
183
- if ENV["FOG_MOCK"] != "true"
184
- snapshot = service.snapshots.get(@snapshot_id)
185
- snapshot.wait_for { ready? }
186
- end
187
234
  updateSnapshotResponse.body
188
235
  end
189
236
 
@@ -224,21 +271,13 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
224
271
  createServerResponse = service.create_server(@datacenter_id, properties, entities)
225
272
  @server_id = createServerResponse.body['id']
226
273
 
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? }
274
+ sleep(60) if ENV["FOG_MOCK"] != "true"
237
275
 
238
276
  createServerResponse.body
239
277
  end
240
278
 
241
279
  tests('#get_server').data_matches_schema(@resource_schema) do
280
+ sleep(10) if ENV["FOG_MOCK"] != "true"
242
281
  getServerResponse = service.get_server(@datacenter_id, @server_id)
243
282
  getServerResponse.body
244
283
  end
@@ -251,17 +290,6 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
251
290
  tests('#attach_volume').data_matches_schema(@resource_schema) do
252
291
  attachVolumeResponse = service.attach_volume(@datacenter_id, @server_id, @volume_id)
253
292
 
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
293
  attachVolumeResponse.body
266
294
  end
267
295
 
@@ -275,28 +303,44 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
275
303
  detachVolumeResponse.status == 202
276
304
  end
277
305
 
278
- tests('#attach_cdrom').data_matches_schema(@resource_schema) do
279
- attachCdromResponse = service.attach_cdrom(@datacenter_id, @server_id, @image_id)
306
+ unless Fog.mock?
307
+ tests('#attach_cdrom').data_matches_schema(@resource_schema) do
308
+ attachCdromResponse = service.attach_cdrom(@datacenter_id, @server_id, @image_id)
280
309
 
281
- if ENV["FOG_MOCK"] != "true"
282
- cd = service.images.get(@image_id)
283
- cd.wait_for { ready? }
310
+ @cdrom_id = attachCdromResponse.body['id']
311
+
312
+ attachCdromResponse.body
284
313
  end
314
+ end
285
315
 
286
- @cdrom_id = attachCdromResponse.body['id']
316
+ if Fog.mock?
317
+ tests('#attach_cdrom').succeeds do
318
+ attachCdromResponse = service.attach_cdrom(@datacenter_id, @server_id, @image_id)
287
319
 
288
- attachCdromResponse.body
320
+ @cdrom_id = attachCdromResponse.body['id']
321
+
322
+ attachCdromResponse.body
323
+ end
289
324
  end
290
325
 
291
- tests('#get_attached_cdrom').data_matches_schema(@resource_schema) do
292
- if ENV["FOG_MOCK"] != "true"
293
- sleep(240)
326
+ unless Fog.mock?
327
+ tests('#get_attached_cdrom').data_matches_schema(@resource_schema) do
328
+ sleep(60)
329
+ getAttachedVolumeResponse = service.get_attached_cdrom(@datacenter_id, @server_id, @cdrom_id)
330
+ getAttachedVolumeResponse.body
331
+ end
332
+ end
333
+
334
+ if Fog.mock?
335
+ tests('#get_attached_cdrom').succeeds do
336
+ getAttachedVolumeResponse = service.get_attached_cdrom(@datacenter_id, @server_id, @cdrom_id)
337
+ getAttachedVolumeResponse.body
294
338
  end
295
- getAttachedVolumeResponse = service.get_attached_cdrom(@datacenter_id, @server_id, @cdrom_id)
296
- getAttachedVolumeResponse.body
297
339
  end
298
340
 
299
341
  tests('#list_attached_cdroms').data_matches_schema(@minimal_schema_with_items) do
342
+ sleep(10) if ENV["FOG_MOCK"] != "true"
343
+
300
344
  listAttachedCdromsResponse = service.list_attached_cdroms(@datacenter_id, @server_id)
301
345
 
302
346
  listAttachedCdromsResponse.body
@@ -308,18 +352,7 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
308
352
  end
309
353
 
310
354
  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? }
355
+ updateServerResponse = service.update_server(@datacenter_id, @server_id, 'name' => 'FogServerRename')
323
356
 
324
357
  updateServerResponse.body
325
358
  end
@@ -333,48 +366,18 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
333
366
  tests('#stop_server').succeeds do
334
367
  stopServerResponse = service.stop_server(@datacenter_id, @server_id)
335
368
 
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
369
  stopServerResponse.status == 202
348
370
  end
349
371
 
350
372
  tests('#start_server').succeeds do
351
373
  startServerResponse = service.start_server(@datacenter_id, @server_id)
352
374
 
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
375
  startServerResponse.status == 202
365
376
  end
366
377
 
367
378
  tests('#reboot_server').succeeds do
368
379
  rebootServerResponse = service.reboot_server(@datacenter_id, @server_id)
369
380
 
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
381
  rebootServerResponse.status == 202
379
382
  end
380
383
 
@@ -393,7 +396,7 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
393
396
  deleteVolumeResponse.status == 202
394
397
  end
395
398
 
396
- if ENV["FOG_MOCK"] == "true"
399
+ if Fog.mock?
397
400
  tests('#delete_image').succeeds do
398
401
  deleteImageResponse = service.delete_image(@image_id)
399
402
  deleteImageResponse.status == 202
@@ -407,25 +410,24 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
407
410
  end
408
411
 
409
412
  tests('failure') do
410
-
411
- tests('#get_datacenter').raises(Fog::Errors::NotFound) do
413
+ tests('#get_datacenter').raises(Excon::Error::HTTPStatus) do
412
414
  service.get_datacenter('00000000-0000-0000-0000-000000000000')
413
415
  end
414
416
 
415
- tests('#update_datacenter').raises(Fog::Errors::NotFound) do
417
+ tests('#update_datacenter').raises(Excon::Error::HTTPStatus) do
416
418
  service.update_datacenter('00000000-0000-0000-0000-000000000000',
417
- { 'name' => 'FogTestDCRename' })
419
+ 'name' => 'FogTestDCRename')
418
420
  end
419
421
 
420
- tests('#delete_datacenter').raises(Fog::Errors::NotFound) do
422
+ tests('#delete_datacenter').raises(Excon::Error::HTTPStatus) do
421
423
  service.delete_datacenter('00000000-0000-0000-0000-000000000000')
422
424
  end
423
425
 
424
- tests('#get_image').raises(Fog::Errors::NotFound) do
426
+ tests('#get_image').raises(Excon::Error::HTTPStatus) do
425
427
  service.get_image('00000000-0000-0000-0000-000000000000')
426
428
  end
427
429
 
428
- tests('#update_image').raises(Fog::Errors::NotFound) do
430
+ tests('#update_image').raises(Excon::Error::HTTPStatus) do
429
431
  service.update_image('00000000-0000-0000-0000-000000000000', {})
430
432
  end
431
433
 
@@ -437,11 +439,11 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
437
439
  service.create_volume_snapshot
438
440
  end
439
441
 
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
+ tests('#create_volume_snapshot').raises(Excon::Error::HTTPStatus) do
443
+ service.create_volume_snapshot('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', :name => 'test')
442
444
  end
443
445
 
444
- tests('#get_snapshot').raises(Fog::Errors::NotFound) do
446
+ tests('#get_snapshot').raises(Excon::Error::HTTPStatus) do
445
447
  service.get_snapshot('00000000-0000-0000-0000-000000000000')
446
448
  end
447
449
 
@@ -453,19 +455,19 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
453
455
  service.restore_volume_snapshot
454
456
  end
455
457
 
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', {})
458
+ tests('#restore_volume_snapshot').raises(Excon::Error::HTTPStatus) do
459
+ service.restore_volume_snapshot('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', :name => 'test')
458
460
  end
459
461
 
460
- tests('#get_volume').raises(Fog::Errors::NotFound) do
462
+ tests('#get_volume').raises(Excon::Error::HTTPStatus) do
461
463
  service.get_volume('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000')
462
464
  end
463
465
 
464
- tests('#update_volume').raises(Fog::Errors::NotFound) do
466
+ tests('#update_volume').raises(Excon::Error::HTTPStatus) do
465
467
  service.update_volume('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000')
466
468
  end
467
469
 
468
- tests('#delete_volume').raises(Fog::Errors::NotFound) do
470
+ tests('#delete_volume').raises(Excon::Error::HTTPStatus) do
469
471
  service.delete_volume('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000')
470
472
  end
471
473
  end