Commit Graph

27 Commits

Author SHA1 Message Date
Erno Kuvaja 3dde3204d5 Remove Images API v1 entry points
This change removes option to configure Images API v1
This change removes Images API v1 endpoints from the router
This change removes all v1 tests
This change removes the v1 dependant glance-cache-manage command

This change does not remove all v1 codebase. Further cleanup and
decoupling will be needed.

Change-Id: Ia086230cc8c92f7b7dfd5b001923110d5bc55d4d
2018-07-13 10:21:49 +01:00
Alexander Bashmakov b75a0fcc59 Fix and enable integration tests on py35.
Fixed the tests in the `glance.tests.integration` module. Enabled
them to run for py35 job in tox.ini. All changes are related to
string/bytes object differences in python 2.7 vs 3.5.

Also added testing of tasks location header value due to a change in
how it is handled in py27 vs py35.

Change-Id: I26aae0c518fe84c9967461a3b9fef02bc0c17923
2017-04-06 18:14:46 +00:00
Gábor Antal 8a8e5bf56c Extracted HTTP response codes to constants in tests
There are several places in the source code where
HTTP response codes are used as numeric values.

These values are used from six.moves and the
numeric values are replaced by constants.

All of the used status codes were replaced with symbolic constants
from six.moves.http_client.
More about six.moves.http_client can be found at [2],
under the table "Supported renames:".

Also, this change improves code readibility.

This patchset does not extract numeric values from
the code itself, but it can be found at [1].

[1]: Ib9e26dcea927e96e65c626c18421621d3a29a64d
[2]: https://pythonhosted.org/six/#module-six.moves

Change-Id: Idfc7b043552f428f01ac3e47b270ee0639a8f5bc
Closes-Bug: #1520159
2016-10-06 15:17:06 +00:00
Tom Cocozzello adfc7e5a3f fix docstring warnings and errors
There are many warnings and errors that occur when the docs are
generated.

Co-Author-By: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Closes-Bug: 1556818
Change-Id: Ifebeb3904f136a56bd6fe6877220b279a1f98354
2016-03-14 18:40:15 +00:00
Béla Vancsics f29e9e6138 Use assertGreater/Less/Equal instead of assertTrue(A * B)
Instead of using assertTrue(A * B), developers should
use assertGreater(A, B) or assertLess(A, B) or
assertGreaterEqual(A, B) or assertLessEqual(A, B)
or assertEqual(A, B).
The * operator: >=, <=, ==

Change-Id: I85e0087c530c2f1132061036fd5427368dfa2316
2016-03-02 07:56:45 +00:00
Julien Danjou 4d5330088f Replace oslo_utils.timeutils
This change introduces glance.common.timeutils that provides the
timeutils previously consumed from oslo_utils.

Oslo is deprecating some timeutils functionality which of Glance
depends on. Suggested replacement (isoformat) would break glance APIs
so it's cleaner to carry this functionality in Glance rather than
re-invent the wheel.

Co-Authored-By: Erno Kuvaja <jokke@usr.fi>
Co-Authored-By: Sabari Kumar Murugesan <smurugesan@vmware.com>

Change-Id: I91e1cc9a273249fd88749cecf21200f3f5e2bab1
2015-12-10 10:53:46 +00:00
Stuart McLaren 34f9f03713 Prevent image status being directly modified via v1
Users shouldn't be able to change an image's status directly via the
v1 API.

Some existing consumers of Glance set the x-image-meta-status header in
requests to the Glance API, eg:

https://github.com/openstack/nova/blob/master/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance#L184

We should try to prevent users setting 'status' via v1, but without breaking
existing benign API calls such as these.

I've adopted the following approach (which has some prior art in 'protected properties').

If a PUT request is received which contains an x-image-meta-status header:

* The user provided status is ignored if it matches the current image
  status (this prevents benign calls such as the nova one above from
  breaking). The usual code (eg 200) will be returned.

* If the user provided status doesn't match the current image status (ie
  there is a real attempt to change the value) 403 will be returned. This
  will break any calls which currently intentionally change the status.

APIImpact

Closes-bug: 1482371

