Change I53caceb08667eb12e27016731868e8015dd10e34 fixed a bug where we
weren't using our novaclient logger default when a logger was not
passed to the Client constructor.
This adds unit tests to assert the fixed behavior and protect against
regression.
Related-Bug: #1921388
Change-Id: I9f622c01a6b1abe328a60de6d3e438e68872dd80
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.
Change-Id: I4d45ae17f6f84f945f5dd049a929216ce6b6b58e
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
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
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
v2 and v2.1 is supported now and it ask user to use v2.x API
should be what we wanted , this already deprecated for a
couple of release, so we can remove it now
Change-Id: I8de6fdbf21ccc4969297044a49590ffcd9cd27d8
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
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
In previous patch we switched to use SessionClient in all cases. It means that all
HTTPClient code is redundant now.
Change-Id: I5a0da970fd82c79db3d88f1b49279133bbdba639
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
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
"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
Arguments 'extenstions' and 'no_cache' were not transmitted to
'_construct_http_client' method. They are redundant
Change-Id: Ibe0f874e510eef7cc28fcee87b0083c7febd5161
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
The novaclient tests are broken with the master (unreleased) branch of
requests. This is because most of the mocking that novaclient does with
requests in insufficient.
Requests-mock is for exactly this purpose and is already widely used in
novaclient so replace using mock with requests-mock where appropriate.
Closes-Bug: #1630157
Change-Id: Ie91daeb5f0c241eb83b77c04ac1b12e431d6671c
When instantiating novaclient with kwargs or named attributes, the 'password'
field is duplicated due to an overwrite on the __init__ method of Client v2.
This patch pops out the password field when it's passed and no api_key is
provided.
Co-Authored-By: Pavel Kholkin <pkholkin@mirantis.com>
Closes-bug: #1511417
Change-Id: Id8310eccef5f0f9a2983e25dd35541d1eb0efe86
The tests in novaclient/tests/unit/test_client.py use several domain
names other than example.com, which should always be used to avoid
conflict with actual domains. These include foo.com, blah.com, and
nooooooooo.com, all of which are legitimate owned domain names. These
have been replaced with example.com usages.
Closes-bug 1555682
Change-Id: I6573e118364300cd09653b87df28ba1a95870d3c
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
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
Problem:
When we run nova client unit test, there are lots of UserWarnings
printed on the screen. These warnings mean to remind users not to
use v2.client directly.
Solution:
1. In top level tests such as some tests in test_auth_plugins.py
test_client.py and fixture_data/client.py, we use updated usage
novaclient.client instead of using novaclient.v2.client directly.
2. In v2 unit tests, we clean those warnings with setting direct_use
False.
Change-Id: I70682e54874860f1d67d29325811c9da616bb705
Closes-Bug: #1532711
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
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
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
If a user doesn't specify for novaclient's Client neither credentials
nor auth token, but specifies http_log_debug=True, and requests Nova
version list, novaclient fails with AttributeError exception.
The reason is that obfuscation of auth token doesn't expect None value
of the token. This patch bypass obfuscation of None token.
Closes-Bug: #1488169
Change-Id: I3712d633719bc77310ce863da33b2eec59a7ce91
novaclient transforms its management_url to get an url for a request for
server versions list. Currently this transformation does not consider
that version part of an url can be complex and contain major and minor
parts. As a result versions.list does request on a wrong url and fails
with NotFound error.
This patch adds support of version formats like 'vN.N', 'vN.NN', etc.
Partial-Bug: #1483030
Change-Id: Ie105bec37ee41c6a77ffc5f1cf680bbf88846159
When novaclient isn't using a session from keystoneclient, it needs to
set reasonable TCP Keep-Alive values otherwise the operating system
defaults may cause the client to hang for hours before a connection will
time out. Using keystoneclient's adpater (which sets good defaults) will
allow us to not have to maintain this adapter here and to benefit from
their defaults.
Closes-bug: 1477275
Related-bug: 1323862
Depends-On: Ibd53ae2d4d2455db0ebc9951e5c764befc57850f
Change-Id: I1924bd96eb1a4bac5d57a5cc5d5461acb3f7f5ac
Compute API version will be transmitted to API side via
X-OpenStack-Nova-API-Version header, if minor part of version is presented.
New module "novaclient.api_versions" was added as storage for all api versions
related functions, classes, variables and etc.
`novaclient.api_versions.APIVersion` class is similar to
`nova.api.openstack.api_version_request.APIVersionRequest`. The main
difference relates to compare methods(method `cmp` is missed from Py3) and
processing "latest" version.
Related to bp api-microversion-support
Change-Id: I0e6574ddaec11fdd053a49adb6b9de9056d0fbac
On my production system, when using client version 3, an exception is
raised with an incomplete message as the installed novaclient is
failing to find the bundled client versions. This commit creates a new
_get_available_client_versions() method and moves the client version
searching from get_client_class() into it.
We also update __get_available_client_versions() to pass
pkgutil.iter_modules the full path to novaclient rather than
'novaclient', which is what actually resolves the issue here.
Lastly, we add a single test to ensure that
__get_available_client_versions() does not return an empty list.
Change-Id: I07ce414863e833c72e50ad8cf1824054cfb41457
Closes-Bug: #1463809
Module novaclient.v1_1 is already deprecated, so it's time to stop using it
inside novaclient.
Since support of v3 nova is undocumented feature, which uses v2
implementation, we can remove code related to it.
Also, this patch removes redundant check for compute api version != 1.0.
Change-Id: I06b349f704d5ae2c592d8d286da268870f2a69e9
Change https://review.openstack.org/#/c/164321 broke the bypass_url
option. It made the assumption that self.service_catalog won't be set
in novaclient/client.py when bypass_url is specified, which isn't
necessarily true. This change adds a check for self.bypass_url and
looks up service url only if bypass_url hasn't been specified.
Closes-Bug: #1445086
Change-Id: I72d2b3e3199aeae7fb2f2c68be259774e07a4501
The expected behavior is when timing is True, then we record each
request's time, then we should call reset_timings() to release memory.
However, the shell, client.{HTTPClient,SessionClient} will record each
request's time no matter what timing is set, then after long running
time in service like ceilometer-agent-compute, the memory keeps increasing.
We'd better not record request's time when timing is set to False.
Users are not responiable to call reset_timings() when they don't want
timing functionality.
Change-Id: I3e7d2fadf9a21be018781d528a1b6562228da6dd
Closes-Bug: #1433491
Currently, several of the volumes apis depend on callers to pass
service_type='volume' as a parameter when creating a client object,
to route correctly. The problem is, it makes it impossible for
callers to work with both the compute and volume endpoints at the
same time. They can either work with compute and have volumes.* calls
return 404, or they can work with volume and have servers.* images.*
flavors.* calls return 404.
The CLI sets service_type='volume' for client objects for the
following commands via a decorator:
volume-list
volume-show
volume-create
volume-delete
volume-snapshot-list
volume-snapshot-show
volume-snapshot-create
volume-snapshot-delete
volume-type-list
volume-type-create
volume-type-delete
With this change, the service_type 'volume' is set in the api,
so the decorators on the shell commands are no longer needed.
Closes-Bug: #1431154
Change-Id: I11b48ac14fa4c64d8aae528552ec5b363be384c5
The following replacements were done:
1) assertEqual(True, *) -> assertTrue(*)
2) assertEqual(False, *) -> assertFalse(*)
3) assertTrue(a in b) -> assertIn(a, b)
4) assertTrue(* is not None) -> assertIsNotNone(*)
TrivialFix
Change-Id: I8d8a2d7b5d3505e07728544b683b301d1a8850cf
Fix E124 failures and enable check for E124
E124 closing bracket does not match visual indentation
Change-Id: Iec6af44362dcf613cfaccbccbe53de82aba51a6a
This reverts commit 4c8cefb98a.
The cache completion was causing a bug where 'nova volume-attach' would
then try to query Nova for volume information using a URL that was not
valid. This caused it to appear that the attach had failed.
Additionally the idea of making extra API queries for a bash completion
cache should be thought through more.
Conflicts:
novaclient/client.py
novaclient/shell.py
novaclient/v2/client.py
novaclient/v3/client.py
Closes-Bug: #1423695
Change-Id: I6676a11f9b5318a1cda2d03a5d4550bda549d5c2
I observed a transient unit test failure [1] where occasionally the
ordering of the keys in the string result from json.dumps() didn't
match the ordering in the call_args_list, causing the test to fail.
This change adds a dict comparison of the POST data payload instead
of comparing the json.dumps(data) strings.
[1] http://logs.openstack.org/03/153203/3/check/
gate-python-novaclient-python34/f8a12bc/
Change-Id: I6b8bd4169b92870f657bf4e7f7fca02722749017
This fix changes the item that cached for completion from
"human_id" to "name".
A string for completion shoud not be changed in any way,
because changed keyword can not use as command line parameter.
But the "human_id" means "human readable id" that is
changed from "name" by method "to_slug". "to_slug" is meant to
create a valid path name from a string.
The tools/nova.bash_completion take the completion string from
the file ".novaclient/*/*-cache". The file is created when client
call "list" command. For example , "nova list","nova image-list",
and the others.
Currently, items that are written to the cache file is the "id"
and "human_id".
Closes-Bug: #1193049
Change-Id: I241ec8b7c8729274ee43db6e360141fd381b265e
Module novaclient.v1_1 is used as implementation of V1.1, V2 and V3.
Since future development(microversioning) will be done across V2,
implementation should be done in appropriate module(to prevent misleading).
Despite the fact that implementation for all versions are equal, discover
method for contrib path worked only for v1.1. This patch fixes this bug and
modifies shell tests to check all versions.
Change-Id: Ib6798f4dfe177586302141f522dc593560ce6a5b
In order to pave the way for functional testing, move existing unit
tests into a directory labeled unit. A subsequent patch will add a
directory for functional tests.
Change-Id: I0adb8b9f14451acb382c725d31f5387b4b6d82bb