Commit Graph

603 Commits

Author SHA1 Message Date
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 5ec4a24b89 Remove uuidutils from openstack-common
This is unused since the last incubator sync.

Change-Id: I10c398c3e907f3830839ce54aae54e5c2f3b4933
2015-02-02 11:02:58 +00:00
Jenkins b595ab73ed Merge "Remove openstack.common.importutils" 2015-02-02 09:44:21 +00:00
Jenkins 4bfd8d5097 Merge "Remove openstack.common.strutils" 2015-02-02 04:49:32 +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
Louis Taylor 878bdcbdbc Remove openstack.common.importutils
This module now lives in oslo.utils, so import it from there.

Change-Id: I41fa4897fc820596fb010336044ff4c493017d5a
2015-01-28 02:12:18 +00:00
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
Zhi Yan Liu 363b170851 Sync latest apiclient from oslo-inc
a908d66 Remove uuidutils
5985b35 Prefer delayed %r formatting over explicit repr use
002999b Curl statements to include globoff for IPv6 URLs
03e6272 Add ConnectionError exception
3bc8231 deprecate apiclient package
fd8dc0c Handle different format of api exception
a7af1e2 Mask keystone token in debug output
55ca7c3 Split cliutils
5d40e14 Remove code that moved to oslo.i18n
6ff6b4b Switch oslo-incubator to use oslo.utils and remove old modules
f76f44c Delete the token and endpoint on expiry of token of client
ed0ffb8 Do not incur the cost of a second method call
cf449e2 Fix response_key parameter usage in BaseManager
94245b1 Make it possible to get the request_id from python clients
d73f3b1 Remove unused/mutable default args
5e00685 Centralize bash-completion in Novaclient
4ef0193 Handle non-openstack errors gracefully
ac995be Fix E126 pep8 errors
de4adbc pep8: fixed multiple violations
e42e77f Restore UUID and human-ID bash completion
9e88af1 fixed typos found by RETF rules
822e09b Don't slugify names that don't exist
4a777e5 Fix warnings in doc build for apiclient
3fb053c apiclient.exceptions.from_response() may miss request_id

Btw, the patch removed the uesless 'network_utils' line from
openstack-common.conf, currently we use oslo_utils.netutils directly.

Change-Id: Ic3d48a13d5366b050b07ef26ab34fad411a0db05
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
2015-01-23 23:05:05 +08:00
Jenkins cb34b9b6eb Merge "Handle HTTP byte returns in python 3" 2015-01-23 14:47:36 +00:00
Jenkins 88f6319b7b Merge "Make non-boolean check strict" 2015-01-23 14:40:27 +00:00
Jamie Lennox 62df6c669f Handle HTTP byte returns in python 3
The returns from requests' response.content is a bytes type. Under
python 3 this fails in error handling and string conversion. The
response.text variable should be used to treat a response body as a
string.

Closes-Bug: #1407531
Change-Id: Ifd588b5f6820ef21beb186d88d0b3f1a267695aa
2015-01-14 12:32:07 +10:00
OpenStack Proposal Bot aebbcff100 Updated from global requirements
Change-Id: Ifae019c18ea0ff32ed2c3cc11e8f2f3ea12ff1d4
2015-01-09 18:35:33 +00:00
Jenkins dac71b4be9 Merge "Curl statements to include globoff for IPv6 URLs" 2015-01-08 14:58:41 +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 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
Jenkins 7ce1ff9325 Merge "Add os_ prefix to project_domain_name/id" 2015-01-04 10:40:07 +00:00
Sabari Kumar Murugesan e3600ad7be Fix broken-pipe seen in glance-api
When file size is an exact multiple of chunk_size, glance client
is processing EOF in image-data as a chunk and sends to
glance-api. The server treats this as the end of chunked 
transmission and sends a http response.

When the actual last chunk is sent by the 'requests' library, the
server sends a 400 response and tracebacks with broken pipe
as the client has already closed the socket.

