Add GLANCE_LOCALEDIR env variable

Part of fixing bug #995287

Syncs these two commits from oslo-incubator:

  Support overriding oslo localedir too
  Add a gettextutils.install() helper function

to get a new gettextutils.install() function which allows the default
localedir to be overwritten via an environment variable.

Note that gettextutils.install() must be called before any other glance
modules are imported since some modules attempt to translate strings
at import time (e.g. the help strings for config options in config.py).
This is broken and inefficient, but fixing it involves adding something
like spinx's l_() function and would be very invaisve.

Also, note that calling gettextutils.install() in glance.cmd.__init__
means that no program which uses a different translation domain should
ever import any of the modules under glance.cmd.

Change-Id: I86562b3a65d371673bb21f7179eecc7602bc0775
RBD store uses common utils for reading file chunks

Prevents cases where the image_size passed to the RBD store is larger
than the actual image_file which attempts to write 0 bytes of data
causing image.write to hang indefinitely.

Fixes LP Bug #1146830

Change-Id: I56216437a212c0c802d2ed349d88b3bd0d3bb4d7
rbd: return image size when asked

Implement get_size(), and use it for the second part of the return
value of get().

Convert the old-style functional tests into tests using the store test
base class. These test the store api directly, and are more up to date
than the old functional tests that went through the api. The store tests
base class already includes tests for get() and get_size().

Fixes bug 1180565

Change-Id: I85ca0a0ab3155d1a25607ba9dc210be5719bf85c
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
rbd: remove extra str() conversions and test with unicode

librbd doesn't handle unicode, so strings passed to it must be plain
ascii. Originally the rbd store did this before each call, but since
3aea9320d20d0291c5b4b027a585370d8e658a95 it only needed to convert to
ascii in StoreLocation and add(). Remove the extraneous calls to
str(), and add a test that uses a unicode image_id and uri to make
sure unicode isn't passed to librbd anywhere.

Change-Id: Ib7656126e044775f516fa6665e28f6d474820665
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Improve unit tests for glance.api.v1 module

Add test for glance.api.v1:
* tests for glance.api.v1.filters.validator
* tests for glance api add member method
* tests for glance api replace member method
* tests for glance api delete member method
* tests for registry api image details method
* tests for registry api image delete method
* tests for registry api add/delete/update/get member methods

Fixes: bug #1152230
Change-Id: I79d06b2281ba0c9b8d10b9300fffe6cc3c69c4ee
Improve unit tests for glance.common package

Add tests for next modules:
* glance.common.wsgi
* glance.common.utils
* glance.common.client
* glance.common.config

Fixes: bug #1152183
Change-Id: Iedbdfb6af411170da10d078e48f5098f8d1c668b
Prevent '500' error when using forbidden marker

If an existing image id was used as a marker, but
the user didn't have access to that image a '500'
error occurred. Return '400' instead.

Fixes bug 1178307.

Change-Id: Ib632297d944a19e18694fff154307a3bc6d5b625
Respond with 412 after upload if image was deleted.

When updating the image after upload, we should return an
HTTPPreconditionFailed instead of a 500 error if the image cannot
be found.

This will also provide more information to nova when this occurs
during snapshotting.

Fixes bug 1176174

Change-Id: I270ee129470323dae3919ed0a8c335eae7c24061
Merge "Improve unit tests for glance.common package"
Merge "Add GLANCE_LOCALEDIR env variable"
Merge "Respond with 412 after upload if image was deleted."
Merge "rbd: return image size when asked"
Merge "rbd: remove extra str() conversions and test with unicode"
Merge "Improve unit tests for glance.api.v1 module"
Merge "RBD store uses common utils for reading file chunks"
Merge "Prevent '500' error when using forbidden marker"