Commit Graph

28 Commits

Author SHA1 Message Date
Tobias Urdin f7551a6bac Fix failing to parse json error msg
It assumes its a requests response but could
be a HTTPResponse from urllib.

Story: 2008789
Task: 42183

Change-Id: I7306d167a17284c7f478ec1c1599a8d4b32040c2
2021-03-30 13:59:07 +00:00
jacky06 038146d500 Remove six
We don't need this in a Python 3-only world.

Change-Id: I7f39c971de09684ad34cdd21ae6819bde797efb0
2020-05-06 00:42:29 +08:00
Zuul ec27571c90 Merge "Fix raw_request of SessionClient" 2020-04-30 13:03:32 +00:00
Feilong Wang ffcaae4f27 Fix raw_request of SessionClient
The the raw_request of SessionClient should return two variables
to be compatible with others.

Change-Id: I2900a08cbf08147791e0a2f41d13b42a43f6897e
Task: 39592
Story: 2007605
2020-04-30 10:29:40 +12:00
Tobias Urdin c024b4fc43 Check response type in _extract_error_json
The response being passed to _extract_error_json
is assumed to be a requests.Response but can also
be a http.client.HTTPResponse.

This patch adds a try statement where it first tries
for a requests.Response and if not set falls back on
parsing the string body instead of trying to use the
json() helper function in requests.Response.

Change-Id: I61840d284b5d3a249f621822b277c9bd6825140d
Closes-Bug: 1870264
2020-04-08 09:46:58 +00:00
Michal Arbet 5deb538930 Fix py37 compatibility
Unit tests are failing under python3.7.
Generators which explicitly raise StopIteration can generally be
changed to simply return instead. This will be compatible with
all existing Python versions.

PEP Documentation for this change:
https://www.python.org/dev/peps/pep-0479/

Change-Id: I4ae2049d8a2469d0a37077bdc722481e68d7cc49
Closes-Bug: #1814890
2019-02-06 15:22:26 +01:00
Erik Olof Gunnar Andersson b4120a1352 Use oslo_serialization instead of the json module directly
* Always use oslo jsonutils.
* Consistently import jsonutils as-is.
* Use dump_as_bytes instead of dumps.
https://wiki.openstack.org/wiki/Python3#Serialization:_base64.2C_JSON.2C_etc.

Change-Id: Ifb6c673da24276b0528e5975f63ac326d558936d
2019-01-21 16:32:15 -08:00
Boris Pilka 125a9a5587 Fix crash on Service catalog empty 403 response
Added handling of message body received as bytes ("application/json")
to avoid "TypeError: the JSON object must be str, not 'bytes'"

Change-Id: I007b33e1b9f210ede2df5d1e2aa32535222d5d67
Task:24818
Story: 2003533
Signed-off-by: Boris Pilka <boris.pilka@x-works.io>
2018-08-24 08:38:19 +02:00
Jenkins 9cc2219d59 Merge "Add ca-rotate command to magnumclient" 2017-03-20 18:47:52 +00:00
Jason Dunsmore 6f6cc3f7ef Add ca-rotate command to magnumclient
Change-Id: I909b1694bfe7b316216f23a9a7c8cac704b839f8
Implements: blueprint revoke-cluster-cert
2017-01-27 13:47:57 -06:00
Jenkins 8fee8c50cb Merge "Integrate OSprofiler in Magnum Client" 2017-01-27 19:06:05 +00:00
Hieu LE cdc1b5e433 Increase UT Coverage
UT Coverage for magnumclient/common/httpclient.py is increased
from 56% to 81%.

Overall coverage is now 79%

Change-Id: I28d0f3406ed9940cf0dee9d2fa5d238152017151
Partially-Implements: blueprint magnumclient-ut-coverage
2017-01-26 08:47:38 +07:00
Tovin Seven 1c2385ca55 Integrate OSprofiler in Magnum Client
Add OSprofiler support in Magnum Client

Co-Authored-By: Hieu LE <hieulq@vn.fujitsu.com>

Change-Id: I85f766f636f754fc6ad8e28e3df2793cd02a618e
Depends-On: I7d68995aab81d365433950aada078ef1fcd5469b
Implements: blueprint osprofiler-support-in-magnum
2017-01-24 08:32:35 +07:00
wangbo 9fa235db02 Pass 'api_version' to create HTTPClient
The bug introduced with following patch:-
https://review.openstack.org/#/c/357629/

Change-Id: I6362cf8b750112c3d7a1fe043d61c8ceec124e50
Closes-Bug: #1655912
2017-01-16 05:40:54 +00:00
OTSUKA, Yuanying a738ea7911 Add microversioning support for httpclient
This patch adds 'OpenStack-API-Version' header for each
requests.

Change-Id: I49310f1b53447ce00e78e26661cc895ce4f1c4e5
Implements: blueprint api-versioning
2016-08-29 14:48:39 +09:00
Jenkins 84bdb36551 Merge "Use os-client-config in shell" 2016-07-25 18:00:34 +00:00
OTSUKA, Yuanying f2c49d203b Use os-client-config in shell
Use os-client-config[1] to process options and get the Session from
keystoneauth1. This adds support for reading clouds.yaml
files and supporting the OS_CLOUD env var for selecting named clouds
from a list of them.