Closes-Bug: #1342080
Change-Id: Icdbff838450db1c252ddc919a230a7d3ca16765f
2014-12-22 19:57:46 +00:00
Jenkins 0cdc947bf9 Merge "Output clear error message on invalid api version" 2014-12-15 15:55:58 +00:00
Louis Taylor 385d97ef38 Add release notes for 0.15.0
This adds release notes for the folowing commits:

    $ git log --oneline --no-merges 0.14.2..HEAD
    9a4d858 Support Pagination for namespace list
    3989cd2 Support schema types with non-str value
    9829d7b Don't require version to create Client instance
    8e02b2a Allow --file in image-create with v2 Image API
    d5a0e65 Add useful error on invalid --os-image-api-version
    49f38a4 Add release notes for 0.14.0 - 0.14.2
    5080d10 Send `identity_headers` through the wire
    d0851c3 Remove readonly options from v2 shell commands
    4194a55 Add --property-filter option to v2 image-list
    ef0abdc Fix py34 failure for glance client
    8c159a2 Don't set X-Auth-Token key in http session header if no token provided
    b83a672 Refactor method of constructing dicts in some tests
    751e064 Adds tty password entry for glanceclient
    597da8a '--public' ignored on image create
    cbbfbc9 Fix to ensure endpoint_type is used by _get_endpoint()
    12a3a82 Add bash completion to glance client

Change-Id: I24fbba80831c311b42d1abb08487cc29c8b5b162
2014-12-11 16:45:46 +00:00
Travis Tripp 9a4d8580e8 Support Pagination for namespace list
The rest api metadefs/namespaces supports pagination using the parameters
of limit, marker, sort_dir, & sort_key. However, the glance client isn't
passing those parameters through (they come in as kwargs). This is
preventing pagination from working properly in horizon.

This is affecting Horizon support: https://review.openstack.org/#/c/104063/

Change-Id: Ib349cf3a3a437eb1711f350b37d0bd0e7d01330a
Closes-Bug: 1381816
2014-12-10 23:21:41 -07:00
Mike Fedosin 8e8dde2052 Output clear error message on invalid api version
Now if --os-image-api-version mistakenly contains a string then
you will get a ValueError

Example:
$ glance --os-image-api-version hui
ValueError: invalid literal for int() with base 10: 'hui'

This code correctly handles this situation, prints a warning
message and interrupts the execution of the client

Change-Id: I4733578adfc70bd57afd5f0d4d361c8ef689a381
Closes-bug: 1401197
2014-12-10 21:39:18 +03: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
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
Oleksii Chuprykov bd73a5482c Add os_ prefix to project_domain_name/id
Running glance without defining --os-tenant-id and
--os-tenant-name leads to AttributeError. Add os_ prefix
to project_domain_name and project_domain_id because args
object doesn't have them

Closes-Bug: #1384759

Change-Id: Id85569aad538efcf327312d9936bb6463279ce34
2014-12-09 11:34:57 +00:00
Jenkins 521cc25a0a Merge "Add release notes for 0.14.0 - 0.14.2" 2014-12-04 15:37:34 +00:00
Jenkins 69981798bc Merge "Send identity_headers through the wire" 2014-12-03 12:08:40 +00:00
Jenkins 6a6a5eff07 Merge "Allow --file in image-create with v2 Image API" 2014-12-03 03:03:12 +00:00
Jenkins acb1659357 Merge "Add useful error on invalid --os-image-api-version" 2014-12-02 01:43:35 +00: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
Louis Taylor d5a0e657ed Add useful error on invalid --os-image-api-version
This adds a useful error message when a user enters an invalid value
for --os-image-api-version. Previously, the shell directly attempted to
import the module the user specified, and printed the error from the
exception raised when that failed:

    $ glance --os-image-api-version stupid-glance-version
    No module named vstupid-glance-version.shell

Glanceclient now catches this exception and prints something
understandable for a user:

    $ glance --os-image-api-version stupid-glance-version
    "stupid-glance-version" is not a supported API version. Example values are "1" or "2".

Closes-Bug: #1395841

Change-Id: I48a95b7562c10bd68d777be408dcfa22cb05ec6a
2014-11-25 16:22:47 +00:00
Louis Taylor 49f38a4242 Add release notes for 0.14.0 - 0.14.2
These were not written at the time of release, so this catches up with
the latest version.

