Commit Graph

37 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
Doug Hellmann 03c0a1875c do not declare code blocks as json when they do not parse
Change-Id: I697be9b9dd15801d8d8df4fdae429e2d639f250e
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2017-06-21 14:15:58 -04: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
kairat_kushaev c27c25f779 Import i18n functions directly
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
2015-12-07 18:20:43 +03:00
Victor Stinner 1c186e23fd Use oslo_utils.encodeutils.exception_to_unicode()
* 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
2015-07-17 18:31:03 +02:00
Louis Taylor 6a19f549a5 Remove string formatting from policy logging
Policy violation logging was added in
I32afbfc98a3de6370b0396f39c2cf481f6fc47a9, but it used explicit string
formatting in each log statement. This is a follow-up patch to refactor
it to let logging decide when to do the formatting.

Change-Id: Ia7feb581adcfe727d602b91debdc33dae42ec50a
2015-05-01 20:01:43 +01:00
Jin Long Wang 7896c00635 Add logging when policies forbid an action
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
2015-04-15 17:59:37 +02:00
Louis Taylor 0acff569e0 Move to graduated oslo.log module
This removes the log module from the oslo incubator directory.

Change-Id: Ib017cc2777e27c58b376c3138c9fba614783cc34
2015-03-12 11:48:24 +00:00
Louis Taylor d759a6fd1a Move from oslo.config to oslo_config
oslo_config was moved out of the oslo namespace in oslo.config>=1.6.0.

Related-to: blueprint drop-namespace-packages

Change-Id: I30ecbf8f9de77496fcb643c7ad9738d79ad359f0
2015-01-12 14:34:22 +00:00
Zhi Yan Liu 1d38a91b54 Fix client side i18n support for v1 api
This change updated relevant debug log to warn level, due to following
the logging guide translated message shouldn't be used for debug log,
and for these cases warn level is more proper for issue logging.

Change-Id: I30e9ae0b60e09947594d6007938ad3c625933bb2
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2014-12-24 15:41:14 +08:00
James Carey 3f2a56ae65 Move from using _ builtin to using glance.i18n _
The builtin _ should not longer be used.  Instead _
should be explicitly assigned from glance.i18n.

This patch does the following:
  (1) adds these explict assignments to any
      glance file that was missing them,
  (2) removes the defintion of _ as a builtin from
      tox.ini so that a pep8 failure will occur
      if _ is not defined,
  (3) removes calls to install().

This removes the last direct use of gettextutils by glance.
The indirect uses, via openstack/common, will be removed
in the next sync with oslo.

Change-Id: Ie54e8a67e747e022cc01022dfad35d89686bdfc4
2014-11-21 18:51:19 +00:00
Christian Berendt 86dd9ff66c debug level logs should not be translated
According to the OpenStack translation policy available at
https://wiki.openstack.org/wiki/LoggingStandards debug messages
should not be translated. Like mentioned in several changes in
Nova by garyk this is to help prioritize log translation.

This patch adds a new hacking check - N319 - that ensures all
debug log messages don't have translations.

Change-Id: I9dd958b904671a7eb95883026e14684469dc52d5
Closes-Bug: #1317847
2014-05-23 15:57:06 +02:00
Leandro I. Costantino 627d5fbc13 Replace unicode() for six.text_type
To support Python3, unicode() calls has been replaced by
six.text_type.
Added utils.exception_to_str(): is the proper way to convert
an exception to string, since it manages logic related to
encoding.

Change-Id: I27101390e4f95e5c7690b1b445b7e75b8bcb9a08
Closes-Bug: #1284677
2014-05-05 15:40:02 -03:00
Fei Long Wang f70b72b78b Add support for API message localization
Add support for doing language resolution for a request,
based on the Accept-Language HTTP header. For example,
an HTTP client can receive API messages in Chinese even
if the locale language of the server is English.

The underscore (_) method is initialized so that it returns
openstack.common.gettextutils.Message objects. The locale
of these Message objects is set when exceptions with which
they are associated are raised in the context of an HTTP
request.

docImpact
Partially implements bp i18n-messages

Signed-off-by: Fei Long Wang <flwang@cn.ibm.com>
Signed-off-by: John Warren <jswarren@us.ibm.com>

Change-Id: I352cda57fe119022c59c6c813b5c8053765b2d3c
2014-03-04 14:18:28 +08:00
Jenkins 9c0ada37c9 Merge "Bump hacking to 0.8 and get python 3.x compatibility" 2014-01-16 01:44:54 +00:00
Noboru arai 8de10b0f34 Remove vim header
No need to set tabstop tons of times, this can be set in your vimrc
file instead.

More disucssion:
http://openstack.10931.n7.nabble.com/Remove-vim-modelines-td21780.html

