Commit Graph

314 Commits (323d32cc6d28434ad57f3ddd5253b9a8950b4c8a)

Author SHA1 Message Date
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
9 years ago
Jenkins dbefc1a3b1 Merge "Fix help text in image-create" 9 years ago
Jenkins 08aaa468d1 Merge "Remove auth token from http logging" 9 years ago
Juan Manuel Olle 083986ad7e Fix help text in image-create
Image-create help text makes reference of a non existing
parameter --copy_from

Change-Id: I26d584c350734bb26a6cf965a2198f0782dd0a9f
9 years ago
Jenkins 803eed6083 Merge "Finalize Python3 support" 9 years ago
Tom Leaman 6149e1db31 Remove auth token from http logging
This redacts the X-Auth-Token header value from the logs by replacing
it with '***'.

Change-Id: I6b80cc94d42a44f9db801de78fa23218e6eca0ee
9 years ago
Jenkins 8f89a14c9f Merge "fixed typos found by RETF rules" 9 years ago
Jenkins e9e933145e Merge "Return request ID to callers" 9 years ago
Frederic Lepied 628c541a69 Finalize Python3 support
Set the environment variable PYTHONHASHSEED to 0 to have
predictive tests under Python 3.

Change-Id: Ia15a9383e0f20bd0e4572e9f9b9772f1704dff86
9 years ago
Christian Berendt afcf3a5611 fixed typos found by RETF rules
rules are avaialble at https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Typos

Change-Id: I70245e5ddf342762eb76d8e2e74b6363767726ef
9 years ago
Dirk Mueller 7bdf2526b7 Remove py3k module
This module is obsolete and has been dropped from oslo-incubator.
Use six instead (which is already done here).

Change-Id: I8e0b49cdfbddcf2d44a601ad06be2e75897905fc
9 years ago
Chris Buccella f0635ecf39 Return request ID to callers
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
9 years ago
Davanum Srinivas 078819cf9e Fix for invalid literal ValueError parsing ipv6 url(s)
Switch to using network_utils for splitting the URL. The code
in oslo-incubator supports ipv6 urls

Change-Id: I76be6173b97eb000319d30b4e9232a5a7c4a5aba
Closes-Bug: #1298137
9 years ago
Davanum Srinivas 58ee451286 Adding network_utils module from oslo-incubator
Needed for fixing bug 1298137

Change-Id: I6803f1af8b0ff036bed634c8aa1cffc52bc508e0
9 years ago
Davanum Srinivas ff0c87eeca Sync with oslo-incubator
Head of oslo-incubator is commit id:
2fd457bf2ccbeb2b84ffb204778b6417cd5405ba

includes a fix for gettextutil.Message handling of deep copy
failures and adding a license header

Change-Id: Ie89de1f95bb6fb9d11058413e682c441c39524f1
9 years ago
Jenkins 59c1103655 Merge "Improve help strings" 9 years ago
Cyril Roelandt 3c16d23293 Sync with Oslo
This will help with porting to Python 3. List of merged commits:

04a1abe59ac39890f57d2eed57d3d1b12bb5d757
12bcdb71ffbe9ee1688beed1f0ddb0c198822682
2cfc1a78d8063cf20083cf7df796d730a576551c
302c7c80b503b8090e8118e45061e8903b5339a9
35dc1d797209f0b22ff3ed3b8a6059961563daee
3b248dd683d83fd564f740ea58565d1bc0bd6cc0
4246ce0f373aa8f8955a99a3b6288a32547d8e80
6650435004af149284f0badb2bb8c89005cc7dab
6d55e26aa379fd043c66d1b7c5bf59a1b4a54632
71c22e9b2fbf04fc91a7343d3de0e0c7f10e3988
84d461e859e4b1eb1a00b9b141df61c37da84d2d
8575d87af49ea276341908f83c8c51db13afca44
885828af2297b20a3f9f8e8f6647f7291f784743
8b2b0b743e84ceed7841cf470afed6a5da8e1d07
9f1e7eb4112067423f845bd99ec52256db1c8bb1
bd5dad97585208ea5e86d636f3dc3b669e361a41
be81d6ba70152e5cdd7e8e9d789b9733c6ff527f
bec3a5eb8157c0c552c6392ccf0da342ffb8da26
c178e567cb48d3bc67dcf06bcbb4c6a97df9f434

Closes-Bug: 1289690
Change-Id: I39fa5e3fa46ffe9448b381ed54759cb4270cc898
9 years ago
Jenkins 9c9b70f0a4 Merge "Python 3: do not use the unicode() function" 9 years ago
Jenkins 4f9fc84118 Merge "Replace file with open, which is Python 3 compatible" 9 years ago
Cyril Roelandt 21c422f730 Python 3: do not use the unicode() function
It is Python2-specific, and should not be used in code intended to be portable.

Change-Id: Ibebef1a7e51a7444538275d22d444c926b8b4dec
Closes-Bug: 1284677
9 years ago
Jenkins 46bf452710 Merge "Only show progress bar for local image files" 9 years ago
Andreas Jaeger 2c53246184 Improve help strings
Make help strings consistent to use "." at end of string.

