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
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
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>
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
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
This patch adds 'OpenStack-API-Version' header for each
requests.
Change-Id: I49310f1b53447ce00e78e26661cc895ce4f1c4e5
Implements: blueprint api-versioning
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
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
Due I05d2bb60b211d1b18611070217b01e3e418eb79a, change the error message
parsing to get error message from response.
Closes-Bug: #1555985
Change-Id: I4da3aff76fe46d1ac9fd90e06cb4931dc9a8d203
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
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
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
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
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