61 Commits

Author SHA1 Message Date
Louis Taylor
4d6b94a679 Print traceback to stderr if --debug is set
This change allows easier debugging of client related issues, with a
full traceback printed out when an uncaught error occurs in the client.
Previously, it could be hard to find the portion of code raising an
exception, with just the message from the exception being displayed.

Previous behaviour (with a rather artificial client error being raised):

    $ glance --debug image-list
    Contrived exception

Behaviour after this patch:

    $ glance --debug image-list
    Traceback (most recent call last):
      File "/opt/stack/python-glanceclient/glanceclient/shell.py", line 590, in main
        args.func(client, args)
      File "/opt/stack/python-glanceclient/glanceclient/v1/shell.py", line 77, in do_image_list
        raise(Exception('Contrived exception'))
    Exception: Contrived exception
    Contrived exception

Change-Id: Id7b76b707e5fc16a0402dcb104ec40787e0ffbe2
2014-09-15 20:04:38 +00:00
Jenkins
e4417169a6 Merge "Import missing gettextutils._ in shell.py" 2014-09-13 00:54:26 +00:00
Pawel Koniszewski
33dcea81b2 Support for Metadata Definitions Catalog API
API calls and shell commands added in this patch:
- CRUD for metadefs namespaces;
- CRUD for metadefs objects;
- CRUD for metadefs properites;
- CRD for metadefs resource types and resource type associations.

Change-Id: I6d15f749038e8fd24fc651f0b314df5be7c673ef
Implements: blueprint metadata-schema-catalog-support
Co-Authored-By: Facundo Maldonado <facundo.n.maldonado@intel.com>
Co-Authored-By: Michal Dulko <michal.dulko@intel.com>
Co-Authored-By: Lakshmi N Sampath <lakshmi.sampath@hp.com>
Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com>
2014-09-03 11:45:57 -06:00
Matthew Booth
d97f03e099 Import missing gettextutils._ in shell.py
Closes-Bug: #1355252

Change-Id: I3aef19235735b3b374b92985f142712cb0f37a35
2014-09-02 15:32:07 +01:00
Zhi Yan Liu
9a53c1fdcb Enable osprofiler interface in glanceclient shell
To help end user uses profiling by glanceclient CLI directly, the
change added '--profile <HMAC_KEY>' argument to the shell.

This change also fixed a function regression, it was used to pass
necessary trace info to glance server via http header:
dbb242b776 (diff-740dd7d9149f46fe4c01ef0ab7eb3bfbL196)

In addition:
1. If client app want to enable profiling feature for glanceclient
object, please see: http://paste.openstack.org/show/85722/
2. Afer adding more trace point into Client object, as fundamental
requirement of osprofiler, what we need to notice caller is providing
correct messaging notifier in the context code.

The relevant change for glance server is ready at:
I45a19f5eb5304c2b78a9e12cbc0744941a807304

DocImpact

Change-Id: If42b69b2695a5f88536ecbc2c1b3592d9dbd880a
Signed-off-by: Zhi Yan Liu <lzy.dev@gmail.com>
2014-08-19 03:20:22 +04: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
Jenkins
558ebf7bb7 Merge "Add support for Keystone v3" 2014-08-07 23:49:53 +00:00
Bob Thyne
f15dc6b82f Add support for Keystone v3
This enables glanceclient to authenticate using Keystone v3
API and includes the addition of several new CLI arguments.

DocImpact

Change-Id: I863ba08d312363dc1ce4fc7822fb21ef53df1a4f
2014-08-05 11:05:09 -07:00
ChangBo Guo(gcb)
1db17aaad9 Enable F841
F841 detects local variable is assigned to but never used.
This commit fixes the violations and enables F841 in gate.

Change-Id: Ic4dcac2733dfe334009327ac17aa3952cafaa63a
2014-07-09 14:10:23 +08:00
Frederic Lepied
628c541a69 Finalize Python3 support
Set the environment variable PYTHONHASHSEED to 0 to have
predictive tests under Python 3.

Change-Id: Ia15a9383e0f20bd0e4572e9f9b9772f1704dff86
2014-05-20 16:42:10 +02: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
Alex Gaynor
d465d60867 Replace file with open, which is Python 3 compatible
Change-Id: I471ae9b372f88a508d4654b1a18c6da90397a828
2014-02-13 06:59:18 -08:00
Stuart McLaren
ee7fd2f5bd Handle endpoints with versions consistently
When using the cli the Glance client wraps the endpoint in a 'strip
version' function. This means that endpoints of the following forms can
both be used:

