47 Commits

Author SHA1 Message Date
Andreas Jaeger
e25df2943d Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Change-Id: Ic161a8f88c28d88898863e5b9d9380016fbb0d08
2020-03-31 12:16:31 +02:00
Gage Hugo
cfcf9ef798 Remove pbr warnerrors in favor of sphinx check
This change removes the unused "warnerrors" setting that
was part of [pbr], which was replaced by "warning-is-error"
in sphinx 1.5 and above[0]. This also fixes any warnings
and errors that came up when running `tox -edocs` using
this new feature:

 - Specified correct instance of 'List'

This change also adds the "warning-is-error" setting
to setup.cfg in order to allow for strict doc validation
which will cause doc building to fail if any warnings
are thrown.

[0] http://lists.openstack.org/pipermail/openstack-dev/2017-March/113085.html

Change-Id: I8111193e5a1ae7d063ab4cc37186aea1299964a4
2017-04-24 16:28:06 -05:00
Navid Pustchi
a9adca02db Fixing D204, D205, and D207 PEP257 violation.
Currently tox ignores D204, D205, and D207.
D204: 1 blank required after class docstring.
D205: Blank line required between one-line summary and description.
D207: Docstring is under-indented.
This change removes  D204, D205, and D207 ignores in tox and fix violations.

Change-Id: Id20d216fbd7647d468859b960088aac61c582d9b
2016-05-04 19:30:03 +00:00
Navid Pustchi
946e928b52 Fix D401 PEP257 violation.
Currently tox ignores D401.
401: First line should be in imperative mood.
This change removes it and make keystoneclient docstrings compliant with it.

Change-Id: If34ff12d18390b357342cf29f2d116dd3c86a44d
2016-04-23 06:25:20 +00:00
Jamie Lennox
bdd44d3142 Map keystoneclient exceptions to keystoneauth
To allow people to use a keystoneauth session with keystoneclient we
need to make it so that any exceptions that keystoneclient catch are the
same as what keystoneauth might throw.

The only practical way to do this is to map the keystoneclient
exceptions onto the keystoneauth equivalents. This is fairly easy as all
these exceptions were extracted from keystoneclient initially.

Closes-Bug: #1515048
Change-Id: I3b74b0ba1e1f9dda937a2d90e2d75ff0b7597a9b
2015-11-19 13:35:18 +11:00
lin-hua-cheng
c45fd909c3 Adding back exception mapping for ConnectionError
The mapping for ConnectionError to ConnectionRefused have been
remove in a recent cleanup to move all exception to
keystoneclient.exceptions

related commit: 26534dadb1d0be00b87b632a038839ab1c18cfe4

Adding the mapping back for backward compatability.

Change-Id: I6f4627b9cd68615b509d17910fe2c1605e89fc26
Closes-Bug: #1492600
2015-09-08 16:42:04 -07:00
Brant Knudson
26534dadb1 oslo-incubator apiclient.exceptions to keystoneclient.exceptions
Applications are using exceptions out of
keystoneclient.openstack.common.apiclient.exceptions so it's part
of the public interface. But since it's from oslo-incubator it's
not considered stable. Since keystoneclient is all stable this
creates bad situation.

With this change, all the symbols out of apiclient.exceptions are
moved into keystoneclient.exceptions rather than the other way
around (keystoneclient.exceptions used to re-export all of
apiclient.exceptions). Now we're in control of the
apiclient.exceptions and keystoneclient.exceptions that
applications are using.

Closes-Bug: 1481806
Change-Id: Ib3afa86b9d276f6a45d1ecd6f9157ee02ec8570d
2015-08-05 14:59:23 +00:00
Jamie Lennox
0ecf9b1ab5 Add get_communication_params interface to plugins
To allow authentication plugins such as using client certificates or
doing kerberos authentication with every request we need a way for the
plugins to manipulate the send parameters.

Change-Id: Ib9e81773ab988ea05869bc27097d2b25e963e59c
Blueprint: generic-plugins
2015-05-26 17:05:09 +10:00
Rodrigo Duarte Sousa
14ace4a5de Implements subtree_as_ids and parents_as_ids
This patch implements the new ways to get the project's hierarchy:
  'subtree_as_ids': If True, returns projects IDs down the hierarchy
                    as a structured dictionay.
  'parents_as_ids': If True, returns projects IDs up the hierarchy
                    as a structured dictionay.

Change-Id: Ia3afe994893dfca059cb8361f7ab1c14e28e1ad5
Implements: blueprint hierarchical-multitenancy-improvements
2015-03-13 17:02:39 -03:00
Jamie Lennox
c57e562d2b Add name parameter to NoMatchingPlugin exception
If you want to handle a NoMatchingPlugin exception rather than simply
exit then the name of the missing plugin is generally more useful than
the message.

