1531 Commits

Author SHA1 Message Date
Eric Fried
51bfa030b1 raise_exc default in Adapter
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
2018-06-12 10:48:39 -05:00
Zuul
36ed4c11cb Merge "fix tox python3 overrides" 2018-06-09 04:24:09 +00:00
Doug Hellmann
3cca1f4eb0 fix tox python3 overrides
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>
2018-06-06 15:27:00 -04:00
Dmitry Tantsur
3c2cf44e1c Add optional support for retrying certain HTTP codes
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
2018-05-29 14:54:56 +02:00
Zuul
db5aa8b3ae Merge "Expose version_between as a real function" 2018-05-17 21:06:53 +00:00
Zuul
c3ef1a11b5 Merge "Add oslo.config option for split-loggers" 2018-05-17 21:06:52 +00:00
Zuul
cc912f0500 Merge "Collect timing information for API calls" 2018-05-17 21:06:52 +00:00
Zuul
775550d256 Merge "Return the endpoint_override from EndpointData" 2018-05-16 21:52:28 +00:00
Monty Taylor
80323289c7
Add oslo.config option for split-loggers
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
2018-05-16 15:42:03 -05:00
Monty Taylor
244780fba8
Collect timing information for API calls
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
2018-05-16 15:41:59 -05:00
Eric Fried
8a963de05a
Return the endpoint_override from EndpointData
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
2018-05-16 10:30:48 -05:00
Monty Taylor
9e45781eab
Expose version_between as a real function
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
2018-05-15 15:11:12 -05:00
Brian Rosmaita
35de6ebe93
Fix logging of encoded headers
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
2018-05-15 09:29:43 -05:00
Monty Taylor
0bebdaf0f9
Fix interface argument to get_all_version_data
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
2018-05-10 19:02:46 -05:00
Zuul
c0d5157157 Merge "Reference class variable in Status" 2018-05-08 20:37:19 +00:00
Zuul
3308cd9944 Merge "Infer version from old versioned service type aliases" 2018-05-08 15:40:15 +00:00
Lance Bragstad
861b0f434f Reference class variable in Status
This is trivial change to use an existing class variable instead
of redefining a string.

Change-Id: Ic4fbbc3b735a30babdfee74225975152476196e3
2018-05-03 20:30:02 +00:00
Lance Bragstad
9688b7938b Use Status variables in tests
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
2018-05-03 20:29:54 +00:00
Monty Taylor
5c79260971
Infer version from old versioned service type aliases
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
2018-05-03 15:28:54 -05:00
Monty Taylor
4629e3c944
Turn normalize_status into a class
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
2018-05-03 15:28:54 -05:00
Monty Taylor
57f9736329
Make VersionData class
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
2018-05-03 15:28:54 -05:00
Monty Taylor
d6670ee5c9
Add methods to get all of the version data
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
2018-05-03 15:28:54 -05:00
Monty Taylor
79cd91e755
Implement service_type alias lookups
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
2018-05-03 15:28:50 -05:00
Zuul
7b297d48b2 Merge "fix a typo in session.py" 2018-05-02 18:39:56 +00:00
Zuul
5ed2c5a51f Merge "Trivial: Update pypi url to new url" 2018-05-02 16:19:32 +00:00
Zuul
3c118a43b3 Merge "Allow tuples and sets in interface list" 2018-05-01 21:58:31 +00:00
XiaojueGuan
d692b1b680 Trivial: Update pypi url to new url
Change-Id: I226e5df7d6bab44da643d3861f5e5b02612250bc
2018-05-01 15:25:26 +00:00
Monty Taylor
2e209e917d
Allow tuples and sets in interface list
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
2018-04-26 11:42:14 -05:00
Zuul
33ccb19557 Merge "Expose version status in EndpointData" 2018-04-25 16:40:07 +00:00
Doug Hellmann
f41e304849 add lower-constraints job
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>
2018-04-19 09:54:28 +02:00
Monty Taylor
43c6e378f9
Expose version status in EndpointData
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
2018-04-13 10:47:35 -05:00
Monty Taylor
0c6094631a
Fix W503 line-break-before-binary-operator
This just started happening. It's only two places though, so just fix
them.

Change-Id: I00ae56543a2a9f24e35744bb35e7984edc2712d2
2018-04-13 10:47:35 -05:00
Zuul
a37d9f6151 Merge "Be more helpful when version discovery fails" 2018-03-28 18:39:57 +00:00
melissaml
2efa5f78f3 fix a typo in session.py
Change-Id: I7638ad73506945cf6e029c518af864023261be70
2018-03-26 16:03:03 +08:00
Zuul
904fb5b2a0 Merge "Remove tox_install.sh and align with constraints consumption" 2018-03-23 22:00:02 +00:00
Monty Taylor
8ece7fcf2d Remove tox_install.sh and align with constraints consumption
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
2018-03-23 19:15:31 +01:00
OpenStack Proposal Bot
f04d1d0ed6 Updated from global requirements
Change-Id: I9bb8a55936d85d75631d7d729e5205e9faf3c024
2018-03-23 01:02:37 +00:00
Jens Harbott
26cb0f6fcb Be more helpful when version discovery fails
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
2018-03-21 09:17:01 +00:00
Zuul
f8a1f0d5a5 Merge "Updated from global requirements" 2018-03-18 17:48:45 +00:00
OpenStack Proposal Bot
ce78397bff Updated from global requirements
Change-Id: I02b333b1cf75419bfad64159976f5aba0f304125
2018-03-15 07:03:34 +00:00
melissaml
d9734a916d Update links in README
Change the outdated links to the latest links in README

Change-Id: Ic40cb694eb1096cfa8723863f761e837f5d0366b
2018-03-11 02:05:53 +08:00
Zuul
80bfea8b3b Merge "Override support message in AuthorizationFailure class" 2018-02-24 02:50:33 +00:00
Zuul
f6dfa0528e Merge "Add pep8 import order validation" 2018-02-15 22:29:28 +00:00
Zuul
cc99aa90a3 Merge "Remove PYTHONHASHSEED setting" 2018-02-15 21:23:04 +00:00
Zuul
a516fdb176 Merge "Add some comments explaining split_loggers flag logic" 2018-02-15 21:14:29 +00:00
Zuul
43698b65c9 Merge "Split request logging into four different loggers" 2018-02-15 21:14:28 +00:00
Colleen Murphy
8bd6312ebc Add pep8 import order validation
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
2018-02-15 20:07:04 +01:00
deepak_mourya
6c309e2bc2 Override support message in AuthorizationFailure class
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
2018-02-12 12:14:38 +05:30
zhangzs
bf6289b7f5 Fix a spelling error
Change-Id: I851801b858378a3702a136714abddb1446415a35
2018-02-08 08:36:28 +08:00
Zuul
96de6d3376 Merge "Zuul: Remove project name" 2018-02-07 01:08:55 +00:00