Commit Graph

86 Commits

Author SHA1 Message Date
Jenkins 5b4aef5742 Merge "Creating task with invalid property crashes in py3" 2015-04-07 13:30:04 +00:00
Kamil Rykowski a6234d1c4e Creating task with invalid property crashes in py3
Currently when you are trying to set invalid additional property for
task using py3 interpreter it will fail, because function `unicode` does
not exist in py3.

Fix it by replacing `unicode` with `utils.exception_to_str` which is
used in other modules already.

Change-Id: I5897868f801467a2eaa7585b5f2d578cef358426
Closes-Bug: 1439513
2015-04-02 06:15:48 +00:00
Alexander Tivelkov 90407d9e47 Expose 'is_base' schema property attribute
Changeset I49255255 has added an 'is_base' attribute for Image Schema
properties, thus allowing to differentiate between base and custom image
properties, but the client hasn't make any use of it.

This patch adds appropriate attribute to SchemaProperty class and a
helper method which allows to validate if the given property is base or
not.

The added helper method (is_base_property) should not be confused with
the existing is_core_property: the latter just checks if the property is
known to the schema, regardless of its being base or not.

Change-Id: I7c397196dad9ae5494ed2f8f3aacef3fc1ce70d8
Partial-Bug: #1323660
2015-03-27 19:03:48 +03:00
Jenkins 6db625f287 Merge "Extend images CLI v2 with new sorting syntax" 2015-03-16 20:12:42 +00:00
Jenkins 82143e26d3 Merge "Add the ability to specify the sort dir for each key" 2015-03-16 20:11:50 +00:00
Jenkins c32a41415d Merge "Adds the ability to sort images with multiple keys" 2015-03-16 20:11:34 +00:00
Mike Fedosin 3f3066be97 Extend images CLI v2 with new sorting syntax
This code enables new syntax for sorting output with multiple
keys and directions based on API Working group sorting
guidelines.

It's a client code to consume API modified in change
Ie4ccfefa0492a3ac94cc7e22201f2f2be5c1cdbb

Example:
glance --os-image-api-version 2 --sort name:desc,size:asc

Implements-blueprint: glance-sorting-enhancements
DocImpact
Depends-On: Ie4ccfefa0492a3ac94cc7e22201f2f2be5c1cdbb
Change-Id: I36a9fa9f0508fea1235de2ac3a0d6a093e1af635
2015-03-16 19:31:49 +03:00
Mike Fedosin bbd27d5276 Add the ability to specify the sort dir for each key
Adds client code to consume API modified in change
Ib43b53abfba7cb5789d916a014376cf38fc5245b

Extends CLI for v2 with multiple sort dirs
Example:
glance --os-image-api-version 2 image-list \
--sort-key name --sort-dir asc --sort-key size --sort-dir desc

Implements-blueprint: glance-sorting-enhancements
DocImpact
Depends-On: Ib43b53abfba7cb5789d916a014376cf38fc5245b
Change-Id: Ia20716f3c75299f796879299da317b2e81496088
2015-03-16 14:29:06 +03:00
Mike Fedosin fc79467ff6 Adds the ability to sort images with multiple keys
Adds client code to consume API modified in change
Ib7a6aeb2df3bc5d23fe8e070290b5bfcab00c0f5

Extends CLI for v2 with multiple sort keys
Example:
glance --os-image-api-version 2 image-list --sort-key name --sort-key size

Implements-blueprint: glance-sorting-enhancements
Change-Id: If79779a4c52c8dc5c4f39192d3d247335a76ba24
DocImpact
Closes-Bug: 1221274
2015-03-13 18:35:00 +03:00
Steve Lewis f6f573316c Apply expected patch format when updating tags in v2.images
Currently, glanceclient.v2.update builds a patch request that does not
match glance API.

This patch overrides the default behaviour to customize the patch
request with the right format for the API.

