Commit Graph

243 Commits

Author SHA1 Message Date
Doug Hellmann 109d41e722 use stevedore to load extensions
Importing pkg_resources causes the app to scan the entire import path
for all distributions, not just those providing entry points. The
scanner in stevedore will have a cache of the entry point data, making
it significantly faster. This will be especially useful in command
line programs like python-openstackclient.

Change-Id: Ic5eb9401c8ea3bd9624b818e0ffb8dcc13f61559
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2020-07-08 08:53:07 -04:00
Takashi NATSUME 81ec72ecf8 Remove deprecated methods and properties
Remove deprecated methods, properties and unused classes.

Change-Id: I16e0b6e55a9c9da04c4582f9be672018d37bf368
2019-07-04 04:06:42 +00:00
Takashi NATSUME 8eb7d1c5cc Remove deprecated novaclient.v2.contrib modules
All modules of novaclient.v2.contrib have been removed.
The 'only_contrib' parameter for the
'novaclient.client.discover_extensions' method is no longer valid.

Change-Id: I6da83057dda1f27afe98a2412bc0815f100f34a4
2019-02-07 15:00:36 +09:00
ZhijunWei 85e9b58e9b Update hacking version
1. update hacking version to latest
2. fix the pep8 failed

Change-Id: I484a40fe3cb868d223a807edcd3e20f5e0ebdf4e
2019-01-04 14:46:07 +08:00
Takashi NATSUME 264c22a9cc Fix setting 'global_request_id' in SessionClient
In Ic75be3acb8b77aae8da631e3c4cd6f545a9a35cb,
'global_request_id' is set
in the constructor of class keystoneauth1.adaptor.Adapter.

But 'global_request_id' was not passed to the constructor,
'global_request_id' was cleared.
It caused the test failure.

It is not necessary to set 'global_request_id'
in the constructor of class SessionClient
and just passing 'global_request_id' in kwargs
is required.

Change-Id: Id587e35c221fe2b11889469f88557d254125ea7e
Closes-Bug: #1697358
2017-06-13 12:15:39 -04:00
Sean Dague d25502cbe2 Have python-novaclient support global_request_id
As part of the Boston Summit, support the global_request_id effort by
making python-novaclient support passing global_request_id during
construction.

part of bp:oslo-middleware-request-id

oslo spec I65de8261746b25d45e105394f4eeb95b9cb3bd42

Change-Id: Ife29b1856c0c278eab1708c3971fef14b9d77e2e
2017-05-26 08:32:05 -04:00
Monty Taylor 92665dbcd8
Add novaclient client_name and client_version to user-agent
keystoneauth supports setting additional info into the user-agent string
about what the client is. Set it so that novaclient shows up in server
logs as the client.

Change-Id: I084a16f5372ec7df598505e9f925a70d26d66f69
2017-04-18 08:03:23 -05:00
libing 736ed310ac Remove log translations
Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: I4c8c83315897c7e64b05402c233b0fa67eb03a6e
2017-03-25 14:03:26 +08:00
Matt Riedemann ac7c96690f Remove deprecated tenant network APIs
These were deprecated in Newton:

aaebeb05a0

Since this is the last of the deprecated contrib extensions,
we can also deprecate the 'only_contrib' parameter from the
novaclient.client.discover_extensions method.

Change-Id: Ie2e3fdc4e044f6eb304724d16a7d0f1f7ba705fd
2017-03-20 16:36:58 -04:00
Matt Riedemann dee51a0163 Remove deprecated baremetal CLIs and APIs
These were all deprecated in Newton with change:

87c1b5311b

So now we can remove them.

Change-Id: Ic74a989b8a6565cc52ab82440fab8605a4b78e6b
2017-03-20 15:33:23 -04:00
Istvan Imre 9940e3fe0e Pass relevant parameters to Token based authentication
In case of token authentication is used pass relevant parameters
to Token authenticator.

Co-Authored-By: Andrey Kurilin <andr.kurilin@gmail.com>
Change-Id: I9a04d89016a834fe96f1b77e91011f7fa4fdda51
Closes-Bug: #1654183
2017-01-24 15:52:22 +02:00
Abhishek Kekane 98976d5ab8 x-openstack-request-id logged twice in logs
In the recent release of keystoneauth1 2.18.0 provision is made to log
x-openstack-request-id for session client. Once this new library is synced
in openstack projects, the x-openstack-request-id will be logged twice
on the console if session client is used.

For example,
$ nova --debug list

DEBUG (session:640) GET call to compute for
http://10.232.48.204:8774/v2.1/servers/detail used request id
req-b6aeff56-0408-44ed-80ba-cd7b950a8f21

