@@ -202,43 +202,36 @@ def _wait_for_instance_action_event(
202
202
'actions: %s. Events in the last matching action: %s'
203
203
% (event_name , actions , events ))
204
204
205
- # TODO(lyarwood): Rewrite this waiter to use os-volume_attachments
206
205
def _wait_for_volume_attach (self , server_id , volume_id ):
207
206
timeout = 0.0
208
- server = self .api .get_server (server_id )
209
- attached_vols = [vol ['id' ] for vol in
210
- server ['os-extended-volumes:volumes_attached' ]]
211
-
212
- while volume_id not in attached_vols and timeout < 10.0 :
213
- time .sleep (.1 )
214
- timeout += .1
215
- server = self .api .get_server (server_id )
216
- attached_vols = [vol ['id' ] for vol in
217
- server ['os-extended-volumes:volumes_attached' ]]
218
-
219
- if volume_id not in attached_vols :
220
- self .fail ('Timed out waiting for volume %s to be attached to '
207
+ while timeout < 10.0 :
208
+ try :
209
+ self .api .get_server_volume (server_id , volume_id )
210
+ return
211
+ except api_client .OpenStackApiNotFoundException :
212
+ time .sleep (.1 )
213
+ timeout += .1
214
+
215
+ attached_vols = self .api .get_server_volumes (server_id )
216
+ self .fail ('Timed out waiting for volume %s to be attached to '
221
217
'server %s. Currently attached volumes: %s' %
222
218
(volume_id , server_id , attached_vols ))
223
219
224
- # TODO(lyarwood): Rewrite this waiter to use os-volume_attachments
225
220
def _wait_for_volume_detach (self , server_id , volume_id ):
226
221
timeout = 0.0
227
- server = self .api .get_server (server_id )
228
- attached_vols = [vol ['id' ] for vol in
229
- server ['os-extended-volumes:volumes_attached' ]]
230
-
231
- while volume_id in attached_vols and timeout < 10.0 :
232
- time .sleep (.1 )
233
- timeout += .1
234
- server = self .api .get_server (server_id )
235
- attached_vols = [vol ['id' ] for vol in
236
- server ['os-extended-volumes:volumes_attached' ]]
237
-
238
- if volume_id in attached_vols :
239
- self .fail ('Timed out waiting for volume %s to be detached from '
240
- 'server %s. Currently attached volumes: %s' %
241
- (volume_id , server_id , attached_vols ))
222
+
223
+ while timeout < 10.0 :
224
+ try :
225
+ self .api .get_server_volume (server_id , volume_id )
226
+ time .sleep (.1 )
227
+ timeout += .1
228
+ except api_client .OpenStackApiNotFoundException :
229
+ return
230
+
231
+ attached_vols = self .api .get_server_volumes (server_id )
232
+ self .fail ('Timed out waiting for volume %s to be detached from '
233
+ 'server %s. Currently attached volumes: %s' %
234
+ (volume_id , server_id , attached_vols ))
242
235
243
236
def _assert_resize_migrate_action_fail (self , server , action , error_in_tb ):
244
237
"""Waits for the conductor_migrate_server action event to fail for
0 commit comments