90 Commits

Author SHA1 Message Date
Nate Potter
a33d87fb42 Update --endpoint-type dest to os_endpoint_type
Currently the dest of the deprecated --endpoint-type arg
is 'endpoint_type'. However, the code only uses 'os_endpoint_type'
so right now it isn't being used at all. This patch updates
the dest to be 'os_endpoint_type' so that the variable can
be assigned correctly.

Change-Id: Ie8592d12bcf95e4ccff571e831440b18f5acfd40
Closes-bug: #1454436
2016-10-21 22:07:51 +00:00
xianming mao
41a4187061 Help msg and output info should support il8n.
Help msg and output info should support il8n.
And delete the unused import six.

Close-Bug: #1629157
Change-Id: Ie1faf0a83ec5f04dc6c8303f1ea0c931ba482e2a
2016-10-18 12:12:25 +00:00
Eric Harney
268f50270d Print backtrace for exception when in debug mode
If the cinder shell is run in debug mode
(CINDERCLIENT_DEBUG is set in the environment or
with --debug), print a traceback for unhandled
exceptions.

This makes it possible to debug issues like this:
  $ cinder credentials
  ERROR: list indices must be integers, not str

Related-Bug: #1631142

Co-Authored-By: Gorka Eguileor <geguileo@redhat.com>
Change-Id: I5e9b3283602d404ab43494f15d57ec5abbcd77dc
2016-10-11 11:17:26 -04:00
Gábor Antal
aa1c3e82dd Removed multiple import from shell.py
In shell.py, six is imported twice.
In this patchset, one of them is removed.

TrivialFix

Change-Id: Ifbf6dcb20d5de54855aab53538b57eb11185ab2b
2016-09-20 11:30:20 +00:00
Gorka Eguileor
8b5a772e36 Make APIVersion's null check more pythonic
Our current APIVersion object has an is_null method to check when the
version instance is null (major=0 and minor=0).

While this works it is not very pythonic, since you have to write
expressions such as:

 if not min_version and not max_version:
     return True
 elif ((min_version and max_version) and
       max_version.is_null() and min_version.is_null()):
     return True

This patch removes the is_null method and instead implements the truth
value testing to simplify expressions and make code more pythonic.

So previous code would just look like:

 if not min_version and not max_version:
     return True

Because this will work with min_version being None or being an
APIVersion instance with major=0 and minor=0.

Change-Id: I7497c5dc940c1e726507117cadbad232d8c1d80d
2016-08-29 11:41:57 +02:00
Cao Shufeng
b76f594413 Add "start_version" and "end_version" support to argparse
Now, "cinder help subcommand" can not show whether an argument
is supported for a specific microversion.
With this change, developers only need to add a start_version or
end_version in the utils.arg wrap, cinderclient will support
the microversion for that arguement.

    @utils.arg(
    '--foo',
    start_version='3.1')
    @utils.arg(
    '--bar',
    start_version='3.2',
    end_version='3.5')
    def do_some_action():
        ......

In previous example, an exception will be raised for such command:
   $ cinder --os-volume-api-version 3.6 --bar some-ation

And only "--foo" will show up for such help command:
   $ cinder --os-volume-api-version 3.1 help some-ation

Change-Id: I74137486992846bbf9fdff53c009851db2356eef
Partial-Bug: #1600567
Co-Authored-By: Nate Potter <nathaniel.potter@intel.com>
2016-08-16 16:16:13 +00:00
dineshbhor
a635fd2199 Use 'six' instead of oslo_utils.strutils.six
'six' is an independent third party module so it doesn't
need to be imported and used from oslo_utils.strutils.

TrivialFix

Change-Id: Icb3232bb1ebae0e8332e66c5806474d7f9dfd6df
2016-08-08 09:22:29 +00:00
dineshbhor
29028b86b9 Use self.ks_logger instead of ks_logger
Currently with '--debug' option any cinder command only logs the
request from keystoneauth and not the main cinder service request.

Added keystoneauth logger to self.ks_logger so that logs can be
logged as expected.

