18 Commits

Author SHA1 Message Date
Erno Kuvaja
2d67dfa97a Unify using six.moves.range rename everywhere
Mainly to improve consistency, use range() from six.moves
renames across glance.

Behaves consistently like py2 xrange() and py3 range().

Change-Id: I7c573a3a9775f454b98d25f2a14f8e9f5f4ac432
2015-02-25 12:17:24 +00:00
Flavio Percoco
3989cd202d Support schema types with non-str value
Change I75da1e9309e0f7ef8839dea3ec9c99c58edc5d63 introduced some
properties' types which are not string. This broke the `schema_args`
utility since lists are not hashable and there was no support for such
type values.

This patch fixes this issue with a very glance specific strategy in
which this values are assumed to have a `null` type and another type -
string, integer, etc. The fix ignores `null` options and it takes the
first non-null type as the valid one.

The patch adds support for enum types that accept `None`

Closes-bug: #1401032
Change-Id: I250e8912aca262a56c54ac59bb24f917e5d8cfce
2014-12-10 13:23:36 +01: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
Eiichi Aikawa
3576b1bdcb Fix the parameter order of assertEqual in glanceclient test
On assertEqual, the order of parameters should be (expected, observed).
But, some part of glanceclient test were written with invalid order.
This patch fixes this problem.

Change-Id: I7722fdce766ce3cc5bc9944dc72d7d0af0b09f69
Partially-bug: #1277104
2014-02-25 16:18:19 +09: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
Dirk Mueller
9f255a9b49 Fix and enable gating on H306
H306 - module imports should be in alphabetical order

Change-Id: I1f8fc25b0e6ca23c21c90bda420f42a45141c2e2
2013-12-16 15:28:05 +01:00
ZhiQiang Fan
2517203975 Replace OpenStack LLC with OpenStack Foundation
Change-Id: I38dcbcf1a6c8efe540fcf5f29e782cb3826e583d
Fixes-Bug: #1214176
2013-09-20 04:05:51 +08: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
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
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
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
Dirk Mueller
31960f0a85 Allow for prettytable 0.7.x as well
Relax requirements to >= 0.6, < 0.8, as 0.7.x seems to
work as well. Added testcase to ensure this.

Change-Id: I1a1a709e6053451b1256a0d78f8fe8562fb10e62
2013-03-15 17:38:04 +01:00
Flaper Fesp
55cb4f4473 Decode input and encode output
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
2013-02-13 21:53:11 +01: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
fe17d35174 Simplify human-readable size output
* Limit human-readable sizes to a single decimal
* Drop trailing zero
* Step one suffix further in the case of a size being 1024

Change-Id: I2eb8ac0571d3d08b52f62155912863870573a37c
2012-11-19 10:35:04 -08:00
Christian Berendt
b24832c22a Make image sizes more readable for humans
By introducing the parameter --human-readable for several functions
(image-list, image-show, image-update, image-create) it's possible
to convert the size in bytes to something more readable like
9.309MB or 1.375GB.

Change-Id: I4e2654994361dcf330ed6d681dbed73388f159cb
2012-11-19 10:15:19 -08: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