20 Commits

Author SHA1 Message Date
lihaijing
d15bbada73 Replace six.iteritems() with .items()
1. As mentioned in [1], we should avoid using six.iteritems to achieve
   iterators. We can use dict.items instead, as it will return iterators
   in PY3 as well. And dict.items/keys will more readable.

2. In py2, the performance about list should be negligible,
   see the link [2].

[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: I4b9edb326444264c0f6c4ad281acaac356a07e85
Implements: blueprint replace-iteritems-with-items
2020-01-09 18:41:29 +09:00
Akihiro Motoki
1af3056e30 Use cliff formattable columns in volume v1 commands
Partial-Bug: #1687955
Partially implement blueprint osc-formattable-columns

Change-Id: Ib4c5798171e32a8ddc08a37ee1d416e366a71d76
2019-06-22 14:53:28 -05:00
Dean Troyer
2c5405ed5e Fix volume qos spec list
This has been sporadically failing in functional tests due to the way
the volume qos spec list command calls get_associations() for each spec.
When tests run in parallel occasionally a spec from another test is present
in the list returned and is deleted before the get_associations() call is
made, causing a NotFound exception.  We should just keep going when this
occurs.

* make v1 match v2
* add tests to ensure the exception is being caught and handled

Closes-Bug: #1687083
Change-Id: If2d17c1deb53d293fc2c7f0c527a4e4ef6f69976
2017-04-28 16:06:00 -05:00
Huanxuan Ao
1be6c2d92f Fix properties format for volume qos in volume v1
Notice that patch [1] fixed the error of properties
format for volume qos in volume v2, but there is the
same bug in volume v1, and the patch missed that, so
fix the problem in v1 as well

[1] https://review.openstack.org/#/c/421065/

Partial-Bug: #1656767
Change-Id: I156bf13d164dbd0d0a7ce394964176718c4ff0e5
2017-02-21 19:34:15 +08:00
Steve Martinelli
0ef8535036 translate all command help strings
Leverage the new cliff command class attribute (_description)
to get the help of a command, this allows us to mark strings
for translation. We could not do this before since the help
was grabbed from the docstring.

This also depends on a new release of cliff and a bump to the
minimum level in osc's requirements.

Closes-Bug: 1636209
Depends-On: Id915f6aa7d95a0ff3dc6e2ceaac5decb3f3bf0da
Change-Id: I8673080bb5625e8e3c499feaefd42dfc7121e96f
2016-11-17 02:33:42 +00:00
Huanxuan Ao
fd876e4cc6 Fix unset commands to pass normally when nothing specified
After I found this problem appear in "volume unset",
I checked all the volume command and also found some
same problems. This patch fix them all.
The main reason of we ignored this problem before is
there was not any tests for it. So I add tests for
"nothing unset" for them all to test and aviod this
problem.
Also, I add unit tests for all snapshot commands
in volume v1 by the way in this patch. We will
need more tests to avoid some ignored problem.

Change-Id: I46775f24643d715e168b30785b8b531c0431a55b
Partial-bug: #1588588
2016-09-23 13:20:51 +08:00
Huanxuan Ao
af81a92c37 Support error handling for delete commands in volume v1
Some delete commands in volume v1 support multi delete
but do not support error handling, this patch fixes them,
and this patch also refactor (or add new) unit tests for
some delete commands in volume v1.

Change-Id: Ia8177698f8733cfe75ea0ff00eee8fdc0820f62e
2016-09-11 11:08:14 +08:00
Huanxuan Ao
4e46c04f92 Add "--force" option to "volume qos delete" command
Add ``--force`` option to ``volume qos delete`` command in volume
v1 and v2 to allow users to delete in-use QoS specification(s).

Change-Id: I46036e5f55ced8b8a1be54c521f2a5c242b89160
Closes-Bug: #1596821
2016-06-28 08:12:40 +00:00
Dean Troyer
9e2b8e6730 osc-lib: command
Leave command.py and test_command.py as a sanity check during the
deprecation period.

Change-Id: I24e1b755cbfbcbcaeb5273ec0c9706b82384fc85
2016-06-13 11:00:22 -05:00
Dean Troyer
be192676bd osc-lib: parseractions
Leave parseractions.py and test_parseractions.py as a sanity check during the
deprecation period.

Change-Id: I1a7469b6d872284e0276502a1a287bc0b87f8f83
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
Tang Chen
2672e37ee2 Make set/unset commands in volume return normally when nothing specified
set/unset commands should ends up normally instead of
logging an error when nothing is specified to modify.
The main reason is: When nothing is specified, the
command sets/unsets nothing, which is a normal behavior,
and ends up normally. No API call fails. No error happens.

Change-Id: Ib03a512650e5da90aa1ef38019772448383d0d33
Partial-bug: #1588588
2016-06-04 21:29:44 +08:00
Sheel Rana
53e05e7c2d i18n support for help and error messages in cinder
Change-Id: I98fbc959034fe0530966291643b381855801de20
2016-05-23 18:04:36 +00:00
Akihiro Motoki
258c1102cc log take_action parameters in a single place
Previously each command logs take_action parameters explicitly
by using @utils.log_method decorator or log.debug().
Some commands have no logging.

This commit calls a logger in the base class and
drops all logging definition from individual commands.

Closes-Bug: #1532294
Change-Id: I43cd0290a4353c68c075bade9571c940733da1be
2016-02-02 09:58:32 +09:00
Tang Chen
f552302b61 Trivial: Remove useless return from files in image and volume
Change-Id: I3526ecd202d0908d91305a066ad72d03cee794b5
2015-12-18 23:25:05 +08:00
Joshua Harlow
e3c46ece4a Use a common decorator to log 'take_action' activation
Instead of duplicating the same log statement throughout
the code, the same logic can be provided by a shared decorator
that abstracts away the logging capability and unifies it behind
a common function instead.

Change-Id: Icc63bced7347c8bbf0299a4c5821425a10892a79
2015-09-01 16:49:54 -07:00
TerryHowe
abfb011527 Support multiple volume qos delete
Also make sure that we are using the singular qos_spec when
we should and the plural qos_specs otherwise.

Change-Id: If4bbeb6fc245d7d80dc3d7dccfe9f949e802653c
2015-07-17 14:14:56 +00:00
Steve Martinelli
36613f9f53 No need for get_parser on QoS list
There are no arguments so there's no need to define the
get_parser function.

Change-Id: Icfa8accf6dbb7f8d1a0472926403b405da3cc611
2015-06-28 23:43:39 -04:00
Steve Martinelli
1d51eb82d0 Alphabetize QoS specs
setup.cfg and the implementation had some functions that were
not in alphabetical order. Since the rest of OSC is alphabetized,
let's stick to that.

Change-Id: Ief5d4694c7b6bc20a0898437b96305885104d45c
2015-06-28 23:42:55 -04:00
David Moreau Simard
7bb038c4a7 Add support for volume API v1 QoS commands
This commit adds the following commands:
  volume qos associate
  volume qos create
  volume qos delete
  volume qos disassociate
  volume qos list
  volume qos set
  volume qos show
  volume qos unset

Change-Id: I72ea1b9a4d0bd0e35eda03071ea438b75439fce9
Partial-Bug: #1467967
2015-06-26 23:19:08 -04:00