https://region-x.images.example.com:443/v1
https://region-x.images.example.com:443

When calling the client library directly (as Ceilometer does) however
only endpoints of the second form work. The cli and library should handle
the two cases consistently.

Addresses bug 1243276.

Change-Id: Ice7b581fee32540a7057ba47433a10166a3caed2
2014-01-22 11:16:58 +00: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
10764641f8 Merge "Fix Pep8 errors found by Pep8 1.4.6" 2013-11-15 08:47:38 +00: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
Dirk Mueller
fb31223291 Fix Pep8 errors found by Pep8 1.4.6
These missed E128 warnings were missed by 1.4.5, adjust
the indentation.

Change-Id: I7b459113a6f5143012acf959639b725238ca8a11
2013-10-18 11:32:25 +02: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
Dazhao
061da46202 Support glance client can get ipv6 image url correctly
This patch is for fix bug 1208784. In openstack ipv6 environment,
if the os image url is not provided, need use the provided host
to generate literal ipv6 image url.

Fixes bug 1208784

Change-Id: Icb71241a639db02d079348f086bd7bd5f0412609
2013-09-06 13:58:24 +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
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
Dirk Mueller
62579fbb21 Start using Pyflakes and Hacking
Instead of globally ignoring pyflakes and
hacking warnings, only blacklist those that trigger
very frequently so far, in order to clean them
up in followup commits. Fix and start gating
on the rest already.

Change-Id: Ied7c7250061e3bf379e8286e8ce3b9e4af817faf
2013-06-22 16:00:26 +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
Dirk Mueller
45feb672af Improve Python 3.x compatibility
Some mechanical translation of the deprecated
except x,y construct. Should work with Python >= 2.6
just fine

Change-Id: I394f9956b9e3e3d9f5f1e9ad50c35b13200af2a1
2013-04-22 16:38:55 +02:00
John Bresnahan
edf9ae5097 Trapping KeyboardInterrupt sooner.
Currently a KeyboardInterrupt can be triggered by the user while the
client is communicating with keystone.  This patch moves the trap
higher up in the stack.

Fixes bug: 1157905

Change-Id: I16889c2d97bc4694ab27c863c62c27333e264b60
2013-03-20 08:51:59 -10:00
Jenkins
8787c82f11 Merge "Control C does not cancel the CLI cleanly" 2013-03-11 21:54:47 +00:00
James Li
d810019d0e Add missing spaces in help msg
Change-Id: Ida1dcd9c75d1c36ea1b4bfefcd1d1292b565ab6b
2013-03-06 23:42:50 +00:00
John Bresnahan
1a3d40ccb4 Control C does not cancel the CLI cleanly
When a user attempts to terminate the CLI with CTL+C a stack
trace is printed to the screen.  When downloading files the
partial amount downloaded will not be cleaned up.  In most
cases the user redirects to stdout, thus this program cannot
clean that up.

Fixes Bug: 1130390

Change-Id: If9f8ffc72b422d5dbd5969eecde8904238dd8860
2013-03-05 12:12:03 -10: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
Dean Troyer
4781da7007 Support --os-cacert
* Rename --ca-file to --os-cacert (--ca-file deprecated for
  backward compatibility)
* Add cacert to keystoneclient initialization to verify the
  keystone server certificate

This aligns glanceclient with keystoneclient for option naming
and the use of TLS for the keystone auth connection.  It does not
change the use of TLS/SSL for the glance connection.

Change-Id: If8b05655aea5f3c62612d77bf947dd790f77eddf
2012-12-11 14:46:33 -08:00
Chuck Short
c0ec97f310 Pin pep8 to 1.3.3
Standardize pep8 to 1.3.3 and cleared up any errors
found by pep8 tests.

Change-Id: Ib7eb97d0789556d1676ccad58b5d3364065b7d15
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2012-11-25 11:34:56 -05:00
Brian Waldon
3003ed8ef8 Hook up region_name argument
Connect the --os-region-name option passed through the CLI
to the call to service_catalog.url_for.

Fixes bug 1080739.

Change-Id: I2d19d62a999a82a91de3883db12bbc24e900de25
2012-11-19 12:47:54 -08:00
Christian Berendt
e20ff23158 added --version as new parameter
fixes bug 1056504
Change-Id: Ib28e3941006b46553001d7895d5ddf4b0f9c540d
2012-11-13 12:02:14 +01:00
Stuart McLaren
556082cd66 Implement blueprint ssl-connect-rework
Use pyOpenSSL for HTTPS connections.

