134 Commits

Author SHA1 Message Date
qinchunhua
6f36385cb8 Correct reraising of exception
When an exception was caught and rethrown,
it should call 'raise' without any arguments
because it shows the place where an exception
occured initially instead of place where the exception re-raised.

Change-Id: I5fb6dea5da7fb6e1e2b339a713c7d37f8c99e407
2016-07-07 15:05:58 +00:00
Dolph Mathews
fe0c8e955b Do not prompt for scope options with default scoped tokens
This changes the scope validation to occur after a token has already
been created.

Previous flow:

1. Validate authentication options.
2. Validate authorization options if the command requires a scope.
3. Create a token (using authentication + authorization options)
4. Run command.

This means that scope was being checked, even if a default scope was
applied in step 3 by Keystone.

New flow:

1. Validate authentication options.
2. Create token (using authentication + authorization options)
3  Validate authorization options if the command requires a scope and
   the token is not scoped.
4. Run command.

Change-Id: Idae368a11249f425b14b891fc68b4176e2b3e981
Closes-Bug: 1592062
2016-06-17 12:37:15 -04:00
Huanxuan Ao
f25a3519c5 Fix missing i18n supports in api/ and shell.py
Change-Id: I28d79d7f44b27d2b600dedad2a3601180650ad83
Partial-bug: #1574965
2016-06-14 11:03:56 -05:00
Dean Troyer
a55eb915a0 osc-lib: timing
Change-Id: I3fe27d98efa5090e084c676f7f8e6dad0157ed21
2016-06-13 11:08:21 -05:00
Dean Troyer
59dffb9c62 osc-lib: logs
Change-Id: I2a4d40cd72cc22e97a600751ae29c2309ebed28b
2016-06-13 10:55:44 -05:00
Dean Troyer
e5e29a8fef osc-lib: utils
Use osc-lib directly for utils.

Leave openstackclient.common.utils for deprecation period.

Change-Id: I5bd9579abc4e07f45219ccd0565626e6667472f7
2016-06-13 10:50:44 -05:00
Dean Troyer
d20c863ebc osc-lib: exceptions
Use osc-lib directly for exceptions.

Leave openstackclient.common.exceptions for deprecation period.

Change-Id: Iea3e862302372e1b31ccd27f69db59b4953ca828
2016-06-13 10:50:01 -05:00
Richard Theis
6f2c1734e3 Fix --enable options on commands
The --enable option on commands is ignored when the arguments are parsed.
This is related to the --enable-beta-commands option. Renaming the option
to --os-beta-command fixes the problem.

There's no need to handle backwards compatibility for the option name
change because there hasn't been an OSC release yet with beta commands.

Change-Id: I0327ba8a2058858a83e9a42e231470ed733cc834
Closes-Bug: #1588384
2016-06-02 10:07:34 -05:00
Richard Theis
1a2e12832d Devref: Command Beta
The devref proposes OSC support for beta commands.

Change-Id: I538a38be33734faf6eb69a3cb50946b2396b0c57
2016-04-21 12:14:42 -05:00
Dean Troyer
530fe42589 Rename --profile to --os-profile
* The --profile global option is deprecated but will be supported
  through at least April 2017.
* Update man page

Closes-bug: #1571812
Change-Id: I2e623411a56096b4cc352f4eedbf770632ae2cc3
2016-04-19 07:50:42 -05:00
Cedric Brandily
3a8320a1d7 Support client certificate/key
This change enables to specify a client certificate/key with:
 * usual CLI options (--os-cert/--os-key)
 * usual environment variables ($OS_CERT/$OS_KEY)
 * os-client-config

Change-Id: Ibeaaa5897ae37b37c1e91f3e47076e4e8e4a8ded
Closes-Bug: #1565112
2016-04-06 20:21:19 +02:00
Tang Chen
dc7e4fc15d Fix dict.keys() compatibility for python 3
In Python 2, dict.keys() will return a list.
But in Python 3, it will return an iterator.
So we need to fix all the places that assuming
dict.keys() is a list.

Change-Id: I8d1cc536377b3e5c644cfaa0892e40d0bd7c11b1
Closes-Bug: #1556350
2016-03-12 10:58:28 +08:00
Dina Belova
8a839ad8b8 Fix regression in interactive client mode
Fix typo introduced in OSprofiler intergation commit, that
leaded to non-working interactive mode of the CLI client.