DEBUG (client:85) GET call to compute for
http://10.232.48.204:8774/v2.1/servers/detail used request id
req-b6aeff56-0408-44ed-80ba-cd7b950a8f21

Above log will be logged twice on the console.

Removed logging of x-openstack-request-id in case of SessionClient as it
is already logged in keystoneauth1.

Depends-On: I492b331ff3da8d0b91178bf0d5fe1d3702f15bd7
Closes-Bug: #1657351

Change-Id: I9ba6a9e498fbcb027f45499d27ece966c52580ba
2017-01-19 18:12:39 +05:30
Boris Pavlovic 0fed79fd8f Add profiling support to novaclient
To be able to create profiling traces for Nova, 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 heat calls nova via python client, if
profiler is initialized in heat, nova client will add extra
header, that will be parsed by special osprofiler middleware in nova
api.)

Security considerations: trace information is signed by one of the
HMAC keys that are set in nova.conf. So only person who knows HMAC key
is able to send proper header.

oslo-spec: https://review.openstack.org/#/c/103825/
Based on: https://review.openstack.org/#/c/105089/

Co-Authored-By: Dina Belova <dbelova@mirantis.com>
Co-Authored-By: Roman Podoliaka <rpodolyaka@mirantis.com>
Co-Authored-By: Tovin Seven <vinhnt@vn.fujitsu.com>

Partially implements: blueprint osprofiler-support-in-nova

Depends-On: I82d2badc8c1fcec27c3fce7c3c20e0f3b76414f1
Change-Id: I56ce4b547230e475854994c9d2249ef90e5b656c
2017-01-19 03:50:06 +00:00
Kevin_Zheng aeec4d11b2 Fix "Message object do not support addition".
In the 7.0.0 Novaclient release we added some warning
log about user should using "endpoint_type" rather than
"interface" when init novaclient:
https://github.com/openstack/python-novaclient/blob/master/novaclient/client.py#L312-L327

https://github.com/openstack/python-novaclient/blob/master/novaclient/client.py#L249-L272

This is now causing a lot jenkins failures acroos projects
that is using novaclient with enable_lazy set to False.
As in this kind of scenario the warning message is a message
object instead of unicode sting and it cannot be added:
http://git.openstack.org/cgit/openstack/oslo.i18n/tree/oslo_i18n/_message.py#n227

and "Message object do not support addition" will raise.

Related Jenkins Error:
Ceilometer:
http://logs.openstack.org/29/333129/3/check/gate-ceilometer-python27-ubuntu-xenial/bd125e7/

Closes-bug: #1652414
Change-Id: I11a490f759fdac9707c1321c9659da2605196a94
2017-01-08 00:21:53 +00:00
Andrey Kurilin 0bdd24518e Deprecate volume_service_name argument
We forgot about it while removing all methods related to Volume API.

Change-Id: I465b91a17e2633ae876c0011bc8af6ec475c8d48
2016-12-17 17:51:57 +00:00
Andrey Kurilin 2e5576dafc Remove all code related to HTTPClient
In previous patch we switched to use SessionClient in all cases. It means that all
HTTPClient code is redundant now.

Change-Id: I5a0da970fd82c79db3d88f1b49279133bbdba639
2016-12-16 12:56:18 +00:00
Andrey Kurilin 8409e006c5 Create keystone session instance if not present
Since all authentication plugins should be stored in Keystone, there is no
need to share responsibility for authentication stuff with Keystone team.
Let's use convinient and the right way to use keystone - keystone sessions.
We have own adapter for it - novaclient.client.Session which can be used in
100% cases of novaclient usage. Let's create session object if it is not
transmitted via arguments and get rid of novaclient.client.HTTPClient
implementation.

NOTE: novaclient.client.HTTPClient and all related code will be removed
      separately.

Co-Authored-By: Clenimar Filemon <clenimar@lsd.ufcg.edu.br>
Change-Id: Ibb99fdafbf02b3e92f1a5d04d168151b3400b901
2016-12-16 12:56:10 +00:00
Andrey Kurilin e4dc84e0f6 Make SessionClient interface similar to HTTPClient
HttpClient will be deprecated soon and SessionClient will be used by default.
To not break integration novaclient with other project at the step of moving
from HTTPClient, SessionClient should have similar interface.

Change-Id: I855ccc5160dc7628f4550e93bf133adf8263aace
2016-12-16 12:55:57 +00:00
Andrey Kurilin b4bd07e5a7 Deprecate connection_pool variable
This is the last variable which is redundant in case of SessionClient.
After this patch we will be able to use SessionClient in 100% usecases.

