19 Commits

Author SHA1 Message Date
zhanghao
3cfa54fa56 Remove usage of six
With python3.x, classes can use 'metaclass=' instead of
'six.add_metaclass', 'six.iteritems' and 'six.iterkeys' can
be replaced by 'items' and 'keys', 'six.moves.urllib.parse'
can be replaced by 'urllib.parse', 'six.StringIO' and
'six.moves.cStringIO' can be replaced by 'io.StringIO',
'six.text_type' and 'six.string_type' are just 'str'.

Change-Id: I357968c6a1932856b1600f6c191966bc90cbc258
2020-05-15 17:27:56 -04:00
Yushiro FURUKAWA
bca82e2fba Fix broken unittests
_clean() method is renamed to clean() in osprofiler 2.3.0.
It was suggested in a past neutronclient review.

Closes-Bug: #1783789
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Depends-On: https://review.openstack.org/#/c/592018/
Change-Id: Ic8e03db85dc08cfdcac5507e99ecdf7eac8eb972
2018-08-15 22:01:17 +09:00
Hongbin Lu
cefa2432f6 Pass headers to httpclient
Right now, it is impossible to set HTTP headers in client because
the 'headers' parameter is not set. This patch fixes it.

Change-Id: Iff002aaca516e8d014074f120b7f713758ebf265
Partial-Bug: #1737473
2018-01-03 20:54:12 +00:00
ritesh.arya
28fc2dcf06 Replace uuid.uuid4() with uuidutils.generate_uuid()
Openstack common has a wrapper for generating uuids.
We should use that function to generate uuids for consistency.

Change-Id: I86ae28e6042d1fac2b08540add8a9e23c9254c86
2017-07-18 12:06:17 +00:00
Sean Dague
af869a4ca6 Allow global_request_id in Client constructor
This provides the facility to take global_request_id as a construction
parameter for a neutron client, and pass it through the system. This
will be used by Nova and others to set global_request_id so requests
can be tracked across services.

oslo spec I65de8261746b25d45e105394f4eeb95b9cb3bd42

Change-Id: I7ed48ad247676c71a3a7b12585572c398dda06e0
2017-05-26 08:38:28 -04:00
Jenkins
7eda3a26e9 Merge "Remove unused object" 2017-03-16 04:21:57 +00:00
Dina Belova
badfc96046 Add profiling support to neutronclient
To be able to create profiling traces for Neutron, client should be
able to send special HTTP header that contains trace info.
This patch is also important to be able to make cross project
traces. (Typical case nova calls neutron via python client, if
profiler is initialized in nova, neutron client will add extra
header, that will be parsed by special osprofiler middleware in neutron
api.)

Closes-Bug: #1335640

Co-Authored-By: Roman Podoliaka <rpodolyaka@mirantis.com>
Change-Id: Ic11796889075b2a0e589b70398fc4d4ed6f3ef7c
2017-02-23 10:21:31 -05:00
lilintan
341d7805c5 Remove unused object
I didn't find where to use it.

Change-Id: I10cbac0b1893650dbb00ed7a87e6f7b6361fe051
2016-10-27 11:56:51 +00:00
shu-mutou
ec4e482731 Fix H405 violations
There are a lot of H405 violation codes.
We need to fix the code for avoiding more violations.

Change-Id: Iaa83626b81a3d8369b16e2b4f394e2bc4628998a
Closes-Bug: #1521899
2015-12-13 05:48:42 +09:00
Elena Ezhova
54a4aea969 Remove XML support
As XML support has been removed from neutron, there is no need
to keep it in client.

Dropped XML serializer and deserializer and deprecated "request-format"
CLI option, making JSON the default and the only supported request
format.

DocImpact

Change-Id: I88b0fdd65a649694252d5ff43a174e75026df5b1
Closes-Bug: #1380787
2015-12-09 11:09:26 +03:00
Monty Taylor
2eed8ea24a Use os-client-config and keystoneauth1 in shell
keystoneauth1 is the new auth-only library for getting keystone
Sessions, which is lighter-weight and does not require the entire
keystoneclient library. It also handles all of the keystone
version discover and plugin selection so that code doesn't have to
live in neutronclient.

