8 Commits

Author SHA1 Message Date
Tatyana Leontovich
8451a94822 Add test for glanceclient shells
Add unittests for the following modules:
* glanceclient.shell
* glanceclient.v1.shell
* glanceclient.v1.legacy_shell
* glanceclient.v2.shell
Also add mock library to the tools/test-requires

Implements: blueprint glanceclient-shells-unittests
Change-Id: I5ec527c5efff3726932d234d7c67e08149643f89
2013-05-17 19:46:07 +03:00
Flaper Fesp
55cb4f4473 Decode input and encode output
Currently glanceclient doesn't support non-ASCII characters for images
names and properties (names and values as well). This patch introduces 2
functions (utils.py) that will help encoding and decoding strings in a
more "secure" way.

About the ensure_(str|unicode) functions:

    They both try to use first the encoding used in stdin (or python's
    default encoding if that's None) and fallback to utf-8 if those
    encodings fail to decode a given text.

About the changes in glanceclient:

    The major change is that all inputs will be decoded and will kept as
    such inside the client's functions and will then be encoded before
    being printed / sent out the client.

    There are other small changes, all related to encoding to str,
    around in order to avoid fails during some conversions. i.e: quoting
    url encoded parameters.

Fixes bug: 1061150

Change-Id: I5c3ea93a716edfe284d19f6291d4e36028f91eb2
2013-02-13 21:53:11 +01:00
Brian Waldon
11e6aadf19 Add happy path tests for ResponseBodyIterator
Change-Id: I5e971b57a0591752e7fca76d0df78ce139308db5
2012-10-02 09:19:37 -07:00
Lars Gellrich
137b3cf975 Enable client V2 to download images
Added the CLI option image-download to download an image via API V2.
Added utility function to save an image.
Added common iterator to validate the checksum.

Related to bp glance-client-v2

Change-Id: I0247f5a3462142dc5e9f3dc16cbe00c8e3d42f42
2012-08-09 17:14:22 +00:00
Brian Waldon
1e744f162e Replace httplib2 with httplib as http driver
* 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
2012-07-23 13:52:12 -07:00
Brian Waldon
0f628b19cb Add pagination to v1 image-list
* Use recursive generator function to make subsequent requests
  to the v1 detailed images resource
* 'limit' continues to act as the absolute limit of images to return
  from a list call
* 'page_size' indicates how many images to ask for in each subsequent
  pagination request
* Expose --page-size through the cli
* Convert v1 images tests to use strict url comparison
* Drop strict_url_check from FakeAPI kwargs - now the functionality
  is always active and tests must directly match fixture urls
* Fix bug 1024614

Change-Id: Ifa7874d88360e03b5c8aa95bfb9d5e6dc6dc927e
2012-07-19 13:26:37 -07:00
Brian Waldon
d88d8fc462 Add pagination to v2 image-list
* Use a recursive generator function to iterate over the image
  container. The presence of next links are indicators to
  continue pagination while their value drives the location of
  the next page.
* A user can pass in --page-size on the command line, or page_size
  when using the controller directly, to control how many images
  are requested with each subsequent paginated request. Default page
  size is 20.
* Add a flag (strict_url_check) for the FakeAPI class to control
  whether it chops off query params when trying to match a request
  to a fixture.
* Related to bp glance-client-v2.

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a12
2012-07-13 20:12:06 -07:00
Brian Waldon
7f48506781 Add 'explain' command to v2 that describes schemas
At its core, this is adding the ability to finx a schema through
published links and convert it to a usable object.

Related to bp glance-client-v2

Change-Id: I7b38ad091c6b0ad80197eb789503cf73989893e5
2012-06-07 14:43:00 -07:00