Closes-Bug: #1606814

Change-Id: I7193aa6f43cb3186c49fc409b6e1ce7a36f596f9
2016-08-01 11:11:47 +05:30
Steve Martinelli
16f83c4a53 Switch to keystoneauth
move cinderclient to keystoneauth as keystoneclient's auth session,
plugins and adapter code has been deprecated.

Co-Authored-By: Paulo Ewerton <pauloewerton@lsd.ufcg.edu.br>
Co-Authored-By: Sean McGinnis <sean.mcginnis@gmail.com>
Co-Authored-By: Jamie Lennox <jamielennox@gmail.com>

Change-Id: Id4bf0e2088e8ad99e83cd4f9b8549c2aca1f65a2
2016-07-23 07:35:40 +10:00
Jenkins
b36ff1fc15 Merge "Fix authentication issue" 2016-07-15 20:58:36 +00:00
Jenkins
d96cc9fc08 Merge "OS_TENANT_NAME is not required when we have OS_PROJECT_NAME" 2016-07-15 20:58:19 +00:00
liyuanzhen
426055c48e OS_TENANT_NAME is not required when we have OS_PROJECT_NAME
Cinder support both v2 and v3 auth. Use v3 if possible.
In consideration of backwards compatibility, when we have
OS_PROJECT_NAME, the v2 auth should be ok because
tenant_name can be set by env[OS_PROJECT_NAME].


Change-Id: I9eed9c41a9deb5ecafa8d9e12f6d1b50d34f986d
Closes-Bug: #1588261
2016-07-07 07:01:30 +00:00
Abhishek Kekane
679cdd2451 Log request-id for each api call
Added new private method to log request-id of each api call
for both SessionClient and HTTPClient. Already available
ks_logger and client_logger will be used for SessionClient
and HTTPClient respectively.

Change-Id: I679c57b96071ecd9bcd1ab2ed50692195586ca52
Implements: blueprint log-request-id
2016-06-28 08:44:23 +00:00
Jenkins
a4109cc3bf Merge "Support --os-key option" 2016-05-18 14:46:23 +00:00
Cedric Brandily
80d3edc71e Support --os-key option
Currently we can specify a client certificate key using --os-key option
inherited from keystoneclient cli options but it has no effect because
keystoneclient Session expects as cert argument, one of the followings:
 * None (no client certificate),
 * a path to client certificate,
 * a tuple with client certificate/key paths.

The change updates cinderclient code to support the last case (ie:
os_cert and os_key are non-empty) in order to take into --os-key option
and OS_KEY environment variable.

Closes-Bug: #1564646
Change-Id: I258fd554ad2d6a5413ffe778acefa3a0b83e591f
2016-05-17 15:02:00 +02:00
Abhijeet Malawade
24deab1090 Fix authentication issue
Fix authentication issue if password is provided from tty prompt.
Set options.os_password to user input from prompt, as it gets
used to create auth object otherwise it will give authentication error.

Change-Id: I0246473f2165f1464d731e0ae9b4afa0b61dcbcc
Closes-Bug: #1575656
2016-04-27 06:37:19 +05:30
scottda
3f75b48f06 Support api-microversions
Changes to cinderclient to use microversions.

Implements: blueprint api-microversion-support-for-cinderclient
api-microversion-support-for-cinderclient

Change-Id: I840a1162b88e8ff36fa3fc4e1d6b9317104df3e0
2016-04-19 11:19:45 -06:00
scottda
27e6f6f7f8 Add /v3 endpoint support for cinderclient
Add support for Cinder API /v3 endpoint.
A couple of unit tests for /v3 endpoint were added to v3/test_shell.py
to ensure that the v3 shell works, and to also test that modules work
with:
from cinderclient.v2.availability_zones import *
syntax.

Change-Id: I6ae0ada221bebb4ab1850d9c99b10fcbb585201f
Implements: https://blueprints.launchpad.net/python-cinderclient/+spec/add-v3-endpoint-support
2016-04-18 10:49:51 -06:00
Ronald Bradford
74252d1abd Graduate to oslo.i18n and cleanup incubator usage
Graduate from Oslo Incubator to oslo.i18n library.
Cleanup of unused Oslo Incubator utils.
Added optional enable_lazy() usage.