Fix capitalization of API in one help string.

Change-Id: I7cc5289d881c5e58aad9c69b4668584cdeb0b376
9 years ago
Cyril Roelandt 23ad1d6db7 Python3: define a __next__() method for VerboseIteratorWrapper
In Python 3, __next__() has replaced next(). Also, call the next() function
rather than the next() method.

Closes-Bug: #1281866
Change-Id: I92b44508c9c875f16ad89ef8410d2c38092ab23d
9 years ago
Alex Gaynor d465d60867 Replace file with open, which is Python 3 compatible
Change-Id: I471ae9b372f88a508d4654b1a18c6da90397a828
9 years ago
Shane Wang 0cda69f6a5 Fix misspellings in python-glanceclient
Fix misspellings detected by:
* pip install misspellings
* git ls-files | grep -v locale | misspellings -f -

Change-Id: I504521e702c675640ab3869c608fa96edd2477b4
Closes-Bug: #1257295
9 years ago
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
9 years ago
Jon Bernard 0934b97897 Only show progress bar for local image files
This patch fixes a bug where both 'location' and 'progress' are passed
as command line arguments.  In this case, the 'data' field is not
present in the fields dict and therefore the progress option cannot be
used.  A check is added to make sure the user has specified both a local
image file and the progress flag together.

Change-Id: Ia563139ee8b56d54d480534986e4b619a503fbfc
Closes-Bug: #1259357
9 years ago
Jenkins 238e9fffcc Merge "Using common method 'bool_from_string' from oslo strutils" 9 years ago
Jenkins ff7b588602 Merge "Handle endpoints with versions consistently" 9 years ago
llg8212 e5f6dee95d Using common method 'bool_from_string' from oslo strutils
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
9 years ago
Jenkins f9c7e3d1cd Merge "server 500 should not be a client error" 9 years ago
Jenkins b6468e0a01 Merge "Allow updating empty created v2 images from v1" 9 years ago
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
9 years ago
David Koo 3c5efdb74e Allow updating empty created v2 images from v1
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
10 years ago
Sean Dague 8e146ca500 server 500 should not be a client error
the client should not log a server 50x response at ERROR level.
It already throws an exception, so the caller can care about what
it wants to do with this. This error will show up regularly in
nova that succeed, and there is no way to disable this message,
which isn't an error from Nova's perspective without turning off
*all* the logs.

Set this to debug instead, because from a caller perspective that's
what you want out of this.

Change-Id: I6d0efb53d1e81adf309f7fa580ec5a8073a811c5
10 years ago
Victor Morales 29674c3f48 It was removed urllib, urllib2 & urlparse modules
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
10 years ago
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
10 years ago
Yassine Lamgarchal 02b00b6226 Python 3: use six.iteritems and six.string_types
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
10 years ago
Jenkins 47de9cfd89 Merge "Python 3: use six.iteritems() instead of iteritems()" 10 years ago
Jenkins d309da1bb2 Merge "Python3: use six.StringIO rather than StringIO.StringIO" 10 years ago
Jenkins 9dd03ce9ce Merge "Python 3: use six.iteritems() instead of iteritems()" 10 years ago
Jenkins bd78a90391 Merge "Reuse Resource from oslo" 10 years ago
Jenkins 36c3b0f3ce Merge "Sync apiclient and py3kcompat from oslo" 10 years ago
Yassine Lamgarchal 440d155558 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: I1c2f1412c586d5d8e0aa866a28232747056e0ca7
10 years ago
Jenkins c473f19fc9 Merge "Fix glanceclient http.py string formatting error" 10 years ago
Yassine Lamgarchal 2c2fdcbb39 Python 3: use six.iteritems() instead of iteritems()
six.iteritems() replaces dictionary.iteritems() on Python 2 and
dictionary.items() on Python 3.

Change-Id: Ie5efa65c0a992e8136087a7b78ab8e8ce967326e
10 years ago
Yassine Lamgarchal 627e66b9d8 Python 3: use six.iteritems() instead of iteritems()
Six.iteritems() replaces dictionary.iteritems() on Python 2 and
dictionary.items() on Python 3.

Change-Id: I12fda5f20d2f4fe8227e45b2fe46b332f63deb97
10 years ago
Le Tian Ren 2ed01afac9 Fix glanceclient http.py string formatting error
* Fix "TypeError: not all arguments converted during string formatting"

* Add a UT case to cover the path where the bug is in

Change-Id: I91a137c5c3a9a3cc603804bef5eaea14ae281c08
Closes-Bug: #1265730
10 years ago
Andrey Kurilin 3002575c80 Reuse Resource from oslo
In the process of unification of the clients code we should
reuse common functionality from Oslo.

Related to blueprint common-client-library-2

Change-Id: I3d82621cced57ad7bc14a2a40e4bef7522f233da
10 years ago
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
10 years ago