Commit Graph

106 Commits

Author SHA1 Message Date
ji-xuepeng 5fca39dbde Replace six.iteritems() with .items()
1.As mentioned in [1], we should avoid usingg
six.iteritems to achieve iterators. We can
use dict.items instead, as it will return
iterators in PY3 as well. And dict.items/keys
will more readable. 2.In py2, the performance
about list should be negligible, see the link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: I71c13040318eca6e5ed993e8aa03f8003986a71c
2017-02-08 16:33:46 +08:00
Evgeny Antyshev 6ab6a740ff Add ploop in disk_format
"ploop" image format is supported in upstream Glance
https://review.openstack.org/341633

And similar patch has been added in python-openstackclient:
https://review.openstack.org/411405

Co-Authored-By: yuyafei <yu.yafei@zte.com.cn>
Change-Id: I1471224df97cf5fecfe7f02e549855af81c45848
Related-Bug: 1650342
2017-01-19 14:31:01 +00:00
Ihar Hrachyshka 3a0007a1c3 Fixed grammar in image-download command description
Change-Id: Ie18e1bee3376fdc01685c6f1d3a949c6934296b3
2016-06-01 10:07:47 +00:00
Atsushi SAKAI 05cd0c7508 Add period in help message
Command help message uses help and CLI-Reference generation.
  and in convention, help message stops with period ".".

Change-Id: I652afdb5e4d69a0476a0a2dc313ae60ece3b7bbc
2015-09-19 17:27:14 +00:00
Gorka Eguileor 8d118ccedc Require disk and container format on image-create
Currently glanceclient doesn't enforce disk-format or container-format
presence in the command line on image-create when providing image data
(with --file, --location, --copy-from), which means that the POST
request is made with the whole image and error is reported by Glance
API.

This post enforces presence of those arguments when image data is
provided so we can get the error quicker and avoid sending unnecessary
data over the network.

Change-Id: I5914fa9cfef190a028b374005adbf3a804b1b677
Closes-Bug: #1309272
2015-08-14 09:59:17 +02:00
Jenkins 0d22e821f9 Merge "Add parameter 'changes-since' for image-list of v1" 2015-06-15 18:11:27 +00:00
Jenkins 0c244b24bd Merge "Check image-download for redirection" 2015-05-25 21:15:09 +00:00
Fei Long Wang 116fac8ae8 Add parameter 'changes-since' for image-list of v1
Now Glance /images/detail API of v1 supports parameter
'changes-since' to query deleted images. But it's missed
in client. This patch will add the parameter.

Related-Bug: #1432701

Change-Id: Id38e3a78b4b2ef680ea04d35e32beb4b9c8efa00
2015-05-06 14:58:44 +12:00
Cindy Pallares 583adc34f8 Check image-download for redirection
Currently when you download an image without specifying
a file or redirecting the output, the image is dumped into
the console as gibberish. We can avoid this if we
check if file is being redirected or if a file is specified.

Change-Id: I257760752f05b82b935cf19fb10573ee7ff1395d
2015-05-05 13:17:39 -05:00
Jenkins 825c4a5df2 Merge "Correct help messages for image-update command" 2015-04-18 10:00:59 +00:00
Abhishek Talwar 6d864ef65c Correct help messages for image-update command
Currently when you are trying to update the location of an image which
is not in queued status you will get an error from the Glance API. The
help message for --location and --copy-from arguments should be updated
to inform the user that it works only for images in queued status.

Co-Authored-By: Abhishek Talwar <abhishek.talwar@tcs.com>
Co-Authored-By: Kamil Rykowski <kamil.rykowski@intel.com>

Change-Id: I82b14ffde3f301d7ffef68e984ba4ad2ae0f8b0f
Closes-Bug: #1220809
2015-03-19 10:24:34 +01:00
Jimmy McCrory 976fe1776b Import sys module
This module is required by the _is_image_data_provided function.

Change-Id: I78265209a2f80aaf61bbe25d69e79c939182516c
Closes-Bug: 1432249
2015-03-14 14:32:40 -07:00
Jenkins e6d2f637ed Merge "Show error on trying to upload to non-queued image" 2015-03-04 17:05:02 +00:00
Jenkins 654ba87a89 Merge "Glance image delete output" 2015-02-20 14:48:49 +00:00
Louis Taylor af29e0a1b0 Show error on trying to upload to non-queued image
Previously, attempting to upload data to an image which has a status
which is not 'queued' would appear to succeed, when the data has
actually never been sent to the glance server. To the user, it appeared
that their request was successful. This patch adds a check for incoming
image data on the 'image-update' command, and exits with an error if the
specified image does not have the status 'queued'.

Examples:

    $ cat os.img | glance image-update d50b0236-b27c-412a-91b9-18ceafa9cc5a
    Unable to upload image data to an image which is active.

    $ glance image-update --file os.img d50b0236-b27c-412a-91b9-18ceafa9cc5a
    Unable to upload image data to an image which is killed.

Change-Id: I91bbd7f86d5851a5e35946c711dba1932283ed79
Closes-Bug: #1395084
2015-02-19 10:40:12 +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
Louis Taylor e99e0c8690 Change oslo.utils to oslo_utils
The oslo.utils libraries are moving away from namespace packages.

This requires oslo.utils>=1.2.0

bp drop-namespace-packages