Change-Id: I102ba25eee7434cb66ea6efbf9ec4ab310d0957a
2016-12-16 12:55:44 +00:00
Andrey Kurilin 2163e6661a Transmit all auth related vars from cli to inner methods
We need cert, project_domain_id, project_domain_name, user_domain_id,
user_domain_name arguments to constract SessionClient in proper way.

These variables will be used in further patches

Change-Id: I44416de7f4dc18916aecb6884158b416e696227e
2016-12-16 12:55:34 +00:00
Andrey Kurilin 77048cc27e Deprecate proxy_token and proxy_tenant_id args
http://lists.openstack.org/pipermail/openstack-dev/2016-October/106098.html

Change-Id: I1ab6d8d36fd2b39c78c5111cbe8191f20e0cda3e
2016-12-15 23:02:58 +00:00
Andrey Kurilin 9bbe5a87b7 Clarify meaning of project_id var
Meaning of project_id (argument of novaclient.client) was not clear.
In different cases, it can be tenant/project id or name (in terms of
Keystone).

* tenant_id - this variable is deprecated now and project_id should be
              used instead;
* project_id - meaning of this variable is clarified now and it expects
               Project ID (in terms of keystone) now.

Change-Id: Ie3fc6b50260203c0debe8664bb87a7d72fb645d7
2016-12-15 19:49:04 +02:00
Andrey Kurilin 9df9aff6fc Rename interface to endpoint_type
'interface' argument was not described anywhere in novaclient's docs,
but since we transmit all additional (unexpected) arguments to
SessionClient implementation, keystoneclient was able to use it.

Change-Id: Id7200a6df416694173b9a02206c53cef984f0fec
2016-12-15 19:49:03 +02:00
Andrey Kurilin f98b8470de Rename api_key to password
"password" term is more clear. Resolves FIXME from the code:

    FIXME(comstud): Rename the api_key argument above when we
                    know it's not being used as keyword argument

Change-Id: I39f810a181b119591cf017eded71356a437a8c0a
2016-12-15 19:49:03 +02:00
Andrey Kurilin 1ce917ef25 Rename bypass_url to endpoint_override
* there are two terms in openstack which describes the same thing:
     bypass_url and endpoint_override
* endpoint_override is more wide term. It is used in Keystone)
* since not all openstack folks knows that bypass_url and endpoint_override
  are the same, bypass_url (variable which was used in novaclient) was not
  transmitted to SessionClient

NOTE: name of variable in inner class HTTPClient was not changed, since
      this class will be abandoned soon.

Change-Id: I2d45820c01851b271de8ea66e0d59ec494040c04
2016-12-15 19:49:03 +02:00
Andrey Kurilin 73196fd3c1 Remove redundant args of _construct_http_client
Arguments 'extenstions' and 'no_cache' were not transmitted to
'_construct_http_client' method. They are redundant

Change-Id: Ibe0f874e510eef7cc28fcee87b0083c7febd5161
2016-12-15 19:49:03 +02:00
Andrey Kurilin bf09ad844e Introduce helper for checking args deprecation
This patch introduces `_check_arguments` methods for processing deprecation
workflow of novaclient.client.Client entry-point.

Also, this patch adds a proper warning messages for 'auth_plugin',
'auth_system' arguments, which were removed previously

Change-Id: I7ee210c08f4126b267572c5428511451aeb17260
2016-12-15 19:49:03 +02:00
Andrey Kurilin 330516543b Sort arguments for client's methods
We have a lot of arguments in several Clients methods. Reviewing their
changes is a hard task, so let's sort them to simplify reviews.

Change-Id: Ie78773fd92017fbc4631d0fc6ae9da2e15935537
2016-12-15 19:49:03 +02:00
Andrey Kurilin 4ff6c617ec Restict usage *args for novaclient.client.Client
Possitional arguments doen't allow to provide proper compatibility
and deprecation workflows. *args was deprecated long time ago and a
proper message was added.

Change-Id: Ib4a8f4db52a0f4cb8e8cf5e8c8e778eef8831e91
2016-12-12 18:06:14 +00:00
Andrey Kurilin f834711d2f Move all extensions from contrib dir
All extensions from novaclient.v2.contrib should be not be extensions in
case of api version >=2.0;<=3.0 (historically, they are turned on by default
for cli layer), so let's move it from contrib dir and turn on by default.

Change-Id: I4ef4e44cf970947dad33110ce658a133e4f2893e
2016-11-30 18:00:05 +00:00
Matt Riedemann daa9bdc823 Remove support for non-keystone auth systems
The support for non-keystone auth systems and plugins
was deprecated with 1f11840dd8
back in the 3.1.0 release in mitaka.

