37 Commits

Author SHA1 Message Date
Dean Troyer
f079b5b9c4 Change --os-auth-plugin to --os-auth-type
User's don't know what a plugin is.

* Internally, os_auth_type and/or auth_type represents what the
  user supplied.
* auth_plugin_name is the name of the selected plugin
* auth_plugin is the actual plugin object

Plugin selection process:
* if --os-auth-type is supplied:
  * if it matches against an available plugin, done
  * (if it can map to an availble plugin type, done; TODO in a followup)
* if --os-auth-type is not supplied:
  * if --os-url and --os-token are supplied, select 'token_endpoint'
  * if --os-username supplied, select identity_api_version + 'password'
  * if --os-token supplied, select identity_api_version + 'token'

Change-Id: Ice4535214e311ebf924087cf77f6d84d76f5f3ee
2014-10-23 15:37:44 -05:00
Dean Troyer
2166d7d3af Remove ClientManager._service_catalog
Anything that needs a service catalog can get it directly from
auth_ref.service_catalog, no need to carry the extra attribute.

ClientManager.get_endpoint_for_service_type() reamins the proper
method to get an endpoint for clients that still need one directly.

Change-Id: I809091c9c71d08f29606d7fd8b500898ff2cb8ae
2014-10-18 00:01:52 -05:00
Dean Troyer
0de67016c7 Remove now-unnecessary client creation hacks
Clients that can use ksc Session don't need the old junk to
fake auth anymore:
* compute
* volume

Clients that still need to be fed credentials can pick directly
from the auth object in clientmanager.  The _token attribute is
removed, the token can be retrieved from the auth object:

  openstackclient/tests/common/test_clientmanager.py

This change will break any plugin that relies on getting a token
from instance._token. They should be updated to use the above, or
preferable, to use keystoneclient.session.Session to create its
HTTP interface object.

Change-Id: I877a29de97a42f85f12a14c274fc003e6fba5135
2014-10-18 00:01:45 -05:00
Jenkins
68130fa921 Merge "Add plugin to support token-endpoint auth" 2014-10-17 23:27:28 +00:00
wanghong
deda023314 use jsonutils in oslo.serialization instead of keystoneclient
keystoneclient/openstack/common/jsonutils.py is removed in this patch
https://review.openstack.org/#/c/128454/
Now, we should use jsonutils in oslo.serialization package.

Change-Id: I7c8e8e6d5dffa85244368fd578616c9b19f4fd21
2014-10-17 14:13:32 +08:00
Jenkins
fa9cdef874 Merge "Add 'command list' command" 2014-10-14 22:23:20 +00:00
Dean Troyer
c3c6edbe8a Add plugin to support token-endpoint auth
The ksc auth plugins do not have support for the original
token-endpoint (aka token flow) auth where the user supplies
a token (possibly the Keystone admin_token) and an API endpoint.
This is used for bootstrapping Keystone but also has other uses
when a scoped user token is provided.

The api.auth:TokenEndpoint class is required to provide the
same interface methods so all of the special-case code branches
to support token-endpoint can be removed.

Some additional cleanups related to ClientManager and creating
the Compute client also were done to streamline using sessions.

Change-Id: I1a6059afa845a591eff92567ca346c09010a93af
2014-10-12 16:48:43 -05:00
Matthieu Huin
0c77a9fe8b Support for keystone auth plugins
This patch allows the user to choose which authentication plugin
to use with the CLI. The arguments needed by the auth plugins are
automatically added to the argument parser. Some examples with
the currently available authentication plugins::

  OS_USERNAME=admin OS_PROJECT_NAME=admin OS_AUTH_URL=http://keystone:5000/v2.0 \
  OS_PASSWORD=admin openstack user list

  OS_USERNAME=admin OS_PROJECT_DOMAIN_NAME=default OS_USER_DOMAIN_NAME=default \
  OS_PROJECT_NAME=admin OS_AUTH_URL=http://keystone:5000/v3 OS_PASSWORD=admin \
  OS_IDENTITY_API_VERSION=3 OS_AUTH_PLUGIN=v3password openstack project list

  OS_TOKEN=1234 OS_URL=http://service_url:35357/v2.0 \
  OS_IDENTITY_API_VERSION=2.0 openstack user list

The --os-auth-plugin option can be omitted; if so the CLI will attempt to
guess which plugin to use from the other options.

Change-Id: I330c20ddb8d96b3a4287c68b57c36c4a0f869669
Co-Authored-By: Florent Flament <florent.flament-ext@cloudwatt.com>
2014-10-09 12:34:47 +02:00
Dean Troyer
d32185cb34 Add 'command list' command
* Add method to CommandManager to retrieve command names by group
* Add ListCommands

To list command groups loaded by cliff

