Commit Graph

116 Commits

Author SHA1 Message Date
Chuck Short 518cb2508d python3: use six.moves for httplib imports
This adds six to the requirements.txt file in order to make
some HTTP-related imports work across Python 2's httplib and Python 3's
http.client modules. Tests were updated, including one change to the
location of HTTPConnection - moving it from being accessed where it was
imported rather than its canonical location inside of
six.moves.http_client.

Change-Id: Ibc4932b37dfdf195cd5091066914513af1876955
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-10-16 10:00:56 -04:00
Jenkins cd11833cff Merge "Fix regression bug after removing posixpath in http.py" 2013-10-09 17:46:01 +00:00
Jenkins 5ec5e7baec Merge "Fix getting header in redirect processing" 2013-10-09 17:36:54 +00:00
Chang Bo Guo 7bf27252e5 Fix misused assertTrue in unit tests
Refactored unit tests to use assertEqual instead of assertTrue
where needed.

Closes-Bug: #1226374

Change-Id: I5f3b582e19f3461a04b5df05960095779ec8aa1a
2013-10-08 19:04:08 -07:00
eddie-sheffield 32d9c42816 Add CLI for V2 image create, update, and upload
Provides command line support for image-create, image-update,
and image-upload using the Glance V2 API. This includes building
help text for create and update based on the image jsonschema
as fetched from the server.

Also fixes bug caused by default warlock patch generation not
matching what Glance expects when updating a core property
which had not originally been set when the image was created.

Related to bp glance-client-v2

Change-Id: I841f9e3d05802f4b794cb6f4849abe03ff0324d9
2013-10-02 13:22:55 -04:00
Yang Yu a0715e966d Fix regression bug after removing posixpath in http.py
After removing posixpath.normpath(url) in http.py, the code has a
regression bug that the url like 'http://example.com:80/test' can
not work. The code urlparse.urljoin() can not work as '%s%s' %
(self.endpoint_path, url).

Fixes bug #1230032

Change-Id: Ie7266fc3a067b92dfeed169086b4bf6a87dedbd6
2013-09-28 21:47:09 -05:00
Russell Bryant 50266eec2b Fix getting header in redirect processing
The code for processing an HTTP redirect included an incorrect method of
getting the Location header from an HTTPResponse.  It needs to use the
getheader() method on the response, instead.  This patch fixes that and
includes a unit test that covers this code path.

Change-Id: I0952fabad581b020dee07bdc4007b55b47c906aa
Closes-Bug: #1231524
2013-09-26 11:45:06 -04:00
Jenkins 7a4a8a0979 Merge "Support glance client can get ipv6 image url correctly" 2013-09-25 20:01:58 +00:00
Jenkins 360a29a763 Merge "Use openstack-images-v2.1-json-patch for update method" 2013-09-19 17:55:45 +00:00
Dazhao 061da46202 Support glance client can get ipv6 image url correctly
This patch is for fix bug 1208784. In openstack ipv6 environment,
if the os image url is not provided, need use the provided host
to generate literal ipv6 image url.

Fixes bug 1208784

Change-Id: Icb71241a639db02d079348f086bd7bd5f0412609
2013-09-06 13:58:24 +08:00
Fei Long Wang 897ae3d795 Enable query image by tag
This patch will enable Glance client to query images by user
defined tags.

Implement bp image-query-by-tag
Implement bp glance-client-v2

Change-Id: I6f54630c5b7c9c567d85485ad4289284e5486814
2013-08-28 14:13:27 +08:00
Ghe Rivero 3307549a0f Use openstack-images-v2.1-json-patch for update method
image.patch returns a JSON schema Draft 10 (application/openstack-images-v2.1-json-patch)
while the glaceclient update method specify a Content-Type header
application/openstack-images-v2.0-json-patch with correspond to a JSON schemea Draft 4.

Fixes bug 1206095
Change-Id: I8c5a96f0e117a81b5b527a96ef45758fc69b518d
2013-08-23 06:52:08 +00:00
Jenkins fe9a62b5b5 Merge "Allow single-wildcard SSL common name matching" 2013-08-22 21:12:36 +00:00
Brian Waldon 683e40fd31 Allow single-wildcard SSL common name matching
Fix bug 1212463

Change-Id: I168601fd9847497c2261c77ce6c856bca187c6c8
2013-08-21 17:57:38 +00:00
eddie-sheffield 7e4ba229c3 \Allow removal of properties using glance v2 api
This adds support to the glance client library for removing
properties from an image. Properties to be removed must be
explicitly listed. There is no equivalent of the 'purge_props'
functionality in v1.

Also beefed up testing around create since some of the
functionality is the same as update.

Fixes bug 1206472

