Glanceclient implemented both functions before they landed into oslo.
Since both functions are already in oslo, it is now possible to pull
them in.
There's a small difference between glance's implementation and oslo's,
that is the later does not convert non-str objects - int, bool - to str
before trying to decode / encode them. This patch takes care of that
where necessary, more precisely, while encoding headers before doing a
new request.
Fixes bug: #1172253
Change-Id: I9a0dca31140bae28d8ec6aede515c5bb852b701b
v1.images._image_meta_to_headers currently encodes headers as a way to
ensure they're an instance of basestring. This is not necessary since
headers will be encoded later during the request. Also, all data within
the client should be already decoded.
Fixes bug: #1187013
Change-Id: I80525adbc6e9e576cfad5b576090ef9ee574c1cf
The patch adds tests for headers encodings, incoming data decoding,
outgoing meta encoding and filters encoding.
Fixes bug: #1187013
Change-Id: I7e59bf6c44b9d188bd3faf32fc09f309f3ad67d3
* Check for available data size in v1/shell.py/_set_data_field, don't
read if 0.
* Add test_shell.py including tests for 3x stdin scenarios:
* closed
* open and empty
* open with data
Change-Id: I6ff65b0e226be509de9cd3f021560081529283b0
Fixes: bug #1173044
Convert non-ascii characters within image property (key/value pair) to
unicode but utf-8 to prevent provisioning failure when cloud using qpid
backend.
This change also make the image property encoding consistency between
the image updating and the receiving. Before this, image property
updating use unicode, but receiving (get) result is utf-8.
Fixes: Bug #1180377
Change-Id: I010760c598a7e008c79f1240255708265352cdb5
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
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
Lists, creates, deletes, updates image members using glance
v2 api.
Related to bp glance-api-v2-image-members
Change-Id: Ic018a265a1676bb0a5638a55e70a527ce6b447fc
Some mechanical translation of the deprecated
except x,y construct. Should work with Python >= 2.6
just fine
Change-Id: I394f9956b9e3e3d9f5f1e9ad50c35b13200af2a1
This adds a test to verify that the copy from attribute is used
properly. It tests for bug 1167899. This submission depends on
the review here: https://review.openstack.org/#/c/26740/
Change-Id: Ied14fb29887b7cbbecbab51bd384cf0f640c9e18
When running the image-list command the user should have the option
to list images according to whether or not the image is was set
to public. A new test is included to verify this behavior.
Change-Id: If645e7390fcf850648cda780a04ea37a26d855a2
Fixes bug: 1118799
Relax requirements to >= 0.6, < 0.8, as 0.7.x seems to
work as well. Added testcase to ensure this.
Change-Id: I1a1a709e6053451b1256a0d78f8fe8562fb10e62
Errors in name resolution have been logged previously with the url path
rather than the hostname. That resulted in incorrect errors like:
InvalidEndpoint: Error finding address for
/v1/images/detail?is_public=none&limit=20: [Errno -2]
Name or service not known
rather than one mentioning hostname itself. This patch changes the log
message to fit the situation.
Change-Id: I1eecbcb22d41b1341c214937b9cbfd046fd301a0
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
* Rename --ca-file to --os-cacert (--ca-file deprecated for
backward compatibility)
* Add cacert to keystoneclient initialization to verify the
keystone server certificate
This aligns glanceclient with keystoneclient for option naming
and the use of TLS for the keystone auth connection. It does not
change the use of TLS/SSL for the glance connection.
Change-Id: If8b05655aea5f3c62612d77bf947dd790f77eddf
The --sort-key and --sort-dir CLI options allow users to control the
field and direction by which their images are sorted in an image-list
operation. The previous default sort behavior of sorting by ID asc has
been preserved.
Fixes bug 1082957.
Change-Id: I1d3664219c275b0379fe176f8288d6ffae0dffbe
Standardize pep8 to 1.3.3 and cleared up any errors
found by pep8 tests.
Change-Id: Ib7eb97d0789556d1676ccad58b5d3364065b7d15
Signed-off-by: Chuck Short <chuck.short@canonical.com>
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
* Limit human-readable sizes to a single decimal
* Drop trailing zero
* Step one suffix further in the case of a size being 1024
Change-Id: I2eb8ac0571d3d08b52f62155912863870573a37c
By introducing the parameter --human-readable for several functions
(image-list, image-show, image-update, image-create) it's possible
to convert the size in bytes to something more readable like
9.309MB or 1.375GB.
Change-Id: I4e2654994361dcf330ed6d681dbed73388f159cb
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
It may not be possible to know in advance the total
size of image data which is to be uploaded, for example
if the data is being piped to stdin.
To handle this we use HTTP Transfer-Encoding: chunked
and do not set any image size headers.
Various subtly different cases needed to be handled for
both image-create and image-update, including:
* input from named pipe
* piped input of zero size
* regular file of zero length
Fix for bug 1056220.
Change-Id: I0c7f0a64d883e058993b954a1c465c5b057f2bcf
When the server refuses the connection the error message displayed now
lists the endpoint that refused the connection.
Fixes: bug 1043067
Change-Id: I62797106732bbb6eec8c99e491fd38850ad58ff8
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
The tests were present but were not asserting list results.
page_size was overriding the absolute limit so limits were
not working if they were less than the page_size.
Fixes bug 1037233
Change-Id: If102824212e3846bc65d3f7928cf7aa2e48aaa63
The legacy client allowed users to pass 'deleted' through an
update call. This is breaking some clients of this library because
they expect to be be able to still do that.
Fixes bug 1036315
Change-Id: I9ae20a5e4579240c7d5e86316d6d1e927755dbf5
To keep a consistent view of an image, is_public, protected, and
deleted need to be cast to a bool when being parsed from headers.
Fix bug 1036299
Change-Id: I2730a0f2d705d26ebc0ba883e99c1caf44d70b51
Cast size, min_ram, min_disk to integers before returning them
to the user from the v1 API.
Fixes bug 1036297
Change-Id: Ib1e2a3bf931e433b6311cc8a1a5219168b50be97
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
* 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
The v2 API no longer returns images in JSON containers like
'{"image": {...}}', so stop trying to decode the responses
as if it does.
Fix bug 1031185
Change-Id: I5209fe76445d4195b12944146a0ef190883f363f
* 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
* 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
* 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
We will want this to be a generator as soon as we implement
pagination. Let's establish the interface now.
Related to bp glance-client-v2
Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a07