summaryrefslogtreecommitdiff
path: root/glanceclient/v1/images.py
Commit message (Collapse)AuthorAgeFilesLines
* Invalid output running the command 'glance image-show <image_id>'David Sariel2015-09-091-0/+5
| | | | | | | | | | | | | Running the command returns the string 'id' and fails on exception. In function _image_meta_from_headers the meta variable was not properly set because key was not lowercased. Converting key to lowercase solves the problem. NOTE: this is a compatibility fix for urllib3 >= 1.11 Closes-Bug: #1487645 Co-Authored-by: Flavio Percoco <flavio@redhat.com> Change-Id: I1b0b327163577585becb5e762536058d21dc1c98
* Enable flake8 checksDarja Shakhray2015-07-211-3/+3
| | | | | | | | | | | | This commit enables new flake8 checks: * E265 block comment should start with '# ' * H405 multi line docstring summary not separated with an empty line * E123 closing bracket does not match indentation of opening bracket's line * H238 old style class declaration, use new style (inherit from `object`) * E128 continuation line under-indented for visual indent and makes related changes in the code. Change-Id: Ie993afc930f6b74d7a990bcaa9fc0e9f5ba1585c
* Fix leaking sockets after v1 list operationLouis Taylor2015-03-041-54/+83
| | | | | | | | | | | | | | | | | | Since the move to using the requests library, v1 list operations keep the connection open to the glance server. This is normally closed by the garbage collector if it is not explicitly closed, however the paginate function used by the list method had a circular reference preventing it from ever being collected during the lifecycle of a service consuming glanceclient. This is problematic, since it causes long running nova processes to run out of file descriptors for new connections. This patch makes paginate() non-recursive, which allows the connection to be freed. Change-Id: I16a7b02f2b10e506e91719712cf34ef0aea1afc0 Closes-Bug: 1423939
* Change oslo.utils to oslo_utilsLouis Taylor2015-02-051-2/+2
| | | | | | | | | | The oslo.utils libraries are moving away from namespace packages. This requires oslo.utils>=1.2.0 bp drop-namespace-packages Change-Id: I803df61e91eabb96329d859aef6bea03530fb84f
* Remove openstack.common.strutilsLouis Taylor2015-01-271-3/+4
| | | | | | | This module now lives in oslo.utils, so import it from there instead. Co-Authored-By: Ian Cordasco <ian.cordasco@rackspace.com> Change-Id: Ib35dc840992433542490670781badd9529ec8947
* Fix Requests breaking download progress barLouis Taylor2015-01-041-2/+3
| | | | | | | | | | | The move to the requests library (dbb242b) broke the progress bar during downloading an image with --progress enabled, due to requests returning a generator, which has no __len__ function. This patch adds an iterable wrapper which provides the length, sourced from Content-Length headers. Closes-Bug: #1384664 Change-Id: I48598a824396bc6e7cba69eb3ce32e7c8f30a18a
* Replace old httpclient with requestsAmalaBasha2014-07-101-26/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Set purge-props header correctly in image updateMaithem2014-06-191-6/+5
| | | | | | | | | Currently when an image is updated, the purge property header is only set to true in some cases, but when required it isn't set to false Change-Id: I885a82643d2620f393f21c36b3ad95cb7ed43f2c Closes-Bug: 1318079
* Reuse class Manager from common codeAndrey Kurilin2014-06-121-10/+19
| | | | | | | | | | | | | | Class `Managers` from `glanceclient.common.base` module is similar to class `apiclient:ManagerWithFind` from common code. In this patch: - class glanceclient.common.base:Managers replaced by apiclient:ManagerWithFind - module glanceclient.common.base marked as 'deprecated' Related to bp common-client-library-2 Change-Id: I41da4a9188e97ca2c07b6234fc2ac0a877553d3f
* Return request ID to callersChris Buccella2014-04-251-9/+43
| | | | | | | | | | | | | | | | | | | | Currently, calls (create, get, etc.) return only the Image to a caller. In order to log a mapping the request IDs of both glanceclient and the caller, the x-openstack-request-id header value is needed on the server side. This change allows that value to be bubbled up and returned to the caller so that the appropriate logging can occur. The return_req_id parameter can be set by services that are logging request IDs. Glance's request ID will then be returned via the return_req_id parameter. This is a prerequisite for Log Request ID Mappings nova-spec to be completed; Change Ib9b820a0feeb0c0e828ed3e4fab8261f8761ba9a Change I43be05c351f901cee5509c76cff6d69f060c0b3f is an example of a caller using this. Implements: blueprint return-req-id Change-Id: Ia82aa14db5f0e453010514fffb9a25d7b0fc2fd1
* Merge "Using common method 'bool_from_string' from oslo strutils"Jenkins2014-01-311-1/+1
|\
| * Using common method 'bool_from_string' from oslo strutilsllg82122014-01-241-1/+1
| | | | | | | | | | | | | | | | | | Using common method 'bool_from_string' from oslo strutils to replace utils.string_to_bool. partially implements blueprint common-client-library-2 Change-Id: I23924db3000feadcfe823c6cc979ea9752a13fa9
* | Merge "Allow updating empty created v2 images from v1"Jenkins2014-01-221-1/+1
|\ \
| * | Allow updating empty created v2 images from v1David Koo2014-01-201-1/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an empty image is created through python-glanceclient using v2 APIs but updated using v1 APIs, python-glanceclient crashes with a "int() argument must be a string or a number, not 'NoneType'" message. This is because v1.images.ImageManager._format_image_meta_for_user expects the 'size' (and 'min_ram' and 'min_disk') field of an image to be convertible to 'int' but the server-side v2 APIs set it to 'None' for an empty image. Therefore the conversion to int fails with the message above. This fix modifies _format_image_meta_for_user to check whether or not a field can be converted to 'int' and, if not, returns 0 (zero) as the value instead. Tests have also been added. Change-Id: I86680bc06c8ce3ee492efeb3f32071da4f293bcd Closes-bug: #1258160
* | It was removed urllib, urllib2 & urlparse modulesVictor Morales2014-01-181-4/+5
|/ | | | | | | | Those modules have been combined in python 3. Therefore, implementing the six module helps to have support to both versions. Change-Id: I164a0f19790ff066d16d0cf4f0daa6f1097c848e Closes-Bug: #1267181
* Python 3: use six.iteritems and six.string_typesYassine Lamgarchal2014-01-131-2/+2
| | | | | | | | | | six.iteritems() replaces dictionary.iteritems() on Python 2 and dictionary.items() on Python 3. six.string_types replaces basestring() in Python 2 and str in Python 3. Change-Id: Ia18510d167df35caec83626718010228e2140bc0
* Python 3: use six.iteritems() instead of iteritems()Yassine Lamgarchal2014-01-091-4/+5
| | | | | | | Six.iteritems() replaces dictionary.iteritems() on Python 2 and dictionary.items() on Python 3. Change-Id: I12fda5f20d2f4fe8227e45b2fe46b332f63deb97
* Replace OpenStack LLC with OpenStack FoundationZhiQiang Fan2013-09-201-1/+1
| | | | | Change-Id: I38dcbcf1a6c8efe540fcf5f29e782cb3826e583d Fixes-Bug: #1214176
* Merge "Cast image_id to string before calling urllib.quote"Jenkins2013-08-091-2/+2
|\
| * Cast image_id to string before calling urllib.quoteJustin Santa Barbara2013-08-071-2/+2
| | | | | | | | | | | | We can't pass a string in; see Bug #1178233 Change-Id: I040c667e122d792fdcb47ee172463339068af48c
* | Revert 02116565d358a4fa254217779fef82b14b38d8ca0.10.0Mark J. Washenberger2013-08-081-1/+1
| | | | | | | | | | | | | | | | 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
* | Show a pretty progressbar when uploading and downloading an image.mouad benchchaoui2013-08-081-36/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | Allow v1 client to list all users' imagesStuart McLaren2013-07-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | 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
* | Add v1 client side owner based filteringStuart McLaren2013-07-261-6/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Increase default page_size valueJared Culp2013-07-161-1/+1
|/ | | | | | | | | | | 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
* Replace utils.ensure_(str|unicode) with strutils.safe(decode|encode)Flaper Fesp2013-06-041-5/+6
| | | | | | | | | | | | | | | | 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
* Do not decode headers in v1/images.pyFlaper Fesp2013-06-041-3/+12
| | | | | | | | | | | 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
* Convert non-ascii characters within image property to unicodeZhi Yan Liu2013-05-211-2/+4
| | | | | | | | | | | | | | 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>
* Improve Python 3.x compatibilityDirk Mueller2013-04-221-1/+1
| | | | | | | | Some mechanical translation of the deprecated except x,y construct. Should work with Python >= 2.6 just fine Change-Id: I394f9956b9e3e3d9f5f1e9ad50c35b13200af2a1
* Merge "Decode input and encode output"Jenkins2013-02-181-2/+13
|\
| * Decode input and encode outputFlaper Fesp2013-02-131-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Quote image ids before passing them to glanceVishvananda Ishaya2013-01-311-3/+7
|/ | | | | | | | | If the image id contains a space it needs to be quoted or else it will construct an improper header. Fixes bug 1111948 Change-Id: I4db2e74401b57de9666d40b38151182b2a76cd1b
* Merge "Add --sort-key and --sort-dir to image-list"Jenkins2012-11-301-0/+20
|\
| * Add --sort-key and --sort-dir to image-listBrian Waldon2012-11-281-0/+20
| | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Allow setting x-image-meta-store through shell on image creation"Jenkins2012-11-261-1/+1
|\ \ | |/ |/|
| * Allow setting x-image-meta-store through shell on image creationFlorian Haas2012-11-241-1/+1
| | | | | | | | | | | | | | Add a command line arg "--store" to "glance image-create" so users can specify a store other than the default on image creation. Change-Id: Icf9a894b08e405d6884964b3cfaa80250e85ed71
* | Pin pep8 to 1.3.3Chuck Short2012-11-251-2/+2
|/ | | | | | | | 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>
* Handle create/update of images with unknown sizeStuart McLaren2012-10-081-10/+10
| | | | | | | | | | | | | | | | | | | | 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
* Specified Content-Length in update request headerUnmesh Gurjar2012-09-061-2/+2
| | | | | | | | | | | | | 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
* Ensure v1 'limit' query parameter works correctly.0.4.2Brian Lamar2012-08-151-2/+4
| | | | | | | | | | | 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
* Allow 'deleted' to be passed through image update0.4.1Brian Waldon2012-08-131-1/+5
| | | | | | | | | | 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
* Cast is_public, protected, deleted to boolBrian Waldon2012-08-131-0/+5
| | | | | | | | | 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
* Return known int values as int, not strBrian Waldon2012-08-131-5/+15
| | | | | | | | | Cast size, min_ram, min_disk to integers before returning them to the user from the v1 API. Fixes bug 1036297 Change-Id: Ib1e2a3bf931e433b6311cc8a1a5219168b50be97
* Enable client V2 to download imagesLars Gellrich2012-08-091-5/+11
| | | | | | | | | | 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
* Replace httplib2 with httplib as http driverBrian Waldon2012-07-231-2/+2
| | | | | | | | * 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
* Add pagination to v1 image-listBrian Waldon2012-07-191-15/+37
| | | | | | | | | | | | | | | | * 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
* Wrap image data in iteratorBrian Waldon2012-07-111-2/+4
| | | | | | | | | | 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
* Preserve image properties on updateBrian Waldon2012-07-091-1/+10
| | | | | | | | | | * 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
* Allow image filtering by custom propertiesBrian Waldon2012-07-041-0/+3
| | | | | | | | | | | 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
* Hook up GET /v1/images/<id>Brian Waldon2012-06-211-0/+13
| | | | | | | This allows us to get raw image data out of the API! Related to bp glance-client-parity Change-Id: Id5f55553d2ff3b7bf58515062afdfd4b9b183a54