43 Commits

Author SHA1 Message Date
Davanum Srinivas
06d9437e83 Work better in server env with no keyrings
We should not try loading keyrings if we dont' have to. We
certainly should not print messages if keyrings are not even
needed

Fix for LP# 1145071

Change-Id: I700a2b40620359f6f1fbe03c6a6239d162ddea61
2013-03-04 14:47:49 -05:00
Chmouel Boudjnah
b3b6a85048 Fix selef to self in class.
Change-Id: I1fec9908fb1aa915158996d57fdd82cfdf483535
2013-02-20 08:48:14 +01:00
Jenkins
f9e1ba8e64 Merge "Implements token expiration handling" 2013-02-19 18:34:47 +00:00
Jenkins
7a33cc0100 Merge "If you specify the --debug argument, it doesn't show the body of a POST request. The body (string rep) is at 'data' in the kwargs dict. 'body' was deleted prior to this call." 2013-02-16 10:58:37 +00:00
Chmouel Boudjnah
1ba04810e9 Fix debug with requests.
- From http://docs.python.org/2/library/functions.html#hasattr :
   hasattr(object, name) -- The arguments are an object and a string.
- Fixes bug 1124084.

Change-Id: I47283abff440abdf827598c2497519f3de510baf
2013-02-13 16:02:48 +01:00
Chuck Short
b998ff9252 Allow requests up to 0.8 and greater
The requests module dropped all configuration with the 1.0.0 release.
There's no danger_mode and no 'verbose'' mode. The former
shouldn't be necessary anymore and the latter can be done by setting
a different log handler for the request.logging root logger.

Change-Id: I41bfaf2574f6d7fc21f86e0124ceae7df6481eee
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-02-11 12:29:39 -06: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
Julien Danjou
0173560864 Implements token expiration handling
This implements handling of token expiration. Once the token is expired,
this will request automatically for a new one.

A special case is introduced if the user specified a token when the client
is initialized: this is the auth_token_from_user. In this case, we can't
know the expiration date, so we just assume it will never expire and don't
handle it ourself.

Change-Id: I3771ff5d669da015d4aa259de422c5d81aed3eb4
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-02-01 10:27:52 +01:00
Jenkins
2e0ed7fe7b Merge "Remove useless code" 2013-01-24 22:06:24 +00:00
Ruby Loo
e0c3e30653 If you specify the --debug argument, it doesn't show the body of a POST request. The
body (string rep) is at 'data' in the kwargs dict. 'body' was deleted prior to this call.

Change-Id: Ieea3d11f5246ee785e41df3bc54ac61200808354
Fixes: bug #1104313
2013-01-24 21:42:14 +00:00
Julien Danjou
ca348fe951 Remove useless code
- There's no need to call parent init function since that's the default
  behaviour.
- The token attribute is nor used nor updated anywhere.

Change-Id: Ib0b2729a396a2d761931ce0e178c49c49814eb21
Signed-off-by: Julien Danjou <julien@danjou.info>
2013-01-23 15:15:30 +01:00
Joshua Harlow
d2edaab531 Allow request timeout to be specified.
Add a new cli argument (--timeout) which
is by default 600 seconds which will be
set in the requests library so that timeouts
can occur correctly.

Change-Id: I845c55dfb6f6b8345663ccdb5b150a2655f20026
2013-01-18 19:11:24 -08:00
Jenkins
882414d807 Merge "Use requests module for HTTP/HTTPS" 2012-12-20 19:07:53 +00: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
Dan Prince
716fc4b48a Print to stderr when keyring module is missing.
Updates keystoneclient so that it uses a print statement to
stderr instead of a logger.warn if stderr is a tty.
This works around problems caused by the fact that logging isn't always
initialized when this module import runs (and fails) thus causing:

  No handlers could be found for logger "keystoneclient.client"

instead of the intended log message.

Fixes LP Bug #1090396