Co-Authored-By: Steve Lewis <steve.lewis@rackspace.com>
Fixes bug 1306774
Change-Id: If0739ac285da1e741bfa40b6c719331a5ce49319
2015-03-12 15:18:20 -07:00
Jenkins c7c4ac9e85 Merge "v2: Allow upload from stdin on image-create" 2015-03-06 19:55:15 +00:00
Jenkins 654ba87a89 Merge "Glance image delete output" 2015-02-20 14:48:49 +00:00
Abhishek Talwar f7cdc3eefe Glance image delete output
Deleting an already deleted image using admin user is throwing an
error "404 Not Found" which is confusing. Deleting an image that does
not exist throws "No image with a name or ID of 'image-id' exists."

Updated the code so that trying to delete an already deleted image
throws "No image with an ID of 'image-id' exists." error.

Closes-Bug: #1333119
Change-Id: I8f9a6174663337a0f48aafa029a4339c32eb2134
Co-Authored-By: Abhishek Talwar <abhishek.talwar@tcs.com>
Co-Authored-By: Kamil Rykowski <kamil.rykowski@intel.com>
2015-02-17 11:27:24 +01:00
Jenkins 4bfd8d5097 Merge "Remove openstack.common.strutils" 2015-02-02 04:49:32 +00:00
Flavio Percoco 93c9bc1fe0 Add a --limit parameter to list operations
In v2, we use the link header during paginations to know when there are
more images available in the server that could be returned in the same
request. This way, it's possible to iterate over the generator returned
by list and consume the images in the server.

However, it's currently not possible to tell glanceclient the exact
number of images we want, which basically means that it'll *always* go
through the whole list of images in the server unless the limit is
implemented by the consumer.

DocImpact
Change-Id: I9f65a40d4eafda6320e5c7d94d03fcd1bbc93e33
Closes-bug: #1415035
2015-01-29 10:37:55 +00:00
Louis Taylor b818826420 Remove openstack.common.strutils
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
2015-01-27 19:22:42 +00:00
Stuart McLaren 6d21959e15 v2: Allow upload from stdin on image-create
For example:

$ glance --os-image-api-version 2 image-create < /tmp/data

This is consistent with v1.

DocImpact
Closes-bug: 1408033

Change-Id: Ifed4ece9e4e02a46d80b49a8e4fc372f1a304241
2015-01-07 17:47:31 +00:00
Louis Taylor df02ee8e2a Fix Requests breaking download progress bar
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
2015-01-04 20:52:00 +00:00
Travis Tripp 9a4d8580e8 Support Pagination for namespace list
The rest api metadefs/namespaces supports pagination using the parameters
of limit, marker, sort_dir, & sort_key. However, the glance client isn't
passing those parameters through (they come in as kwargs). This is
preventing pagination from working properly in horizon.

This is affecting Horizon support: https://review.openstack.org/#/c/104063/

Change-Id: Ib349cf3a3a437eb1711f350b37d0bd0e7d01330a
Closes-Bug: 1381816
2014-12-10 23:21:41 -07:00
Flavio Percoco 9829d7b6b9 Don't require version to create Client instance
We currently require a version to always be passed to discover the
client version that should be loaded. However, this information is
commonly present in the URL instead. The current behavior forces
consumers of the library to keep the required version around and/or to
strip it themselves from the URL.

This patch relaxes that requirement by making the version a keyword and
requesting instead an endpoint to be passed. The patch gives priority to
the version in the endpoint and falls back to the keyword if the later is
not present.

Follow-up patches will improve this code making it interact a bit more
with the endpoint's catalog.

Closes-bug: #1395714
Change-Id: I4ada9e724ac4709429e502b5a006604ca0453f61
2014-12-09 14:45:06 +00:00
Erno Kuvaja 8e02b2a641 Allow --file in image-create with v2 Image API
Allows passing --file and --progress to glance image-create with Image API v2.

if --file is present the image-create effectively calls image-upload with the
newly created image's id and the '--file' + '--progress' paramaters. The image
metadata will be printed after the upload call instead of after creation.