The exception is specific enough that you can know what went wrong, but
you cannot determine the name of the missing plugin if you want to do
your own logging - only use the message that is generated.

We should keep the message but expose the plugin name as well.

Closes-Bug: #1410391
Change-Id: Ic93ec6583b8d7797529d36d63995ef0d8db754f1
2015-02-02 09:23:39 +11:00
Jenkins
2e900a9347 Merge "Cleanup docs - raises class" 2014-11-18 19:18:13 +00:00
Brant Knudson
fece74ca3e I18n
Keystoneclient didn't provide translated messages. With this
change, the messages are marked for translation.

DocImpact

Implements: blueprint keystoneclient-i18n

Change-Id: I85263a71671a1dffed524185266e6bb7ae559630
2014-10-28 20:33:19 +00:00
Brant Knudson
3b766c5143 Correct use of noqa
The use of "#flake8: noqa" disables hacking checks for the entire
file. Switched to use of "# noqa" and fixed hacking problems.

Change-Id: I18785fb18bdce88e61e2451960e55aed0863c285
2014-10-27 16:55:39 -05:00
Brant Knudson
14a6d80116 Cleanup docs - raises class
The argument to the :raises: directive is the class name. If the
class name is a valid reference it's rendered as a link to the
class. This change cleans up the :raises: directives to use the
reference correctly and use a valid class reference.

Change-Id: I84188b60de0ab4c6b5b2fb5a203c43bfde094707
2014-10-18 17:59:08 -05:00
Dolph Mathews
a15c8bcb49 remove useless part of error message
also did a bit of code cleanup for consistency

Change-Id: I48832c36e1a8b5a0029598dc74aaeaa3b3d2a66f
2014-07-15 12:43:25 -05:00
Rodrigo Duarte Sousa
0b0d2d3a9a Add /role_assignments endpoint support
This patch adds role assignments list support
to keystoneclient.

Created RoleAssignment resource and RoleAssignmentManager
classes. RoleAssignmentManager only implements the list()
method, the other inherited methods from base.CrudManager
raises a MethodNotImplemented error with customized messages.

This bp is complimented with the OSC part:
https://blueprints.launchpad.net/python-openstackclient/+spec/roles-assignment-list

Change-Id: I164b58b67ff42320238e943ddfa9d0a8aadd0a6d
Implements: blueprint roles-assignment-support
Closes-Bug: #1246310
2014-05-27 14:08:50 +00:00
Adam Young
3d6d749e6f Compressed Signature and Validation
Allows for a new form of document signature.

pkiz_sign will take data and encode it in a string that starts with
the substring  "PKIZ_".  This prefix indicates that the data has been:
1) Signed via PKI in Crypto Message Syntax (CMS) in binary (DER) format
2) Compressed using zlib (comparable to gzip)
3) urlsafe-base64 decoded

This process is reversed to validate the data.

middleware/auth_token.py will be capable of validating Keystone
tokens that are marshalled in the new format.  The current existing
"PKI" tokens will continue to be identified with "MII", issued by
default, and validated as well.  It will require corresponding changes
on the Keystone server to issue the new token format.

A separate script for generating the sample
data used in the unit tests,
examples/pki/gen_cmsz.py,
also serves as an example of how to
call the API from Python code.

Some of the sample data for the old tests had to be regenerated. A
stray comma in one of the JSON files made for non-parsing JSON.

Blueprint: compress-tokens
Closes-Bug: #1255321

Change-Id: Ia9a66ba3742da0bcd58c4c096b28cc8a66ad6569
2014-05-09 11:48:17 -07:00
Jamie Lennox
4a81a14685 Add new error for invalid response
There are a number of places where we expect a certain format of
response. If it's not found we often end up raising a KeyError when
accessing data.

Create a new Exception type that is raised when a HTTP response is not
appropriate for parsing and use it within authentication calls.

Closes-Bug: #1307306
Change-Id: I3cf2db07a8e76ee17702130e9efb0edf640d293a
2014-04-15 09:41:33 +10:00
Jamie Lennox
ce92f37f0b Rename HTTPError -> HttpError
With the move to the apiclient exceptions from oslo the basic HTTP error
class was renamed. This was not reflected in all places in the code.

It was also not picked up by the tests because the apiclient tests
weren't running due to a missing __init__.py file. Because this should
be backwards compatible it was added to the list in exceptions, the
check that this is available is in the (now running) apiclient tests.