Change-Id: I3b830a5bb831a63c188109e6fad66ba48884fff3
Partial-Bug: #1229324
2014-01-14 16:03:28 +00:00
Sergio Cazzolato 2eca65eb5f Bump hacking to 0.8 and get python 3.x compatibility
Bump hacking dependency to 0.8 to get python 3.x compatibility
Fixes done in order to avoid errors after enabling hacking 0.8

Change-Id: Ic878fe2e1bd3f65f7f95a9b5c7a192dac81b749d
Closes-Bug: #1257282
2014-01-09 23:25:22 -05:00
Alex Meade b13e10b5e5 Add config option to limit image members
This patch adds the image_member_quota config option. This allows a deployer
to limit the number of image members allowed per image. The default value
is 128, to be consistent with other quota defaults. Users will only be able
to update an image if the result of the transaction would be under this limit.

This is for both Glance v1 and v2

Fixes bug 1252459
docImpact

Change-Id: I02f5e82ca4c4acf6cd7bc94f9b99086054a616c9
2013-12-03 16:05:49 +00:00
Edward Hope-Morley dbfaf9aedb Disallow access/modify members of deleted image
It should not be possible to access or modify memberships for a
deleted image. A 404 error will now be returned if a deleted
images' members are accessed or modified.

Fixes: bug #1207266
Co-authored-by: Hirofumi Ichihara <ichihara.hirofumi@lab.ntt.co.jp>

Change-Id: I3e1a7c1cd96b8c85cf0c20286533ced510580492
2013-09-11 11:09:08 -04:00
James Li c2d3f3c802 Add a policy layer for membership APIs
Added a policy layer for the membership APIs of the domain
model.

Added following policies for membership APIs:

v1: 'get_members', 'delete_member' and 'modify_member'.

v2: 'add_member', 'get_member', 'modify_member',
'get_members' and 'delete_member'.

Implements blueprint membership-policy

Change-Id: I0d5782d1d9b7b8a563a689fcb192958ab3fea0f4
2013-05-30 21:08:18 +00:00
Flaper Fesp 9174753332 Create package for registry's client
Currently, Registry's client doesn't have a version and It's being
imported from glance.registry.(__init__|client).

As part of the blueprint registry-api-v2 the registry's client will be
modified. That for, it is necessary to keep backward compatibilities
with older versions until the db-registry-driver is completed.

This code might be removed / re-factored in the future once glance's api
v1 will be migrated to use the db-registry-driver.

Change-Id: I3f27cec5b6e5f857d7aa94731305629190ae642e
2013-05-01 22:34:17 +02:00
Stuart McLaren 19b82a022c Standardize on newer except syntax
We currently have a mix of 'except X, y:' and 'except X as y:' syntax.
Standardize on the newer 'except as' form.

This patch was generated automatically using:

find * -type f -name 'glance-*' ! -name '*\.conf' ! -name '*\.ini' -o \
 -name '*\.py' | xargs 2to3 -f except | patch -p0

Addresses bug 1160331.

Change-Id: Ica8d1303973af64d0406457267ee75f608e869d0
2013-03-26 12:14:55 +00:00
annegentle a2b9bed75d Updates OpenStack LLC with OpenStack Foundation
Patchset addresses reviewer's comments, rebase against master,
and follows new guidance from Foundation:
http://wiki.openstack.org/Documentation/Copyright

Change-Id: I94367461505778973528eb8835d991f4fb796dab
2013-02-17 19:19:43 -08:00
Zhongyue Luo ce85c38158 Fix import order nits
Change-Id: I972c463131ba688ab9352590eb53f5b1822ac943
2012-12-31 22:12:53 +08:00
Dan Prince 480743a2d7 Update v1/v2 images APIs to set store ACLs.
Updates the images controllers so they call set_acls on
the backend store when adding/updating images and members.

Made some changes to the v2 API unit/functional tests to
use real locations instead of just UUIDs so the tests work
with the new set_acls call.

Partially implements blueprint: swift-tenant-specific-storage.

Change-Id: Ib249acfe440f4b75bc9edd7b73fe10127b8333b1
2012-08-01 13:37:39 -04:00
Brian Waldon 279d07eebb Update 'logging' imports to openstack-common
Change-Id: Ia1a7b5062e7f882971f2061274f6a4a44cfc8ced
2012-07-12 15:59:26 -07:00
Dan Prince c1e9986353 Allow admin's to modify image members.
Updates the v1 Glance API and Registry controllers so that admins
can modify image membership regardless of image ownership.

