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
fix the ":raises:" to ":raises".
Probably the most common format for documenting arguments is reST field
lists [1]. This change updates some docstrings to comply with the field
lists syntax.
[1] http://sphinx-doc.org/domains.html#info-field-lists
Change-Id: Ic7e2f80a48057547115453432c41803eb1cc948e
Currently, when we make an update on a public image, Swift ACL disappears.
This patch allows to avoid the ACL update if there is no change to the
is_public_attribute.
If an update is made on a Glance image without changing the public attribute
or location, then the function which modifies ACLS is not called, in order
to keep ACLS.
Closes-Bug: 1584076
Change-Id: I21e9deb9105faee87500998eff47c6faa1d02914
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
With this change, all Glance unit tests now pass on Python3!
* Replace dict.keys() with list(dict.keys()) to get a list on Python
3. On Python 3, dict.keys() now returns a view, not a list
* Replace filter() with a list-comprehension with if, to get a list
on Python 3.
* Don't encode HTTP headers to UTF-8 on Python 3. Python 3 already
encodes them for us.
* On Python 3, decode the request identifier of the context to get
a Unicode string.
* Replace jsonutils.dumps(obj) with jsonutils.dump_as_bytes() to
create a HTTP body, since the HTTP body must be a bytes string.
* start_http_server(): use bytes for image data, not Unicode.
* Use byte strings to check HTTP body, not Unicode. Or on some unit
tests, decode the HTTP body to get Unicode.
* Skip test on invalid unicode image property on Python 3. It's now
supported on Python 3.
* tox.ini: remove the whitelist of tests run on Python 3, since the
whole test suite now pass on Python 3!
Note: With the gate, the Python 3 gate became unstable: bug #1521756.
The bug was caused by eventlet and the eventlet bug has been fixed in
eventlet 0.18, released a few days ago.
Co-authored-by: Victor Stinner <vstinner@redhat.com>
Change-Id: I99e0a80df93d0304c33ce50859c92e62ccc71648
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
Import i18n functions from module directly and do not use
global module variables like _ = i18n._. It makes code shorter
and cleaner. It also to detect cases when these functions are not
used in module.
Change-Id: Iaa593ac1f2dd15cbcad049bef6ba68f1cfa610da
When empty string is passed as location value the glance
raises internal server error.
The patch checks that location value is present in image meta
and generates BadRequest if it is empty.
Change-Id: I8f3640276368292ced508d5f4c918c147b9d1f19
Closes-Bug: #1498460
Replace all the ":return:" with ":returns:"
Replace all the ":returns " wtih ":returns:"
Replace all the ":returns :" with ":returns:"
Add the changes for ":raise" also, change ":raise" to ":raise:"
Change-Id: I5d0def4665d0cd69b73c3c3826ad8f208e1e970e
The change Ib342ef6640efbc3d76c4bafc622ccfdfa3d16ade added a new
_validate_time() function for API v1. On Python 2, the function
relies on the datetime module to get a ValueError for datetime with
year older than 1900. On Python 3, the datetime module accepts years
before 1900 and so we have to test manually.
Change-Id: Id1dbf98ecf23e401f696a575dfea80fac2e297ed
Currently if you send a bad date format such as 'foo', as one of the
settable dates ie. `created_at`, `updated_at` and `deleted_at` it will
cause the server to return a 500.
This change means that the server will respond with a 400 and a helpful
message.
Change-Id: Ib342ef6640efbc3d76c4bafc622ccfdfa3d16ade
Closes-Bug: 1483649
Postpone formatting of log messages until check that debug is
turned on. It allows not to format and prepare formatted log
messages if debug mode is turned off.
Change-Id: Ic26a2940948fe9891e4898689e2ea9fc7f0d4350
Currently the user can change the ACTIVE_IMMUTABLE properties whilst
the image is 'deactivated'. This should not be the case once an image
has become 'active'.
APIImpact
Change-Id: I744fbce90893008ef49568c3cba47bf0e26dec9d
Closes-Bug: 1517060
Closes-Bug: 1517963
When the registry has an error validating the token that the api
has sent it a 500 is returned rather than 401. This fix catches the
NotAuthenticated exception and throws an HTTPUnauthorized instead.
Change-Id: I405cd98346e2df06c02e37bfdf903a54a29f7b19
Closes-bug:1504184
A more explicit way of checking if the immutable image metadata is
present or not.
Closes-Bug: #1499038
Change-Id: I72d372b8c2894cd3f8f0a3eebeae68886d4e0d65
As stated in Openstack logging and i18n guidelines it is
recommended that formatted string for log messages should be
generated by logger (not by logger client/user). In this case
we can skip formatted message generation if log level configured
not to show info messages.
Also some non-used initialization of logger has been deleted
from the code.
Change-Id: I25660395417ea288aee6a70609a5336e6f74c291
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
Dictionary creation could be rewritten as a dictionary literal.
for example:
filters = {}
filter['namespace'] = namespace
could be rewritten as
filters = {'namespace': namespace}
Closes-Bug: 1482586
Change-Id: I860483e958296da248a579a6032c14370843d9e4
After the split glance_store raises its own exceptions, that
have the same names as in glance. Several times those exceptions
aren't caught in glance and it leads to incorrect behaviour.
This code fixed it.
Change-Id: I8600e0813ecbc599b5411e1fc0d0c9b470f68f6b
Closes-Bug: #1469817
* Replace glance.common.utils.exception_to_str() with
oslo_utils.encodeutils.exception_to_unicode().
* Remove exception_to_str() from glance.common.utils
* Add "from oslo_utils import encodeutils" and remove "from
glance.common import utils" (when utils is no more used)
* glance/api/v2/images.py: replace utils.exception_to_str() with
six.text_type() to cast the oslo_i18n message to Unicode
Glance exception_to_str() function was not compatible with Python 3,
whereas exception_to_unicode() is compatible with Python 3, it's in Oslo
common libraries and it's well tested.
This patch was first generated by a tool (modified version of sixer),
and then fixed to respect the PEP8 (especially the constraint of 80
columns).
Change-Id: I86008c8adc0c5664f96573c1015cc15e2d06e3e2
Image params such as checksum, min_ram and min_disk are validated.
Checksum is expected to be not longer than 32 characters,
min_ram/min_disk can't exceed pow(2, 31) - 1.
A method for mysql_int validation has been moved to glance.common.utils.
Change-Id: I78554ef1ba65fc11da3de56467d6d70bb7991787
Closes-Bug: #1454730
Closes-Bug: #1460060
When an image can not be found an ImageNotFound exception
will be raised instead of a generic NotFound
exception. Does not apply to Image Metadata,
Image Members, Image Tags, Image Tasks
Closes-Bug #1247633
Change-Id: I84c754e51fb40ef1f9744bf85dbaa716b55cbb95
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
There is currently no logging in images.py of glance API v1 or v2
and other files of glance API when policies forbid an action.This
patch adds logging in these situations.
Co-Authored-By: Ian Cordasco <ian.cordasco@rackspace.com>
Co-Authored-By: Kamil Rykowski <kamil.rykowski@intel.com>
Closes-Bug: #1270229
Change-Id: I32afbfc98a3de6370b0396f39c2cf481f6fc47a9
There are a couple of places where an UnknownScheme
exception could be raises but was not being caught.
Change-Id: I25af9a762c49a1bbea661c3858ffb46cff891ee2
Closes-bug: #1379308
This patch provides the ability to 'deactivate' an image by
providing two new API calls and a new image status 'deactivated'.
Attempting to download a deactivated image will result in a
403 'Forbidden' return code. Also, image locations won't be visible
for deactivated images unless the user is admin.
All other image operations should remain unaffected.
The two new API calls are:
- POST /images/{image_id}/actions/deactivate
- POST /images/{image_id}/actions/reactivate
DocImpact
UpgradeImpact
Change-Id: I32b7cc7ce8404457a87c8c05041aa2a30152b930
Implements: bp deactivate-image
Glance doesn't catch NotFound exception when --location parameter
is used with non-exist http store URL.
If the URL returns HTTP 404, glance is just ignoring it and returns
image-size as zero.
While getting the image-size caught NotFound exception as well
if location parameter is specified.
Depends-On: Ieb3dcb79ed9ba4368d0b3ca69b30095c1fd800b9
Change-Id: I9ffad7666c6e64c007c9938684903aed44e60151
Closes-Bug: 1316137
This patch is work for glance, and the main change on glance_store side
is change Iedf0d4f829e46ca64c3f4fc6a7dfee54d9b0605b .
This change works with glance_store v0.1.11 at least.
Implements: blueprint store-capabilities
Depends-On: I5055b837e94fdee7e01cc94f8bdb89bada34f77b
Change-Id: Ibbc85b6bc2ea98c564d316db2874d7df5aac32a6
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
Add the ability to dynamically change configuration settings of a running
glance server with no impact to service.
A running glance server consists of a parent/master process and one or
more child/worker processes.
On receipt of a SIGHUP signal the master process will:
* reload the configuration
* send a SIGHUP to the original workers
* start (a potentially different number of) new workers with the new
configuration
* its listening socket will *not* be closed
On receipt of a SIGHUP signal each original worker process will:
* close the listening socket so as not to accept new requests
* complete any in-flight requests
* complete async requests (V1 create with copy-from option and V2 task api)
* exit
This approach is based on nginx's behaviour and avoids some of the
disadvantages of the current oslo Launcher reload:
* Race conditions: Launcher does not shutdown eventlet cleanly, existing
requests can fail.
* If all workers are busy (likely if #workers is small) there can be a
lengthy delay when new requests are not processed.
* Long lived pre-SIGHUP idle client connections can stall request
processing indefinitely.
* Not all parameters can be changed, eg number of workers.
* The wsgi pipeline cannot be changed, eg to enable caching.
Change-Id: I73875c654410f207e3efdb2932147cf26d75b3f1
Partially implements: bp sighup-conf-reload
HTTPInternalServerError 500 response is returned to the user while
image server is down during downloading the image. When glance tries
to download the image from the remote location (image server) which
is down, Connection refused ECONNREFUSED error is raised on the
glance server.
Raised RemoteServiceUnavailable exception from glance_store and handle
it in v1 and v2 api's to return 503 HTTPServiceUnavailable response
to user.
Note: Please refer below link to check glance_store related changes
which addresses this issue partially.
I065b9a3e8e674ea74ff8563aad99d7d022417caa
Closes-Bug: #1379798
Change-Id: I45099153e75d53b028e249fad8a4d944d38adf65
Add missing chars (':', ' ', '=', '.', "is") to some messages
to reduce translation effort by unifying them.
Change-Id: Iab5ee81169dbcee2ca514b696369d2ac53086164
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
oslo_config was moved out of the oslo namespace in oslo.config>=1.6.0.
Related-to: blueprint drop-namespace-packages
Change-Id: I30ecbf8f9de77496fcb643c7ad9738d79ad359f0