Now that we're working on shoring up the support for
keystone auth sessions in the client and eventually moving
to remove support for the non-session HTTPClient, we should
also remove the support to load non-keystone auth plugins.

The whole concept of non-keystone auth systems/plugins is
a legacy artifact and is a barrier to interoperability which
is a goal of nova and OpenStack in general.

Change-Id: Ia649db257c416ca054977812ecb3f1a8044fa584
2016-10-20 12:04:58 -04:00
bhagyashris 744c9b6ada Replace functions 'Dict.get' and 'del' with 'Dict.pop'
Refactoring code: Making 'kwargs' dict to use single instruction: pop()
rather than two instructions: get() and del, giving the codes a format
that carries through.

TrivialFix

Change-Id: Icaf4a57314a8fe48f51993d7b32a1671fec40f31
2016-08-24 11:56:56 +05:30
Takashi NATSUME d16c3692e6 Log request_id for each api call
Add the function to log 'x-openstack-request-id' or
'x-compute-request-id' in each API call.
If the caller (e.g. heat) uses oslo.log,
the caller's request id in oslo.context and
the callee's request id can be output in the same
log message (same line).

Change-Id: I29312ce278ecfae41a688a0ddf76c24cfa0eaf6b
Implements: blueprint log-request-id
2016-06-08 00:10:55 +00:00
Andrey Kurilin 2a72b86cd1 Restrict positional arguments for Client
It is hard to deprecate or remove arguments for Client objects. We already
have several args which are not used anywhere and we need to do something
with them(clean code).

Change-Id: I2218ff0c750922a105d21a13e42f193ffd86ec01
2016-04-19 12:39:12 +03:00
jichenjc 68c16f82d5 Prepare to move extension into core plugin
As nova stable_api.rst indicated: As the extension will be removed
from Nove V2.1 REST API. So the concept of core API and extension
API is eliminated also. There is no difference between Nova V2.1
REST API, all of them are part of Nova stable REST API.

so we can move all extensions from contrib to core, this
patch is prelude of https://review.openstack.org/#/c/285213/ and
its following patchs.

Change-Id: Ibd5df4bcc70a4b4854fd519330d89c751f7409dc
2016-02-24 17:15:31 +08:00
Jenkins eb461f082b Merge "Add a way to discover only contrib extensions" 2016-03-01 00:48:38 +00:00
Andrey Kurilin c18ccb1bfa Add a way to discover only contrib extensions
Several OS projects(cinder, neutron, osc...) use
`novaclient.discover_extensions` for initialization novaclient.client.Client
with novaclient.v2.contrib extensions. In this case, it would be nice to
provide a way to not discover extension via python path an entry-point.

Change-Id: I030f4c55c2795c7f7973f5f12e54b9819c4a5578
Closes-Bug: #1509500
2016-02-19 11:42:24 +00:00
Andrey Kurilin 55a97ea267 [microversions] Turn off check for header in response
We need to check header only for nova-related calls. While we are unable to
determine nova's calls, let's just temporary disable it now and turn on it
in the future with 2.18 microversion.

Change-Id: I92cecb140fc478f0cf37783d2fcfcaccd935bdfc
NOTE: this check affects only novaclient-as-a-lib
2016-02-16 16:54:07 +02:00
Dirk Mueller fa3a8edf20 Fix W503 line break before binary operator
According to PEP8 the line break should be always after
a binary operator.

Change-Id: I9d0f6909d0e649fe740b748b831894ccb4e80b15
2016-01-09 09:27:38 +01:00
Sean Dague f9f9a4654c Add python 2.7 comment
Change-Id: Ie4183da314bd7ca0719f45f0d9b3c26f8707e266
2016-01-04 12:33:27 +00:00
Jim Rollenhagen 48c9a91de6 Fix extension loading from python path on Python 2.7
Commit 81f8fa655c broke extension loading
from pythonpath on python 2.7 due to the removal of code that was
erroneously marked for 2.6 compatibility. Put it back.

Change-Id: Ic04f4d57953967fde9817ff5119ce0182453a86d
Closes-Bug: #1530230
2015-12-31 00:04:33 +00:00
Monty Taylor 1f11840dd8 Migrate to keystoneauth from keystoneclient
As a stepping stone to the os-client-config patch, first switch to
using keystoneauth, its Session and its argparse registration and
plugin loading to sort out any issues with that level of plumbing.
The next patch will layer on the ability to use os-client-config
for argument processing and client construction.

