91 Commits

Author SHA1 Message Date
Jenkins
d59e341a4c Merge "Fix location update" 2016-03-11 22:52:56 +00:00
Fei Long Wang
8b6dbb2065 Fix location update
After commit Ieb03aaba887492819f9c58aa67f7acfcea81720e, the command
location-update is totally broken now. This patch removes the updating
for an image from non-empty to empty since it's not supported now.
And also removing the default value of metadata for location-update
cli command because now the only purpose of location-update is updating
the location's metadata, so it doesn't make sense to give it a default
value which may update existing metadata by mistake.

Closes-Bug: #1537626

Change-Id: I9ce98e6c63996bbfdbc56761055e37a871f9d3e2
2016-03-11 12:51:13 +00:00
Danny Al-Gaaf
860908c517 Catch InUseByStore case in do_image_delete
In case do_image_delete() is called on an image that is
in use and can't be deleted by the driver a HTTPConflict
error is raised in glance. Catch this error and print a
propper error message.

Closes-Bug: #1551037

Change-Id: Id17098f27511df8e05e56b8df21e748921223bd9
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2016-03-09 23:27:02 +01:00
Jenkins
6aaa6f2f8c Merge "Handle 403 forbidden on download" 2016-02-29 13:04:08 +00:00
Stuart McLaren
5b9f21b38b Handle 403 forbidden on download
A download of a deactivated image may result in a 403.
The cli should catch this error rather than stack trace.

We also catch other unexpected http responses.

Change-Id: If33fbc3a56cdb02b3ab32a6479a67fff20b4b1a9
Closes-bug: 1523612
2016-02-24 18:31:38 +00:00
kairat_kushaev
56c27d1cb8 Change metavar for location commands in V2
Currently location-add, location-delete and location-update
shows <ID> in help messages as metavar for image id. It may be
not clear to the users so we need to change this to <IMAGE_ID>.

Change-Id: I59c787e449fa34bc792de179993c55f59734b9fe
Closes-Bug: #1535220
2016-01-20 12:04:29 +03:00
KATO Tomoyuki
a74a3648ec Add help the ability to sort images with multiple keys
Related Change: If79779a4c52c8dc5c4f39192d3d247335a76ba24
This help is also used for OpenStack Command-Line Interface Reference.

Change-Id: Iadce779afebe4aa80026e46f169546aba9055477
Partial-Bug: #1432813
2016-01-04 23:17:41 +09:00
Long Quan Sha
44d0b02c67 Fix the download error when the image locations are blank
When the image locations are blank, glance client will get a http response
with no content, glance client should show user no data could be found,
instead of processing the blank response body that will lead to exception.

Glance client will also get a 204 response when an image is in a queued
state (this is true for 'master' and liberty/kilo/juno based servers).

Closes-Bug: #1472449

Co-Authored-by: Stuart McLaren <stuart.mclaren@hp.com>
Change-Id: I5d3d02d6aa7c8dd054cd2933e15b4a26e91afea1
2015-12-07 16:45:01 +00:00
Jake Yip
255b10df28 Fix help for image-create
The help for image-create states that --file 'Must be present if images
are not passed to the client via stdin.'

However, doing image-create without --file is a valid operation - it
queues a file to be created.

Change-Id: I8167c6a891fa2540c84e3b888031d90a34a9b5fc
2015-11-30 16:10:43 +00:00
Jenkins
af91e2cc0c Merge "Remove self from image-create/image-update" 2015-11-23 18:18:18 +00:00
Darja Shakhray
bff356ed73 Added reactivate/deactivate image using CLI
Added commands 'glance image-reactivate image_id'
and 'glance image-deactivate image_id' for
reactivate/deactivate image using CLI

DocImpact

Change-Id: I2c370c6bf6ff664d94d756cc76aaa983fbdb8869
Closes-bug: #1508356
2015-11-02 14:00:38 +00:00
kairat_kushaev
4fb3092cb0 Add translation to v2 shell
Add translation support for v2 shell help messages. It allows
to detect the messages that needs to be translated for translation
team.

Change-Id: Id1fb0355090d4e223d13c15100e6726e15563670
2015-10-16 11:26:15 +03:00
wangxiyuan
bf02b048bf Support image deletion in batches in v2
Client doesn't support image deletion in batches in v2 now.
It's useful. So it's need to add it.

Change-Id: Idf5a6890b3fd01a65fecab2033b21367c30bc6b1
Closes-bug:#1485407
2015-10-10 10:18:02 +08:00
NiallBunting
b396e73e73 Remove self from image-create/image-update
Self is not meant to exist as it is a READ ONLY property, that is not
meant to exist as something the user can change.

Closes-bug: 1496024
Change-Id: I28fd51a4cbef40fc7c90999fe8121611c7f89f21
2015-09-30 10:19:16 +00:00
Jenkins
6e7c64bd5b Merge "Add period in help message" 2015-09-25 16:48:54 +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
Flavio Percoco
b8a881f5ea Don't get the image before deleting it
The client currently downloads the image metadata to check if it's deleted
or not. This logic belongs to the server and it's already implemented
there. Instead of getting the image, send the delete request and catch
the 404 error, which is already raised by the server.

Change-Id: I1e6ef42340f8e380ff99b9d6ca7ea416e0eebfbc
Closes-bug: #1496305
2015-09-16 09:34:34 +00:00
Jake Yip
c8c8964ddd Updates default --sort behaviour
When querying against a Juno glance-registry, we found that having the
--sort option defaulting to 'name:asc" results in querying the registry
with additional SQL parameters like the following:

WHERE image_properties_2.name = :name_1 AND image_properties_2.value =
:value_1

as a result of handling the newer 'sort' filter. This results in a
blank list being returned as the output of glance image-list.

