summaryrefslogtreecommitdiff
path: root/openstackclient/common/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* Use osc-lib and set up deprecation warningsDean Troyer2016-06-101-420/+8
| | | | | | | | | | | | | | The initial use of osc-lib is behind the compatibility/deprecation modules that we will leave in place for a time for plugins to catch up. * openstackclient.common.exceptions * openstackclient.common.utils Module-level warnings are emitted directly on stderr since logging has not been configured yet. Change-Id: I79e57ce9523a20366bccaf9b949ab5906792ea0d
* Fix i18n supports in commomHuanxuan Ao2016-06-071-19/+34
| | | | | | | | I checked all the files in openstackclient/common and fixed the missing i18n supprots. Change-Id: Id7f76a24aae663f5832ef9bcf1bd5a6b7081af24 Partial-bug: #1574965
* Don't mask authorization errorsHidekazu Nakamura2016-04-011-16/+9
| | | | | | | | | Project show with name argument returns 'Could not find resource' error when the user is not authorized. It should report the authorization error instead. This patch makes that change. Change-Id: Iac3521f8a411060b0ec9ef46c8f0e1f3551e56ae Closes-Bug: #1511625
* Fix dict.keys() compatibility for python 3Tang Chen2016-03-121-1/+1
| | | | | | | | | | In Python 2, dict.keys() will return a list. But in Python 3, it will return an iterator. So we need to fix all the places that assuming dict.keys() is a list. Change-Id: I8d1cc536377b3e5c644cfaa0892e40d0bd7c11b1 Closes-Bug: #1556350
* Fix Mutable default argumentting.wang2016-02-201-2/+12
| | | | | | | | | | | | Python’s default arguments are evaluated once when the function is defined, not each time the function is called. This means that if you use a mutable default argument (like list and dict) and mutate it, you will and have mutated that object for all future calls to the function as well. more details about this wrong usage here: http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments Change-Id: If187f16bfb305ac4fe6e4177e498a06c49c3f946
* Merge "Allow wait_for_delete to work for all clients"Jenkins2016-02-041-2/+6
|\
| * Allow wait_for_delete to work for all clientsMark Vanderwiel2016-01-281-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow the exception and error status strings to be passed in such that other plugins can make use of this function. There is a comment in find_resource: The exception to catch here is dependent on which client library the manager passed in belongs to. Eventually this should be pulled from a common set of client exceptions. Since I think that is a long ways off, this change will work now and also work when a common exception is defined and used. Change-Id: Iab56cd1166028caed4f1e657e0b1ee81af3f48d8
* | Merge "Add "os port show" command"Jenkins2016-02-031-0/+10
|\ \
| * | Add "os port show" commandRichard Theis2016-02-021-0/+10
| |/ | | | | | | | | | | | | | | Add "os port show" command. Change-Id: Id87c81640e74c60ae8f247c722c64fdadff022a2 Partial-Bug: #1519909 Partially-Implements: blueprint neutron-client
* | Drop log_method decoratorAkihiro Motoki2016-02-021-27/+0
|/ | | | | | | | | | | | | | As a result of the recent logging refactoring, log_method decorator is no longer required. oslo.log provides a similar decorator oslo_log.helpers.log_method_call. If a similar feature is needed, we can use the decorator from oslo_log. searchlightclient is the only OSC external plugin which uses this decorator. The depending patch removes it, so we can safely drop the decorator. Change-Id: If3df09cf6aa0a401d9f89e8924adce851d0c6dec Depends-On: Ib94e7ba77262a9a8cbfce71f3083c47cb1973364
* log_method: get logger from decorated method if unspecifiedAkihiro Motoki2016-01-201-9/+13
| | | | | | | | | | | | | This commit makes 'log' optional. 'log' attribute of each command class does not exist when the class is defined because 'log' is now setup dynamically when a class is instantiated. Instead log_method looks for a logger from a decorating method. compute.v2.server is changed in this commit as an example. Change-Id: Ic4d128f8e027d3b8e6f884f31369e9085c0f0871 Partial-Bug: #1532294
* Merge "Trivial: Remove useless string_to_bool()"Jenkins2016-01-081-4/+0
|\
| * Trivial: Remove useless string_to_bool()Tang Chen2015-12-291-4/+0
| | | | | | | | | | | | | | | | | | | | string_to_bool() is not used by anyone. Furthermore, it is not well designed. It tries to convirt 't', '1' to True, which could be confused. So remove it. If we need something similar, let's make a better one. Change-Id: Ic1f63480c806bf7bcc9f541fc806eed297ddf718
* | Improve output for "os security group show"Richard Theis2015-12-231-3/+4
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve the security group rules output when running the "os security group show" command. Each security group rule is now displayed on a separate line. Current output example: $ openstack security group show default +-------------+------------------------- ... ---+ | Field | Value ... | +-------------+------------------------- ... ---+ | description | Default security group ... | | id | 048a5fc3-3be1-407d-ae47-9... | | name | default ... | | project_id | 3b96bb2020c1459da76963f9e... | | rules | [u"id='5d812367-9829-4340...t"] | +-------------+------------------------- ... ---+ New output example: +-------------+------------------------- ... ---+ | Field | Value ... | +-------------+------------------------- ... ---+ | description | Default security group ... | | id | 048a5fc3-3be1-407d-ae47-9... | | name | default ... | | project_id | 3b96bb2020c1459da76963f9e... | | rules | id='5d812367-9829-4340-95...lt' | | | id='ee451d1c-ade3-4975-8e...lt' | +-------------+------------------------- ... ---+ Change-Id: I1386075310896c58a2b776e2bbec3603bd00eff1 Partial-Bug: #1519511 Related-To: blueprint neutron-client
* Trivial: Fix a typo.Tang Chen2015-11-271-1/+1
| | | | Change-Id: I236b4f53ee23cc97900e6244ab709404cc44a4ca
* Trivial: Add missing doc for parameter in wait_for_delete().Tang Chen2015-11-261-0/+1
| | | | | | The doc of parameter manager is missing. Change-Id: I4e99c06ab713532d73615670ada0a61462285d76
* Merge "Trivial: Fix wrong doc for wait_for_status()."Jenkins2015-11-231-1/+2
|\
| * Trivial: Fix wrong doc for wait_for_status().Tang Chen2015-11-241-1/+2
| | | | | | | | | | | | | | | | Two trivial fixes: 1. docs for parameters are not sorted correctly 2. missing doc for a parameter Change-Id: I0cfb65e0f897c391b9b6e7225251e88855b07a56
* | Trivial: Remove doc for non-existing param in format_dict().Tang Chen2015-11-211-1/+0
|/ | | | | | There is no parameter named format. Change-Id: I286006430efb2850b978b6f2abaed87216156d12
* Allow error status to be specifiedMark Vanderwiel2015-11-181-1/+2
| | | | | | | | For some apis, heat, the error status is "failed". This patch changes the wait_for_status method to allow for the error status to be passed in the same way as the success status. Change-Id: I20db4051d3f5611a4b13fe23ea8798b82a40da81
* validate non-ascii values for swift propertiesSteve Martinelli2015-11-121-0/+8
| | | | | | | | | skip properties that are non-ascii values, but proceed with properties that work. log these failed values back to the user. Change-Id: Iaca8909f4465a01c8aebfd290b1a322823702359 Closes-Bug: 1503898
* attempt to find resource by listingSteve Martinelli2015-09-301-2/+18
| | | | | | | | | | | add a last-ditch effort to find the resource in question by listing all the resources and doing a simply match for name and id. if no match is found then raise an error, if the list call is unsuccessful, raise the same error. we have failed this city. Closes-Bug: #1501362 Change-Id: I0d3d7002e9ac47b17b1ef1a5534406c85b1fc753
* Additional exception handling for find_resourceSteve Martinelli2015-09-301-7/+11
| | | | | | | | | | A few things here: 1) we need to check if the client class even has a 'resource_class', in the case of glanceclient, it does not. 2) If everything fails we should print a better error message, rather than a "find" failed, since some clients don't support find. Change-Id: I6277322639e75b1635f9f3d159753efadbce1031
* Use a common decorator to log 'take_action' activationJoshua Harlow2015-09-011-0/+23
| | | | | | | | | Instead of duplicating the same log statement throughout the code, the same logic can be provided by a shared decorator that abstracts away the logging capability and unifies it behind a common function instead. Change-Id: Icc63bced7347c8bbf0299a4c5821425a10892a79
* More minor docs fixesTerryHowe2015-07-191-3/+3
| | | | Change-Id: Ia74b8e14bacb562d9bac29221f511acbab5296df
* Merge "Add --os-endpoint-type cli optional argument"Jenkins2015-07-031-0/+8
|\
| * Add --os-endpoint-type cli optional argumentRoxana Gherle2015-07-021-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | User should be able to specify the endpoint type through a CLI optional argument/ENV variable setting. We will name this new optional argument: --os-endpoint-type (Env: OS_ENDPOINT_TYPE) and based on the value given, the service API will use that specific endpoint type. Possible values: public, admin, internal. DocImpact Closes-Bug: #1454392 Change-Id: Ife3d4e46b44c0ddcd712b1130e27e362545a9a29
* | Enables retrieval of project's parents and subtreeRodrigo Duarte Sousa2015-06-091-2/+2
|/ | | | | | | | | | | | Adds the possibility to retrieve a project and list its parents and subtree in the hierarchy. Co-Authored-By: Rodrigo Duarte <rodrigods@lsd.ufcg.edu.br> Co-Authored-By: Samuel de Medeiros Queiroz <samuel@lsd.ufcg.edu.br> Implements: bp hierarchical-multitenancy Change-Id: I874f6faffc8a2db9d99f12cbe0a69c0a30c0d9df
* Add --wait to server deleteMatt Riedemann2015-05-291-0/+46
| | | | | | | | | | | | | | This allows the server delete command to wait for the server to be deleted (obviously). The wait method is the same model that Tempest uses, i.e. wait for a 404 on server GET (successful deletion), fail if the server went to ERROR status, or fail if a timeout is reached. The default timeout of 300 seconds is also what Tempest uses. Closes-Bug: #1460112 Change-Id: I0e66c400903e82832944d1cad61e7eb30177c3e8
* Merge "Fix error msg in sort_items"Jenkins2015-03-021-1/+7
|\
| * Fix error msg in sort_itemszhiyuan_cai2015-02-111-1/+7
| | | | | | | | | | | | | | | | Include direction users pass in the error msg to help users know which part of the argument is troublesome. Change-Id: I796a85fbf40f6ddf544fb52a61f967e1914abdcc Closes-Bug: #1420732
* | change oslo namespace to avoid warningTerry Howe2015-02-251-1/+1
|/ | | | Change-Id: Ieff86f841623e1ce34b79c66bc5e8b1b239fa3e9
* Add sort support to image listzhiyuan_cai2015-02-061-0/+40
| | | | | | | | | | Add sort support to image list by sorting items in the client side. The parameter syntax follows this spec[1]. [1] https://review.openstack.org/#/c/145544/ Change-Id: I42b487d18f00f937db1938daa46487cea2a896ab Closes-Bug: #1410251
* Add domain parameters to user show for Identity V3Steve Martinelli2014-10-091-3/+25
| | | | | | | | | | | Update `user show` for Identity V3 to account for a domain argument, in doing so, also update `find resource` to be more flexible by allowing **kwargs. Also update `group show` and `project show` since they follow the same logic as a user within a group. Change-Id: Ib828e4dbeb0bd31164396069ce8a64c873179779 Closes-Bug: #1378165
* utils.find_resource does not catch right exceptionwanghong2014-09-241-2/+9
| | | | | | | | | Currently, utils.find_resource catch NotFound exception defined in openstackclient. However, different client libraries raise different exceptions defined in thire own library. Change-Id: Idc40428e30e59f71dbdbfa0555c0066fddc441c2 Closes-Bug: #1371924
* Use oslo.utilsOleksii Chuprykov2014-09-221-1/+2
| | | | | | | | Module `importutils` from common code was graduated to oslo.utils, so it would be great if we reuse this library. Remove unused strutils.py and gettextutils.py Change-Id: Iaae19fc5018d83103e5f15ff76d6da686bfdf5f8
* Merge "Add action 'user password set' for identiy v3"Jenkins2014-09-071-3/+6
|\
| * Add action 'user password set' for identiy v3Mouad Benchchaoui2014-09-071-3/+6
| | | | | | | | | | | | | | | | | | | | | | This new action will allow a user to change their own password by either providing the new password as an argument (--password) or by being prompted to enter the new password. In both cases user will be prompted to enter their current password as required by the v3 API. Closes-Bug: #1337245 Change-Id: I5e1e0fd2b46a4502318da57f7cce2b236fb2d93d
* | Merge "Unordered dicts and lists causes variable results"Jenkins2014-09-071-2/+2
|\ \
| * | Unordered dicts and lists causes variable resultsTerry Howe2014-09-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Leverage openstack.common.importutils for import_classAaron Rosen2014-09-061-13/+2
|/ / | | | | | | | | | | | | | | This patch drops the import_utils method from common.utils and leverages it from openstack.common.importutils instead. Change-Id: If7e7383aa742afe44f750f916c0d90d747793150 Closes-bug: 1365273
* | Python 3: remove a useless code to safe_encode()Cyril Roelandt2014-07-041-3/+1
|/ | | | | | | | The safe_encode method returns bytes, so we cannot concatenate its output with text strings. This call does not seem needed after all, so let's just remove it. Change-Id: I6c18427559147d4c732ff7daa6d6006e7e5f6365
* Network CRUDTerry Howe2014-06-241-0/+10
| | | | | | | bp/neutron https://wiki.openstack.org/wiki/OpenStackClient/Commands#Network_2 Change-Id: I89ee083154afa544b03587e84becace36d9d522a
* Fix find_resource for keystone and cinderTerry Howe2014-06-171-13/+0
| | | | | | | | | | | | | | | | | | | 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
* move read_blob_file_contents to utilsSteve Martinelli2014-04-141-0/+10
| | | | | | | | Thinking ahead, a few other upcoming keystone features could benefit from reading contents from a file. Thus, moving the function from policy to utils. Change-Id: I713ab0e5a00c949ad996daf83b775a7c19044888
* Produce a useful error message for NoUniqueMatchTerry Howe2014-03-171-0/+4
| | | | | | | | | 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
* Add ability to prompt for passwords for user create and setTerry Howe2014-02-211-0/+16
| | | | | | | | | | * 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
* Displaying curl commands for nova and cinder callsFlorent Flament2014-01-021-0/+14
| | | | | | | | | | | | When using the -v option, displays curl equivalent commands and http messages exchanged with the nova and cinder API servers. Displays the same messages as those displayed with the --debug option of python-novaclient and python-cinderclient. Implements: blueprint curl-commands-in-debugging-messages for nova and cinder related calls Change-Id: Ibc8ef79d874334585b81d652b9c7df9e874fffa9
* Create a new base REST API interfaceDean Troyer2013-08-231-0/+24
| | | | | | | | | | | * 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
* Merge "Remove tenant round 3 - other commands"0.2.alpha1Jenkins2013-07-311-1/+1
|\