Change-Id: Id681e5eb56b47d06000620f7c92c9b0c5f8d4408
2015-12-12 20:39:57 -08:00
Jenkins f02ca48a4e Merge "Fix H404/405 violations in client.py,base.py,api_version.py" 2015-12-03 17:51:58 +00:00
Ghanshyam aa73df2649 Fix H404/405 violations in client.py,base.py,api_version.py
There is a lot of H404/405 violations in novaclient, and it is better
to fix those to have a better doc string for class/methods.

This patch fixes these violations for below files-
-api_versions.py
-base.py
-client.py

As there are lot of violations and cannot be fixed in single patches,
So separating those in multiple patches for easy review.

Change-Id: I30a714fc3b0b317f7ffa4a99fbb224b4d5f5477b
Partial-Bug: #1521899
2015-12-03 11:45:22 +09:00
Chuck Carmack 81f8fa655c Remove python 2.6 support from python-novaclient
Since oslo is removing support for python 2.6, nova
needs to also remove support from clients and libraries.
This commit is to remove support from python-novaclient.

-- Python 2.6 compatibilty code was removed.
-- Python 2.6 was removed as a tox environment, install venv,
and from the classifiers in setup.cfg.
-- Release notes have been updated.

UpgradeImpact

Co-Authored-By: Andrey Kurilin <andr.kurilin@gmail.com>

Change-Id: I3f587ff38d478d075af5fd014e2b4b8416e185d4
Closes-bug: 1518390
2015-11-30 16:04:24 +00:00
Andrey Kurilin 4393d90524 Check response headers for microversions
novaclient provides version negotiation on CLI layer. In case of usage
novaclient as a lib, user can specify api_version with microversion part
and can try communicate with Nova endpoint which doesn't support
microversions. Nova endpoint will not check X-OpenStack-Nova-API-Version
header and will execute request(it can be correct or not). It this case
we should warn user about his mistake and about "incorrect" response.

Change-Id: I7a5ab964b7b2b2a49cc80c22bf67ad5548afb30b
2015-11-23 20:13:13 +02:00
Matt Riedemann 63c7a576e1 Revert "Do not expose exceptions from requests library"
This reverts commit 2961e82bfa

This broke cinder unit tests that have a timeout test for novaclient
where they mock the requests library raising a Timeout exception. That
test expects to get a requests Timeout passed through but with the
change being reverted it was getting a RequestTimeout exception from
novaclient, which breaks the test and fails the gate runs.

We could change the cinder unit test to handle both the requests.Timeout
and the new novaclient RequestTimeout, but that's just papering over
the cinder failure, we wouldn't know what other clients are failing
in the same way because they have code working around the requests
exceptions getting passed through, so we should treat this like an API
change.

I'd be in favor of making the same change again iff the novaclient
exceptions extended the requests exception types so it would be transparent
to consumers, since novaclient.exceptions.RequestTimeout would be a
requests.Timeout via inheritance. But given the gate breakage and it being
summit week I'm inclined to revert first and think about a better long term
fix later when people are back to discuss.

Change-Id: I368728588e5997eef860a168539eb66c58f2e72a
Closes-Bug: #1510790
2015-10-28 07:27:40 -07:00
Jason Dunsmore 2961e82bfa Do not expose exceptions from requests library
Novaclient expects the requests library to always be able to get a
response back and doesn't handle other cases where it might raise
an exception even before the request is completed (e.g.
ConnectionError).

These exceptions should be captured and properly converted to some
native novaclient exception.

Change-Id: Iec7247b715c38c29910b30e76413cead4e951a37
Co-Authored-By: Kuo-tung Kao <jelly.k@inwinstack.com>
Closes-Bug: #1406586
2015-10-22 14:34:23 -05:00
Andrey Kurilin 147a1a6ee4 Deprecate 'novaclient.client.get_client_class'
This method is redundant and blocks versioned client classes to change
interface. `novaclient.client.Client` should be used instead.

Releated-Bug: #1493576
Change-Id: I73cea2c6062419d75646e9239c6194f4d1ffd2b1
2015-09-10 15:55:26 +03:00
Andrey Kurilin a96e9d57c5 Restrict direct usage of novaclient.v2.client
A lot of project uses incorrect import of versioned novaclient client obj
(i.e. novaclient.v2.client.Client). It leads to unability to change
interface of such inner classes.

This patch updates docs to include warning note and add warning message to
`novaclient.v2.client.Client` object.

Change-Id: Ifeba391716d3d51d6a75a53cad405e1ec595e27b
Related-Bug: #1493576
2015-09-10 15:54:38 +03:00