Sync importutils changes from openstack-common

Syncs the following changes from stable/folsom:

 769ec65 Don't trap then re-raise ImportError.
 8c74b37 Improve exception from importutils.import_class().
 1fb2361 add import_object_ns function

Change-Id: Ib6046181ec4712702c30c8a8e938fc9a21b1a594
Specified Content-Length in update request header

While uploading a Volume to an image, the HTTPConnection's request method does
not set the Content-Length header (since the volume file is a sym link i.e. the
os.fstat call returns a st_size of 0). This causes Volume uploads to Glance
fail (since the image data is ignored as no content-length is specified).
Therefore setting the Content-Length from update( ) method if the image data is
provided.

Fixes LP: #1045824

Change-Id: If259fc5a338e3e90214a52b773132ed901691c0f
Fix PEP8 issues.

Fix some pep8 issues in doc/source/conf.py  make the code looks pretty.

Change-Id: I44f8152de76ae217d1dd81c9c0c1b1e075ec8792
Merge "Fix PEP8 issues."
get_connection should raise httplib.InvalidURL

In http.py the exception raised in get_connection
should be httplib.InvalidURL rather than httplib.InvalidUrl.

Fix for bug 1048698.

Change-Id: I7f18321fe7d8669b3b95bf823273ee8ae6961661
Catches HTTP 300 while printing responses

If glance v1 api is not enabled, and a request is made to it,
it gives a KeyError. This patch catches the 300 error and
displays error message.

Fixes bug 1046607

Change-Id: I0009a5deca3b5dd5ccaeaea90feee21274bfe090
Corrects URI to display hostname, port properly

Fixes bug 1035931

Change-Id: I1b4e8a226c21d137b24bc5b75299bcf4ab4efefb
Merge "Catches HTTP 300 while printing responses"
Merge "Specified Content-Length in update request header"
Update docs for v0.5.1 release

Change-Id: I377caf14379ebffe3bbc70c67e9378fc0ebcea95
Document remaining bug for v0.5.1

Change-Id: I97144b22e2040441e6507ff1810ab7a3da9b1ae2
Make ConnectionRefused error more informative.

When the server refuses the connection the error message displayed now
lists the endpoint that refused the connection.

Fixes: bug 1043067
Change-Id: I62797106732bbb6eec8c99e491fd38850ad58ff8
Fix weird "None" displayed on some errors

logging.exception() should only be called from an exception handler,
which is not the case here.

Part of bug 1050260.

Change-Id: I591a68c458cd733c04cea7d2d640afdbb7dd19f6
Fixes glance add / update / image-create / image-update on Windows

Fixes Bug #1050345

The image upload hangs if the file contains a byte with value 0x1A (EOF), due to
the fact that the file or stdin streams are treated as text and not
binary streams. This fix sets the proper binary mode.

Change-Id: I3425cb9729a8da4d1b73fbfba06fd6f2c7e8833e
Typo in image-create help page

The image-create help page reversed the DISK_FORMAT
and CONTAINER_FORMAT metavars.

Fixes bug 1051968.

Change-Id: I385cb0912ad87a62fd10742b5da23a5ea8bc9bb8
Merge "Fixes glance add / update / image-create / image-update on Windows"
Use full URI path from Glance endpoint in HTTP requests

Fixes bug 1052846

Now the connection uses host, port and path to connect to Glance. So proxied connections to Glance are allowed.

Change-Id: I53a890e6532adb8168961d1d09f938bf439e895c
Add happy path tests for ResponseBodyIterator

Change-Id: I5e971b57a0591752e7fca76d0df78ce139308db5
Simplify http(s) connection instantiation

The endpoint parsing and connection instantiation code was too
complicated and easily broken. This assigns human-readable names to
instance variables and breaks up the parsing into more understandable
chunks.

Fixes bug 1060316.

Change-Id: I5c5236f90d88b9e797cf0a476aabe8cc7cfa1cc9
Display acceptable disk/container formats in help text

Fixes bug #1056497

This patch provides more information in the help text. Originally the text
provided the trivial definitions of the arguments disk_format and
container_format. This patch updates the text to display the acceptable
formats.

Change-Id: I893b52c9f72a34c75e8bea522820863592300302