In a case argumented file does not exist the image will not be created and
error will be printed instead.

DocImpact
Closes-Bug: #1324067

Change-Id: I5d41fb2bbeb4e56213ae8696b84bf96b749414f8
2014-11-26 09:34:48 +00:00
Jenkins 9a4fec4a1e Merge "Refactor method of constructing dicts in some tests" 2014-11-20 09:53:56 +00:00
Louis Taylor 4194a55a09 Add --property-filter option to v2 image-list
The option is present in the v1 shell, but missing from the v2 shell. This
allows the user to filter based on any image property.

Example:

    $ glance --os-image-api-version 2 image-list --property-filter os_distro=NixOS

DocImpact
Closes-Bug: #1383326

Change-Id: Ia65a08520e3eaf3ecd9b9018be9f6a8e2d3d4f0b
2014-11-14 10:45:31 +00:00
Fei Long Wang ef0abdc885 Fix py34 failure for glance client
Fix somes tests failures for py34, most of them are related
to items order of dict.

Closes-Bug: 1382582

Change-Id: I954b884f03931e4f0ecb654fb38edd0c46a3c379
2014-11-11 15:36:47 +13:00
Louis Taylor b83a6726d3 Refactor method of constructing dicts in some tests
In some of the v2 tests, dictionaries are construed from lists of
tuples of length two. For example:

    dict([('visibility', 'private')])

There could be a very good reason for doing it that way, but it eludes
me. This patch replaces those with dictionary literals.

Change-Id: Ie9668bd681538ef41521f08a20cb8c3417ac91e8
2014-10-29 12:04:39 +00:00
Jenkins cfe0623520 Merge "Adds support for Glance Tasks calls" 2014-10-16 03:37:48 +00:00
Jenkins a23a364e29 Merge "Skip non-base properties in patch method" 2014-10-03 02:57:08 +00:00
Kamil Rykowski 2b567cf917 Skip non-base properties in patch method
It's currently impossible to update properties which are defined in
image schema and which are not a base image property. Proposed fix skips
every non-base property when building a json patch, that is used to
update image properties through glance API.

Change-Id: I3b35cef379fcf437715e2966f9a0d25c1b4e4016
Closes-Bug: #1371559
2014-09-29 16:50:21 +02:00
Fei Long Wang 7ef1b7c9b1 Adds support for Glance Tasks calls
Add tasks operations on client side to support task create,
list all and show.

DocImpact
Implement blueprint async-glance-workers

Change-Id: Ib4b8e347a8a47817e3b427c8ba024e8c32f65155
2014-09-22 15:23:55 +12:00
Louis Taylor 1511c86933 Fix the ordering of assertEqual arguments
This keeps testtools happy, since it expects the argument ordering to be
(expected, actual).

Change-Id: I95b41ad7645700ce23b46c7a5700e79008ed08be
Closes-bug: #1277104
2014-09-19 13:00:28 +00:00
Lakshmi N Sampath 97b1506bdb Fix v2 requests to non-bleeding edge servers
In the case where v2 requests are sent to a server which is not running
head of tree which includes the v2 metadef code some 404 cases need to
be handled to enable standard requests to complete.

This patch aslo improves fetching schemas -- they are now only
fetched as needed.

Change-Id: I8c871f11b909337bd7df19b77e606772dbc634b2
Closes-bug: #1367326
2014-09-12 09:12:49 +00:00
Pawel Koniszewski 33dcea81b2 Support for Metadata Definitions Catalog API
API calls and shell commands added in this patch:
- CRUD for metadefs namespaces;
- CRUD for metadefs objects;
- CRUD for metadefs properites;
- CRD for metadefs resource types and resource type associations.