Change-Id: If5dfc90dbbe64d4665c3e33e936f0cc674738351
Closes-Bug: 1551160
2016-03-01 13:45:19 +03:00
Jenkins
2819450be5 Merge "Add shell --profile option to trigger osprofiler from CLI" 2016-02-26 19:49:21 +00:00
Dina Belova
16f00833a7 Add shell --profile option to trigger osprofiler from CLI
This will allow to trigger profiling of various services that
allow it currently and which APIs support is added to openstackclient.
Cinder and Glance have osprofiler support already, Nova and Keystone
are in progress.

To use this functionality osprofiler (and its storage backend) needs
to be installed in the environment. If so, you will be able to trigger
profiling via the following command, for example:

$ openstack --profile SECRET_KEY user list

At the end of output there will be message with <trace_id>, and
to plot nice HTML graphs the following command should be used:

$ osprofiler trace show <trace_id> --html --out result.html

Related Keystone change: https://review.openstack.org/#/c/103368/
Related Nova change: https://review.openstack.org/#/c/254703/

The similar change to the keystoneclient
(https://review.openstack.org/#/c/255308/) was abandoned as new
CLI extenstions are not more accepted to python-keystoneclient.

Change-Id: I3d6ac613e5da70619d0a4781e5d066fde073b407
2016-02-25 20:13:27 +00:00
guang-yee
41e1bd0be6 Support unscoped token request
Make scope check optional for the "token issue" command as unscoped token is
a valid Keystone V2/V3 API.

Change-Id: Ie1cded4dbfdafd3a78c0ebdf89e3f66762509930
Closes-Bug: #1543214
2016-02-19 16:07:13 -08:00
Hideki Saito
e5b8e08eb1 Fix 'openstack --help' fails if clouds.yaml cannot be read
'openstack --help' can display the basic information, even if
 openstack command does not have permission to read clouds.yaml.

Change-Id: I7d5255c5ce3bd60af77fc70f433ca78dc011a79f
Closes-Bug: #1541047
2016-02-14 22:08:01 +09:00
Terry Howe
2348617606 The format_exc method does not take an exception
For py35, this call blows up.  Seems to be ignored for py27, but
even in py27, it doesn't take an exception.

https://docs.python.org/2.7/library/traceback.html
https://docs.python.org/3/library/traceback.html

Change-Id: I2602426b966045b15b96e5e41d0df6524ed05119
2015-12-08 09:23:47 -07:00
TerryHowe
2f00fcda77 Allow int version numbers in the clouds.yaml
OSC blows up if you try to use for example identity_api_version: 2
in the clouds.yaml.  It will only work with a string '2'.  This
fixes that.

Change-Id: I785d37a288126a1582464e907c7f9c9947bac27c
2015-11-04 11:20:43 -07:00
Jenkins
cb28cd9ac0 Merge "Rename context.py to logs.py" 2015-10-30 11:02:08 +00:00
Jenkins
17ebd15a13 Merge "Allow debug to be set in configuration file" 2015-10-30 09:08:37 +00:00
Terry Howe
05800c4722 Rename context.py to logs.py
At one point this file contained the context for logging, but
the reason for its existence is now for logging.

Implements: blueprint logging-migration

Change-Id: I4ba42bbef97b09d31236ac8c01b6fb23827b8bee
2015-10-30 17:38:42 +09:00
TerryHowe
bfebac8282 Allow debug to be set in configuration file
The current default value for debug in cliff is False.  Cloud
config assumes that it was set that way on the command line and
does not overlay it with the value from the configuration file.
Cliff bug:

https://bugs.launchpad.net/python-cliff/+bug/1483378

Change-Id: I66d82b489b2241dbcd1e1350e94259a54ce09de7
2015-10-30 11:16:36 +09:00
lin-hua-cheng
f0a81c284d Mask the sensitive values in debug log
Change-Id: I0eb11a648c3be21749690f079229c8e63a678e6c
Closes-Bug: #1501598
2015-10-12 16:55:48 -07:00
Jenkins
678e690648 Merge "Override the debug default and help text" 2015-09-24 21:47:33 +00:00
Jenkins
2616fdb089 Merge "Set default auth plugin back to 'password'" 2015-09-21 14:40:18 +00:00
Dean Troyer
d6788f7e75 Move option logging back to start if initialize_app()
The log for the options should be printed early enough to see what
is being passed in to occ.

Change-Id: I97b09bc28abcd485b6793d0223b9f8602237fd80
2015-09-18 14:29:01 -05:00
Dean Troyer
b1972fb561 Set default auth plugin back to 'password'
This was a hack that should be less needed now...

Change-Id: Id8cba87ad05b106aa36e356c0d70a568316fd327
2015-09-18 14:17:05 -05:00
Jenkins
46696f5ed5 Merge "Create log configuration class" 2015-09-09 20:15:54 +00:00
Jenkins
67387ba9cd Merge "Move options to log level out of shell.py" 2015-09-09 19:46:28 +00:00
Jenkins
1a2bb48432 Merge "Move set warnings filters to logging module" 2015-09-08 22:06:02 +00:00
Jenkins
24ca952eb6 Merge "Set up every time record log in file" 2015-09-08 20:22:24 +00:00
Dean Troyer
3abfea083a Fix compute API version snafu
novaclient 2.27.0 introduced the API microversion discovery and client.Client
now wants an api_version argument to properly work out the correct API
version in use.  OSC needs to provide this when required.

Letting the compute client plugin do the version validity checking makes more
sense than encoding it into shell.py, so I've added a new OSC plugin interface
function check_api_version() that is called from shell.py if it exists.  If it
either does not exist or it returns False the previous version checking using
API_VERSIONS is still performed.

compute.client.check_api_version() conditionally imports the new
novaclient.api_versions module and uses it if successful.  Otherwise
check_api_version() returns False and the previous code path is resumed.

One side-effect of this is that it is now valid to use --os-compute-api-version
with any valid microversion supported by the installed python-novaclient.

Closes-Bug: #1492467
Change-Id: I4535b38a5639a03a9597bf83f6394f9bb45c2b9e
2015-09-04 16:25:55 -05:00
TerryHowe
85a03945f0 Create log configuration class
Configuration of logging gets triggered twice.  The first time it
uses the CLI options when the application is started and second
it uses the configuration file after that is read.  The state of
the logging needs to be saved from the first to the second time,
so I created a class.

Implements: blueprint logging-migration

Change-Id: I7b8d1a3b6fd128e98cafd7c16009c7b694a52146
2015-08-26 10:23:53 +00:00
TerryHowe
00eebaf5bc Override the debug default and help text
Cliff sets the default debug value to False and this makes it
impossible to override debug with OCC.  If we set the default to
None, we can override debug in clouds.yaml.  Also, OSC changes
the meaning of --debug, so modify the help text.

Change-Id: I5e6680b2286cd7f55afe4b083fae5f8a4a9567a2
Closes-Bug: #1483378
2015-08-18 17:22:34 +00:00
TerryHowe
ca9965c328 Move options to log level out of shell.py
Move the conversion of command line options to log level out
of shell.py.

Change-Id: I86cb45a85cd63927aa1c87c1eed27542981df659
Implements: blueprint logging-migration
2015-08-13 16:11:25 -06:00
TerryHowe
9c3c336391 Move set warnings filters to logging module
This is the first step in moving logging out of shell.py

Change-Id: I3dcb4e17bb4687988ddf9b793ad1a308ef89b242
Implements: blueprint logging-migration
2015-08-13 16:05:01 -06:00
Daisuke Fujita
e23dd6de58 Set up every time record log in file
This will allow users to record logs of all their commands into
a predefined log file, in clouds.yaml. The log should have a
format similar to that of oslo.log.

Change-Id: I1b334bf429d575fc25809c9706fc0b11116be3f1
Implements: blueprint every-time-record-log-in-file
2015-08-08 10:02:46 -06:00
Jenkins
55d9eba093 Merge "Do not set default versions in parsed args" 2015-07-24 19:51:30 +00:00
Javier Pena
c5b4383160 Fix the way auth_type default value is overriden
Commit 50f05448982b5fafd9d9a7783b639dd145090a0d to os-client-config
removed the default values in the _defaults dict. This makes any
call to cloud_config.set_default() before initializing the dict
fail.

The fix changes the way the auth_type default is overriden, by
doing it when cloud_config.OpenStackConfig() is executed.

Change-Id: If37d3ba303f01d4c77fd7c15a3cde9634534b64a
Closes-bug: #1473921
2015-07-20 15:29:41 +02:00
TerryHowe
b3335b3474 Do not set default versions in parsed args
Setting default versions in parsed args makes it so OCC
cannot tell if the argument was parsed, an environment
variable was set or it is just defaulted.  In order to
set api versions from OCC, it will have to be defaulted
after processing OCC.

Closes-Bug: #1453229
Change-Id: I4d065919397b783f3bdd4022c986c0234a7a16e6
2015-07-18 06:28:09 -06:00
TerryHowe
36391a81a3 Rename endpoint type to interface
Change-Id: I4e21d09bc747e8210f4f79a1d6c4c7ccf2f25d1c
Closes-Bug: #1454392
2015-07-15 10:11:59 -06:00
Jenkins
ee64c2fa6b Merge "Add --os-endpoint-type cli optional argument" 2015-07-03 02:48:47 +00:00
Roxana Gherle
5521e4c504 Add --os-endpoint-type cli optional argument
User should be able to specify the endpoint type through
a CLI optional argument/ENV variable setting. We will name this new
optional argument: --os-endpoint-type (Env: OS_ENDPOINT_TYPE) and
based on the value given, the service API will use that specific
endpoint type. Possible values: public, admin, internal.

DocImpact
Closes-Bug: #1454392
Change-Id: Ife3d4e46b44c0ddcd712b1130e27e362545a9a29
2015-07-02 10:10:46 -07:00
Dave Chen
b3289601c7 Fix the typo in openstackclient/shell.py
Change-Id: Ia101f6d50ecd4a195aa93b1f289def581b0c6f38
2015-06-14 14:59:38 +08:00
Dean Troyer
31d785ec69 Allow --insecure to override --os-cacert
Change --insecure to ignore the --os-cacert setting.  This is a change
from before where OSC followed the requests pattern of cacert taking
priority.

This logic is also introduced in os-client-config 1.3.0; we
do not require that release yet so it is duplicated here for now.
That change will come with the upcoming global options refactor.

Closes-Bug: #1447784
Change-Id: Iaa6d499ed0929c00a56dcd92a2017487c702774a
2015-06-04 09:37:46 -05:00
Dean Troyer
a05cbf4c99 Rework shell tests
This is the first step in reworking the shell argument handling,
clean up and add tests to ensure functionality doesn't change.

* Rework shell tests to break down global options and auth options.
* Make tests table-driven
* Remove 'os_' from 'cacert' and 'default_domain' internal option names

Change-Id: Icf69c7e84f3f44b366fe64b6bbf4e3fe958eb302
2015-06-02 09:49:17 -05:00
Jenkins
9bf24f3ae1 Merge "Set tenant options on parsed namespace" 2015-06-02 02:15:52 +00:00
Jamie Lennox
3ae247fdce Set tenant options on parsed namespace
Because of the way OSC registers all plugins together we end up
with os-tenant-X parameters being saved to the project-X attribute after
parsing. If you are using the v2 plugins directly then they and os-client-config
expect the tenant_X values and will assuming no scoping information if
they are not present.

Validating options for scope will also fail in this situation, not just
because the resultant auth dictionary is missing the tenant-X
attributes, but because OSC validates that either project or domain
scope information is present.

Fix this by just always setting the v2 parameters if the v3 parameters
are present. This will have no effect on the generic or v3 case but fix
the v2 case.

Expand validation to include the tenant options so it knows that v2
plugins are scoped.

Change-Id: I8cab3e423663f801cbf2d83106c671bddc58d7e6
Closes-Bug: #1460369
2015-05-31 15:03:42 +10:00
Dean Troyer
2c4b87869b Add cli tests for --verify and friends
The tests that will change after the verify-always-true bug is fixed
are currently commented out.  The commented asserts show where we
want to go.

Also fixes --verify parser value

Change-Id: I891e3ead5fc3da3ed2ecba5d2befd9e910778655
2015-05-28 18:01:49 -05:00