Implements: blueprint graduate-oslo-i18n [1]
https://blueprints.launchpad.net/oslo-incubator/+spec/graduate-oslo-i18n

Change-Id: I9c8db9487b554b637a41620c858a7e7abf802879
2016-03-24 11:40:38 -04:00
Cory Stone
b670b73e44 Pass insecure option to HTTPClient
This option was silently being ignored.

Closes-Bug: #1538648
Change-Id: I3a1b5268e87cbc9803924be95b374d76b72a3a5d
2016-01-27 15:11:41 -06:00
huangtianhua
aa06b2dd54 Make _discover_extensions public
Heat wants to use
`cinderclient.shell.OpenStackCinderShell._discover_extensions`
function (https://bugs.launchpad.net/heat/+bug/1527071),
which is private currently. It's better to change this method
to public for public use.
This change will do it as novaclient did.

Change-Id: Iaaa4cab530fd495877e15a372fff1354ddbeaa17
Closes-Bug: #1527169
2016-01-06 01:30:46 +00:00
Ivan Kolodyazhny
1396308631 Set default service type to 'volumev2'
We are already use Cinder API v2 by default so it sould be consistent to
use 'volumev2' service type by default

Change-Id: I9f2da310f6ad53a40d476ede62369cc364371064
2015-12-29 16:56:10 +00:00
Eric Harney
6fe9f20663 Use oslo_utils encodeutils and strutils
With oslo-incubator being deprecated, move
our use of strutils to oslo_utils.

This leaves in place the use of oslo-incubator's
strutils by other oslo-incubator modules for now.

Change-Id: Ic4e50060b42aeca9d1e54424a8a3a123140fbf2a
2015-11-23 10:44:12 -05:00
Tom Hancock
a3610f045d Fully support os-endpoint-type
Fix Change-Id: I98a8507f2369deff6a6f7f8f08271b169fe651ad for bug #1454436
doesnt allow OS_ENDPOINT_TYPE environment variable to be used as a default
for --os-endpoint-type as argparse takes the first definition of the
default expression for dest=os_endpoint_type

Closes-bug: 1500489
Change-Id: I76cc963b10bc7a549fe5a0cd2c73dfc6a30bb759
2015-09-28 16:36:09 +01:00
chenying
dba302e1dd Add a period for the description string of a argument
This change add a period for the description string of
a argument that gets dropped.

Closes-Bug: #1489317
Change-Id: Ica1a74625a640f8d664f5ca183ada14ef63be077
2015-09-06 02:28:07 +00:00
Ivan Kolodyazhny
04caf88307 Set default OS_VOLUME_API_VERSION to '2'
Cinder API v1.1 is deprecated and will be removed. Switching to API v2 in
cinderclient makes it works well with new API after API v1 will be
removed.

Change-Id: I639f4b54dc7e220e8e351113a4de1dff104b50a7
2015-07-30 18:24:57 +03:00
Jenkins
a0f13ea8f1 Merge "Remove unnecessary check for tenant information" 2015-07-20 13:05:41 +00:00
Jenkins
159783743e Merge "Use shared shell arguments provided by Session" 2015-07-16 22:03:34 +00:00
Ian Cordasco
8afc06c562 Remove unnecessary check for tenant information
Keystone v3 has changed the name of tenants to projects which means that
OS_TENANT_NAME is meaningless in a cloud where v3 is the default
authentication version. As such, if a user does not have OS_TENANT_NAME
enabled, cinderclient will not work even though it has checks for v3
immediately below this check (and the same check replicated further
below that). Removing this allows cinderclient to work with Keystone v3
without setting OS_TENANT_NAME unnecessarily.

Further, the check for project information was incorrectly referring to
project_domain_name and project_domain_id instead of
os_project_domain_name and os_project_domain_id.

Closes-bug: 1472636
Change-Id: Ifabb4a2aec070c00349e794364a71394feea99f1
2015-07-08 12:11:07 -05:00
Mike Perez
1f52746bcb Revert "Enable version discovery"
This reverts commit ae03d2a721bd9acb61805ce792a27fb7cf88e5cd.

Cases where a deployment is using a proxy, Cinder servers won't return
the expected publicURL, and instead gives an internal URL that the
client can't use.

Commit 2eb25ab8803214cb3beb5d8fe3efbf70a462c414 in Cinder introduces the
public_endpoint config option, but not everyone is expected to be
running that later of a version to take advantage of this.

Closes-Bug: #1464160
Change-Id: I61228c1e8630b958c792be077674b48fbdb83135
2015-07-02 11:57:33 -06:00
Michal Dulko
891ef3e71e Use shared shell arguments provided by Session
The cinderclient implemented it's own version of the CLI arguments that
are now provided by keystoneclient's session object. This changeset
converts cinder over to utilizing the shared argument registration.

Closes-Bug: 1434105
Change-Id: I72b16aab909d72a47097434436093e616667634a
2015-06-25 13:27:42 +00:00
scottda
a609eda7b4 cinderclient does not honor --os-region-name or ENV[OS_REGION_NAME]
When we use version discovery, we must pass in os-region-name for it
to work.

Change-Id: I82765f7a899d84283dd3a3672f6e151805c1c6fa
Fixes: bug 1467628
2015-06-22 18:26:04 +00:00
Jenkins
c0c5c984bb Merge "cinderclient deprecated endpoint_type needs dest=" 2015-06-16 19:07:31 +00:00
Jenkins
e88c96e18e Merge "Avoid _get_keystone_session() if auth_plugin" 2015-06-02 04:18:30 +00:00
Tomoki Sekiyama
2f97e1e3ca Bump hacking to >=0.10.0,<0.11 to fix failure of gate pep8
pbr 1.0.1 released in 2015-05-19 requires the newer
hacking module >=0.10.0,<0.11 than the versions
specified in the test-requirement.txt file,
which causes failure in gate-python-cinderclient-pep8.

This patch bumps the pbr version in test-requirement.txt
to make it consistent with requirements repository,
and adds some fixups to avoid some new hacking rules.

Change-Id: I7de6e04e30a475ec1c26224461faf0c708178a40
Closes-Bug: #1460774
2015-06-01 15:33:03 -04:00
Jenkins
a15c74361c Merge "cinderclient no longer honors --endpoint-type" 2015-05-13 16:24:04 +00:00
scottda
be46cdb711 cinderclient deprecated endpoint_type needs dest=
Fix for https://bugs.launchpad.net/python-cinderclient/+bug/1453901 did
not set dest=os_endpoint_type for synonym endpoint_type

Change-Id: I98a8507f2369deff6a6f7f8f08271b169fe651ad
Closes-Bug: 1454436
2015-05-12 22:49:24 +00:00
scottda
adc561a7b1 cinderclient no longer honors --endpoint-type
Commit for "Enable version discovery":
ae03d2a721bd9acb61805ce792a27fb7cf88e5cd
breaks CLI use of --endpoint-type. This is because we were using the
default interface instead of checking to see if an endpoint_type is
passed in.

Change-Id: I412bb6b4bcb9bf10aa6118a2ed43e28cbd3ed236
Closes-Bug: 1454407
2015-05-12 21:39:51 +00:00
scottda
24aff3b796 Add --os-endpoint-type to match other services
Cinder uses the parameter '--endpoint-type' but other services
 (Glance, Nova, Swift) use '--os-endpoint-type'. (Neutron has deprecated
 'endpoint-type' in favor or 'os-endpoint-type' as well.
'--endpoint-type' should be deprecated and 'os-endpoint-type' should
be added.

Change-Id: I0ac6573be35c86b9f764a39f1e60486d2345f51b
Closes-Bug: #1453901
2015-05-12 15:21:12 +00:00
Derrick J. Wippler
e3a0556e56 Avoid _get_keystone_session() if auth_plugin
Avoid calling _get_keystone_session() if auth_plugin is provided by the
user

Closes-Bug: 1421433
Change-Id: I37a7139107c357caf1a25ac3d0a3457afade0f83
2015-05-07 14:46:55 -05:00
Mike Perez
ae03d2a721 Enable version discovery
The service catalog can now have the cinder endpoint x.x.x.x:8776 with
service_type volume, without needing to specify a version in the
endpoint. Keystone will do discovery of the root / GET of the Cinder API
to discover the versions that can be talked to.

This also provides backwards compatibility for the previous solution of
having v1 enabled on service_type volume and v2 on service_type
volumev2.

Change-Id: Id0347f8370dbc8fd7fa8096cd5859e10b0c5d67c
2015-04-20 15:50:08 +00:00
Jenkins
7c68f6f6df Merge "cinderclient accepts arguments after metadata without -- separator" 2015-03-16 16:52:02 +00:00
rajiv
57c9bf17b3 cinderclient accepts arguments after metadata without -- separator
Added a function, which parse arguments and add -- separator
after metadata subcommand

Change-Id: I907eb89209d549dcdad361d88352491110eaadb9
Closes-Bug: #1379486
2015-03-10 09:45:00 +05:30
Kallebe Monteiro
d76387cc9f Add -d short option for --debug
A short option for --debug is a convenience.
This commit adds the -d short option as a shortcut for --debug

Glance already provides -d.

Change-Id: Iefae6cee566f9c7d7375e89c3f8603f149e555ef
Closes-Bug: #1421210
2015-02-12 10:52:17 -03:00
Vincent Hou
7a50182fbe Add the parameter bypass_url to the cinder client
If the bypass_url is specified in the http client, there is no need
to get it from Keystone.

Change-Id: I891849f77ad2ba98a83c993b401121216c8cfff6
closes-bug: #1350702
2014-12-01 02:43:52 +00:00
John Trowbridge
122bf5bdcc Adds tty password entry for cinderclient
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: If5b27cb8c67712860faa24d543ed48eaa542f28b
Closes-Bug: 1357559
2014-10-24 15:43:04 +00:00
Boris Pavlovic
6f5fd37ee9 Add profiling support to cinderclient
To be able to create profiling traces for Cinder, client should be
able to send special HTTP header that contains trace info.

This patch is as well important to be able to make cross project
traces. (Typical case nova calls cinder via python client, if
profiler is initialized in nova, cinder client will add extra
header, that will be parsed by special osprofiler middleware in cinder
api)

Don't worry no security issue here, trace information is signed by HMAC
key that is setted in api-paste.ini. So only person that knows HMAC key
is able to send proper header.

Main patch (in Cinder) is:
https://review.openstack.org/#/c/103415/

Change-Id: I53bb1b92e62841a02f941bdafaed7f8ed5db7ce1
2014-10-08 19:30:10 +04:00
git-harry
36dd138aa6 Enables debug mode for keystone session object
This fixes the lack of debug messages introduced by commit 84af49c.

Change-Id: I7bf3e98c21f09bd4f3c2d5d3bc372f60d717c9d5
Closes-bug: #1370152
2014-09-18 17:14:19 +01:00
Jamie Lennox
b4acbd2586 Move debug logging to shell
Adding channels to a logger is not the responsibility of a library. This
sort of thing should be handled by an application so move the logging
over to the shell.

Change-Id: Ie11571d428913eba1aae5aa42a6e925228ba6808
2014-07-29 12:26:33 -06:00
Haneef Ali
b4906c855f Fix version discovery and auth_plugins
V3Client support added version discovery and session supports. Most
of the external auth system doesn't support this. This fix bypasses
version discovery if the idenity service doesn't support that. Session
is used only if  no external auth plugin is used

Change-Id: Ia84a2ad45940d35c5ef740727f5f7477c72ea9d4
Closes-Bug: #1333961
2014-07-01 09:22:06 -07:00