Commit Graph

173 Commits

Author SHA1 Message Date
M V P Nitesh 4d0a3c309e help text for container_format, disk_format
Updated the container_format and disk_format in v1 help text.

Change-Id: I4ebe4982c179450defe8ad5703999f4074ae32f8
Closes-Bug: #1659010
2017-07-06 13:09:44 +05:30
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
Abhishek Kekane c2898998a7 Move old oslo-incubator code out of openstack/common
As part of the first community-wide goal, teams were asked to
remove the openstack/common package of their projects if one
existed. This was a byproduct of the old oslo-incubator form
of syncing common functionality.

Package openstack/common/apiclient is moved to glanceclient/v1
package as it is used by v1 api only.

NOTE:
Removed glanceclient/common/base.py as it is deprecated and not
used anywhere.

Closes-Bug: #1639487
Change-Id: Ib3ac09743ce761ab0186e99e1c9de02517f89510
2016-11-08 11:33:09 +05:30
Ihar Hrachyshka 3a0007a1c3 Fixed grammar in image-download command description
Change-Id: Ie18e1bee3376fdc01685c6f1d3a949c6934296b3
2016-06-01 10:07:47 +00:00
PranaliD 41e10e3690 Corrected wrong parameter in docstring
In docstring of list() method of glanceclient/v1/images.py,
parameter 'return_request_id' used within **kwargs is
'return_req_id', not 'return_request_id'.

Changed 'return_request_id' to 'return_req_id'.

Change-Id: I7f4a2a5af1b13184c67fa81be971dc5139569f8b
Closes-Bug: 1573049
2016-05-02 03:43:44 -04:00
wangxiyuan 1f1934eb82 Add versions list function
This patch add a function to query the Glance API versions.

DocImpact

Change-Id: I21eeaee3db4ae23f608b68bb319772ac612975b4
Closes-bug: #1511180
2015-11-10 10:28:32 +08:00
Jenkins 2fcff11b90 Merge "Add support for setting Accept-Language header" 2015-10-14 15:25:03 +00:00
Frode Nordahl ca050ed4c1 Add support for setting Accept-Language header
DocImpact

Closes-Bug: 1480529
Change-Id: I35a37d55edb700a5993bd5cc352335a87a15e47a
2015-10-14 12:57:07 +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
David Sariel 2c7da7cb60 Invalid output running the command 'glance image-show <image_id>'
Running the command returns the string 'id' and fails on exception.
In function _image_meta_from_headers the meta variable was not properly
set because key was not lowercased. Converting key to lowercase solves
the problem.

NOTE: this is a compatibility fix for urllib3 >= 1.11

Closes-Bug: #1487645
Co-Authored-by: Flavio Percoco <flavio@redhat.com>
Change-Id: I1b0b327163577585becb5e762536058d21dc1c98
2015-09-09 14:35:59 +02: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
Darja Shakhray ec0f2dfd85 Enable flake8 checks
This commit enables new flake8 checks:
* E265  block comment should start with '# '
* H405  multi line docstring summary not separated with an empty line
* E123  closing bracket does not match indentation of opening bracket's line
* H238  old style class declaration, use new style (inherit from `object`)
* E128  continuation line under-indented for visual indent
and makes related changes in the code.

Change-Id: Ie993afc930f6b74d7a990bcaa9fc0e9f5ba1585c
2015-07-21 17:08:27 +03: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 0d22e821f9 Merge "Add parameter 'changes-since' for image-list of v1" 2015-06-15 18:11:27 +00:00
Jamie Lennox 5ce9c7dc96 Make glanceclient accept a session object
To make this work we create a different HTTPClient that extends the
basic keystoneclient Adapter. The Adapter is a standard set of
parameters that all clients should know how to use like region_name and
user_agent. We extend this with the glance specific response
manipulation like loading and sending iterables.

Implements: bp session-objects
Change-Id: Ie8eb4bbf7d1a037099a6d4b272cab70525fbfc85
2015-06-11 13:11:56 +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
Jamie Lennox fd2f989cca Don't accept *args for client
The HTTPClient object that we are passing *args to does not accept any
args. Don't accept them from the main client interface.