The motivation for this change is to be able to test image membership
when noauth middleware (UnauthenticatedContextMiddleware or
FakeAuthMiddleware) is being used and includes the following changes:

 * Added is_admin option to FakeAuthMiddleware.

 * Refactors the access checks into a common function called
   _check_can_access_image_members.

 * API unit tests which require is_admin=False for noauth were also
   refactored to use an improved FakeAuthMiddleware which supports
   is_admin = False.

 * Update RegistryClient to use get_status_code int for 204 status code
   comparisons. Fixes issue where incorrect status code was returned.

 * Updated members unit tests to support these changes.

Fixes LP Bug #1021740.

Change-Id: I9d0e4679f9c0cb37f6df7c6f90460c22c37f3fbd
2012-07-06 11:00:57 -04:00
Brian Waldon 4363af6cc8 Standardize logger instantiation
Use LOG for variable name and __name__ for logger name. Also
document this fact in HACKING.rst

Fixes bug 1015685

Change-Id: I0d9d80bef66197a28ed3d650f17859202048d776
2012-06-25 08:27:08 -07:00
Mark McLoughlin 9d9d225419 Port remaining code to global conf object
Implements blueprint cfg-global-object

This iteration fixes up the remaining places where we're passing a
conf object around.

Change-Id: I3b627d093a6b7afeee129ab66b377a3b0af5439b
2012-06-08 17:36:25 +01:00
Eoghan Glynn fdc98c9089 Add read-only enforcement to v2 API.
Provide a new @mutating decorator to provide a concise marker for
operations that should not be accessible to a read-only request.

Related to bp api-v2-anonymous-access

Change-Id: I52710083b4f112d2429afe4faa0660e2a6822929
2012-05-31 09:52:15 +01:00
Brian Waldon b0a608c09f Ensure all unauthorized reponses return 403
* Clean up authorization vs authentication failures internally
* Remove ambiguous exception.NotAuthorized in favour of exception.Forbidden for authorization failures
* Add exception.NotAuthenticated to make authentication failures more clear
* Fixes bug 956206

Change-Id: I39ce0fcd77d4f06273040a2aa4913a9be911ceab
2012-03-20 12:42:01 -07:00
Gabriel Hurley 2e94076ca4 Disambiguates HTTP 401 and HTTP 403 in Glance. Fixes bug 956513.
Change-Id: I82865293f60eabaf3bc40b40dc9c8612b12a6d1b
2012-03-16 12:00:26 -07:00
Brian Waldon ee2d212f81 General cleanup
* Reorder imports
* Remove unused code
* Add missing copyright header in glance.api.v1.members
* Pass in 'pool' to glance.store.scrubber.Scrubber._cleanup
* Fix NameError in glance.api.v1.images.Controller: request -> req
* Fix except block in glance.notifier to properly catch multiple exceptions

Change-Id: I30d895b5ff1246e8d637720ef2f4aacab9cf7ede
2012-03-14 14:31:17 -07:00
Kevin L. Mitchell eb2ab3a40a Return 400 if registry returns 400.
Fixes bug 919244.  The registry would return 400 for invalid input,
which resulted in an exception.Invalid being thrown in the registry
client.  There was no exception handler for this exception, so it
got bubbled up and turned into a 500.  This should fix the problem
by adding the missing exception handlers.

Change-Id: I75ecfec1c0b0b4b3df1a8c9ace83e75d19527c93
2012-01-20 13:31:47 -06:00
Mark McLoughlin 002d711fb7 Rename 'options' variables to 'conf'
In the common-config patch, I'm going to be using 'conf' as the name of
the variable holding configuration values rather than 'options.

This patch does the renaming across the codebase without making any
functional changes.

Change-Id: I3a86fc01fc76825d6d1e86af882eb8245828ce5f
2011-12-07 12:44:16 +00:00
Jay Pipes eec5c1afa1 Adds SSL configuration params to the client
* Adds SSL configuration params to all client classes
* Adds unit test for bad SSL client configuration
* Refactors the registry methods to no longer need
  configuration options passed, and to configure the
  registry client once, on images.Controller.__init__
* Adds glance-api.conf options for SSL support in
  registry client connections.
* Adds SSL CA file socket wrappers via a client auth
  HTTPS connection class
* Adds server SSL support, but not functional tests
  for SSL support yet. Still need to research self-signed
  cert generation for tests...
* Updates documentation for bind and startup options
* Adds functional test case for secure communication
  with API server stood up with SSL supprt. Note it is
  not very DRY. There is some DRY cleanup to do in the
  future...

TODO: Integrate options with bin/glance CLI tool

Change-Id: Ie9fcd36337cc93fd5beeabb9186ad5e93ae2a0f0
2011-10-11 16:40:06 -04:00
Brian Waldon e068296d6d Extract image members into new Glance API controller
Replacing method names with more common controller actions and simplifying the API router. Also refactors how members.py
imports and uses webob.exc.

Change-Id: I975b2095980cfc56408fa76b47cf830cdd650ff2
2011-09-29 11:59:10 -04:00