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
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
There is not a way to pass the socket options to the HTTPAdapter upon
creation so we have to sub-class it and override the init_poolmanager
method. This also requires at least python-requests 2.4.0 but that
has 2 severe bugs that were fixed in 2.4.1. If we try to fix this
without a hard lower limit, we will not be able to properly set these
options on the socket at creation time.
Change-Id: I06e0d2c67d3197607e5f23f623c8fca69e1b23d7
Closes-bug: 1323862
Novaclient displays curl statements for debugging/troubleshooting
purposes. For IPv6 URLs, curl requires --globoff to be passed in
the arguments. Since novaclient does not use curl directly, this
patch displays the curl commands with globoff option which works
for both IPv4 and IPv6 URLs.
Closes-Bug: #1228744
Change-Id: Ib7099e8e3bbc15f29bbaa1db37ef21e78a74e7bc
This code change redacts the password in keystone request, and
also redact the token text in keystone response. The code still
makes REST call by itelf, instead of calling keystone client.
Closes-Bug: 1327019
Change-Id: Ib9c0610c1ef351a127364478721cf961c2a30125
Nova provides REST API versions.
This patch adds a subcommand "version-list" for outputting the versions.
Change-Id: I1b40ad57912aa740c0b1d9221018aba9b13a5436
F841 detects local variable is assigned to but never used.
This commit fix the violations and enable F841 in gate.
Change-Id: I52419f5e17db70e511ff2d4d61c85458c958e9c3
based on openstack-dev mailing list thread, support the {SHA1}
convention for headers that is generally agreed on.
Also fix a minor issue that Johannes found after the review landed,
which was doing substring matching instead of tuple matching.
Change-Id: I80a456c765026ac6179fd424ead01715798c1dac
replaying the keystone token in debug output is both completely
burdensome to read (given it's unbounded size), but it's also
potentially a security issue given that it could be used in replay
attacks.
Instead, filter the headers to sha1 sensitive things, with X-Auth-Token
being the only one listed so far. The sha1 will at least give us the
understanding of tokens being the same or different (and an administrator
could use that to figure out if they were valid later).
This also removes some extra '\n' that were being injected into the
debug logs, because they were not helping with readability.
Lastly, actually test logging. This introduces the first tests of the
logging path using the logging fixture. It's pretty basic, but does
verify that requests are logged at debug, that the SHA1 format works,
and that headers which are not listed get shown straight through.
DocImpact because this changes the curl dumped strings which people
may have been using. They can still do that as long as they generate
their own keystone token.
Change-Id: I1edb94785705c3b6a05f118b77d3aeb07461cd44
Prior to this patch, novaclient was handling sessions in an inconsistent
manner.
Every time we created a client instance, it would use a global
connection pool, which made it difficult to use in a process that is
meant to be forked.
Obviously sessions like the ones provided by the requests library that
will automatically cause connections to be kept alive should not be
implicit. This patch moves the novaclient back to the age of a single
session-less request call by default, but also adds two more
resource-reuse friendly options that a user needs to be explicit about.
The first one is that both v1_1 and v3 clients can now be used as
context managers,. where the session will be kept open (and thus the
connection kept-alive) for the duration of the with block. This is far
more ideal for a web worker use-case as the session can be made
request-long.
The second one is the per-instance session. This is very similar to what
we had up until now, except it is not a global object so forking is
possible as long as each child instantiates it's own client. The session
once created will be kept open for the duration of the client object
lifetime.
Please note: client instances are not thread safe. As can be seen from
above forking example - if you wish to use threading/multiprocessing,
you *must not* share client instances.
DocImpact
Related-bug: #1247056
Closes-Bug: #1297796
Co-authored-by: Nikola Dipanov <ndipanov@redhat.com>
Change-Id: Id59e48f61bb3f3c6223302355c849e1e99673410
auth_url can be None, for example, when we use bypass_url.
Also, add rstrip('/') for bypass_url (and management_url), which
is done when management_url is gotten from service catalog.
Change-Id: I4f59cc405386a15f8a266d279b27f279eacdb7f1
Replace assertEqual(None, *) with assertIsNone in tests to have
more clear messages in case of failure.
Change-Id: I6deee90c31adf61d80e2678a5f29ba9e187281c9
Adds --os-auth-token (matching Glance client at least) to accept a
pre-obtained authentication token.
CS will be called iff:
One or both of token and URL are not provided;
AND the cache is empty/disabled or we don't have a tenant-id.
Removed some code altering the auth request to a GET if a token is
supplied - did not work for me and I think the path was dead previously.
Fixed test to account for this change.
Completes blueprint token-endpoint-instantiation
Change-Id: I67410b80e506bb80c152223cd113b7139a62a536
some of tests use different method of assertTrue(isinstance(A, B))
or assertEqual(type(A), B). The correct way is to use
assertIsInstance(A, B) provided by testtools
Closes-Bug: #1268480
Change-Id: Ie3b3e49ea3cc4357a65605ad54ff4ee1fbde12c7
In novaclient.client.HTTPClient.request, json.dumps() process the
body of "POST":
kwargs['data'] = json.dumps(kwargs['body'])
So, in test case, we should pass the same forat for mock.call().
Also, transform the "data" variable to json format.
Close-Bug #1234067
Change-Id: I3a0abaa8064b4360cb94b7b205454e26bddef8e4
Client.__init__ method used self.os_cache variable in an internal method call
though this variable had not been initialized earlier.
In addition, unittests added for full coverage of client v3.
Change-Id: I421f82932b65f137932d933e04d42064bec0d08d
Fixes bug 1192656
Previously, the attempt to re-authenticate on possible token
expiry actually re-used the expired token, which was clearly
bound to fail in the expired case.
Now the old authentication state is discarded before attempting
re-authentication.
Change-Id: I3fd125702061f7ac84eb501d2a488aab5b2385b9
tests/__init__.py implies a package in the global namespace. These
tests are not global python tests, but rather tests for novaclient.
Change-Id: Ifeb8082aa010d15dddc9ae02e35589bc78ad48cc
Currently HTTPClient creates a new TCP connection for each
API request. We could actually reuse created connections by
relying upon HTTP keep-alive feature. That would enable us
to do a few queries in a row more efficiently.
Fixes bug 1170385.
Change-Id: Ie6d8fb9670938e3790017509a242630b67abd794
The requests module dropped all configuration with the 1.0.0 release.
There's no danger_mode and no 'verbose'' mode. The former
shouldn't be necessary anymore and the latter can be done by setting
a different log handler for the request.logging root logger.
Change-Id: Iec169ef6e39097814cdbf1b777bc0590236692ba
Add a new cli argument (--timeout) which
is by default 600 seconds which will be
set in the requests library so that timeouts
can occur correctly.
Change-Id: I716ac15fe08f42c9464ee43010bc8fd2667bcbde
Use testtools as the base testclass. Use fixtures library for managing
fixtures.
Part of blueprint grizzly-testtools
Change-Id: Iac5af286b988787acf7049344641aadf140b9398
Deprecates the old --no-cache option in favor of --os-cache.
The old CLI args (--no_cache and --no-cache) and ENV option
(OS_NO_CACHE) are still supported but no longer show up
in help.
The new option for --os-cache can also be set via the OS_CACHE ENV
variable... which now defaults to False. This should be much more user friendly.
Fixes LP Bug #1087776.
Change-Id: I3cea089c7e11ce75f22c2d7f3242b02b80441323