This patch sets the --sort-key and --sort-dir instead of --sort when
neither --sort-key nor --sort-dir are specified, so as to maintain
backwards compatibility with Juno glance-registry.

Change-Id: I8bd64cca7f1b7abdbabf4c09e3dbbcb4044e51b4
Closes-bug: #1492887
2015-09-09 22:44:08 +10:00
wangxiyuan
14be6072e5 Add more information show in v2
In v2, it's only show Id and Name. When use --verbose, although added
owner and status, it's still lack of Disk-format,Container-format and
Size.

Change-Id: I26b4b7bd3a3f6dbf82ca73c32dd94c56e8e173a1
Closes-bug:#1486329
2015-08-19 11:40:35 +08: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
89b2dc58da Merge "Ship the default image schema in the client" 2015-08-12 11:49:45 +00:00
Flavio Percoco
3949e0e918 Ship the default image schema in the client
Now that we have stable branches for clients, it's easier to keep track
of the current default image's schema in Glance and update it
respectively. This patch adds the current image schema, including the
schema-properties.

One good reason to do this is to be able to react when a running Glance
instance is not around to be introspected. It's really unfortunate that
things like help text can't be rendered when there image schema is not
available in the system.

We could keep the schema in a json file but rather than shipping data
files with glanceclient we can just have it in the python modules.

Change-Id: I9b8cc1d18d6717ccf991fb8149ab13c06d653ee4
Closes-bug: #1481729
2015-08-12 11:10:54 +02:00
Wayne Okuma
c0e90fa2bd Support for Metadata Definition Catalog for Tags
This set provides API and shell commands support for:
- CRUD on metadef_tags;

Change-Id: I09bdf43edee6fff615d223f1a6df7c15a1e40565
Implements: blueprint metadefs-tags-cli
DocImpact
2015-07-16 14:00:50 -07:00
Cindy Pallares
997c12d3ab Import only modules and update tox.ini
As stated in the OpenStack Hacking Guidelines, it is prefered
that only modules should be imported.

Also updated tox.ini to ignore opestack/common among others.

Change-Id: I2f0a603c31052eadee581c11880c0ec6bd392829
2015-06-17 10:56:37 -05:00
Jenkins
2eb5292e9d Merge "Include owner and status option in v2 image list" 2015-05-25 21:15:12 +00:00
Jenkins
0c244b24bd Merge "Check image-download for redirection" 2015-05-25 21:15:09 +00:00
Cindy Pallares
6cb26fc2bf Include owner and status option in v2 image list
Show the owner and status information when adding -v or --verbose
to the image-list command.

Closes-bug: #1381514
Change-Id: I90bf622147b12ed157072fad0823af58223caf91
2015-05-22 01:56:42 -05: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
Fei Long Wang
c73026634c Omit 'locations' as image-create parameter
Based on current implementation, locations is reserved
attribute, so it should not be a parameter for image
create.

Closes-Bug: #1399778

Change-Id: Ie51e52157e905fdecf736125be0dac87b1a966ec
2015-04-11 00:02:22 +12:00
Jenkins
93569c61de Merge "glance image-show now have --human-readable option" 2015-04-08 13:26:09 +00:00
Jenkins
b3d2c636ec Merge "Use any instead of False in generator" 2015-03-27 23:56:39 +00:00
yatin karel
c149a94ee1 glance image-show now have --human-readable option
Added option '--human-readable' to image-show cli which allows users
to display image size in human-readable format.

Change-Id: Ic3452ce4560d3cf90fa7f59f98e5ff42e804f8c9
Closes-Bug: #1434381
2015-03-22 17:26:55 +05:30
Yamini Sardana
db5d72947c Updated help for v2 member-update api
help message for v2 glance member-update api
now displays the Valid Values of member status
variable.

The valid values are: pending, accepted, rejected

Change-Id: Ibe6f55c933668451b407ed9a19c520c3fbf1912a
Closes-bug: #1420707
2015-03-17 11:45:43 +05:30
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
Jenkins
23c8d1818a Merge "v2: read limit for list from --limit in shell" 2015-03-06 22:38:24 +00:00
Jenkins
c7c4ac9e85 Merge "v2: Allow upload from stdin on image-create" 2015-03-06 19:55:15 +00:00
Jenkins
8eaf97d42e Merge "Fix v2 image create --file documentation" 2015-03-06 19:49:13 +00:00
Louis Taylor
a9a692b351 v2: read limit for list from --limit in shell
Previously this was read from the --page-size argument, which lead to
incorrect behaviour.

Change-Id: I08ecda95eca0ff524e28a1d5371ce6c73dfc548e
Closes-Bug: #1429088
2015-03-06 13:18:11 +00:00
Kirill
6e0b1f4d2b removed excessive call to os.path.exists
os.path.isfile checks for existance anyway so
there is no point in checking both isfile and exists

Change-Id: Idbc2d22a807d5413db6e27ff0f6b5a87a5af8fa3
2015-03-03 01:03:28 +03: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
5b2603d74e Merge "Disable progress bar if image is piped into client" 2015-02-04 23:41:11 +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
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
Stuart McLaren
4c7c7adb3f Fix v2 image create --file documentation
Help for 'v2 image create --file' should refer to upload,
not download.

DocImpact

Change-Id: I2ae00e3242fb10001e216cde93fdf9c6f18ad13e
Closes-bug: 1408028
2015-01-06 17:13:42 +00: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
Ian Cordasco
a1bb3eb0a5 Use any instead of False in generator
any is both idiomatic and easier to read. There's no performance difference
because both will stop as soon as a matching value is found.

Change-Id: Ia527d96844015085cc289869a3c4d2722db1043c
2014-11-26 12:20:40 -06: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