Change-Id: I16f4c39cdfc8a0cd07bede600461b7a289fbb080
2013-08-13 14:13:27 -04:00
Jenkins 0c2d2a982d Merge "Cast image_id to string before calling urllib.quote" 2013-08-09 20:34:10 +00:00
Mark J. Washenberger eb47b55dbd Revert 02116565d3
A patch slipped in that modified the default image list limit in a
backwards-incompatible way. This change reverts that patch, but
preserves some of the formatting improvements.

Change-Id: I17ae5024896ca7b1064be66b9e47653e953771d6
2013-08-08 22:31:40 -07:00
mouad benchchaoui 1d7da740b2 Show a pretty progressbar when uploading and downloading an image.
Add a new module that contain generic wrapper for file and iterator, which
are used to wrap image to upload and the request body iterator in upload and
download cases repectively, to show and advance a pretty progress bar when this
laters are consumed, The progress bar is triggered by adding a --progress command
line argument to commands: image-create, image-download or image-update.

Change-Id: I2ba42fd0c58f4fa087adb568ec3f08246cae3759
bug fix: LP#1112309
blueprint: progressbar-when-uploading
2013-08-08 15:40:15 +02:00
Justin Santa Barbara f629692917 Cast image_id to string before calling urllib.quote
We can't pass a string in; see Bug #1178233

Change-Id: I040c667e122d792fdcb47ee172463339068af48c
2013-08-07 11:17:01 -07:00
Jenkins 43e71e3993 Merge "Changes to allow image upload with V2 api" 2013-07-31 19:10:12 +00:00
eddie-sheffield e827c37a05 Changes to allow image upload with V2 api
Related to bp glance-client-v2

Change-Id: I72a1d2825dd5c1ff4890e8be477cb4447d59f136
2013-07-31 12:28:24 -04:00
Jenkins 5c4fb2f7a1 Merge "Fix test assertions & test cases for V2 Shell Unit test" 2013-07-31 15:22:04 +00:00
Jenkins 937b65b513 Merge "Enable client library V2 to create an image." 2013-07-30 22:08:19 +00:00
Jenkins e0e6030a09 Merge "Allow v1 client to list all users' images" 2013-07-30 17:31:08 +00:00
Jenkins e34dc38a70 Merge "Add v1 client side owner based filtering" 2013-07-30 17:31:06 +00:00
Flaper Fesp fd0e117579 Encode error messages before sending them to stdout
When an error with non-ascii characters is caught by glanceclient, it
fails at printing it and exists with a UnicodeEncodedError. This patch
encodes errors' messages using strutils before sending them to stdout.

Fixes bug: #1200206

Change-Id: I4dabcd76ffb258840bd6a66ad23c030f34960e86
2013-07-29 09:30:44 +02:00
Stuart McLaren bb47812765 Allow v1 client to list all users' images
Add a '--all-tenants' option to the image-list command.  This adds
'is_public=None' to the query string passed to the server, and for an
admin user results in a listing of all images present on the server
irrespective of owner or public values.

Addresses bug 1201787.

Change-Id: I38dd0752a31ebea84f16b786d205e82eba1a96bc
2013-07-26 11:01:52 +00:00
Stuart McLaren 12feedb2cf Add v1 client side owner based filtering
Add the --owner option to the v1 client's image-list command to support
filtering images based on the owner (tenant id).

Allows administrators to more easily list a particular user's images.

Note that this is far less efficient than v2 server-side owner based filtering.

Addresses bug 1201765.

Change-Id: I4ffa522b96c91e659c87f5452f2f1f44e47e806b
2013-07-26 11:00:32 +00:00
eddie-sheffield 92e4ee201a Enable client library V2 to create an image.
Adds support for creating an image to the client library only, not the CLI.
Replaced reference to deprecated BaseException.message

Related to bp glance-client-v2

Change-Id: I8e3d09d89493368d22f7b1f69f79ebd2518e289d
2013-07-25 14:45:00 -04:00
Venkatesh Sampath 060a3fe2c0 Fix test assertions & test cases for V2 Shell Unit test
Fixes bug 1195674