Change-Id: I6d15f749038e8fd24fc651f0b314df5be7c673ef
Implements: blueprint metadata-schema-catalog-support
Co-Authored-By: Facundo Maldonado <facundo.n.maldonado@intel.com>
Co-Authored-By: Michal Dulko <michal.dulko@intel.com>
Co-Authored-By: Lakshmi N Sampath <lakshmi.sampath@hp.com>
Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com>
2014-09-03 11:45:57 -06:00
AmalaBasha dbb242b776 Replace old httpclient with requests
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
2014-07-10 13:22:05 +05:30
ChangBo Guo(gcb) 1db17aaad9 Enable F841
F841 detects local variable is assigned to but never used.
This commit fixes the violations and enables F841 in gate.

Change-Id: Ic4dcac2733dfe334009327ac17aa3952cafaa63a
2014-07-09 14:10:23 +08:00
Manuel Desbonnet a945b3d448 Prepend '/' to the delete url for the v2 client
... and update tests to match.

The missing slash results in a non-absolute DELETE request
being sent to the API.
E.g.
DELETE v2/images/62fac489-23b4-4929-87af-2e7236e8542b HTTP/1.1

This is not strictly valid http/1.1 - rfc2616 specifies that the path must
be absolute.
This doesn't cause a problem for the API server, but this can cause
problems if the API server is fronted by something else (see #133161).

It also means that the curl command logged in debug mode has a
bad url.
E.g.
curl -i -X DELETE ... http://10.0.0.13:9292v2/images/...

Change-Id: Ib0c749dedbfcf07303fcddae4512db61b0f3fd78
Closes-bug: #1327101
2014-06-23 15:22:57 +01:00
Jenkins 3b694ca89f Merge "Add support for location parameters in v2 commands" 2014-06-17 09:13:41 +00:00
Jenkins 2739317260 Merge "progress flag not supported in v2 API" 2014-06-17 05:38:14 +00:00
David Koo 323d32cc6d Add support for location parameters in v2 commands
Currently glanceclient's v2 commands don't support modification
operations on an image's location attribute - the argparse specification
for the location attribute of the image-update command causes the image
id argument to be included in list of locations and so the command
parsing fails (because it causes the image id to appear to be missing).

Furthermore even if the 'locations' argument were to be accepted by
argparse (e.g. by changing the argument specs and using --id to specify
the image id) the command would still fail because the arguments are
passed directly to the schema which expects the value of the 'locations'
argument to be a valid dictionary (there is nobody to convert the
argument string to a python dictionary that the schema expects).

This commit adds the following location related commands to
glanceclient:
    --location-add: Add a new location to the list of image locations.
    --location-delete: Remove an existing location from the list of
        image locations.
    --location-update: Update the metadata of existing location.

The glanceclient.v2.images.Controller class has been agumented with
three new methods to support the commands listed above:
    - add_location
    - delete_locations
    - update_location

The server has not been modified, i.e. all location related API requests
are passed to the server via HTTP PATCH requests and handled by the
server's image update function.

The v2 'image' and 'shell' related tests have also been supplemented.

Note that in order to use these options the server must be first
configured to expose location related info to the clients (i.e.
'show_multiple_locations' must be set to 'True").

I also added a mailmap entry for myself.

DocImpact
Closes-bug: #1271452
Co-Author: David Koo (koofoss) <david.koo@huawei.com>

Change-Id: Id1f320af05d9344645836359758e4aa227aafc69
2014-06-16 21:56:41 +00:00
Frederic Lepied 628c541a69 Finalize Python3 support
Set the environment variable PYTHONHASHSEED to 0 to have
predictive tests under Python 3.

Change-Id: Ia15a9383e0f20bd0e4572e9f9b9772f1704dff86
2014-05-20 16:42:10 +02:00
wanghong 8619100597 progress flag not supported in v2 API
Currently only download method supports --progress flag in v2 API.
This patch let upload method in v2 API support this flag too.

Change-Id: I1d22379c320adb47a2178697e546413b9257f987
Closes-Bug: #1286265
2014-04-16 06:20:08 +00:00
Eiichi Aikawa 900dc612d7 Fix the parameter order of assertEqual in glanceclient v2 test
On assertEqual, the order of parameters should be (expected, observed).
But, some part of glanceclient v2 test were written with invalid order.
This patch fixes this problem.

Partially Close-bug: #1277104

Change-Id: Iae3fb9dda28b67a07f527b15ca83d9cca3e867d4
2014-02-27 15:02:58 +09:00
Cyril Roelandt 3cced6085d Python 3: Fix JsonPatch-related issues
In Python 3, the generated JSON patches have a different representation than
those generated with Python 2. For instance, the patch generated in
test_patch_should_replace_missing_core_properties() is:

    '[{"op": "replace", "value": "red", "path": "/color"}]'

in Python 2, but:

    '[{"path": "/color", "value": "red", "op": "replace"}]'

in Python 3. Therefore, the comparison fails, and the test fail. We fix the
tests by comparing JsonPatch objects rather than strings.

Closes-Bug: #1281374
Change-Id: Id435e87664b2d2aa0ba69f2df1c1fad431651963
2014-02-19 01:43:23 +01:00
Edward Hope-Morley 4a41358cea Add support for image size in v2 api upload
Some backend stores e.g. RBD, will fail if told to create an
image without a valid size (RBD will fail to write to a zero-size
image). Here we add support to allow the image size to be provided
when doing an upload. The result is that the upload content-length
will be set if available either from checking the supplied file
object or as provided by user.

Closes-Bug: 1220197
Change-Id: Ia1f2ea5680a139750d931591949b3e0058148b4b
2014-02-03 11:10:50 +00:00
Stuart McLaren ee7fd2f5bd Handle endpoints with versions consistently
When using the cli the Glance client wraps the endpoint in a 'strip
version' function. This means that endpoints of the following forms can
both be used:

https://region-x.images.example.com:443/v1
https://region-x.images.example.com:443

When calling the client library directly (as Ceilometer does) however
only endpoints of the second form work. The cli and library should handle
the two cases consistently.

Addresses bug 1243276.

Change-Id: Ice7b581fee32540a7057ba47433a10166a3caed2
2014-01-22 11:16:58 +00:00
Noboru arai 869ea2e61c Remove vim header
No need to set tabstop tons of times, this can be set in your vimrc
file instead.

More disucssion:
http://openstack.10931.n7.nabble.com/Remove-vim-modelines-td21780.html

Change-Id: I2b37758f9dbb2cad6457a879d4ed7ff0aa69ef8e
Partial-Bug: #1229324
2014-01-14 16:40:22 +00:00
Yassine Lamgarchal ae579aae09 Python3: use six.StringIO rather than StringIO.StringIO
It’s an alias for StringIO.StringIO in Python 2 and
io.StringIO in Python 3.

Change-Id: I5316eaffa2d9d2d5679b85a901933ef0fbfcc2f7
2014-01-10 17:25:45 +01:00
Fei Long Wang 336feeb523 Get better format for long lines with PrettyTable
Based on current implement, the cli output format will be bad if
the lines are too long. This issue can be fixed by setting 'max_width'.
However, there is a bug against it, see
https://code.google.com/p/prettytable/source/browse/trunk/CHANGELOG?r=85
line 3. So the requirements.txt is updated as well.

docImpact
Fixes bug 1251283

Change-Id: I0d4192ad9d10a3d6d47a8319463a5edb57719a68
2014-01-06 20:48:54 +08:00
Jenkins a7c33d5802 Merge "change assertEquals to assertEqual" 2013-11-15 06:33:29 +00:00
Jenkins 9a649d46ea Merge "Replace OpenStack LLC with OpenStack Foundation" 2013-11-15 06:33:28 +00:00
Christian Berendt 7f8292f39d change assertEquals to assertEqual
According to http://docs.python.org/2/library/unittest.html
assertEquals is a deprecated alias of assertEqual.

Change-Id: I22f4702f41537c05684dfacb3f305627b36849c5
2013-10-24 07:54:16 +02:00