Blueprint: common-client-library-2
Change-Id: I307c1083f29e3207cc86aa938043270e5c32b4bb
2014-04-15 09:38:20 +10:00
Andrey Kurilin
61544f01d4 Reuse module exceptions from Oslo
The exception module in oslo common code and in keystoneclient are similar.
In case of unification openstack clients, we should use modules from Oslo.

Changes of this patch:
- imported exceptions from common code instead of `apiclient.exception`
- added aliases for exceptions which was renamed
(reason: backwards compatibility)
- moved exceptions `EmptyCatalog` from `apiclient.exception` to `exceptions`
- cleaned `apiclient.exception` from duplicated exceptions
- `apiclient.__init__` and `apiclient.exceptions` are kept and labeled as
'deprecated'(reason: backwards compatibility)

bp common-client-library-2

Change-Id: Iedf4e5d753d4278d81751ba0f55fdef3566b56de
2014-04-01 08:26:47 +03:00
Jamie Lennox
96b8e81b1d Create V2 Auth Plugins
Extract the authentication code from a v2 client and move it to a series
of auth plugins. Auth plugins each represent one method of
authenticating with a server and there is a factory method on the base
class to select the appropriate plugin from a group of arguments.

When a v2 client wants to do authentication it will create
a new v2 auth plugin, do the authentication and then take that result
for the client to use.

Change-Id: I4dd7474643ed5c2a3204ea2ec56029f926010c2c
blueprint: auth-plugins
2014-02-21 12:31:35 +10:00
Eric Guo
d6d0d66374 Remove vim header
We don't need vim modelines in each source file, it can be set in
user's vimrc.

Change-Id: Ic7a61430a0a320ce6b0c4518d9f5d988e35f8aae
Closes-Bug: #1229324
2014-02-08 22:22:08 +08:00
Jamie Lennox
96267731ec Create Authentication Plugins
Provides the framework for creating authentication plugins and using
them from a session object.

To allow this system to co-exist with the original client there is a bit
of a hack. The client object itself is now also an authentication
plugin, that supports the original client pattern. If a client is
created without a session object then that session object uses the
client as it's authentication plugin.

Change-Id: I682c8dcd3705148aaa804a91f4ed48a5b74bdc12
blueprint: auth-plugins
2014-02-04 14:29:15 +10:00
Jamie Lennox
fd0a176a49 Discover supported APIs
Allow discovery of the API versions a server supports and create an
appropriate client based on this.

Implements: blueprint api-version-discovery
Change-Id: I63e6759889066a784dc47e35152c82e1ead7951d
2013-12-03 12:00:03 +10:00
Jamie Lennox
2c5dcf9bf1 Extract a base Session object
A wrapper around a number of connection variables. This will be extended
later with principals such as Kerberos authentication and http sessions.

The intent is that this session object will become the basis for all
other client library communications in OpenStack (as keystone wants to
control things like authentication for everybody).

Change-Id: I8ee728c49d554659d7057ebf17d0f8ceea4d7d8e
Part of: blueprint auth-plugins
2013-11-28 09:20:43 +10:00
Lei Zhang
0c8faa3efc Migrate the keystone.common.cms to keystoneclient
- Add checking the openssl return code 2, related to following review

  https://review.openstack.org/#/c/22716/

- Add support set subprocess to the cms, when we already know which
  subprocess to use.

Closes-Bug: #1142574
Change-Id: I3f86e6ca8bb7738f57051ce7f0f5662b20e7a22b
2013-10-28 23:35:56 +08:00
Jenkins
9edf7d0336 Merge "Add apiclient.exceptions hierarchy" 2013-08-30 21:01:00 +00:00
Morgan Fainberg
35deb1ae1b Fix License Headers and Enable Gating on H102
Add ASLv2 headers to files that were missing it.

fixes bug #1211587

Change-Id: Iede918e1ce84993cee4ecbb2d9c2606627fa412e
2013-08-27 00:04:03 -07:00
Alessio Ababilov
fba0cd51d9 Add apiclient.exceptions hierarchy
The new apiclient.exceptions hierarchy is more comprehensive
and it covers almost all HTTP error status codes. These
exceptions can be used in novaclient, keystoneclient,
glanceclient, and other client projects thus providing a
single inteface.

Users can have benefit from OpenStack clients raising exceptions
of known classes while now every client has its own classes making
difficult to catch, e.g., NotFound for every client.

Change-Id: Ia7b25880e0ffca3526525a0f0e77c7e77c4f0076
2013-08-20 14:03:26 +03:00
Dirk Mueller
dc5c33a9e5 Fix and enable Gating on H404
Enable gating on the Hacking H404 check - docstring
should start with a summary.