[1]: https://github.com/openstack/os-client-config

Closes-Bug: #1599747
Change-Id: I23a6e80648e67c0b652693cd146bd9e94ad4fb23
2016-07-25 13:44:34 +09:00
Akhila Kishore 2a3bb81087 Update the magnum client to send the latest version.
In Magnum client, Magnum calls should include the OpenStack-API-Version
header with the value of 'latest' as default, so that the latest
version of Magnum API is run.

Change-Id: I324a88d5e70ea9d68e7caf59061f5ad0807d37aa
2016-07-20 20:19:36 +00:00
Eli Qiao e9c6c1a2a3 Adapt http response error message parsing
Due I05d2bb60b211d1b18611070217b01e3e418eb79a, change the error message
parsing to get error message from response.

Closes-Bug: #1555985
Change-Id: I4da3aff76fe46d1ac9fd90e06cb4931dc9a8d203
2016-03-17 00:51:42 +00:00
Christoph Jansen 1a7a781e48 Python 3.4 compatibility
This commit fixes two issues, which make the client work with Python
3.4 and still being compatible with Python 2.7. The first issue is,
that the command line args somehow become a Map instead of list in
Python 3.4. I fixed it by explicitly making argv (sys.argv) a list.
The second issue is in the httpclient.py, where the values of a http
response are of type byte, which cannot be joined by join method of
string. I fixed it by decoding byte to utf-8 string. Additional if
statement satisfies wrong Python 3.4 test behavior.

Change-Id: Ifaf03cbc5512dcbe82cfc37bc0c8471ffdbc7018
Closes-Bug: #1535821
2016-01-21 13:53:38 +01:00
Corey O'Brien fcfbc40162 Fix bypass_url and errors with no headers
When using bypass_url the endpoint_override needs to be set in the
SessionClient.
Don't assume all responses have a Content-Type

Fixes Bug: 1532278
Change-Id: I5e1319aae28e16448e20dd2b41836341f3156c59
2016-01-13 07:43:56 -05:00
Wanlong Gao 094009f494 Python 3 deprecated the logger.warn method in favor of warning
Python 3 deprecated the logger.warn method, see:
https://docs.python.org/3/library/logging.html#logging.warning, so we
prefer to use warning to avoid DeprecationWarning.

Change-Id: If47818a6ce8adb14bc275dc5a6b5ab4b9d189ff7
Closes-Bug: 1508442
2015-12-29 13:17:51 +08:00
Hongbin Lu 14efefd01f Handle faultstring when using SessionClient
When the magnum-api returns an error code 400-600, SessionClient
faultstring did not return to users. It should return a detailed
error message.

This commit was ported from Ironic:
https://review.openstack.org/#/c/142021/

Change-Id: I8bc15c0ddab10f0e117fb6acb2f3995929fa65e2
Closes-Bug: #1520363
2015-11-27 18:21:38 -05:00
Monty Taylor 5cbc5e722e Use keystoneauth to create a Session
All client interactions should actually flow through a keystoneauth
Session. Add the parameter for a user to pass one in, but support
the old style of direct parameters too. A followup patch will add
os-client-config support to the shell, so add that to requirements.txt
instead of keystoneauth directly to look forward.

Also, trim unneeded things from requirements.txt because we're adding
os-client-config which pulls in various things.

Closes-Bug: #1514733
Change-Id: I88b1d0e4e119429599dec75c5db24237a92edcec
2015-11-11 18:51:18 +01:00
Lan Qi song e0c2ad4687 Log the correct url in debug mode
Change-Id: I7bf01dc6ea60811c2235e61187a8f97458acc3ec
Closes-Bug: #1448839
2015-04-27 11:31:40 +08:00
Hongbin Lu 442e08b289 Revert "Fix an error on not finding log handler"
This reverts commit 5b59253667.

Change-Id: I86cfc0acff9f47846dc5d953af2ee5bf6a8b241c
2015-01-15 17:14:56 +00:00
Hongbin Lu 5b59253667 Fix an error on not finding log handler
Magnum client should not log any warning message if there is no logging
handler. Otherwise, magnum client will print a confusing message when
server return a failure status. Below is the exact message:

No handlers could be found for logger "magnumclient.common.httpclient"

This message is just a warning that can be safely ignored. In particular,
this message does not indicate the root cause of the problem. Users
should find the root cause from other places (e.g. the server logs).

Change-Id: If6ba4f1bb4900b5632049e8a8a8bfd3b12035f8d
2015-01-15 03:37:48 +00:00
Motohiro OTSUKA cc031af4ca Add client resources and managers
Add initial managers for client resources, which are
- BayManager
- PodManager
- ServiceManager
- ContainerManager

Change-Id: Ib314225fa237f44b56cf81e2a8df6e15f8592e5b
2014-11-26 09:52:30 +09:00