Commit Graph

17 Commits

Author SHA1 Message Date
Takashi Natsume 7ef2c28bf3 Use unittest.mock instead of third party mock
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>
2020-04-26 10:12:09 +00:00
Stephen Finucane b9a7e03074 Random cleanups
Remove some cruft from Sphinx config files, drop the use of 'u' prefixed
strings, which are unnecessary in Python 3, and generally tidy stuff up.

Change-Id: Ib0f33576e160ec842d7fc82b4fcfee99829623d7
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-02-21 09:56:37 +00:00
Stephen Finucane c4c44bcb2d Remove six
Mostly a find-replace job. Let's do this now so we don't have to carry
it for the next decade.

Change-Id: I7bef9fb7c6895f746cee1aca6522786f38b9857c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-02-21 09:48:38 +00:00
Takashi NATSUME 33e89f99a4 Fix server strings in reboot operation
The following message is shown currently in the reboot operation.

  Request to reboot server <Server: server1> has been accepted.

The server name string is a bit odd. So fix it as follows.

  Request to reboot server server1
  (ff79e91e-e2a7-4e0f-b4c3-7157676d43c9) has been accepted.

Change-Id: I62df4589dc950f69fdc23eafcbb5792e897cb635
Closes-Bug: #1785495
2018-08-07 15:30:48 +09:00
Andrey Kurilin ca27736810 Remove 2 redundant methods
I suppose that methods get_resource_manager_extra_kwargs and
add_resource_manager_extra_kwargs_hook were designed in those days when
Nova API had extensions.
Nowdays, Nova API has strict schema validation of requests, so no
additional arguments are allowed and these methods look redundant.

The fact that get_resource_manager_extra_kwargs lists of the objects
added by add_resource_manager_extra_kwargs_hook whereas
add_resource_manager_extra_kwargs_hook is not called anywhere
doesn't add chances for leaving these methods in our code.

Compatibility: both methods are designed for CLI and the CLI behaviour
  will not change after removing them, so we can do a cleanup without
  following standard deprecation cycle.

Change-Id: Id61457c3db8a17e2294dc579b2519873927fec48
2018-02-09 15:26:08 +00:00
Yikun Jiang 50460bddfc Use utils.prepare_query_string instead of duplicated code
There are some duplicated code in nova client for generating
query string.

The 'prepare_query_string' method can convert dict params to
query string(it transforms the dict to a sequence of two-element
tuples in fixed order, then the encoded string will be consistent
in Python 2&3.)

This patch use utils.prepare_query_string instead of these and
plus some notes in the 'prepare_query_string' method.

Change-Id: Idb3c5e97f8bbcd5ec5446f776c10fa8c84b54d5d
Closes-Bug: 1727968
2017-11-22 13:35:27 +00:00
Hironori Shiina fae24eee4a Modify flatten method to display an empty dict
When a dict is flattened, if a value of an item is empty,
e.g. {"cpu_info": {}}, the item is not displayed.

This patch fixes _flatten method to display such an item including an
empty dict.

Change-Id: I2e4ada0de217c5c4ddea10f3f283c6d8e78083b6
Related-Bug: #1594230
2016-08-05 02:15:14 +09:00
Andrey Volkov 6bbcedb000 Add support for microversion 2.33
This change allows novaclient to get several hypervisors
with the help of new optional parameters 'limit' and 'marker'
which were added to hipervisor-list command.

Change-Id: Ib723fb1dc1cd57b6f796bb93e0dd8ddf2da4b2a0
2016-08-03 18:37:55 +03:00
Andrey Kurilin cd88097ff5 [microversions] Enable 2.21
2.21 - The os-instance-actions API now returns information from deleted
       instances.

Change-Id: Iff514e4fa9135207c6f8e32e444d45b1b61d8c7c
2016-02-24 20:57:34 +02:00
Takashi NATSUME 2220c56375 Add wrapper classes for return-request-id-to-caller
Added wrapper classes which are inherited from base data types str,
list, tuple and dict. Each of these wrapper classes and
the Resource class contain a 'request_ids' attribute
which is populated with a 'x-compute-request-id' or
a 'x-openstack-request-id' received in a header from a response body.

This change is required to return 'request_id' from
client to log request_id mappings of cross projects.

This patch is one of a series of patches for implementing
return-request-id-to-caller.

Co-authored-by: Ankit Agrawal <ankit11.agrawal@nttdata.com>
Change-Id: I422c4f4ee59991ca89a0a16f548b537c8b61bb97
Implements: blueprint return-request-id-to-caller
2016-01-26 23:46:10 +00:00
jichenjc 8b8edc72e0 Not transform to str on potential unicode fields
some fields such as instance.display_name can be unicode,
nova client should not translate it to 'str'. otherwise
it will report UnicodeEncodeError.

Change-Id: I4f6011105b3b11dbbcb23f3a7c1bbcf7f20bcc8c
Closes-Bug: 1518141
2015-11-22 04:34:07 +08:00
rsritesh a061470a8e Improve hypervisor-show print list
Current hypervisor-show <hostname> command does not properly list
when there is a long list of cpu info feature. The long list of
cpu info feature has comma-separated values.
Because of this user is not able to read the print out properly.

print_dict() has been changed to show a list with comma-separated
values properly.

Change-Id: Icc53439cecd3b5eee2340267a0447ce209d7b653
Closes-Bug: #1466435
2015-07-10 16:13:24 +02:00
ZhiQiang Fan 1c39f8fabf Don't record time when self.timing is False
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
2015-03-21 19:27:36 +08:00
Pavel Kholkin 560eeafb6d Cleanup in asserts in python-novaclient
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
2015-03-03 15:36:49 +03:00
Pavel Kholkin f2a581ee28 Fixed redeclared test_names
Fixed redeclared test_names for two test functions that pass now:
 1) 'test_list_security_groups_all_tenants_on'
 2) 'test_find_by_str_name'

Small spelling corrections

TrivialFix

Change-Id: Iacb0ce5697779f9342c22a22cb2f29a8e063b459
2015-02-24 19:29:23 +03:00
Tomofumi Hayashi 0fd8816aa5 Change logic in find_resource() to identify upper-case/lower-case name.
Currently find_resource() searches resource with human_id before does
with name_attr.  With this logic, find_resource() cannot identify
upper/lower case. In find_resource(), human_id always matches and
name_attr never used in find_resource() because human_id made from
small letters of name_attr string (see bug/1318503).

To identify upper/lower case, name_attr should be used before human_id.
This fix moves name_attr to ahead of human_id with unit-test cases.

Change-Id: I9b821d7111c11a97be38f19de06172daf410022d
Closes-Bug: #1318503
2015-02-05 02:48:24 +00:00
Joe Gordon 3561772f8b Move unit tests into unit test directory
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
2015-01-27 13:06:06 -08:00