Change-Id: I80612a15bd11f689e9e9f4dc2ff812138630ddbd
2013-08-15 20:35:35 -07:00
Jamie Lennox
d454676cf8 Extract basic request call
Create a function out of the standard request call that handles common
headers like user agent and logging.
This makes future changes easier to digest.

Change-Id: Ia25f997df64efdce27c8fb815e544922940145c3
2013-08-12 14:19:23 +10:00
Dirk Mueller
ad73bfd2c7 Fix and enable gating on H403
Only a few occurrences of "multiline docstrings
should end on a new line."

Change-Id: I3fb4591259b1e7c8202365cbadc8967a1639254f
2013-07-13 00:45:58 +02:00
Dirk Mueller
f2ad113d1c Fix and enable gating on H402
Docstring summaries need punctuation.

Change-Id: I1b740c13d5fedf9a625ca0807c908f651ee08406
2013-07-12 09:36:07 +02:00
Dirk Mueller
fe8f9023ac Fix and enable H401
Remove leading spaces from doc comments.

Change-Id: I75b055c0d64dda478c63839d44158e301900107f
2013-06-27 01:28:30 +02:00
Kannan Manickam
d10218ff29 Added Conflict Exception to the exception code map
The Conflict Exception is added for HTTP error code 409.
However this exception is never raised as this class is not added to
the error_code map and always raises the ClientException whenever a
409 code is returned.

Fixes bug #1168826

Change-Id: I7045eae33533ff603f4aab61ea988264b46f0d09
2013-05-07 10:56:59 +05:30
Jenkins
acdba5ee52 Merge "Add name arguments to keystone command." 2013-02-13 08:27:39 +00:00
Lin Hua Cheng
382441a9f1 Treat HTTP code 400 and above as error.
Fixes bug 1116559.

Change-Id: I4b12176599686f7e545b63c8e54cf9da6a1f963e
2013-02-05 11:30:27 -08:00
Ken'ichi Ohmichi
9351665062 Add name arguments to keystone command.
This patch adds name arguments to the following subcommands:
  * role-delete
  * role-get
  * service-delete
  * service-get
  * tenant-delete
  * tenant-get
  * tenant-update
  * user-delete
  * user-get
  * user-password-update
  * user-role-add
  * user-role-list
  * user-role-remove
  * user-update

Fixes bug 1100648

Change-Id: I73c08c0ba553a72ec57ff3a684a00be4ef1294a6
2013-01-17 18:11:27 +09:00
Dean Troyer
51dc6a0cef Use requests module for HTTP/HTTPS
* Implement correct certificate verification
* Add requests to tools/pip-requires
* Fix OS_CACERT env var help text
* Add info to README
* Rework tests to use requests

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

Change-Id: I120d2c12d6f20ebe2fd7182ec8988cc73f623b80
2012-12-18 15:30:43 -06:00
Dolph Mathews
1b7eca8349 Merge remote-tracking branch 'origin/feature/keystone-v3' into HEAD
Conflicts:
	tests/v2_0/test_tenants.py

Change-Id: I37037e60210edd574da86b1dc07aa73e6761e338
2012-10-30 22:22:17 +00:00
Gabriel Hurley
0dfc69806d Don't log an exception for an expected empty catalog.
Cleans up the code around exception handling and logging
when first authenticating (which often returns an unscoped token).
There's no need to be logging an exception on an expected empty
catalog and moreover the except block was a bare "except" which
could mask other errors.

Fixes bug 1070493

Change-Id: I5e791e95ce3f9ab77723a7f4698cb11b169dacfb
2012-10-23 11:27:43 -07:00
Dolph Mathews
46360085eb v3 Domain/Project role grants
Change-Id: Idbe0702b42603d6f9f133c9f1855ea9b4f222066
2012-10-09 22:58:29 +00:00
Bhuvan Arumugam
15d134d130 Handle "503 Service Unavailable" exception.
Bug: 1028799

No traceback, if service is unavailable; error out gracefully.

* keystoneclient/exceptions.py
  ServiceUnavailable: New class to handle 503 status code.
  Add the new class to list of handled exceptions.

Change-Id: I39a8ac594ef922d682731a926be26c8b6f648f9d
2012-09-24 19:21:58 +00:00
Joe Heck
52b392281e pep8 1.1 changes and updates
Change-Id: I8bc3582bb3f35a3d841bb1e8c03b62ba61ff92d7
2012-06-01 18:07:26 -07:00
Gabriel Hurley
6c164d2fe0 Improved error message when unable to communicate with keystone. 2011-12-07 13:05:13 -08:00
Gabriel Hurley
0c2a521974 Improved logging/error messages. 2011-11-17 14:25:04 -08:00
Gabriel Hurley
17f6b83ee6 Initial commit. 2011-10-25 16:50:08 -07:00