Change-Id: I473bb64be95e058375ebd1e55d4bda4168c3c430
2015-03-28 14:22:49 +11: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 cc4c402f09 Merge "Fix leaking sockets after v1 list operation" 2015-03-11 15:02:22 +00:00
Louis Taylor f98ab688ef Fix leaking sockets after v1 list operation
Since the move to using the requests library, v1 list operations keep
the connection open to the glance server. This is normally closed by the
garbage collector if it is not explicitly closed, however the paginate
function used by the list method had a circular reference preventing it
from ever being collected during the lifecycle of a service consuming
glanceclient.

This is problematic, since it causes long running nova processes to run
out of file descriptors for new connections.

This patch makes paginate() non-recursive, which allows the connection
to be freed.

Change-Id: I16a7b02f2b10e506e91719712cf34ef0aea1afc0
Closes-Bug: 1423939
2015-03-04 20:07:53 +00: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
Jenkins 88f6319b7b Merge "Make non-boolean check strict" 2015-01-23 14:40:27 +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
Louis Taylor df02ee8e2a Fix Requests breaking download progress bar
The move to the requests library (dbb242b) broke the progress bar during
downloading an image with --progress enabled, due to requests returning
a generator, which has no __len__ function. This patch adds an iterable
wrapper which provides the length, sourced from Content-Length headers.

Closes-Bug: #1384664

Change-Id: I48598a824396bc6e7cba69eb3ce32e7c8f30a18a
2015-01-04 20:52:00 +00:00
Flavio Percoco 9829d7b6b9 Don't require version to create Client instance
We currently require a version to always be passed to discover the
client version that should be loaded. However, this information is
commonly present in the URL instead. The current behavior forces
consumers of the library to keep the required version around and/or to
strip it themselves from the URL.

This patch relaxes that requirement by making the version a keyword and
requesting instead an endpoint to be passed. The patch gives priority to
the version in the endpoint and falls back to the keyword if the later is
not present.

Follow-up patches will improve this code making it interact a bit more
with the endpoint's catalog.

Closes-bug: #1395714
Change-Id: I4ada9e724ac4709429e502b5a006604ca0453f61
2014-12-09 14:45:06 +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
AmalaBasha dbb242b776 Replace old httpclient with requests
This review implements blueprint python-request and replaces the old
http client implementation in favor of a new one based on
python-requests.

Major changes:
* raw_request and json_request removed since everything is now being
  handled by the same method "_request"
* New methods that match HTTP's methods were added:
    - get
    - put
    - post
    - head
    - patch
    - delete
* Content-Type is now being "inferred" based on the data being sent:
    - if it is file-like object it chunks the request
    - if it is a python type not instance of basestring then it'll try
      to serialize it to json
    - Every other case will keep the incoming content-type and will send
      the data as is.
* Glanceclient's HTTPSConnection implementation will be used if
  no-compression flag is set to True.

Co-Author:  Flavio Percoco<flaper87@gmail.com>
Change-Id: I09f70eee3e2777f52ce040296015d41649c2586a
2014-07-10 13:22:05 +05:30
Maithem cddc37dcab Set purge-props header correctly in image update
Currently when an image is updated, the purge property
header is only set to true in some cases, but when
required it isn't set to false

Change-Id: I885a82643d2620f393f21c36b3ad95cb7ed43f2c
Closes-Bug: 1318079
2014-06-19 17:35:26 -07:00
Jenkins e6579f43cc Merge "Reuse class Manager from common code" 2014-06-18 19:46:02 +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
Andrey Kurilin d54faad042 Reuse class Manager from common code
Class `Managers` from `glanceclient.common.base` module is similar to
class `apiclient:ManagerWithFind` from common code.

In this patch:
- class glanceclient.common.base:Managers replaced by
apiclient:ManagerWithFind
- module glanceclient.common.base marked as 'deprecated'

Related to bp common-client-library-2

Change-Id: I41da4a9188e97ca2c07b6234fc2ac0a877553d3f
2014-06-12 14:42:46 +03:00
Jenkins dbefc1a3b1 Merge "Fix help text in image-create" 2014-06-10 19:46:58 +00:00