Commit Graph

14 Commits

Author SHA1 Message Date
Victor Stinner 68f6f080b2 Replace dict.iteritems() with six.iteritems(dict)
This patch was generated by the sixer tool version 0.2 using the
"iteritems" operation:
https://pypi.python.org/pypi/sixer

Manual changes:

- Don't change get_instance_metadata() in nova/compute/api.py:
  fixed by the change Ifd455e70002eb9636b87f83788384127ba6edeeb.
- Don't change sqlalchemy code and
  nova/tests/unit/db/test_db_api.py. sqlalchemy objects cannot be
  converted to a dictionary using dict(obj) directly yet. It will be
  possible with the change I702be362a58155a28482e733e60539d36c039509.
- Revert change in a comment in nova/objects/instance.py; the sixer tool
  is limited and don't understand comments
- Reformat nova/virt/vmwareapi/driver.py to respect the 80 columns
  contraint

Blueprint nova-python3
Change-Id: I81465661cb8a74778d70ba9b6641073f1effa49b
2015-05-22 11:33:18 -07:00
Victor Stinner b259659a22 Use six.moves.range for Python 3
The function xrange() was renamed to range() in Python 3.

Use "from six.moves import range" to get xrange() on Python 2 and range() on
Python 3 as the name "range", and replace "xrange()" with "range()".

The import is omitted for small ranges (1024 items or less).

This patch was generated by the following tool (revision 0c1d096b3903)
with the "xrange" operation:
https://bitbucket.org/haypo/misc/src/tip/python/sixer.py

Manual change:

* Replace range(n) with list(range(n)) in a loop of
  nova/virt/libvirt/driver.py which uses list.pop()

Blueprint nova-python3
Change-Id: Iceda35cace04cc8ddc6adbd59df4613b22b39793
2015-05-20 15:19:51 -07:00
Victor Stinner 8b306d0f31 Replace iter.next() with next(iter)
On Python 3, iterators have a __next__() method, but no next() method.
Use the builtin next() function which works on Python 2 and Python 3.

This patch was generated by the sixer tool version 0.2:
https://pypi.python.org/pypi/sixer

Manual change:

* Fix indentation
* tarfile.TarFile is not an iterator and has a next() method on Python 2
  and Python 3: revert changes in
  nova/tests/unit/virt/xenapi/image/test_utils.py and changes on
  self._tarfile in nova/virt/xenapi/image/utils.py.

Blueprint nova-python3
Change-Id: Ie691d6f236a5aeef049f0b191dd07167020443d7
2015-05-13 11:17:05 +02:00
Timofey Durakov eafa17d0c0 refactored tests in test_wsgi to pass with random PYTHONHASHSEED
assertions compare parsed response so element order message/code
became not important

Partial-Bug: #1348818

Change-Id: I0be46d38851f4532a0d0738fc1c93d56faa22052
2015-03-26 09:59:11 +03:00
Chris Yeoh 800b112885 Consolidate use api request version header
Finish off use of a definition of what the api request version header is rather
than literally copy it through the tests. This was partially done in the dependent
changeset I3ea2b2982c5f792c82832d772ae951b157da8b39

Partially implements blueprint api-microversions

Change-Id: I029d0f4d9b11a47925aaa0faaa97384f2af80ba9
2015-02-24 12:12:47 +10:30
Ken'ichi Ohmichi 9a792e0f72 Change microversion header name
Ironic has already implemented its own microversion mechanism, and
the header name is X-Ironic-API-Version, not X-Baremetal-API-Version.
Because Ida9f60d8cbd0dcf48669b82e619fc4016ee0bcb7 removed program
terminology from the governance repo.
The microversions of Nova is not used yet. And for consistency of
whole OpenStack projects, this patch changes microversion header
names on Nova side.

Partially implements blueprint api-microversions

Change-Id: I3ea2b2982c5f792c82832d772ae951b157da8b39
Depends-on: I1b43e2662107ad81e57b96f0c9430c61b795fdea
2015-02-19 05:17:55 +09:00
Sergey Nikitin a8a87900cf Enable check for H238 rule
Fix H238 failures and enable check for H238

H238 old style class declaration, use new style
(inherit from `object`)

Change-Id: I71dd353ab260a513c5df5af0ee07754e23878570
2015-01-20 18:05:47 +03:00
Davanum Srinivas 417704816e Nuke XML support from Nova REST API - Phase 1
In I5a580fc323c3809790b4a68a9f8f8129ecdc2cf0 we switched off XML support. In
this review we entirely remove all the testcases and supporting files.

Change-Id: I83827d438753fd3899053dd6e09bc77c997c7406
2015-01-05 12:46:04 -05:00
Chris Yeoh 220738f621 Add support for microversions API special version latest
Adds support for specifying 'latest' as the version of the API in
the X-OpenStack-Compute-API-Version header. This will always
behave as if a request was made for the maximum version
supported.

Partially implements blueprint api-microversions

Change-Id: Ib40b20a01991e6f356b9376f797405a4c50b7e99
2014-12-17 10:05:42 +08:00
Chris Yeoh a290cdb7cf Adds API microversion response headers
Adds the following headers to REST API headers for API
microversions:

X-OpenStack-Compute-API-Version: Version
Vary: X-OpenStack-Compute-API-Version

Partially implements blueprint api-microversions

Change-Id: I5748d7b81b355bf8aad6bb8703d1a29a97798452
2014-12-17 10:05:42 +08:00
Chris Yeoh d8a17851b4 Adds global API version check for microversions
Adds a check for a request that the version requested is within the
global API version range supported by the REST API. Both the minimum
and maximum are currently set to "2.1". The maximum will be increased
everytime an API change is made.

Also sets up some template/doc files for clearly documenting
the REST API changes with each microversion increment.

Partially implements blueprint api-microversions

Change-Id: Ie7fdb2928d957c03ed788c2ddd29fe798c645fce
2014-12-05 09:55:37 +08:00
Davanum Srinivas 0e0b9bfd75 Break V2 XML Support
Nova's XML support has been deprecated with a warning that it could be
removed as early as Juno. Now that we are in Kilo we are ready to remove
support.  Before actually doing the surgery to properly remove XML
support, intentionally break XML support in a 'clean' way, so if someone
freaks out that we are removing XML support we can easily re-enable it.

Follow up to I4acc15ce5f487738bb34a95c2261a5d05d827d8d

Co-Authored-By: Joe Gordon <joe.gordon0@gmail.com>
Change-Id: I5a580fc323c3809790b4a68a9f8f8129ecdc2cf0
2014-12-03 13:13:50 -05:00
Chris Yeoh b81de68d05 Set API version request information on request objects
This adds the looking for the X-Openstack-Compute-API-Version
header on REST API requests. If it is found it is parsed and the
version information attached to the request which is passed to
the API code. If the header does not exist then a version of 2.1
is set. If the header is specified but badly formatted a 400 Bad
Request is returned to the client.

Partially implements blueprint api-microversions

Change-Id: I8e73533cb0256b8a9329870714ffacb9893bb4c7
2014-11-28 11:07:33 +11:00
Sean Dague 89cd6a0c49 move all tests to nova/tests/unit
As part of the split of functional and unit tests we need to isolate
the unit tests into a separate directory for having multiple test
targets in a sane way.

Part of bp:functional-tests-for-nova

Change-Id: Id42ba373c1bda6a312b673ab2b489ca56da8c628
2014-11-12 15:31:08 -05:00