Change-Id: I94e2c45eec14edfe3c2f356af6907aa827808a13
2012-12-14 16:05:30 -05:00
Dan Prince
93d243147e Make use_keyring False by default.
Updates the use_keyring option for the Keystone Client class
to default to False by default. This provides for a much
easier upgrade path the the most recent keystone-client code
and is backwards compatible with the previous release.

This does not change the default of the no_cache keystone CLI
which will still enable use_keyring by default.

Fixes LP Bug #1087434.

Change-Id: Iaafadde660b0542a9c0a9c1bb742cb369b523a68
2012-12-06 15:37:50 -05:00
Guang Yee
5939541bc7 bug-1040361: use keyring to store tokens
User can optionally turn off keyring by specifying the --no-cache option.
It can also be disabled with environment variable OS-NO-CACHE.

Change-Id: I8935260bf7fd6befa14798da9b4d02c81e65c417
2012-12-04 09:18:20 -08:00
Derek Higgins
1f6a0af9c1 Add command to allow users to change their own password
Fixes Bug 1082539

The Equivalent of doing
curl -X PATCH http://localhost:5000/v2.0/OS-KSCRUD/users/<userid> \
    -H "Content-type: application/json"  \
    -H "X_Auth_Token: <authtokenid>" \
    -d '{"user": {"password": "ABCD", "original_password": "DCBA"}}'

Change-Id: Ia1a907c5fd138c4252196145b361f43671047a1a
2012-11-27 09:14:14 +00:00
Joe Heck
1a35545db3 fixes auth_ref initialization error
bug 1078589

* allow client values to be overridden, but use auth_ref if none
  available
* added tests to match this flow
* refactored tokens into test_fixtures.py file

Change-Id: I771a2dee6dedf31d883417d9b4e6e64bbb620f14
2012-11-15 17:07:04 +00:00
Joe Heck
f1cc3cfc42 removing repeat attempt at authorization in client
blueprint solidify-python-api

* extended and updated documentation strings
* updated README.rst with latest options
* made debug a pass-through value, optionally set on client (instead of
  just being pulled from environment variable)
