24 Commits

Author SHA1 Message Date
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
9a649d46ea Merge "Replace OpenStack LLC with OpenStack Foundation" 2013-11-15 06:33:28 +00:00
Jenkins
12a1d719b2 Merge "Fix python 3.x related Hacking warnings" 2013-11-12 04:38:33 +00:00
eddie-sheffield
32d9c42816 Add CLI for V2 image create, update, and upload
Provides command line support for image-create, image-update,
and image-upload using the Glance V2 API. This includes building
help text for create and update based on the image jsonschema
as fetched from the server.

Also fixes bug caused by default warlock patch generation not
matching what Glance expects when updating a core property
which had not originally been set when the image was created.

Related to bp glance-client-v2

Change-Id: I841f9e3d05802f4b794cb6f4849abe03ff0324d9
2013-10-02 13:22:55 -04:00
ZhiQiang Fan
2517203975 Replace OpenStack LLC with OpenStack Foundation
Change-Id: I38dcbcf1a6c8efe540fcf5f29e782cb3826e583d
Fixes-Bug: #1214176
2013-09-20 04:05:51 +08:00
Dirk Mueller
69fa91b432 Fix python 3.x related Hacking warnings
Convert print operator usages to print functions.
Fix one instance of outdated "except x,y:" syntactical construct.
Remove usages of local() in string formatting alongway.

Change-Id: Id0673a9183a6ea6bd9bf3f5c6d8e7c5f114ebf01
2013-08-26 14:25:23 +02:00
Monty Taylor
1f2eef510f Updated from global requirements
Change-Id: I2e2bd3a38458e1307bcc0410da74dc76c0a5987a
2013-08-10 10:49:11 -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
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
Stuart McLaren
2f33f5f283 Prevent WantReadError when using https
If the glance client is instantiated when the socket module has been
monkey patched requests to the server can yield a WantReadError because
the socket has been set to non-blocking but this is not being handled
correctly. When this is the case use eventlet's GreenConnection which
handles non-blocking sockets correctly.

Also, for now, add a required getsockopt method to GreenConnection.
This can be removed once the eventlet fix
(https://bitbucket.org/eventlet/eventlet/commits/609f230) lands.

Fixes bug 1157864.

Change-Id: I187b69f75b8bcfe16facd41e69b1cd0490dae605
2013-04-23 13:48:10 +00: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
Ken'ichi Ohmichi
0aba81ac1f Add image names to glance command arguments.
Now a user should specify ID as an image by glance command, and I feel
it is easy-use that a user can specify name also as an image like nova
command(ex. "nova boot").

By applying this patch, a user can specify name as image like the
following examples:

$ glance image-show cirros-0.3.0-x86_64-uec
$ glance image-update --name root-fs cirros-0.3.0-x86_64-uec
$ glance image-delete cirros-0.3.0-x86_64-uec
$ glance image-download cirros-0.3.0-x86_64-uec
$ glance member-create cirros-0.3.0-x86_64-uec 94b0e63a27ca43348fe056622fe3fe94
$ glance member-delete cirros-0.3.0-x86_64-uec 94b0e63a27ca43348fe056622fe3fe94

Fixes bug 1093380

Change-Id: Ia0a070eed6ae3853ef02032f479087edb1d75a67
2013-01-05 07:32:25 +09: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
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
Brian Waldon
8bf9e11244 Align print_dict to the left
Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a10
2012-07-13 20:11:52 -07:00
Brian Waldon
f0445a1b44 Rewrite link parsing for finding v2 schemas
What we called 'links' are no longer returned in a container of
objects, they are top-level entity attribtues. This fixes the
parsing of the entities to look in the correct place when trying
to locate a specific schema.

Add a helper for printing to stderr and exiting with a non-zero
exit code.

Map 'name' to 'Attribute' when explaining a schema.

Related to bp glance-client-v2

Change-Id: Ib98e912a7af0bb570b4fd738733edd9b837d1a05
2012-07-13 18:38:40 -07:00
Brian Waldon
53acf1a0ca Establish the supported importable interface
* Consumers of this client should not depend on being able to import
  any module other than glanceclient and glanceclient
* The only attributs of the glanceclient module are Client
  and __version__
* The attributes of the glanceclient.exc modules have yet to be
  locked down
* glanceclient.common.exceptions was replaced with a placeholder
  module until consumers of it are updated

Change-Id: Iea9648cd06906d65764987c1f2ee5a88ebeee748
2012-07-13 18:38:15 -07:00
Brian Waldon
2822748bc1 Stick prettytable at v0.6
Doing this so we can align columns reliably

Change-Id: Ibdbc6f3df08d6f9c45b6e0a0f5a2440ba2637dbd
2012-06-07 14:41:14 -07:00
Brian Waldon
4b62848a4c Add minimal support for the v2 API
This only allows you to run image-list, but sets up a framework
that we can use to fill in the rest of the v2 functionality.

* Related to bp glance-client-v2

Change-Id: I8827e36fdcf79fe402990a6d05898ec00cbd54c6
2012-06-04 08:49:26 -07:00
Dean Troyer
332858d56b Remove printt
prettyprint 0.6 removed printt at the last minute, replace with get_string

Fixes bug 995826

Change-Id: I9a25efc3d723ab0208ea88fc6431a95cc9176acb
2012-05-07 10:39:45 -05:00
Brian Waldon
c530de6389 Basic get/list operations work
* 'glance image-list' and 'glance image-show' work
* Set up tests, pep8, venv
2012-03-26 22:48:48 -07:00