21 Commits

Author SHA1 Message Date
Vishakha Agarwal
81fd5c995d Updated the take_actions for unified limits
When user passes --region None, the find_resource
of osc_lib calls get() of region. The get API of
region ignores the name param returning all the
regions in result. As the find_resource checks
many cases against the result returned by get API.
The output comes greater than 1, thus returning
"More than one region ID exist" which is incorrect.
However in case of region which cannot be filtered
by name we do not require to check these many cases.

The solution is to directly call the get method of
APIs and returning No resource name exist with the
xyz" on passing invaid parameter. And returning all
in case of None.

Thus created a new function get_resource which can
be used in future too by these types of API's.

Change-Id: Ib3f881d34a82af97199ce51bfbefc6f3f08599f1
Closes-bug: #1799153
2018-11-09 07:53:55 +05:30
Colleen Murphy
375964f270 Add CRUD support for application credentials
Add support for creating, retrieving, and deleting application
credentials. Application credentials do not support updates.

In order to provide a positive user experience for the `--role` option,
this patch also includes an improvement to the
`identity.common._get_token_resource()` function that allows it to
introspect the roles list within a token. This way there is no need to
make a request to keystone to retrieve a role object, which would fail
most of the time anyway due to keystone's default policy prohibiting
unprivileged users from retrieving roles.

bp application-credentials

Change-Id: I29e03b72acd931305cbdac5a9ff666854d05c6d7
2018-01-30 21:50:01 +01:00
Anton Frolov
f6f5ce03c5 Optimize getting endpoint list
Currently ListEndpoint.take_action method unconditionally iterates
over all endpoints and issue GET /v3/services/<ep.service_id>
request for each endpoint. In case of HTTPS keystone endpoint this
can take significant amout of time, and it only getting worse in
case of multiple regions.

This commit change this logic to making just two GET requests: first
it gets endpoint list, then it gets service list, searching service
in the list instead of issuing GET /v3/services/<id> request.

Change-Id: I22b61c0b45b0205a2f5a4608c2473cb7814fe3cf
Closes-Bug: 1719413
2017-09-26 14:31:07 -07:00
jiangpch
a01bf55d20 Fix 'domain' filter not work well in some commands
The 'domain' filter not work well in commands 'project show',
'user show' and 'user set'.

Depends-On: I490900d6249f01654d4cba43bddd3e7af7928a84
Closes-Bug: #1704097
Change-Id: Ib4f47cbaba27eb56c4a41d187fee74a995e62dc7
2017-07-18 23:01:22 +00:00
Henry Nash
5eb7e626b1 Add support for domain specific roles
A role entity can now be specified as domain specific.

Closes-bug: #1606105
Change-Id: I564cf3da1d61f5bfcf85be591480d2f5c8d694a0
2016-08-10 20:32:55 +00:00
sunyajing
c45b1d7b23 Fix error for find_service() in identity
if there are more than one services be found with one
name, a NoUniqueMatch exception should be raised but
we can see a NotFound Exception raised instead. It is
because in "find_service()", we use "find_resource()"
first, if "find_resource()" return a exception, we just
think it is a NotFound Exception and continue to find
by type but ignore a NoUniqueMatch exception of
"find_resource()". This patch refactor the "find_service()"
method to solve this problem.

Change-Id: Id4619092c57f276ae0698c89df0d5503b7423a4e
Co-Authored-By: Huanxuan Ao <huanxuan.ao@easystack.cn>
Closes-Bug:#1597296
2016-07-22 19:40:50 +08:00
David Rosales
337d013c94 Use resource id when name given for identity show
Currently a user is allowed to specify either a resource ID or name
when running openstack identity comands. In some cases, when a name
is specified instead of an ID, the command will return as not able
to find the resource when it in fact does exist.

The changes here are to check the client against the token on such
requests and to extract the ID of the resource specified if enough
information exists between the two. We then use the ID associated
with the resource to complete the user requests.

Change-Id: I40713b0ded42063b786dc21247e854224b9d2fe2
Closes-Bug: #1561599
2016-06-22 21:55:46 -07:00
Tang Chen
304f565439 Fix i18n problems for common files in identity
Some missing parts in identity.

Change-Id: I8777b845613d7d7df36ac3c198da552e11aaad1b
Partial-bug: #1574965
2016-06-14 09:50:23 +08:00
Dean Troyer
e5e29a8fef osc-lib: utils
Use osc-lib directly for utils.

Leave openstackclient.common.utils for deprecation period.

Change-Id: I5bd9579abc4e07f45219ccd0565626e6667472f7
2016-06-13 10:50:44 -05:00
Dean Troyer
d20c863ebc osc-lib: exceptions
Use osc-lib directly for exceptions.

Leave openstackclient.common.exceptions for deprecation period.

