27 Commits

Author SHA1 Message Date
Chaynika Saikia
0cb09cc560 Add cinder create --poll
Usage: It adds an optional argument --poll to the cinder
create command which waits while the creation of the volume
is completed and the volume goes to available state. In case
there is an error in volume creation, it throws an error message
and exits with a non zero status. The error message printed here
is the async error message in case it generates one.

Depends-On: Ic3ab32b95abd29e995bc071adc11b1e481b32516

Change-Id: I1a4d361d48a44a0daa830491f415be64f2e356e3
2017-07-24 09:06:28 -04:00
Akira KAMIO
19befa6965 Handle error response for webob>=1.6.0
WebOb change https://github.com/Pylons/webob/pull/230 changed
the way in which the error response body is formatted such that
it's no longer a nested dict. So we have to handle both the
old convention of an error message key to the response body error
dict and the new way with just the error body dict.

This was reported upstream:

https://github.com/Pylons/webob/issues/235

But given this was apparently implemented as a long-overdue change
in WebOb the behavior is not likely to change.Handle error response for
webob>=1.6.0

Change-Id: I7d589415aa024588faf77c8234ac026110f6c3cd
Closes-Bug: #1559072
2016-12-09 20:21:16 +09:00
Gorka Eguileor
8b5a772e36 Make APIVersion's null check more pythonic
Our current APIVersion object has an is_null method to check when the
version instance is null (major=0 and minor=0).

While this works it is not very pythonic, since you have to write
expressions such as:

 if not min_version and not max_version:
     return True
 elif ((min_version and max_version) and
       max_version.is_null() and min_version.is_null()):
     return True

This patch removes the is_null method and instead implements the truth
value testing to simplify expressions and make code more pythonic.

So previous code would just look like:

 if not min_version and not max_version:
     return True

Because this will work with min_version being None or being an
APIVersion instance with major=0 and minor=0.

Change-Id: I7497c5dc940c1e726507117cadbad232d8c1d80d
2016-08-29 11:41:57 +02:00
Cao Shufeng
b76f594413 Add "start_version" and "end_version" support to argparse
Now, "cinder help subcommand" can not show whether an argument
is supported for a specific microversion.
With this change, developers only need to add a start_version or
end_version in the utils.arg wrap, cinderclient will support
the microversion for that arguement.

    @utils.arg(
    '--foo',
    start_version='3.1')
    @utils.arg(
    '--bar',
    start_version='3.2',
    end_version='3.5')
    def do_some_action():
        ......

In previous example, an exception will be raised for such command:
   $ cinder --os-volume-api-version 3.6 --bar some-ation

And only "--foo" will show up for such help command:
   $ cinder --os-volume-api-version 3.1 help some-ation

Change-Id: I74137486992846bbf9fdff53c009851db2356eef
Partial-Bug: #1600567
Co-Authored-By: Nate Potter <nathaniel.potter@intel.com>
2016-08-16 16:16:13 +00:00
Javier Pena
ebe02fb877 Fix _get_rate_limit when resp is None
https://review.openstack.org/332848 added retry logic for the client.
Function _get_rate_limit may receive resp=None (seen in the Sahara
unit tests), and in that case we get an exception.

Change-Id: Ibfbb10087121bae7d6f4abdd4cdb8d04d039c970
2016-07-06 18:42:30 +02:00
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
scottda
3f75b48f06 Support api-microversions
Changes to cinderclient to use microversions.

Implements: blueprint api-microversion-support-for-cinderclient
api-microversion-support-for-cinderclient

Change-Id: I840a1162b88e8ff36fa3fc4e1d6b9317104df3e0
2016-04-19 11:19:45 -06:00
Eric Harney
c4c2c56042 Don't print HTTP codes for non-HTTP errors
This changes:
 $ cinder rename asdf
 ERROR: Must supply either name or description. (HTTP 1)

To:
 $ cinder rename asdf
 ERROR: Must supply either name or description.

Affects rename, snapshot-rename, consisgroup-update,
and consisgroup-create-from-src.
(consisgroup-* previously printed HTTP 400.)

Closes-Bug: #1549020
Closes-Bug: #1549026
Change-Id: Ia920b3b75b53170789b694cbdd49100bd6a72d21
2016-02-24 11:00:05 -05: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
Lin Yang
56778a1220 Fix typo in comment message
an request => a request
rest => resp
exception_from_response() => exceptions.from_response() '.' operator means call
from_response() in exceptions module.

Change-Id: I5e780dd2882b39d1b39f7c64bf274e90934c09ec
Signed-off-by: Lin Yang <lin.a.yang@intel.com>
2015-07-02 15:51:59 +08:00
Christian Berendt
17e4d6c381 Fixed typos found by RETF rules
Rules are available at
https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Typos