For reference:

    $ git log --oneline --no-merges 0.13.0..0.14.0
    33dcea8 Support for Metadata Definitions Catalog API
    16077d9 Catch new urllib3 exception: ProtocolError
    6dda6f3 Fix error when logging http response with python 3
    d6498b6 Ensure server's SSL cert is validated
    9a53c1f Enable osprofiler interface in glanceclient shell
    69361a1 Hide stderr noise in test output
    1dfce53 Remove deprecated commands from shell
    867e4ca Normalize glanceclient requested service url
    4494853 Fix glance-client to work with IPv6 controllers
    f15dc6b Add support for Keystone v3
    7736349 Update theme for docs
    e79031b Add a tox job for generating docs
    68c1d1f Don't stream non-binary requests
    f75a810 Use a correctly formatted example location in help
    dbb242b Replace old httpclient with requests
    1db17aa Enable F841
    797d101 Resolving the performance issue for image listing of v2 API
    e305dad Add profiling support to glanceclinet
    9b9f3be Use immutable arg rather mutable arg
    1c46c76 Add CONTRIBUTING.rst

    $ git log --oneline --no-merges 0.14.0..0.14.1                                                                                                                                                                                                                                                                                                                                                                                      f980fc5 Update how tokens are redacted
    ba19a53 Handle UnicodeDecodeError in log_http_response
    4d6b94a Print traceback to stderr if --debug is set
    61e4eba Updated from global requirements
    97b1506 Fix v2 requests to non-bleeding edge servers
    9fbc313 Work toward Python 3.4 support and testing
    d97f03e Import missing gettextutils._ in shell.py
    4631b76 Fix indentation in tox.ini
    cda8c4d Downgrade log message for http request failures
    8770586 CLI image-update gives a wrong help on '--tags' param

    $ git log --oneline --no-merges 0.14.1..0.14.2
    052904b Don't replace the https handler in the poolmanager
    5f4966d Remove network_utils
    2b567cf Skip non-base properties in patch method
    7ef1b7c Adds support for Glance Tasks calls
    1511c86 Fix the ordering of assertEqual arguments
    ab07caf Stop using intersphinx
    929a72e Default to system CA bundle if no CA certificate is provided

Change-Id: Ie4195fa9ad7f5f45c387fda4b1db4fbce7a3f98c
2014-11-25 15:53:29 +00:00
Flavio Percoco 5080d10099 Send identity_headers through the wire
Change I09f70eee3e2777f52ce040296015d41649c2586a, introduced a bug where
the identity_headers are not added to the request headers anymore
causing the former to be completely ignored and useless.

This patch fixes that issue by restoring the previous code. A new test
has been added to avoid regressions.

Closes-bug: #1394965
Change-Id: I1b1633636448398cf3f41217f1d671b43ebd9946
2014-11-25 10:01:39 +00:00
Jenkins 3b6754a8cc Merge "Adds tty password entry for glanceclient" 2014-11-25 09:38:15 +00:00
sridhargaddam 465c5cef8d Curl statements to include globoff for IPv6 URLs
python-glanceclient displays curl statements for debugging/troubleshooting
purposes. For IPv6 URLs, curl requires --globoff to be passed in the
arguments. Since glanceclient does not use curl directly, this patch
displays the curl commands with globoff option which works for both
IPv4 and IPv6 URLs.
Fix adapted from python-novaclient Ib7099e8e3bbc15f29bbaa1db37ef21e78a74e7bc

Closes-Bug: #1228744
Change-Id: Ie02c4e75ca1ab995102aa55bbff39b2161218b2d
2014-11-24 06:55:43 +00:00
Jenkins 265bb4aa17 Merge "Add bash completion to glance client" 2014-11-20 10:06:53 +00:00
Jenkins 9a4fec4a1e Merge "Refactor method of constructing dicts in some tests" 2014-11-20 09:53:56 +00:00
Jenkins 46bfeb4f2c Merge "Don't set X-Auth-Token key in http session header if no token provided" 2014-11-20 09:53:49 +00:00
Jenkins b04bbf38d5 Merge "'--public' ignored on image create" 2014-11-20 09:50:34 +00:00
Jenkins 3756388af4 Merge "Add --property-filter option to v2 image-list" 2014-11-20 01:50:38 +00:00
Michal Dulko d0851c32ed Remove readonly options from v2 shell commands
This commit is removing the read-only properties from shell options to
prevent user from doing invalid requests using the client.