Change-Id: I46c10040ea10415498dd1eed69e45139cfa37eb4
2013-07-25 08:11:58 +05:30
Jenkins 49a1207266 Merge "Fix SSL certificate CNAME checking" 2013-07-22 21:50:07 +00:00
Jenkins 093064caa8 Merge "Increase default page_size value" 2013-07-19 09:45:42 +00:00
Jenkins 46ce865506 Merge "Pass all identity headers received to glance" 2013-07-18 17:45:33 +00:00
Jenkins eb6ed51647 Merge "Expose checksum index image property in client" 2013-07-17 19:00:48 +00:00
Jared Culp 02116565d3 Increase default page_size value
This is a temporary solution. Increasing the default page size (which is being
used everytime, since the client is ignoring nova's --limit param). This should
decrease the number of queries that glance does when nova requests an image
detail list.

Bug 1200257

Change-Id: I7ed4521698570cbae9c20e69ddca8b11b57c65ad
2013-07-16 11:46:47 -04:00
iccha.sethi 95810ef1d2 Pass all identity headers received to glance
There is an upcoming patch in nova which passes identity
headers to glance client. We want to ensure that these get
passed to glance, which in turn with help the no auth
option in glance.

Resolves bug 1200761

Change-Id: Ifbef582aa4e64a2e7a46db43a9cc6cf8c3531dbd
2013-07-15 14:20:37 +00:00
Thomas Leaman 822cd64c07 Fix SSL certificate CNAME checking
Currently, accessing a host via ip address will pass SSL verification;
the CNAME is not checked as intended as part of verify_callback.

'preverify_ok is True' will always return false (int/bool comparison).
preverify_ok will be 1 if preverification has passed.

Fixes bug 1192229

Change-Id: Ib651548ab4289295a9b92ee039b2aff2d08aba5f
2013-07-15 08:50:17 +00:00
amalaba 09b29aac12 Expose checksum index image property in client
Implement checksum image index property in the python-glanceclient

Change-Id: If1426b7938457014ef27a86d3902d53854161627
Implements: blueprint index-using-checksum-image-property
2013-07-12 15:05:26 +05:30
Jenkins 8427208015 Merge "Rename invalid domain name to be RFC compliant." 2013-07-08 16:16:21 +00:00
Venkatesh Sampath b9c1df8dfc Enable client V2 to update/delete tags for a given image.
Added the CLI option image-tag-update to associate a tag to an image via API V2.
Added the CLI option image-tag-delete to delete a tag associated with an image via API V2.

Related to bp glance-client-v2

Change-Id: I76060e1982223770a6c2c0bd9376d568af0df456
2013-07-02 21:32:49 +05:30
Monty Taylor bd0880cc94 Rename invalid domain name to be RFC compliant.
http://tools.ietf.org/html/rfc6761 and
http://tools.ietf.org/html/rfc2606 define invalid domain names to
be used in contexts such as this. It's good to be compliant with RFCs.

Change-Id: Ibb7f9ee12c0c4331f8a33470def74c3a136ef6d9
2013-06-30 23:33:07 -04:00
Dirk Mueller 62579fbb21 Start using Pyflakes and Hacking
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
2013-06-22 16:00:26 +02:00
Kevin McDonald d8a537c7fe Removes extra slash on endpoints without a path
Change-Id: I5ce54117c5ac276fb9629c71eb16db88e078c947
Fixes: bug #1179984
2013-06-19 15:49:05 +00:00
Jenkins c120aff87f Merge "Fix problem where image data is not read from a pipe." 2013-06-18 12:47:31 +00:00
Flaper Fesp 7818387d4a Replace utils.ensure_(str|unicode) with strutils.safe(decode|encode)
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
2013-06-04 00:42:32 +02:00
Flaper Fesp 7daa976d14 Do not decode headers in v1/images.py
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
2013-06-04 00:41:24 +02:00
Hugh Saunders 9fda0dc815 Fix problem where image data is not read from a pipe.
For image-updae and image-create commands, glanceclient attempts to
determine whether image data should be uploaded based on the presence
of data on stdin. Unforunately it is difficult to determine if data is
available, especially when standard in is from a pipe.

This is especially problematic for update operations, where data must
only be uploaded if the image is in queued state. For example data may
be uploaded when the user only wants to rename an image, but the rename
will be rejected because data cannot be uploaded to an unqueued image.

This patch removes the check that attempts to determine if data is
available to read as it didn't work for pipes. It also re-introduces a
check for image state in the update operation, so that glanceclient only
attempts to read data if the image being updated is in queued state.

The image state check is part of the original patchset that was removed
so the patchset could have a single focus [1]

This patch also removes a test for handling empty stdin, and adds a test
for reading stdin from a pipe.

[1] https://review.openstack.org/#/c/27536/3/glanceclient/v1/shell.py

Fixes: bug 1184566
Related to: bug 1173044

Change-Id: I8d37f6412a0bf9ca21cbd75cde6a4d5a174e5545
2013-06-03 18:01:58 +01:00
Flaper Fesp 81e88344fb Add tests for encodings
The patch adds tests for headers encodings, incoming data decoding,
outgoing meta encoding and filters encoding.

Fixes bug: #1187013

Change-Id: I7e59bf6c44b9d188bd3faf32fc09f309f3ad67d3
2013-06-03 17:40:50 +02:00
Hugh Saunders a3585ef62d Don't attempt to read stdin if it is empty.
* 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
2013-05-23 13:37:09 +01:00
Jenkins 985c06bea1 Merge "Improve unit tests for python-glanceclient.glanceclient.common.base" 2013-05-22 23:40:25 +00:00