Change-Id: I37fe2471aa2fafa8aa223159452d52b1981021d6
2014-10-08 21:57:26 -05:00
Dean Troyer
5b6c24fdb0 Update for cliff commandmanager >=1.6.1
Cliff 1.6.1 added  CommandManager.load_commands() so we can adopt it
rather than rolling our own.

Also, that second group is Greek, not Latin.  Jeez...

Change-Id: I4a63c22f37bcfd0ef5d83c2dbd08b58fda0db35c
2014-10-08 18:05:43 -05:00
Jenkins
df69d3264f Merge "Add network extension list" 2014-09-18 09:41:51 +00:00
Dean Troyer
ae957b176e Use Keystone client session.Session
This replaces the restapi requests wrapper with the one from Keystone client so
we can take advantage of the auth plugins.

As a first step only the v2 and v3 token and password plugins are supported.
This maintainis no changes to the command options or environment variables.

The next steps will include reworking the other API client interfaces to
fully utilize the single auth session.

Blueprint: ksc-session-auth
Change-Id: I47ec63291e4c3cf36c8061299a4764f60b36ab89
2014-09-08 00:06:52 -05:00
Jenkins
dcf658cc4e Merge "Unordered dicts and lists causes variable results" 2014-09-07 12:59:35 +00:00
Terry Howe
514ecc6e96 Unordered dicts and lists causes variable results
The unordered dict and lists causes variable results.  The user
may see different results and tests can fail.  Might as well make
this more consistent.

Change-Id: I7045b40b44cbf3ee0f2ca79c6ea0d279b6d8cfe3
2014-09-06 23:55:31 -04:00
Dean Troyer
4bbd03210f Change app.restapi to app.client_manager.session
This is step 1 toward using Keystone client's session.Session as the
primary session/requests interface in OSC.

* Move the session create into ClientManager and rename 'restapi' attribute to 'session'
* Set up ClientManager and session loggers
* Fix container and object command references to restapi/api

Change-Id: I013d81520b336c7a6422cd22c05d1d65655e64f8
2014-08-25 13:38:03 -05:00
Terry Howe
25e0d2ab27 Add network extension list
Network extension list support

Change-Id: I013f68ef2c3329c8db59e2441dd8d4ffafd4470e
Closes-Bug: #1337685
2014-07-26 15:57:48 -06:00
Dean Troyer
4844a25779 Add basic timing support
Add support for --timing options.  Use cliff via a pseudo-command
'Timing' to support multiple outputformats.

If an output format other than the default 'table' is selected
use CSV since the timing data is in list form.

Will pick up timing data for any client object that has a method
similar to novaclient's get_timings().

TODO:
* Stop instantiating all of the clientmanager client objects just
  to check for timing data.  Descriptor magic required?

Change-Id: I7f1076b7a250fba6a8b24b2ae9353a7f51b792b2
2014-07-08 02:04:00 -05:00
Dean Troyer
11f3654f6e Fix PEP8 E265 errors
Change-Id: Ieb9a9af1da27d3935d1a4d3cfb61b0ccb03d099a
2014-06-27 09:12:55 -05:00
Terry Howe
0b2987fef3 Fix find_resource for keystone and cinder
The find_resource method had two hacks in in to support cinder
and keystone and I have removed those in favor of a monkey patch
for cinder.

The find_resource method used to attempt to UUID parse the id, but
it would do a manager.get anyway.  I changed it to skip the UUID
parsing.  This will make things run minorly faster and it supports
LDAP for keystone.

The find_resource used to attempt to use display_name=name_or_id
when finding.  This was a hack for cinder support, but it breaks
keystone because keystone totally messes up with the bogus filter
and keystone refuses to fix it.

Change-Id: I66e45a6341f704900f1d5321a0e70eac3d051665
Closes-Bug: #1306699
2014-06-17 10:24:26 -06:00
Jenkins
0da5bfe428 Merge "Ignore most of the new hacking 0.9.2 rules" 2014-06-14 18:37:12 +00:00
Dean Troyer
0059f045a9 Ignore most of the new hacking 0.9.2 rules
So we can update requriements.txt.  But fix a couple of easy ones:
* Fix E251 (1 occurrance)
* Fix E131 (1 occurrance)

Change-Id: I62aaa423aa6da9e9f0ca026ec586b51cc6a6df03
2014-06-13 17:06:28 -05:00
Matt Fischer
4ae4dc35bd Add support for extension list
- Add support in the common section for extension list. This only
   supports Identity for now. Once the APIs for volume and compute
   are supported in the respective APIs, they will be added. Once
   network is added to this client, it will be added (the API already
   supports it).
 - Include extension fakes for volume and compute for pre-enablement.