Change-Id: I44fadf32abb57c962b67467091c3f51c1ccc25e6
2015-09-22 16:07:02 +02:00
Erno Kuvaja e8e71dba4d Rationalize test asserts
Utilizing assertIn and assertNotIn in a consistent way rather than
assertTrue( x <not> in y) and assertFalse(x in y).

Change-Id: Ic43d107c40a5a50b852ee476b1167c21e5ad86e8
2015-07-09 13:48:49 +00:00
Mike Fedosin ac9f373cd0 Fix delayed activation without disk and containers formats
If we want to perform a delayed activation of an image without
providing disk format or container format, Glance tries to
upload a file and fails with 400 error.

This code handles this situation by checking that no sources
were provided, and returns information about the image before
starting the upload.

Change-Id: Id6f81df9bb43697b0d694528b010bb3c7c9bedb3
Closes-Bug: #1268680
2015-05-08 16:10:42 +03:00
Doug Hellmann ae21f4dffa Drop use of 'oslo' namespace package
The Oslo libraries have moved all of their code out of the 'oslo'
namespace package into per-library packages. The namespace package was
retained during kilo for backwards compatibility, but will be removed by
the liberty-2 milestone. This change removes the use of the namespace
package, replacing it with the new package names.

The patches in the libraries will be put on hold until application
patches have landed, or L2, whichever comes first. At that point, new
versions of the libraries without namespace packages will be released as
a major version update.

Please merge this patch, or an equivalent, before L2 to avoid problems
with those library releases.

Blueprint: remove-namespace-packages
https://blueprints.launchpad.net/oslo-incubator/+spec/remove-namespace-packages

Change-Id: Ifa8baab33cdb3e606cf175a8c29c3a4ef6c44480
2015-04-28 18:57:45 +00:00
Louis Taylor 41d45dfb1c Move from oslo.utils to oslo_utils
oslo_utils has been moved out of the oslo namespace.

bp drop-namespace-packages

Change-Id: Ie818e72b31efd2a6ab182444967bdfaca9366f4a
2015-01-09 20:01:42 +00:00
Roman Vasilets cb2456ea5e Wrong order of assertEquals args(Glance)
Args of assertEquals method in glance.tests are arranged
in wrong order. In result when test fails it shows incorrect
information about observed and actual data. It's found more
than 2000 times. Right order of arguments is "expected, actual".

Change-Id: Ifea4809f5a696b608a19e36a9ed9e5eec46c8a21
Co-Authored-By: Li Yingjun <liyingjun1988@gmail.com>
Closes-Bug: 1277104
2014-11-13 17:10:09 +02:00
liyingjun 2365a3fb5f Fix assertEqual arguments order
assertEqual method's arguments should be in ('expected', 'actual')
order.

Change-Id: I88b5b0558720a91236b62b6e4a3590901e817f85
Closes-bug: 1277104
2014-09-19 00:25:18 +08:00
Julien Danjou 581cb4ca43 Switch to oslo.serialization
Change-Id: I983bb5b6e2c7fbbd8556ff0f99212803cb0269e9
2014-10-07 14:58:55 +02:00
Julien Danjou 874e643549 Switch to oslo.utils
Change-Id: I47dc734c6d6e2ab99c25701ae3492acd5e442212
2014-10-07 14:55:57 +02:00
Julien Danjou fadbef8511 hacking: upgrade to 0.9.x serie
Change-Id: I252758fd633662de9659a402c5e3d7e3ce1fae0f
2014-10-06 14:41:03 +02:00
Bartosz Fic 0b246bb5f5 Replaces assertEqual with assertTrue and assertFalse
In order to improve coding practices and be aligned to a standard,
self.assertEqual(...,True) statements where replaced with
self.assertTrue and self.assertFalse.

Change-Id: I4150a343493beae03d6f71c88e84f60d14fb60e1
Closes-Bug: #1230127
2014-09-12 10:51:02 +02:00
Louis Taylor 65c4e73104 Fix collection order issues and unit test failures
A randomized PYTHONHASHSEED caused the glance API to return certain data
in a nondeterministic order, breaking some tests. This patch sorts the
returned data before testing against a pre-sorted expected values.

