2 Commits

Author SHA1 Message Date
Yuriy Nesenenko
f8eef18297 Cinder client should retry with Retry-After value
If a request fails but the response contains a "Retry-After",
the cinder client should wait the amount of time and then retry.
Cinder client should report a warning to user and continue with
retry, so that user can cancel the operation if not interested
in retry. The value in "Retry-After" header will be in seconds
or GMT value, client should handle both the cases.

How many times client should retry will be controlled by user
through "--retries" argument to cinder api example,
$ cinder --retries 3 availability-zone-list

If request was not sucessful within the retries, client should
raise the exception.

Change-Id: I99af957bfbbe3a202b148dc2fcafdd20b5d7cda0
Partial-Bug: #1263069
2016-07-06 11:42:20 +03:00
Matt Riedemann
03542ee65a Fix ClientException init when there is no message on py34
BaseException.message was removed in python 3 per PEP 0352 so if no
message is passed to the ClientException __init__ it will blow up:

AttributeError: type object 'ClientException' has no attribute 'message'

So this change does two things:

1. Default to 'n/a' for message and details when body['keys'] doesn't
   have a message or details in it (which should be fine since
   from_response defaults to n/a if 'keys' is not in body).
2. Use getattr for self.__class__.message and default to None if that
   attribute is not set.  Arguably we could just remove this and make
   the message kwarg default to 'n/a' in ClientException.__init__ but
   I figured that was more invasive.

Closes-Bug: #1481478

Change-Id: I738cb9c8d4f015048c45a1df16bf18e29190e392
2015-08-04 14:21:52 -07:00