143 Commits

Author SHA1 Message Date
Takeaki Matsumoto
b9eee5ee32 Add check Identity validate when get schemas
Glance client don't check Identity validate when get schemas.
So when you exec "glance image-create" with invalid credentials in
glance-api.conf, it returns "unrecognized arguments: --foo".
It is difficult to debug such message.

This change makes invalid credentials error clear.

Change-Id: Ib641333cd8d51f459df70306a1eeda250ada5ca1
Closes-Bug: 1467719
2015-07-24 09:20:56 +09: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
d80c70e58a Merge "Improve import related error handling" 2015-05-26 18:20:16 +00:00
Thomas Goirand
1686d6aa53 Do not crash on homedir mkdir
Glanceclient is trying to create ~/.glanceclient, and crashes if it can't
do that. In some environment (for example, when building the package
under Jenkins), writing on $HOME is simply not allowed, and Glanceclient
can simply ignore it. This patch allows the mkdir() to fail, which fixes
the issue.

Closes-Bug: #1446096
Change-Id: Ib3591fb4e54ccd2fe63a1a4815551ac10ef5b961
2015-05-14 15:41:24 +00:00
Stuart McLaren
1f89beb609 Improve import related error handling
If there was a problem importing a library we would incorrectly raise
an unsupported version error:

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

We should change this to provide information on the failed import, eg:

  $ glance --os-image-api-version 1 image-list
  No module named badimport

We also now raise the full stacktrace in this case if '--debug' is passed
on the command line.

Change-Id: I1c687ae6c5da239090b0b7a4a855b3271a9076da
Related-bug: 1402632
2015-05-08 12:51:02 +00:00
Jenkins
9e09211914 Merge "Remove duplicate 'a' in the help string of --os-image-url" 2015-03-10 11:50:53 +00:00
Jenkins
7f9b643371 Merge "Remove graduated gettextutils from openstack/common" 2015-03-03 23:38:17 +00:00
Jenkins
99c46d64a0 Merge "Strip json and html from error messages" 2015-03-01 16:19:15 +00:00
Jenkins
437c44f40b Merge "Fixed CLI help for bash-completion" 2015-02-23 19:02:44 +00:00
d34dh0r53
01caf4e734 Strip json and html from error messages
Error messages were being passed with either JSON or HTML formatting
leading to an unpleasant user experience. This strips the JSON or HTML
tags and presents the clean error message to the user.

Rewrote the lispy function to be more pythonic, added test cases
and cleaned up some pep8 violations.

Removed commented out cruft from a previous version of this
patch.

Changed the HTML details from a set to a list in order to ensure
the ordering of the exception details.

Added code to eliminate the duplicate detail messages from the list
and reordered the assertion string to match actual output.

Refactored duplicate elimination code to be more readable and
reliable.

Some reworking of the duplication elimination loop to make it
more readable.

Removed unneeded conditional to filter out empty elements.

Change-Id: I79985b3e305cb30328a3c16b025315a8e969243d
Closes-Bug: 1398838
2015-02-16 10:01:53 -06:00
Jenkins
1c37721287 Merge "Return 130 for keyboard interrupt" 2015-02-06 16:23:21 +00: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
Rakesh H S
96ff6e46c4 Return 130 for keyboard interrupt
When keyboard interrupt is received by glanceclient, the return code as
of now is 1.

But since the client was terminated by an keyboard interrupt, the return
code should be 130. (http://tldp.org/LDP/abs/html/exitcodes.html)
It is useful when people are writing automation test cases and want to
validate based on the return code.

Change-Id: Ia70116ab6f0708a0ce6eeaed07c1e7a56e68c9f4
Closes-Bug: #1373231
2015-02-05 05:08:59 +00:00
Ian Cordasco
1d823962e1 Remove graduated gettextutils from openstack/common
Use oslo.i18n package and handle different versions properly in
glanceclient._i18n. The oslo namespace is being deprecated so imports
will be oslo_i18n going forward. For older versions of oslo.i18n though,
we will still be able to import i18n from oslo.

Change-Id: Id56d34ccf447dc6f7becafb74d6a30e8a1642030
2015-02-03 13:20:39 -06: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
Yvonne Stachowski
9daada9b9a Fixed CLI help for bash-completion
When running 'glance help' the following lines were displayed:

bash-completion     Prints all of the commands and options to stdout so
                    that the

The help now prints:

bash-completion     Prints arguments for bash_completion.

similar to other Openstack CLIs (such as Cinder and Trove).

Change-Id: I1b1d60e23a3662675c5e81a332e9fd8360f6c7b1
2015-01-28 13:25:31 -05: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
Christian Berendt
b64dba8fa2 Remove duplicate 'a' in the help string of --os-image-url
Instead of 'url contains a a version number' it should be
'url contains a version number'.

Change-Id: I7caa350954a37e2af90c656ceb698d9ab772e463
2015-01-20 10:06:13 +01:00
Jenkins
7ce1ff9325 Merge "Add os_ prefix to project_domain_name/id" 2015-01-04 10:40:07 +00: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
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
acb1659357 Merge "Add useful error on invalid --os-image-api-version" 2014-12-02 01:43:35 +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
Jenkins
3b6754a8cc Merge "Adds tty password entry for glanceclient" 2014-11-25 09:38:15 +00:00
Jenkins
265bb4aa17 Merge "Add bash completion to glance client" 2014-11-20 10:06:53 +00:00
Jenkins
b126351d9d Merge "Fix to ensure endpoint_type is used by _get_endpoint()" 2014-11-11 03:31:55 +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
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
Andy McCrae
cbbfbc91c9 Fix to ensure endpoint_type is used by _get_endpoint()
* ks_session get_endpoint uses "interface" instead of "endpoint_type"

Change-Id: I59e45423703774f6dc26c96644f83083832b0627
Closes-Bug: #1367782
2014-09-10 15:43:46 +01: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
Michal Dulko
12a3a82734 Add bash completion to glance client
Currently glance client does not support command completion.
The intention is to add this functionality to the client

blueprint add-bash-completion

Change-Id: I725dd308118b101e87182acf0cee6dbfd214e0e4
2014-08-22 12:14:10 +02: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