* exc.py: Encode body in response before calling replace over it.
* http.py: prepend the bytes literal to the empty string or else
we hit bug 1342080 again in python 3.
* utils.py: Use sys.stdin.buffer in python 3.
Change-Id: Ieefb8c633658e507486438e5518c5d53e819027d
Error messages were being passed with either JSON or HTML formatting
leading to an unpleasant user experience. This strips the JSON or HTML
tags and presents the clean error message to the user.
Rewrote the lispy function to be more pythonic, added test cases
and cleaned up some pep8 violations.
Removed commented out cruft from a previous version of this
patch.
Changed the HTML details from a set to a list in order to ensure
the ordering of the exception details.
Added code to eliminate the duplicate detail messages from the list
and reordered the assertion string to match actual output.
Refactored duplicate elimination code to be more readable and
reliable.
Some reworking of the duplication elimination loop to make it
more readable.
Removed unneeded conditional to filter out empty elements.
Change-Id: I79985b3e305cb30328a3c16b025315a8e969243d
Closes-Bug: 1398838
This review implements blueprint python-request and replaces the old
http client implementation in favor of a new one based on
python-requests.
Major changes:
* raw_request and json_request removed since everything is now being
handled by the same method "_request"
* New methods that match HTTP's methods were added:
- get
- put
- post
- head
- patch
- delete
* Content-Type is now being "inferred" based on the data being sent:
- if it is file-like object it chunks the request
- if it is a python type not instance of basestring then it'll try
to serialize it to json
- Every other case will keep the incoming content-type and will send
the data as is.
* Glanceclient's HTTPSConnection implementation will be used if
no-compression flag is set to True.
Co-Author: Flavio Percoco<flaper87@gmail.com>
Change-Id: I09f70eee3e2777f52ce040296015d41649c2586a
Instead of globally ignoring pyflakes and
hacking warnings, only blacklist those that trigger
very frequently so far, in order to clean them
up in followup commits. Fix and start gating
on the rest already.
Change-Id: Ied7c7250061e3bf379e8286e8ce3b9e4af817faf
Current glance command does not show the details of error message.
For example, the glance command shows HTTPBadRequest only if some
necessary parameter is not specified.
$ glance image-create --file root-fs.img --name cirros-0.3.0-x86_64-uec
Request returned failure status.
HTTPBadRequest (HTTP 400)
$
By only the above message, it is not easy that a user understand the reason
of an error. glance-api server returns the details of reason, but glance
command does not show it.
This patch adds details, which is gotten from glance-api server, to error
message. And a user will be able to understand the reason of a error like
the following:
$ glance image-create --file root-fs.img --name cirros-0.3.0-x86_64-uec
Request returned failure status.
400 Bad Request
Invalid disk format 'None' for image.
(HTTP 400)
$
Fixes bug 1094917
Change-Id: I49192c3ebbc8a70b63dcfcede9fd13f1688388cf
When using https verify that the Common Name (CN) or
the Subject Alternative Name listed in the server's
certificate match the host we are connected to.
Addresses LP bug 1079692.
Change-Id: I24ea1511a2cbdb7c34ce72ac704d7b5e7d57cec2
Use pyOpenSSL for HTTPS connections.
This allows:
* Neater loading of system CA files
* Optional disabling of SSL compression
The performance gain from disabling SSL compression is significant
in cases where the image being uploaded/downloaded is in an already
compressed format (eg qcow2).
Related to bp ssl-connect-rework.
Change-Id: I0568b6c95c5fc7b8eafdbd0284e24c453660a55a
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
Expand exceptions to cover more failures cases. This adds
CommunicationFailure to represent any failures while attempting
to communicate with the remote endpoint. This also adds a new base
exception class BaseException which should be used for all non-HTTP
related failures.
Change-Id: Ie3e1d45c520d816a3f491a85fde94a6c4edf295e
* Refactor helper function that builds the map of http status codes
to local http exceptions - now we don't have to explicitly list
every single exception name
* Add several exceptions to represent http status codes that were not
previously represented
* Improve consistency of exceptions naming by prepending 'HTTP' to
necessary exception names
* Use HTTPException instead of ClientException
* Deprecate old http exceptions (those that aren't prefixed with HTTP)
* Deprecate ClientException
* Deprecate unused NoTokenLookupException and EndpointNotFound
* Add test module to spot-check the from_response helper
Change-Id: Ibc7fef9e2a5b24bd001d183d377901f302d650a9
We don't need to look at the container of available schemas in order
to get the one we want. Remove glanceclient.exc.SchemaNotFound as it can
no longer be raised.
Change-Id: Ib49ad58c4fdfc9bc9f535115674d92040a97db65
A few files were missing copyright headers:
* glanceclient/common/http.py
* glanceclient/v1/__init__.py
* glanceclient/exc.py
Change-Id: Ibbd53cd49f9367994de66a30601b3aefe1a8d6ee
Add glance.exc.InternalServerError and .ServiceUnavailable to
represent HTTP statuses 500 and 503. Users will definitely see
these from Glance, so let's be nice and map them to handy
exception classes.
Change-Id: I8e8fcda532455793ea4d0f08a23f7c92b68c186c
* This allows us to send truly chunked responses to users
* Handle bad connection url schemes with a new InvalidEndpoint exception
* Fixes bug 1023240
Change-Id: I34500987f51d4e0c6e1f89ecf93853de3fcbb1c3
* Consumers of this client should not depend on being able to import
any module other than glanceclient and glanceclient
* The only attributs of the glanceclient module are Client
and __version__
* The attributes of the glanceclient.exc modules have yet to be
locked down
* glanceclient.common.exceptions was replaced with a placeholder
module until consumers of it are updated
Change-Id: Iea9648cd06906d65764987c1f2ee5a88ebeee748