Change-Id: Iea3e862302372e1b31ccd27f69db59b4953ca828
2016-06-13 10:50:01 -05:00
Min Min Ren
b98aee57c1 Fix "sevice show" cannot catch NoUniqueMatch Exception
Fix a bug for "service show" subcommand cannot cache NoUniqueMatch Exception

Change-Id: I393c5417de0fef424618b08119ddbc8fea27e114
Closes-Bug: #1524305
2015-12-09 05:47:12 +08:00
Steve Martinelli
37c83e6231 Fix the way we call find_resource when only using ID
Change-Id: I6fb08edd5499767863e0e67f363bcd9fff3aea60
Closes-Bug: 1475127
2015-07-16 06:31:46 +00:00
Samuel de Medeiros Queiroz
ed241ef9bc Add support to inherited project role grant calls
Once inherited project role grant calls are
implemented on python-keystoneclient,
python-openstackclient also should support such
calls.
This patch add such support as well as its
related tests.

Co-Authored-By: Raildo Mascena <raildo@lsd.ufcg.edu.br>

Change-Id: Id72670be8640e5c6e2490a6ef849e9ec3493b1a9
Implements: blueprint hierarchical-multitenancy
2015-06-22 11:05:01 -03:00
Steve Martinelli
2b0013c5c1 Refactor option handling for user|group|project domain scoping
put the common options in identity.common, this way the help is
consistent

Change-Id: I5b09cfb56fa0f8d16feb95150f216fccbe9f2b22
2015-06-17 12:38:40 -04:00
Juan Antonio Osorio Robles
f7feef7f8d Enable specifying domain for group and role commands
Many of the commands for the group and role resources were lacking an
option to specify the specific domain groups, projects or users belong
to. This commit fixes that.

Change-Id: I461d2bcfd01ad2dea970de38ec7ad6f4a631ceb1
Closes-bug: #1446546
2015-06-08 17:05:10 +03:00
Juan Antonio Osorio Robles
3ca96ef93c Enable specifing domains in "role add"
If users, projects or groups are provided by name, there is a
possibility of the existence other users/projects/groups with the same
name in other domain.  Even though this is not a problem if the actual
ID is given instead of a name; this is mostly a usability enhancement.

So, three options were added, one for specifying the domain where the
user belongs, another one to specify the project's domain, and finally
one to specify the group's domain.

Change-Id: Iab04b0e04fa75ea5aa3723b8ea42a45f58a6cdb2
Closes-Bug: #1421328
2015-05-12 11:48:01 +03:00
Steve Martinelli
d733e457e3 Refactor utility to find identity resources
Based on the comments made in this patch:
  https://review.openstack.org/#/c/174908/2/

We should simplify and refactor the way we handle finding identity
resources.

Change-Id: I77db2e3564faa90a917082a6c6cb87269e93aebe
2015-04-20 12:40:33 -04:00
Nathan Kinder
4c107e6f1b Role operations should not require list object permission
When using Keystone's policy.v3cloudsample.json policy file, a project admin is
supposed to be able to manage role assignments.  Unfortunately, a project admin
isn't allowed to perform these operations using python-openstackclient, as we
attempt to perform list operations for any of the object types specified (users,
groups, projects). This is done in an attempt to lookup the id of the object by
name, but we perform this list operation even when the user specifies everything
by id. This causes 403 errors.

This patch still attempts to look up the object id by name, but we catch the 403
and assume that the user specified an id if the list operation is not allowed.
This is similar to what we do with the --domain option for other commands.

Closes-bug: #1445528
Change-Id: Id95a8520e935c1092d5a22ecd8ea01f572334ac8
2015-04-17 10:14:57 -07:00
Victor Silva
bfff44fc17 Fixing typo and improving docstring of find_domain
This should make it easier to understand the
purpose of find_domain - I believe the reason
for which find_resource wasn't enough was not
quite clear.

Change-Id: I6a1cdfa86f52401d95c6da2cd38d7c95a140b4a1
2014-09-19 19:51:01 +00:00
Terry Howe
b638488697 Domain administrator cannot do project operations
Domain administrator cannot do project operations because the
require access to the domain API (which they don't have).  When
attempting to find a domain for project operations, ignore errors
because the API returns nothing without indicating there is a
problem.  The domain administrators will have to use a domain id,
but they will still be able to do project operations.  If the user
does not have permission to read the domain table, they cannot
use domain names.

Change-Id: Ieed5d420022a407c8296a0bb3569d9469c89d752
Closes-Bug: #1317478
Closes-Bug: #1317485
2014-07-07 20:18:39 +00:00
Terry Howe
bea6e6ac23 Make endpoint commands more consistent
Make endpoints more consistent across create, show, etc
* Make the name option required for create
* Use a common function to fetch services by id, name or type
* Have show work by endpoint id or by service id, type or name
* Have show display all the fields by default
* Remove capability to filter queries by attribute value pairs

Change-Id: Idaa4b8d930ba859fd62de777e44a10b1ed58c79b
Partial-Bug: #1184012
2014-03-28 12:33:58 -06:00