* adding AccessInfo object and associated tests
  (access.AccessInfo meant to be a cacheable object external to client
  and ultimately to replace service_catalog and it's existing functionality)
* extending authtoken to support lists of endpoints
* maintaining a single entity for client.management_url with first from
  list of possible endpoints
* create project_name and project_id synonyms to match tenant_name and
  tenant_id
* replacing authenticate call to a pure method, not overloading the
  resource/manager path that confuses base URL concepts.
* throw AuthorizationFailure if client attempts to access keystone
  resources before it has a management url
* special case listing tenant using auth_url for unscoped tokens authorized
  through client
* special case listing tokens.authenticate for Dashboard to allow unscoped
  tokens to hand back parity information to dashboard

Change-Id: I4bb3a1b6a5ce2c4b3fbcebeb59116286cac8b2e3
2012-11-09 00:02:41 +00:00
Jenkins
b6f1b619d6 Merge "Replace refs to 'Keystone API' with 'Identity API'" 2012-11-06 06:12:53 +00: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
Dolph Mathews
5f38eb736c Replace refs to 'Keystone API' with 'Identity API'
Formally, OpenStack Keystone implements the OpenStack Identity API, and
this is a client to the API, not to Keystone itself.

Change-Id: If568866221a29ba041f0f2cd56dc81deeb9ebc00
2012-10-24 07:21:47 -05:00
Ionuț Arțăriși
56a4e4bd7d add a new HTTPClient attr for setting the original IP
The original IP is useful in cases where keystoneclient is used by a
different openstack component and we need to know who made the original
request. Otherwise it gets overwritten by e.g. Dashboard's host's IP.

bug 1046837

Change-Id: Ic22c565e92010afd89c8573c375919215b70d73d
2012-10-22 17:47:26 +02:00
Jay Pipes
a6102fe0b9 Ensure JSON isn't read on no HTTP response body
This patch moves the json.loads(body) call in the
HTTP response handling to after the check for non-
200-300 return codes. This gets rid of the
ValueError exception raise when you hit, for instance,
a 400 or 404.

Also changes a number of logger.exception() calls to
logger.debug() calls, since some exceptions are expected
and should not be logged as exceptions per-se.

fixes LP bug#1067512

Change-Id: If66fb1846ddc19da5bc2f15c6e0dd09019a56932
2012-10-17 14:52:48 -04:00
Dolph Mathews
e259597245 Allow serialization impl to be overridden
Change-Id: I0f955c78897d4212f06942e59a7018dbe5d28540
2012-09-11 11:10:40 -05:00
Dolph Mathews
b91cdf492a Add support for HEAD and PATCH
Change-Id: Ic874c49b791e9d2cb3d44b15511cbb467a551589
2012-09-11 11:06:54 -05:00
Joe Heck
869192654c splitting http req and resp logging
also some pep8 cleanup in shell.py

Change-Id: I71aa2586a0196c0a6ba64b892b56c9d221bdcc1d
2012-08-23 16:09:38 +00:00
Sascha Peilicke
dec8f77c92 Add '--insecure' commandline argument
Allows to ignore validation errors that typically occur with self-signed
SSL certificates. Making this explicit is important as one would
typically only use this in development or in-house deployments.

This should also fix bug 1012591.

Change-Id: I1210fafc9257648c902176fbcfae9d47e47fc557
2012-07-20 10:22:03 +02:00
Liem Nguyen
abc7c47c18 Support 2-way SSL with Keystone server if it is configured to enforce
2-way SSL.  See also https://review.openstack.org/#/c/7706/ for the
corresponding review for the 2-way SSL addition to Keystone.

Change-Id: If0cb46a43d663687396d93604a7139d85a4e7114
2012-07-03 17:26:34 -04:00
Josh Kearney
5628eeaf76 Removed unused imports and variables.
Also fixes AUTHORS file. Previous version was copied directly from python-novaclient.

Change-Id: I33654b6fe7197efbff300ebaf4892a8b53d85c54
2012-04-05 17:27:12 -05:00
Dolph Mathews
9c07999dd5 Removed ?fresh=nonsense (bug 936405)
Change-Id: I69f7411967ef23348854c206efc79a3cf7d3755d
2012-03-07 10:32:32 -06:00
Vishvananda Ishaya
587862c151 Allow --token and --endpoint to bypass catalog
* allows skipping of service catalog
 * removes odd logic about password equivalence
 * also removes extra call to authenticate

Change-Id: I5c0979107da99593b4ce8eb16c9695ba530da095
2012-02-08 22:04:41 -08:00
Dean Troyer
173ea0ce0e Blueprint cli-auth: common cli args
Remove os_ from internal variable names corresponding to OS_ env
variables.

Strip trailing '/' from --auth_url since server doesn't seem to
tolerate '//' in the URL path.

Fixes lp923920

Change-Id: I3e48441d63b6504fd088aa07241f66d63590d935
2012-02-02 16:43:20 -06:00
Jesse Andrews
f765daf336 finish removing project_id 2011-12-19 10:00:39 -08:00
Jesse Andrews
55c01652b2 remove print statements and uncomment exceptions 2011-12-17 22:48:37 -08:00
Jesse Andrews
a8001d3e6c more work on standardization of cliauth 2011-12-17 22:36:59 -08:00
Jesse Andrews
0f392a58c3 remove user_id as you shouldn't auth using it 2011-12-17 22:28:31 -08:00
Jesse Andrews
cfbebeeae0 initial pass to cliauth blueprint 2011-12-17 22:07:13 -08:00
Gabriel Hurley
0c2a521974 Improved logging/error messages. 2011-11-17 14:25:04 -08:00
Joe Heck
5788d215e9 more pep8 cleanup 2011-11-10 17:24:48 -08:00
Gabriel Hurley
2cb99fccfe Project ID always treated as a string.
Keystone chokes on authorization if the project id is sent as an integer, so we'll cast it to a unicode string on our end.
2011-10-31 15:41:05 -07:00
Gabriel Hurley
17f6b83ee6 Initial commit. 2011-10-25 16:50:08 -07:00