Additionally, use os-client-config 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.

This is a step towards bug#1503428 but is not the whole picture.

Remove the auth tests - since they are covered inside of ksa.

Closes-Bug: #1507384
Change-Id: Ic4f9fd8f231c33513fd74da58ab1b4a3fb00d9f4
2015-10-28 08:01:13 +09:00
Jamie Lennox
5822d619e5 Use requests_mock instead of mox
Kill off mox and use requests_mock. There are fixtures available for
everything we want to test - there is no reason to resort to using mox.
This cleans up and makes clearer a lot of tests.

Change-Id: I2633bcaf36388fb4db1de4cd75d5ccd76f961509
2014-12-23 10:07:21 +10:00
Ilya Shakhat
9d8ab0df56 Replace httpretty with requests_mock
The httpretty library has poor Py3 support, currently the only
working version is 0.8.0, all later minor versions are pinned.

Requests-mock library provides mocking layer for requests package. It is
written in such a way that it is fairly simple to convert existing
httpretty test suites to requests-mock. The library is hosted at Stackforge
and gated as usual OpenStack project.

Change-Id: If7f4baefb53976571efc47dda17a7b543112d555
2014-09-18 17:18:16 +04:00
Cedric Brandily
fb83043e15 Correct Content-Type/Accept management in HTTPClient/SessionClient
Currently SessionClient.request never specifies Content-Type/Accept
headers in requests where HTTPClient.request always specifies json
Content-Type/Accept even with "--request-format xml" option ... requests
succeed because neutron deduces Content-Type/Accept from url suffix when
defined.

This change ensures HTTPClient/SessionClient define Content-Type/Accept
headers when needed and align them with --request-format option.

Closes-Bug: #1368335
Change-Id: I909e055e5e59fa5870a28ebb0f171812acca0745
2014-09-15 15:44:42 +02:00
Dirk Mueller
58e48df0f8 Switch over to mox3
mox3 is a Python 3.x compatible drop-in and allows
to continue with the porting effort to Python 3.x with
minimal code changes.

Closes-Bug: #1283482
Change-Id: Ib052f1b87e312481e4c7c8d775ece94f53e7106b
2014-06-26 11:54:50 +02:00
armando-migliaccio
70f2e7113e Use requests module for HTTP/HTTPS
This change introduces the use of requests in lieu of httplib2
to ensure proper handling of SSL termination.

Implements: blueprint tls-verify

Change-Id: If182f2addf26421873b8c3d2b60f8cba9b7a9450
2014-04-23 08:37:13 -07:00
Akihiro Motoki
abfc6b6ae9 Print human friendly string as an error message
This commit also removes a blank line displayed
when error_dict['detail'] is empty.

When 403 is returned, Forbidden exception is raised from
HTTPClient (neutronclient/client.py). There is no reason
this exception is raised by it. By this commit v2_0.client
now handles 403 response to show human friendly message
by parsing Neutron 2.0 -specific error format.

Change-Id: Iefbd7db094267fe3799ebf4713e142e62c63174c
Closes-Bug: #1246271
2014-03-03 02:04:34 +09:00
liu-sheng
e955a1fc80 Remove vi modelines
We don't need to have the vi modelines in each source file,
it can be set in a user's vimrc if required.

Change-Id: Ic30e91df1b0e25beda9b8d8c19be58573cdae4f6
Closes-Bug: #1229324
2014-02-10 17:00:28 +08:00
Monty Taylor
e34a06adf0 Move tests back to neutronclient package
Neutron itself has all of its tests in neutron/tests, as do 2/3 of
the projects in OpenStack. There are a wealth of reasons to put
them in the package, not the least of which that tests/__init__.py
implies a code living in a global namespace called tests.

Change-Id: I2aaacfe59d6790648aa4587e89e6dd28a9149a6c
2013-08-22 09:10:36 -04:00