Replace file.write and os.path.exists by mock

During the test files may be lost in the temporary directory.
Therefore, it would be nice if we reduce dependence of temporary directory.

This patch replace buildin method file.write by mock in ShellCacheSchemaTest.
Also we need to replace method os.path.exists by mock to correct all checks.

Fixes bug: #1267515

Change-Id: I3faca27348e15b28619e49f11d0d6cff5a9e2906
python3: Switch to mox3 instead of mox

In order to transition to a python 3.x compatible world,
lets switch to mox3 which is python 3.x compatible drop-in
replacement of mox.

Change-Id: Id971475f0e92900689d6784ffc55ae5fe63d9fe4
It was removed urllib, urllib2 & urlparse modules

Those modules have been combined in python 3. Therefore,
implementing the six module helps to have support to both versions.

Change-Id: I164a0f19790ff066d16d0cf4f0daa6f1097c848e
Closes-Bug: #1267181
server 500 should not be a client error

the client should not log a server 50x response at ERROR level.
It already throws an exception, so the caller can care about what
it wants to do with this. This error will show up regularly in
nova that succeed, and there is no way to disable this message,
which isn't an error from Nova's perspective without turning off
*all* the logs.

Set this to debug instead, because from a caller perspective that's
what you want out of this.

Change-Id: I6d0efb53d1e81adf309f7fa580ec5a8073a811c5
Allow updating empty created v2 images from v1

When an empty image is created through python-glanceclient using v2 APIs
but updated using v1 APIs, python-glanceclient crashes with a "int()
argument must be a string or a number, not 'NoneType'" message.

This is because v1.images.ImageManager._format_image_meta_for_user
expects the 'size' (and 'min_ram' and 'min_disk') field of an image to
be convertible to 'int' but the server-side v2 APIs set it to 'None' for
an empty image. Therefore the conversion to int fails with the message
above.

This fix modifies _format_image_meta_for_user to check whether or not a
field can be converted to 'int' and, if not, returns 0 (zero) as the
value instead.

Tests have also been added.

Change-Id: I86680bc06c8ce3ee492efeb3f32071da4f293bcd
Closes-bug: #1258160
Merge "Replace file.write and os.path.exists by mock"
Handle endpoints with versions consistently

When using the cli the Glance client wraps the endpoint in a 'strip
version' function. This means that endpoints of the following forms can
both be used:

https://region-x.images.example.com:443/v1
https://region-x.images.example.com:443

When calling the client library directly (as Ceilometer does) however
only endpoints of the second form work. The cli and library should handle
the two cases consistently.

Addresses bug 1243276.

Change-Id: Ice7b581fee32540a7057ba47433a10166a3caed2
Merge "It was removed urllib, urllib2 & urlparse modules"
Merge "Allow updating empty created v2 images from v1"
Merge "server 500 should not be a client error"
Using common method 'bool_from_string' from oslo strutils

Using common method 'bool_from_string' from oslo strutils to replace
utils.string_to_bool.

partially implements blueprint common-client-library-2

Change-Id: I23924db3000feadcfe823c6cc979ea9752a13fa9
Merge "Handle endpoints with versions consistently"
Merge "Using common method 'bool_from_string' from oslo strutils"
Add support for image size in v2 api upload

Some backend stores e.g. RBD, will fail if told to create an
image without a valid size (RBD will fail to write to a zero-size
image). Here we add support to allow the image size to be provided
when doing an upload. The result is that the upload content-length
will be set if available either from checking the supplied file
object or as provided by user.

Closes-Bug: 1220197
Change-Id: Ia1f2ea5680a139750d931591949b3e0058148b4b
Update my mailmap

Using new email address.

Change-Id: I4df8536d848fee91ced6debcd259a6cf8f748b44
Fix misspellings in python-glanceclient

Fix misspellings detected by:
* pip install misspellings
* git ls-files | grep -v locale | misspellings -f -

Change-Id: I504521e702c675640ab3869c608fa96edd2477b4
Closes-Bug: #1257295
Merge "Update my mailmap"
Remove tox locale overrides

* tox.ini: The LANG, LANGUAGE and LC_ALL environment overrides were
introduced originally during the testr migration in an attempt to be
conservative about the possibility that locale settings in the
calling environment could cause consistency problems for test runs.
In actuality, this should be unnecessary and any place where it does
cause issues ought to be considered an actual bug. Also, having
these in the configuration actively causes older pip to have
problems with non-ASCII content in some package metadata files under
Python 3, so drop it now.

Change-Id: I6be8e42167191096b16d0f16e8c89e85aeedd74c
Closes-Bug: #1277495