332 | 332 |
Barbican key creation is done asynchronously, so this loop continues
|
333 | 333 |
checking until the order is active or a timeout occurs.
|
334 | 334 |
"""
|
335 | |
active = u'ACTIVE'
|
|
335 |
active_status = u'ACTIVE'
|
|
336 |
error_status = u'ERROR'
|
336 | 337 |
number_of_retries = self.conf.barbican.number_of_retries
|
337 | 338 |
retry_delay = self.conf.barbican.retry_delay
|
338 | 339 |
order = barbican_client.orders.get(order_ref)
|
339 | 340 |
time.sleep(.25)
|
340 | 341 |
for n in range(number_of_retries):
|
341 | |
if order.status != active:
|
|
342 |
if order.status == error_status:
|
|
343 |
kwargs = {"status": error_status,
|
|
344 |
"code": order.error_status_code,
|
|
345 |
"reason": order.error_reason}
|
|
346 |
msg = u._LE("Order is in %(status)s status - status code: "
|
|
347 |
"%(code)s, status reason: %(reason)s") % kwargs
|
|
348 |
LOG.error(msg)
|
|
349 |
raise exception.KeyManagerError(reason=msg)
|
|
350 |
if order.status != active_status:
|
342 | 351 |
kwargs = {'attempt': n,
|
343 | 352 |
'total': number_of_retries,
|
344 | 353 |
'status': order.status,
|
345 | |
'active': active,
|
|
354 |
'active': active_status,
|
346 | 355 |
'delay': retry_delay}
|
347 | 356 |
msg = u._LI("Retry attempt #%(attempt)i out of %(total)i: "
|
348 | 357 |
"Order status is '%(status)s'. Waiting for "
|
|
354 | 363 |
else:
|
355 | 364 |
return order
|
356 | 365 |
msg = u._LE("Exceeded retries: Failed to find '%(active)s' status "
|
357 | |
"within %(num_retries)i retries") % {'active': active,
|
358 | |
'num_retries':
|
359 | |
number_of_retries}
|
|
366 |
"within %(num_retries)i retries") % {
|
|
367 |
'active': active_status,
|
|
368 |
'num_retries': number_of_retries}
|
360 | 369 |
LOG.error(msg)
|
361 | 370 |
raise exception.KeyManagerError(reason=msg)
|
362 | 371 |
|