Commit Graph

48 Commits

Author SHA1 Message Date
ZhiQiang Fan 2517203975 Replace OpenStack LLC with OpenStack Foundation
Change-Id: I38dcbcf1a6c8efe540fcf5f29e782cb3826e583d
Fixes-Bug: #1214176
2013-09-20 04:05:51 +08: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
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
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
Jenkins 8427208015 Merge "Rename invalid domain name to be RFC compliant." 2013-07-08 16:16:21 +00:00
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
Jenkins c120aff87f Merge "Fix problem where image data is not read from a pipe." 2013-06-18 12:47:31 +00: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
Zhi Yan Liu 8c70c5b08d Convert non-ascii characters within image property to unicode
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>
2013-05-21 00:03:31 +08:00
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
Jenkins 4bbc7b8a9b Merge "Improve Python 3.x compatibility" 2013-04-24 16:38:25 +00:00
Dirk Mueller 45feb672af Improve Python 3.x compatibility
Some mechanical translation of the deprecated
except x,y construct. Should work with Python >= 2.6
just fine

Change-Id: I394f9956b9e3e3d9f5f1e9ad50c35b13200af2a1
2013-04-22 16:38:55 +02:00
John Bresnahan 2178120e9a Test that copy_from is used properly in old API
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
2013-04-12 10:59:28 -10:00
John Bresnahan a8f7de2afd Filter images list by public=True|False
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
2013-03-30 21:26:35 -10:00
Monty Taylor 1d461a6496 Use testtools instead of unittest.
Part of blueprint grizzly-testtools

Change-Id: Ie914fd8f59cddb1a480566ec4eff908bfb51921c
2013-01-02 15:20:36 -08:00
Brian Waldon 4da8b287b4 Add --sort-key and --sort-dir to image-list
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
2012-11-28 09:46:32 -08:00
Chuck Short c0ec97f310 Pin pep8 to 1.3.3
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>
2012-11-25 11:34:56 -05:00
Stuart McLaren 727aadbc25 Handle create/update of images with unknown size
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
2012-10-08 11:16:18 +00:00
Unmesh Gurjar 30d8e1b97c 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
2012-09-06 00:41:08 -07:00
Brian Lamar d64876424e Ensure v1 'limit' query parameter works correctly.
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
2012-08-15 14:50:11 -04:00
Brian Waldon a5b8165d7d Allow 'deleted' to be passed through image update
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
2012-08-13 10:56:27 -07:00
Brian Waldon 8f0d5c4f2c Cast is_public, protected, deleted to bool
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
2012-08-13 10:55:43 -07:00
Brian Waldon 1e539dfdbe Return known int values as int, not str
Cast size, min_ram, min_disk to integers before returning them
to the user from the v1 API.

Fixes bug 1036297

Change-Id: Ib1e2a3bf931e433b6311cc8a1a5219168b50be97
2012-08-13 10:18:51 -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 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 da360462a5 Wrap image data in iterator
This is establishing the API for a future optimization. We want to
be able to offer true socket-level caching, but can't do that with
httplib2 right now. For now, we will just fake the optimization
by returning an iterator over the image body, which happens to already
be fully loaded into a string.

Change-Id: I2d36e3cdd45b26d7c7c27ba050bf6a4b5765df6c
2012-07-11 19:55:02 -07:00
Brian Waldon cf8613e76d Preserve image properties on update
* By default, image properties should not be deleted on image update.
* A user can specify --purge-props through the CLI or purge_props
  as a keyword argument to ImageManager.update to override the default
  behavior and force properties to be deleted.
* Fixes bug 1022758

Change-Id: Ib079378cb765552fc29a66913aefbbcd934d2065
2012-07-09 21:03:46 -07:00
Brian Waldon a1691ddc10 Allow image filtering by custom properties
A user can filter a list of images by passing in a 'properties'
sub-dictionary inside of the 'filters' keyword argumen to
ImageManager.list(). The same functionality can be used through
the CLI through the use of one or more'--property-filter' options.

Related to bp glance-client-parity.

Change-Id: I7d119174d83faa894dde557e1944289de296a02c
2012-07-04 15:49:41 -07:00
Brian Waldon 99e872a57b Hook up GET /v1/images/<id>
This allows us to get raw image data out of the API! Related to
bp glance-client-parity

Change-Id: Id5f55553d2ff3b7bf58515062afdfd4b9b183a54
2012-06-21 13:06:18 -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
Brian Waldon 3943699427 Refactor HTTPClient to use two request methods
Rather than depend on magic, I would prefer that we explicitly call
two different request methods: json_request and raw_request. The
former will encode/decode request bodies to and from JSON, while
the latter will not.

Change-Id: I6a429a5975993f71df85df55f11c5d51c050c289
2012-05-22 08:45:00 -07:00
Gabriel Hurley 3344eac545 Adds filter support to images.list().
This existed in glance.client, and should exist in the new
client as well! :-)

Change-Id: Iea8c55fcb0f0d30d6dc138072354c3f20d1288cf
2012-04-27 12:25:48 -07:00
Brian Waldon 538a9e30a2 Adding id for image members 2012-04-03 19:26:38 -07:00
Brian Waldon c72e4dd2b5 image membership management works 2012-04-03 17:39:32 -07:00
Brian Waldon b87b1b5086 Adding support for passing image data through cli 2012-04-03 17:01:48 -07:00
Brian Waldon d191262413 Image update works 2012-04-03 16:00:49 -07:00
Brian Waldon d5bb951e5f More complete image creation 2012-04-03 14:43:04 -07:00
Brian Waldon d75a029a01 Adding shared-images support 2012-04-02 16:26:19 -07:00
Brian Waldon ca8434f2c3 Image members bones 2012-04-02 15:44:43 -07:00
Brian Waldon 664f370677 Basic testing 2012-04-02 14:08:03 -07:00