This patch also fixes some unit test failures with the new version of
testtools (0.9.36) and directly calling setUp(). This was added to this
patch to avoid blocking more Glance tests.

Co-authored-by: Fei Long Wang <flwang@catalyst.net.nz>
Co-authored-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>

Partial-bug: #1348818

Change-Id: Ie92c6bb5663826713ca99e8f2f7d70f3faef6675
2014-08-23 21:34:26 +08:00
Jon Bernard 503be24afa Prevent creation of http images with invalid URIs
Active images should always be ready to be downloaded, regardless
they're locally or remotely stored. This patch prevents images with
invalid location URIs from being created and entering the 'active'
state with no data. This is only for the HTTP store.

Closes-Bug: #1257273
Co-authored: Jon Bernard <jobernar@redhat.com>
Change-Id: Iffce79b654cabe8397c85b2cc50c4b7f59733ea5
2014-05-05 10:01:38 +02:00
Jia Dong 8d4312a2c9 Modify assert statement when comparing with None
Replace assertEqual(None, *) with assertIsNone in glance's
tests to have more clear messages in case of failure.

Also, replace assertTrue(* is not None) with assertIsNotNone
for the same reason.

Change-Id: If41a71bd750057c7136b03bef94c04517092134c
Closes-Bug: #1280522
2014-02-19 14:37:41 +08:00
Yanis Guenane 16c3a33c0b Migrate json to glance.openstack.common.jsonutils
Every call to json.loads/json.dumps have been changed to
jsonutils.loads/jsonutils.dumps respectively. Import json has been removed
also replaced by import glance.openstack.common.jsonutils

654d80b416dc5f413cb791aa838ec8688bf7da44 Create openstack.common.jsonutils

Change-Id: I8ef580e5eb91526dfaef37050ce1f5c6d88d56b5
Closes-bug: #1257922
2014-01-05 14:38:07 +00:00
Yanis Guenane ec08ca1a87 Make code base E125 and E126 compliant
This commit makes the glance code base E125 and E126 compliant :
  * E125 continuation line does not distinguish itself from next logical line
  * E126 continuation line over-indented for hanging indent

Change-Id: I7120149bedb665fb66320498fe98948602a6cd52
Closes-bug: #1263437
2013-12-30 13:03:24 +00:00
Chang Bo Guo 30696aa243 Clean up numeric expressions with oslo constants
Replace numeric expressions with olso constants to make code
more readable. This patch won't replace single 1024 if 1024 not
in an expression like number * 1024.

Change-Id: Ic1137774f0f9a2be89a7c2706d6eb52eb906ff1f
2013-11-21 20:05:19 -08:00
Paul Bourke 607acb33be Add policy style '@'/'!' rules to prop protections
A value of '@' will always allow the corresponding operation for a
property, and '!' will always disallow the operation.

Related to blueprint api-v2-property-protection

DocImpact

Change-Id: I1196a58a6f97cd0856bf97463386776a00359a49
2013-11-12 14:15:44 +00:00
Dirk Mueller 753885d3cd assertEquals is deprecated, use assertEqual
Also change to assertTrue/False where assertEqual(True,/False) was
used.

Change-Id: I9e592d9c40c3da61b5e7af7e7ad5247645249eff
2013-11-07 02:34:48 +01:00
Paul Bourke 08987b12eb Implement protected properties for API v1
Related to bp api-v2-property-protection

DocImpact

Change-Id: Ia56ca251e78f37dcd6cf63c9696f0e5e07ed5f5c
2013-09-10 15:05:48 +00:00
Mark J. Washenberger 541419dfa0 Port slow, overly assertive v1 functional tests to integration tests
This patch ports existing v1 api functional tests to a newly added group
of integration tests. The new tests take about 1/8th of the time of the
previous tests, thanks to not forking off api and registry server
processes.

One original functional test is preserved, to ensure that we are still
testing the basic v1 functional wireup.

Related to bp refactoring-better-faster-stronger-functional-tests

Change-Id: Ifcc76b4bf4e484a52558538e5398cad882e48e4c
2013-06-21 19:09:43 -07:00