This was only needed for Python < 2.7, but glanceclient's setup.cfg
already declares compatibility only with 2.7.
Change-Id: I80d42abf5dd5565da424a90a93545ba82ef7a58d
Old deprecated ssl options block the new keystoneauth parser get the
correct value, should be removed.
Change-Id: Ie080f9a8fa7f4407b1fcbb7fb7c763152c5ec295
Closes-Bug: 1697163
On Python 2, decoding all arguments leads to the possibility that users
that use the wrong command or mistype the name will see error output
with a unicode string's representation instead of one without it. To
avoid this we try and find the first non-option string in the argument
list and replace it with an string that is not text only on Python 2. If
we encoded the string at all times, then users installing glanceclient
on Python 3 would see b'invalid-subcommand' instead. That's as bad as
seeing u'invalid-subcommand' on Python 2.
Closes-bug: 1533090
Change-Id: I018769e159a607ebb233902cbeb13b95ca417190
Add unit tests to ensure that any stray output (eg print
statements) during image-download cause a test failure.
Regression test for bug 1488914.
Change-Id: Ic19ba5693d059bf7c283702e7c333672a878a1a1
Partial-bug: 1488914
The correct order of arguments to assertEqual that is expected by
testtools is (expected, observed).
This patch fixes the inverted usage of arguments in some places
that have cropped up since the last fix of this bug.
Change-Id: If8c0dcb58496bc2fcf4c635f384522a1f7d2b2af
Closes-Bug: #1259292
construct method is marked as deprecated and might be deleted
in one of future releases. So glanceclient need to be aware of
that and initialize sesssion from command line arguments directly.
Change-Id: Ie81b62b7e70bb177f178caadc41554ae88e51b05
If env['OS_IMAGE_URL'] is not set then None is returned. This is then
used ignoring the endpoint_type, service_type and region_name. This
patch will use those values if the endpoint is None.
Change-Id: I76cc527b05d2be75d3dbc33123a0d71be97fe25c
Closes-bug: #1579768
Commit 1f89beb609 introduced the behaviour
that a stacktrace is printed if an exception is encountered.
This helped make the client more supportable:
$ glance --debug image-list
.
.
.
File "glanceclient/common/http.py", line 337, in get_http_client
xxx
NameError: global name 'xxx' is not defined
global name 'xxx' is not defined
The behaviour was lost at some point. This patch re-enables it.
Change-Id: I25fc8624797909d606590747f54b9cf649ade079
Closes-bug: 1563830
you can see the default help informatiion is v2
subcommand information if input glance command
Co-Authored-By: Stuart McLaren <stuart.mclaren@hp.com>
Closes-bug: #1563649
Change-Id: I7d227f3e68aa555b2e25848618f76df4872af35d
After the introduce of this patch set[1], cli user can't get debug
info even --debug is passed. With the patch set[1], the request
action will be performed in keystoneclient.session.Session.
However the default log level of keystoneclient module is WARNING,
so user can't get debug info from keystoneclient.session.Session.
This change set the root log level to DEBUG when --debug is
passed.
[1]: https://review.openstack.org/#/c/262220/
Change-Id: I0db0fd7ab07a0d61082b86829a671d8dbc0f2963
Closes-bug: 1551076
Now the help message of namespace and resource_type are wrong,
we could see a <unavailable> error when try to get the help
information, such as "glance help md-namespace-create".
See the patch[1] to get more information. the patch[1] added
image schema, but the metadata schema are needed as well.
This patch adds the current metadata schema into client, so that
help text can't be rendered when there schema is not available in
the system.
[1]: https://review.openstack.org/#/c/209536/3
Change-Id: I2ab94d8768114a7e5c475310ba094af653627658
Closes-Bug: #1536430
Some of the assertions in glanceclient test are sequential, we should
better use assert_has_calls() instead of assert_any_call().
And assert_has_calls() provides more clear messages in case of failure.
Change-Id: Ie45e7c56b1c859916a1f31636c639422f1ffef28
Shell tests initialized glanceclient with force_auth parameter
but this parameter doesn't exist at all.
The patch fixes this behavior and modifies client mocking to
prevent from these errors in future.
Change-Id: If4b469cf8da8105204a7f1f6e80ae19b86c7daee
When no token or endpoint, it creates a session and from there
taken the necessary values.
This commit proposes to transfer a session in such cases.
This will avoid unnecessary actions and some of the problems.
Change-Id: Idc874b6c01e915e52904604d59e8e0b460e71621
Partial-bug: #1519546
Pass the subcomand's arguments instead of the base ones to the endpoint
creation call when quering the `/versions` endpoint. Passing the wrong
arguments will end in the auth_requirement not being identified and an
error 'Expected Endpoint' will be raised as no endpoint will be gotten
from keystone.
This patch also removes an unnecessary mock in the test code related to
this fix.
Depends-On Iefeb9bc123f8c65fecd0cba585ecd3eb349b23a6
Change-Id: I46088130b9175798e3719e43f48dc474fbc8a251
Closes-bug: #1504058
When running just 'glance' under python3, we will get the error:
ERROR: 'Namespace' object has no attribute 'func'
This is because map() is used to decode sys.argv, but under Python3
it returns a map object which is an iterable. Some code later tries
to use this in a boolean context and it will always return True,
even if it's empty.
Change-Id: I2f03e462cb813833b75b9f2de7badd10b10cddff
Closes-Bug: #1295356
The latest change to the auth_required logic introduced a bug were even
when the token and endpoint were passed, authentication was being
required.
This patch fixes that issue and makes sure that authentication is not
required when these 2 arguements are present.
Closes-bug: #1499540
Change-Id: I4c9c15ba526378970da5461511ed922d42c5a9f9
If CLI client is called without any subcommands or arguments it will
fail with """'Namespace' object has no attribute 'command'""". This
is coming from the getattr which does not have alternate value
specified.
Closes-Bug: #1494259
Change-Id: I461f0d4a91f3af2224bafc14a88572a8e4a3c051
The `help` command was behaving a bit funky. This patch re-orders the
code a bit so that the `help` command will be parsed at the very
beginning before running other commands and checks.
It also allows to get help without downloading/checking schemas and
without requiring auth credentials (previously required by the schema
operations).
Change-Id: Ib7b10d4d80f15e6b75bb8644d7d916bef09413d6
Closes-bug: #1490457
The `_cache_schemas` call currently forces authentication even when the
`auth_token` and `os_image_url` are passed. Instead of handling forced
authentications, let the client use the passed arguments and
authenticate only once if needed.
This was not caught by the existing tests because the call to
`_cache_schemas` was mocked.
Change-Id: I93cec9a68cafc0992d14dab38114d03e25f1e5da
Closes-bug: #1490462
We have a basic implementation for a fallback mechanism that will use v1
rather than v2 when downloading schema files from glance-api fails.
However, this is not sound. If the schemas are cached already, we won't
check if v2 is available and fail to fallback.
This patch fixes the aforementioned issue by getting the list of
available versions from the server only when the API versions was not
explicitly specified through the CLI. That is, for all commands that
don't pass `--os-image-api-version 2`, we'll check v2's availability and
we'll fallback to v1 if it isn't available.
This patch also changes how we handle `/versions` calls in the client.
The server has been, incorrectly, replying to requests to `/version`
with a 300 error, which ended up in the client re-raising such
exception. While I think 300 shouldn't raise an exception, I think we
should handle that in a spearate patch. Therefore, this patch just
avoids raising such exception when `/version` is explicitly called.
This fallback behaviour and the check on `/versions` will be removed in
future versions of the client. The later depends on this bug[0] being
fixed.
[0] https://bugs.launchpad.net/glance/+bug/1491350
Closes-bug: #1489381
Change-Id: Ibeba6bc86db2a97b8a2b4bd042248464cd792e5e
There's a corner case where password may be requested twice. In a fresh
environment, when schemas have not be downloaded for v2, the client will
ask for a password to download the schemas and then it'll ask for the
password again to run the actual command. This happens because we parse
the CLI arguments twice to make sure we're parsing them for the right
client version.
This patch checks if the password is unset in the newly parsed arguments
and if it's been set in the previously parsed ones. In this case it
keeps the set password. I believe this approach is safer than re-using
the already parsed arguements which may have been parsed for a different
API version (might happen because we fallback to v1 if v2 is not
available).
Change-Id: I080253170e3e84a90363e5bb494cf137895fe2e7
Closes-bug: #1488892
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
Now we have claimed v2 is the current API version of Glance,
we should change the Glance client as well to be consistent
with Glance server.
DocImpact
Change-Id: I09c9e409d149e2d797785591183e06c13229b7f7
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
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
This patch moves the glanceclient unit tests to the standard directory
(xxxclient/tests/unit) in preparation for adding functional gate tests
'check-glanceclient-dsvm-functional' in the same vein as existing client
tests for other projects, eg:
* check-novaclient-dsvm-functional
* check-keystoneclient-dsvm-functional
* check-neutronclient-dsvm-functional
Change-Id: I29d4b9e3a428c851575ee9afde40d6df583456c4