Change-Id: I8de0631346b703870ce8ebe9ce728a0360f1ba7f
2014-09-08 11:31:22 +00:00
Jenkins
04eaa48eb6 Merge "When there is no error body return the HTTP reason" 2014-04-18 19:30:36 +00:00
Russell Sim
52ce0b205e When there is no error body return the HTTP reason
Return the response reason when there is no message body to return.

DocImpact
Change-Id: Ia60da4f04b059a13fcbe0059bb42fd77f272d8aa
Closes-Bug: 1248773
2014-03-04 10:00:44 +11:00
Cory Stone
d5334aa929 Add auth_plugin support to cinderclient
With CINDER_RAX_AUTH being rightfully removed, cinderclient is no longer
compatible with Rackspace/any non-keystone auth. To fix this, I stole
auth_system/auth_plugin from novaclient's implementation.

See https://review.openstack.org/#/c/23820/.

Change-Id: If5f84003f868ef02bb7eb7da67cf62018602e8f0
Closes-Bug: 1280393
2014-02-14 15:09:44 -06:00
Chuck Short
b0b8afaf55 python3: Refactor dict for python2/python3 compat
Python3 changed the behavior of dict.keys such that it is now
returns a dict_keys object, which is iterable but not indexable.
You can get the python2 result back with an explicit call to list.

Refactor list(*.keys()) so that it just uses list().

Change-Id: Ib2e9646ac967e9bd7cc4f47e2099f5d1358808a9
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-10-11 09:04:49 -04:00
Jenkins
2ba74ecb54 Merge "convert third-party exception to ConnectionError" 2013-08-12 12:17:14 +00:00
Monty Taylor
6100651000 Sync with global requirements
Change-Id: Iccc824fef7dc7ae5675d6528a1ea33566e5f7eef
2013-08-06 14:45:24 -03:00
Christian Berendt
c95e59f510 convert third-party exception to ConnectionError
fixes bug #1207635

Change-Id: I37da522e812286e72706409b8a6d4652515f720f
2013-08-06 12:11:24 +02:00
John Griffith
3d30126e93 Revert "Use exceptions from oslo"
This reverts commit a7cce08eab5e2e42275b84bd56127bd09b00f5bf

Change-Id: I6c0047adbc33d0d6b5890f11853974578c36c78c
2013-07-15 10:30:05 -06:00
Alessio Ababilov
a7cce08eab Use exceptions from oslo
These exceptions can be used in novaclient, keystoneclient,
glanceclient, and other client projects.

Partially implements: blueprint common-client-library

Change-Id: I43918316622b1c1d722872fe30199db6a3a7bb76
2013-07-01 11:55:31 +03:00
Jenkins
dcc2f67bee Merge "Connectivity between the endpoint version and OS_VOLUME_API_VERSION." 2013-06-25 16:29:09 +00:00
Anastasia Latynskaya
6adda93c9d Connectivity between the endpoint version and OS_VOLUME_API_VERSION.
Adds functionality which allows user to work with
that cinder API version which is the same as
the endpoint version.

Fixes: bug #1169455

Change-Id: I9bb46e602d15856d2da502a6ac2b6c25e76f4fa3
2013-06-25 13:01:33 +00:00
Chuck Short
3044671b36 python3: Fix traceback while running tests
The testsuite is full of the following:

TypeError: 'dict_keys' object does not support indexing

This is due to the fact in python3 dict methods dict.keys(),
dict.items() and dict.values() return “views” instead of lists.

Change-Id: Ifa5383e6485fdbabf363fd1442877b2452346c1c
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-06-19 20:52:22 -05:00
Dirk Mueller
7359c976d1 Start Gating on Pyflakes and Hacking
Instead of globally ignoring Pyflakes and Hacking
warnings, only blacklist those that occur frequently
and fix the others. Start gating on those checks.

Change-Id: Ice032c16d445ef08ef018bcdc5c221ab3c323755
2013-06-09 13:29:23 +02:00
Dean Troyer
82e47d0866 Use requests module for HTTP/HTTPS
* Implement correct certificate verification
* Add --os-cacert
* Rework tests for requests

Pinned requests module to < 1.0 as 1.0.2 is now current in pipi
as of 17Dec2012.

Blueprint: tls-verify

Change-Id: I71066ff7297f3b70c08b7ae1c8ae8b6a1b82bbae
2012-12-18 13:58:05 -06:00
John Griffith
93f9fa75fa Set pep8 version to 1.1 in test_requires
* Fixes bug 1007520
* Changes in pep8 cause new failures

Change-Id: Ie678f01a5008b0df6ef43a360b599890cab40776
2012-06-15 13:56:39 -06:00
Jenkins
471704df64 Initial split from python-novaclient. 2012-05-21 16:32:35 -04:00