Change-Id: Iebb0156a779887d2ab06488a2a27b70b56369376
Closes-Bug: #1319115
2014-06-11 13:40:30 -06:00
Alex Gaynor
a8087a6c8b Fixed several typos throughout the codebase
Change-Id: I048ee857fc1215fea7f60978364894e1b5abdf66
2014-05-21 07:47:52 -07:00
Terry Howe
4900c64d09 Produce a useful error message for NoUniqueMatch
Most of the CLIs use a NoUniqueMatch, so produce a useful
error message if that happens.  Added some tests for
find_resource as well.

Change-Id: I85ba61d5f6d1be5bd336a1cc4b02501492905f33
Closes-Bug: #1293846
2014-03-17 17:32:41 -06:00
Jenkins
034a9d158f Merge "Add ability to prompt for passwords for user create and set" 2014-02-22 06:00:18 +00:00
Terry Howe
033f27fe4d Add ability to prompt for passwords for user create and set
* Add get_password method to the utilities
* Add --password-prompt option
* Call the get_password method if a prompt is requested
* Various tests

Change-Id: I1786ad531e2a2fbcc21b8bc86aac0ccd7985995a
Closes-Bug: 1100116
2014-02-21 14:42:22 -07:00
Cyril Roelandt
5f9e7d09cb Python 3: the content of a FakeResponse must be bytes
Encode '_content' if necessary.

Change-Id: I25c1e1cd5330f0519bf062be840045d0ef520b28
2014-02-18 00:49:10 +01:00
Cyril Roelandt
9dc3eb5b18 FakeResponse: use a default status code
When running some tests from test_restapi.py, the following error happens:

    TypeError: unorderable types: NoneType() < int()

In Python 2, comparing NoneType and integers is possible:

    >>> None < 2
    True

But in Python 3, it's not allowed. Fix this by using a default status code.

Change-Id: Ic0fad5c68f3bf2dd8a2b98423549903f982192c9
2014-02-11 17:31:37 +01:00
Alexander Ignatov
ad4367839f Remove copyright from empty files
According to policy change in HACKING:
http://docs.openstack.org/developer/hacking/#openstack-licensing
empty files should no longer contain copyright notices.

Change-Id: Iba09a00f24dfbd1cd03c1c9f70ea216788e64d93
Closes-Bug: #1262424
2014-01-20 17:28:13 +04:00
Jenkins
facdc8704e Merge "Bring RESTApi closer to ithe imminent keystoneclient.Session" 2013-12-06 22:48:29 +00:00
Jenkins
b88a7b8ccc Merge "Add module list command" 2013-12-05 23:34:31 +00:00
Dean Troyer
a93cc3fae2 Add module list command
Lists versions of installed python modules

(Origianlly proposed as 'version list')

Change-Id: I76a51d3d6783f46ef2daa0a41626019a880a2a50
2013-12-03 17:53:55 -06:00
Dean Troyer
74a27056b3 Update OSC's CommandManager subclass
cliff.commandmanager.CommandManager gained an option, update
openstackclient.common.commandmanager.ComamndManager to match.

Also add CommandManager.get_command_groups() to return a list of the
currently loaded command groups.  I expect this to be useful in
upcoming client diagnostic commands for plugins/extensions.

If these turn out to be generally useful we'll propose them to
upstream cliff.

Change-Id: Ic15a7ca0ef975ca679e753be861be7c628b8e10c
2013-12-03 17:40:54 -06:00
Dean Troyer
f2dbe2e437 Bring RESTApi closer to ithe imminent keystoneclient.Session
Prepare to use the (soon to be) common Session from keystoneclient
* Rework RESTApi to eventually be a subclass of keystoneclient.Session

Change-Id: I68e610f8b19a3f6267a93f7bf3de54a228be68aa
2013-12-03 14:26:46 -06:00
Dean Troyer
916bb68dfd Add to clientmanager tests
Change-Id: Iea59c494f31de9c3e1d662f89e6e2babcc8fbd61
2013-09-05 12:54:14 -05:00
Dean Troyer
17f13f7bf4 Create a new base REST API interface
* restapi module provides basic REST API support
  * uses dicts rather than Resource classes
  * JSON serialization/deserialization
  * log requests in 'curl' format
  * basic API boilerplate for create/delete/list/set/show verbs
* ignore H302 due to urllib import

Change-Id: I3cb91e44e631ee19e9f5dea19b6bac5d599d19ce
2013-08-23 12:08:32 -05:00
Monty Taylor
196daf859b Move tests into project package.
There are several reasons for this. One is that the majority of
OpenStack packages behave this way. The second is that it makes writing
software that extends something easier to test (which is a clear usecase
for openstackclient) And third, tests/__init__.py implies a global
package named "tests" - which I'm pretty sure we're not providing.

Change-Id: Ic708ffd92aea78c2ffc1a8579af0587af4fca4ff
2013-06-30 23:30:54 -04:00