This allows:

* Neater loading of system CA files
* Optional disabling of SSL compression

The performance gain from disabling SSL compression is significant
in cases where the image being uploaded/downloaded is in an already
compressed format (eg qcow2).

Related to bp ssl-connect-rework.

Change-Id: I0568b6c95c5fc7b8eafdbd0284e24c453660a55a
2012-10-08 13:51:41 +00:00
Stuart McLaren
37caf870ac Use system CA certificate file
When SSL is being used and the --ca-file option is
not specified use an available system CA file to
verify the server's certificate.

Change-Id: Id5c9fda6fd9bd05cde3c2a9160a6e72cef086a44
2012-08-13 09:52:29 +00:00
Brian Waldon
227d166109 Client-side SSL Connection
This allows a user to pass a cert and a key to use in HTTPS
connections. The flags --cert-file and --key-file are added
to the CLI.

Addiionally, update the debug curl logging to print --cacert and
-k when ca_file and insecure are set.

Related to bp glance-client-parity.

Change-Id: Ibaea51419a903afb7939a6b5b848f7a6667893bf
2012-08-04 12:14:11 -07:00
Brian Waldon
ff34cfc50f SSL Certificate Validation
This adds support for validation of ssl certs returned by remote
servers over SSL. The --ca-file param represents the CA cert used
to sign the remote server's cert. Use --insecure if the remote
server is using a self-signed cert or you don't have the CA cert.

Related to bp glance-client-parity

Change-Id: I45253a6e2d88da599addfcc464571e62ae920166
2012-08-04 12:09:49 -07:00
Jenkins
18543b1a46 Merge "Allow CLI opts to override auth token and endpoint" 2012-08-03 00:29:25 +00:00
Brian Waldon
a511e6a05e Add legacy compat layer to v1 shell
All legacy CLI commands should work as expected with a few
minor exceptions:
- no upload animation
- no interactive pagination
- help/usage output has changed

Deprecated options are indicated as such in their usage info. Deprecated
commands have descriptions that label them as such.

Related to bp glance-client-parity

Change-Id: I584b2447361967228bea332e14880e18db12fca8
2012-08-01 22:21:27 -07:00
Brian Waldon
2541f3ce84 Allow CLI opts to override auth token and endpoint
Previously, both --os-auth-token and --os-image-url had to be
provided in order for either of them to be used in any API requests.
This breaks the tie between them and allows a user to override
either the auth token or the endpoint returned by Keystone independently
of one another.

Fixes bug 1029586

Change-Id: I8b81be723286c546d9cbd97c8b7d7aa89c03b2d4
2012-08-01 20:41:41 -07:00
Jenkins
bb0b59bda1 Merge "Honor '--insecure' commandline flag also for keystone authentication" 2012-07-31 03:38:44 +00:00
Brian Waldon
158f7ccd74 Fix --debug CLI option
The --debug argument has been ignored since httplib2 was replaced
with httplib. This re-enables the --debug flag as an equivalent
to the env var GLANCECLIENT_DEBUG.

Fixes bug 1030700

Change-Id: Ib653049eea2f18c4cc2f8f8aac7884245afd0f04
2012-07-29 21:21:29 -07:00
Sascha Peilicke
bb282936a0 Honor '--insecure' commandline flag also for keystone authentication
Currently, keystone auth fails with self-signed certificates.

Change-Id: Ice89bcd0662038260bc4bd12058972bb35e61e3b
2012-07-26 15:48:23 +02:00
Brian Waldon
1e744f162e Replace httplib2 with httplib as http driver
* This allows us to send truly chunked responses to users
* Handle bad connection url schemes with a new InvalidEndpoint exception
* Fixes bug 1023240

Change-Id: I34500987f51d4e0c6e1f89ecf93853de3fcbb1c3
2012-07-23 13:52:12 -07:00
Sascha Peilicke
71a0caece8 Clarify usage of --insecure flag
Change-Id: If19a7aab92350fb68e447a0ffe8a97e079d762e4
2012-07-20 10:18:23 +02: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
d2ab65255f Remove AuthorizationFailure exception
The AuthorizationFailure exception isn't used anywhere, so
remove it.

Fix bug 1015940.

Change-Id: Ie6da74b63e3d1658c8ae26c272222f00f1209e38
2012-07-10 21:10:40 -07:00