Change-Id: I17e9578e705bd3cf628fe39630ebecc4ea43e392
Closes-Bug: 1350802
2014-11-14 11:46:39 +00:00
Louis Taylor 4194a55a09 Add --property-filter option to v2 image-list
The option is present in the v1 shell, but missing from the v2 shell. This
allows the user to filter based on any image property.

Example:

    $ glance --os-image-api-version 2 image-list --property-filter os_distro=NixOS

DocImpact
Closes-Bug: #1383326

Change-Id: Ia65a08520e3eaf3ecd9b9018be9f6a8e2d3d4f0b
2014-11-14 10:45:31 +00:00
Jenkins 711f28a5a8 Merge "Fix py34 failure for glance client" 2014-11-13 22:45:57 +00:00
Jenkins b126351d9d Merge "Fix to ensure endpoint_type is used by _get_endpoint()" 2014-11-11 03:31:55 +00:00
Fei Long Wang ef0abdc885 Fix py34 failure for glance client
Fix somes tests failures for py34, most of them are related
to items order of dict.

Closes-Bug: 1382582

Change-Id: I954b884f03931e4f0ecb654fb38edd0c46a3c379
2014-11-11 15:36:47 +13:00
Jenkins 695dbc910d Merge "Don't replace the https handler in the poolmanager" 2014-11-05 19:06:11 +00:00
Matt Riedemann 8c159a2eb4 Don't set X-Auth-Token key in http session header if no token provided
Commit f980fc5492 changed how the
X-Auth-Token header was scrubbed when logging the request, but
effectively made the value required which can lead to an AttributeError
if the value for the header is None.

The value can be None if you're using Nova but don't have Nova
configured with auth_strategy='keystone' (see
nova.image.glance._create_glance_client for details).

This patch simply checks if the auth_token is set in the http client
object and if not, it doesn't set the X-Auth-Token key in the session
header.

Closes-Bug: #1381295

Change-Id: Ie285d5253df28a9f0f964147a53c99ceaa919c5c
2014-10-30 18:07:50 +08:00
Flavio Percoco 052904ba32 Don't replace the https handler in the poolmanager
In order to keep the support for `--ssl-nocompression` it was decided to
overwrite the https HTTPAdapter in `requests` poolmanager. Although this
seemed to work correctly, it was causing some issues when using
glanceclient from other services that rely on requests and that were
also configured to use TLS.

THis patch changes implements a different strategy by using
`glance+https` as the scheme to use when `no-compression` is requested.

Closes-bug: #1350251
Closes-bug: #1347150
Closes-bug: #1362766

Change-Id: Ib25237ba821ee20a561a163b79402d1375ebed0b
2014-10-30 09:06:02 +01:00
Louis Taylor b83a6726d3 Refactor method of constructing dicts in some tests
In some of the v2 tests, dictionaries are construed from lists of
tuples of length two. For example:

    dict([('visibility', 'private')])

There could be a very good reason for doing it that way, but it eludes
me. This patch replaces those with dictionary literals.

Change-Id: Ie9668bd681538ef41521f08a20cb8c3417ac91e8
2014-10-29 12:04:39 +00:00
John Trowbridge 751e064761 Adds tty password entry for glanceclient
Added functionality from keystoneclient to fallback to the tty for password
entry if no password is given via the environment or the --os-password option.

Change-Id: I096e81b61d7f499cbda300abdc14430928d18491
Closes-Bug: 1357549
2014-10-23 18:31:36 +00:00
Jenkins cfe0623520 Merge "Adds support for Glance Tasks calls" 2014-10-16 03:37:48 +00:00