Change-Id: I803df61e91eabb96329d859aef6bea03530fb84f
2015-02-05 22:27:16 +00:00
Jenkins 945a697bba Merge "Use utils.exit rather than print+sys.exit" 2015-02-05 12:09:10 +00:00
Jenkins 5b2603d74e Merge "Disable progress bar if image is piped into client" 2015-02-04 23:41:11 +00:00
Jenkins 9a78cb2471 Merge "Add validation to --property-filter in v1 shell" 2015-02-04 23:40:50 +00:00
Louis Taylor 869e6ace0e Use utils.exit rather than print+sys.exit
This replaces the use of a pattern along the lines of

    print(error message)
    sys.exit(1)

in a couple of place in the shell. utils.exit does much the same job,
but outputs to stderr.

Change-Id: I1d3b52e0685772c10aa806a8f208eb6dd7a0e7ef
2015-02-03 18:21:04 +05:30
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
Louis Taylor cb046bc4fc Add validation to --property-filter in v1 shell
Previously, using --property-filter with invalid arguments resulted in
a rather cryptic error message:

    $ glance image-list --property-filter name
    dictionary update sequence element #0 has length 1; 2 is required

Now, something which is human decipherable is printed:

    $ glance image-list --property-filter name
    Argument --property-filter requires properties in the format KEY=VALUE

Change-Id: I61d19894fd8864bdca2fa3f627da3c7eb1341c51
2015-01-08 17:01:17 +00:00
Cindy Pallares 6eaaad532a Make non-boolean check strict
Currently when we enter any non-boolean strings in the client, it
accepts it and defaults the value to false. It should check if the
strings are boolean values and respond with an error if they're not.

Closes-Bug: #1394236
Change-Id: Ie498ee1b93524d91a43343f73140446c2cc9ab92
2015-01-06 11:36:01 -05:00
Louis Taylor 9054324442 Disable progress bar if image is piped into client
Previously, running:

    cat something.img | glance image-create --progress --container-format=bare --disk-format=raw

or

    cat something.img | glance --os-image-api-version 2 image-upload --progress <image id>

would result in an error. This error was caused by the length of the
input being unknown, so the overall progress cannot be found.

This patch disables the progress bar whenever the size of the input file
cannot be determined.

Change-Id: I6bfef7441864b638194126880241cc2c96d5b18b
Closes-Bug: #1402746
2015-01-06 10:36:01 +00:00
Stuart McLaren 597da8aa55 '--public' ignored on image create
Currently, if '--public' is specified, an image is created but
it is not marked as public:

$ glance image-create --public --name minus-minus-public --disk-format raw \
 --container-format bare < /etc/fstab
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
.
.
.
| is_public        | False                                |
.
.
.
+------------------+--------------------------------------+

This is inconsistent.

'--public' has been deprecated for some time, and has
been removed from devstack (https://review.openstack.org/#/c/39323/),
so we can finally get rid of it.

We now raise the standard error for unsupported arguments.

Change-Id: I15d16f690f9bd92b4cefbc8ed36ed2d171ff22f3
Closes-bug: #1378844
2014-10-08 13:58:22 +00:00
Cindy Pallares 1dfce5301c Remove deprecated commands from shell
Remove all deprecated commands from the shell
since they are no longer used and to keep
the command line menu from looking cluttered.

Closes-bug: #1314218

Change-Id: I66e82872988e3835e4f290f48dfc80538271426c
2014-08-12 05:30:59 -05:00
Stuart McLaren f75a81000e Use a correctly formatted example location in help
Change-Id: Iea1ebc13979a61d7bed397fb79e2b2a85f00c400
Closes-bug: 1342753
2014-07-16 15:05:37 +00:00
Cindy Pallares 04fb3c2624 Convert passed integer values into int in v1 shell
Add the type to the parameters that require an integer
in the V1 shell to avoid sending an improper request.

Change-Id: Idb1ed39b11ca737fdd42d24e297c142f28dce35c
2014-06-12 15:59:49 +00:00
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
2014-06-03 17:15:01 -03:00
Jenkins 59c1103655 Merge "Improve help strings" 2014-03-16 17:16:54 +00:00
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
2014-02-26 13:57:58 +01:00
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
2014-01-31 13:54:44 -05:00
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
2014-01-24 10:07:44 +08:00
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
2014-01-09 13:41:46 +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
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
Gabe Westmaas b6e117f151 Fix glanceclient usage inconsistences for options
Enumerated options should have the same format for all enumerated options.

This commit moves all options to the {option1,option2} format.

fixes bug: #1155171

Change-Id: I8e0ecf3896c76021cb027cbbbb3b5564a04aacec
2013-08-25 01:14:07 +00:00
Dean Troyer 53d3a0e129 Revert "removed deprecated parameter --public"
While trunk devstack was updated for this, stable/folsom and stable/grizzly
are not and grenade is now broken.  I'm not sure how long --public was
undocumented but it may be that certain cli args may need to remain deprecated
but supported for longer than we wish.

This reverts commit ce8636b6b3

Change-Id: I91d4884e470c8fcc611dae62a30fa22d08dbec03
2013-08-19 14:46:28 -05:00
Jenkins 20bd548d71 Merge "removed deprecated parameter --public" 2013-08-19 15:34:56 +00: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
Christian Berendt ce8636b6b3 removed deprecated parameter --public
As noted by bcwaldon the parameter can be removed after updating
Devstack. Should be done after merging the following change:

https://review.openstack.org/#/c/39323/

Change-Id: I8d0f7ab4cccccf022446374a31e03ac913cfb136
2013-07-30 19:12:59 +02:00
Stuart McLaren bb47812765 Allow v1 client to list all users' images
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
2013-07-26 11:01:52 +00:00
Stuart McLaren 12feedb2cf Add v1 client side owner based filtering
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
2013-07-26 11:00:32 +00:00
Jenkins c120aff87f Merge "Fix problem where image data is not read from a pipe." 2013-06-18 12:47:31 +00:00