It can be annoying to have to say raise_exc=False (or use try/except) on
every call when talking to an API where 4xx response codes are
useful/normal/informative or where the preferred coding style is to use
conditionals rather than try/except.
With this change, the Adapter constructor takes a new kwarg, raise_exc.
It defaults to None, and the existing behavior is unchanged. If set to
a boolean value, that is used as the default for requests. Specifying
raise_exc to the primitives (get, head, put, post, patch, delete,
request) at any point along the chain will still take precedence.
Change-Id: Ie291c3cb891467728d8ca33cf62afdab37c82f34
Closes-Bug: #1776501
We want to default to running all tox environments under python 3, so
set the basepython value in each environment.
We do not want to specify a minor version number, because we do not
want to have to update the file every time we upgrade python.
We do not want to set the override once in testenv, because that
breaks the more specific versions used in default environments like
py35 and py36.
Change-Id: I2db130183c0a657b281e0990593fb86be6bef017
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Ironic commonly returns HTTP 409 when a node is locked by another routine
and HTTP 503 when the conductor has no free threads to process the request.
Currently it is managed by custom code in ironicclient and openstacksdk,
this change will allow to move it to Session itself.
Change-Id: I04e356e7856b020cd20aa598e291ef31e02730d2
For people setting creating Sessions via load_from_conf_options, such as
the OpenStack services, turning on split-loggers needs to be done in a
config file. In order to do that, we need to expose it in the conf
options list.
Don't add it to the argparse options for now - it would just add another
command line option that is less likely to see use.
Change-Id: I106c6acbe306e581d293612630ec810c11d9d61c
python-openstackclient does this in a wrapper class around Session,
and openstacksdk does something similar that could be removed if support
were directly in keystoneauth.
Add this so that we can remove the custom wrapper/manipulation in
openstackclient and openstacksdk.
Change-Id: Icf00c66f57d20d2cef724c233160d3b1e0d52102
Setting up an Adapter with an endpoint_override, calling
get_endpoint_data() on that adapter, and accessing the `url` @property
of the resulting EndpointData now regurgitates the endpoint_override
initially set on the Adapter.
Change-Id: I1033c97a7b0e19a75fa0d3c5682cf18b75918514
Closes-Bug: #1707993
We expose version_to_string and version_match but not version_between.
openstacksdk would really like to use version_between too for matching
microversion suitability. Turn it in to a public function.
Change-Id: I710f9e1441f4caeb9bd9830f9d4a3398a71249ec
A change introduced in 3.5.0 sorts headers, but runs into a problem
when the headers are bytes, such as the headers provided by the
python-glanceclient.
requests expects headers to be str type in both python2 and python3.
This means in python2 we need to encode unicode objects as ASCII (the
encoding that should be used for HTTP headers) and in python3 we need to
decode bytes as ASCII into str.
Change-Id: Ib81497c3a873616c22ba68256c596a6fb113e11e
Closes-bug: #1766235
The new get_all_version_data call lists 'public' as the default value
for interface, but had None in the arguments. 'public' was the intent,
and is what the similar call on the base auth plugin does.
Change-Id: I5db2b66d0c130ed80b13ee0c41e0e37c6f7234a7
A recent change pushed API status definitions into a class:
I93ee971125bc0c7a497e1fb839df38ebd38340e1
We can reuse this in the tests instead of duplicating the same
string across assertions.
Change-Id: I07a602a05f896d7cc70120bd89424e3c553baf9f
The last piece of service type alias support is to handle volumev2,
volumev3, workflowv2, workflowv3 and friends.
Although it's an annoying scenario, luckily legacy code that uses them
has a clear meaning. volumev2, version='3' is just legit not a thing.
Needed-By: https://review.openstack.org/564494
Change-Id: Iec09bcb16d8e9b09e09bf12d03c2a55e679ad70c
For better readability, make normalize_status a class that has constants
for each of the status values.
While in there, add a test for unknown status values.
Co-Authored-By: Eric Fried <efried@us.ibm.com>
Change-Id: I93ee971125bc0c7a497e1fb839df38ebd38340e1
We're repeating ourselves a bunch with a plain dict that contains the
version data. Make a class to encapsulate it. Make the class a subclass
of dict so that json translation works.
Change-Id: Ic7d122487174a5b0378a8dfaa39514c5cb2a604b
We've got great discovery support, but if someone is wanting to find out
what is available and doesn't otherwise know what they're looking for,
they're out of luck.
Add a method to EndpointData which will return all of the version data
for a given service, and then add a method to the base auth plugin that
will use that method to collect all of the version discovery documents
for every service in the cloud.
This commit adds os-service-types so that the resulting datastructure
can return only official service type keys. A followup patch will also
use os-service-types to allow catalog lookups by service-type alias.
There is a change to the test_identity_common.V2.get_auth_data method
to remove the public and internal urls for keystone from the catalog.
The V3 catalog only has keystone on admin, so this makes them have
equivilent data.
Change-Id: I07243edb939865a5df8b283e7c626874ffd830db
The Service Types Authority has grown support for aliases, and the
os-service-types library exposes the data. Add support for matching
known aliases when matching endpoints for a user.
Change-Id: Ie90c265cb17905981d877abfaaa52354a3e63692
While writing an SDK patch, I accidentaly sent a tuple for interface and
things went boom. We already accept a list, so go ahead and accept
tuples and sets too.
Change-Id: I4b14792c7eda4e489c53fdc95e40bde14a61c052
Create a tox environment for running the unit tests against the lower
bounds of the dependencies.
Create a lower-constraints.txt to be used to enforce the lower bounds
in those tests.
Add openstack-tox-lower-constraints job to the zuul configuration.
See http://lists.openstack.org/pipermail/openstack-dev/2018-March/128352.html
for more details.
Also fix the lower bound for requests-kerberos.
Change-Id: Ie5da1d132321b2cffea3eb8522462daad45900b5
Depends-On: https://review.openstack.org/555034
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
We collect the status when doing discovery, but it's not exposed
anywhere to the use when they look at the EndpointData for an endpoint.
Add a function to normalize the statuses and then add normalized status
to the EndpointData object.
Change-Id: Icf855d7892335b093c1083cd0106946d8911010d
As part of removing reliance on the old and deprecated zuul-cloner, we
need to shift constraints declaration to the deps line. This means we
unfortunately have to duplicate the extras declarations into
test-requirements - because otherwise the contraints for keystoneauth
conflicts with the installation of itself.
Change-Id: If162dde93423a495064c4ae1a5dad4e7eb8f9577
Modify the error message for failed discovery in an attempt to better
help the user fixing the issue.
Include a reference to the actual exception that occured in the
error message. Add SSLError to the list of caught exceptions so that
we can log this case, too.
Add some unit tests to verify the handling of possible exceptions during
version discovery.
Change-Id: I9c26ab35d5515a937e016421e26e844212cb0bb3
Closes-Bug: 1749144
Add the flake8-import-order library to our test requirements so that we
can avoid these PEP8 violations and maintain consistent import ordering.
Also fix our violations.
This library is in requirements but is blacklisted from being
automatically updated since it is never shipped. For now, don't bother
to pin it.
Change-Id: I4e788292b98b7f2f835cc80081763b2d249fe43e
AuthorizationFailure exception class should support
message override
class AuthorizationFailure(base.ClientException):
message = "Cannot authorize API client."
Users will only be able to see the above message
"Cannot authorize API client." which is less useful to debug.
Change-Id: I27ac6ebfb68ba3edad08a5c97b91f4abab9b395f
Closes-Bug: #1745930