Add options to "volume type list" command
Add "--public" and "--private" options to "volume type command" in volumev2 (v2 only) to list optional volume types Change-Id: I8605990d62116c10d89ce192c14e550657dabee5 Closes-Bug: #1597198
This commit is contained in:
parent
9f6148132c
commit
e31408d2a4
@ -71,11 +71,24 @@ List volume types
|
||||
|
||||
os volume type list
|
||||
[--long]
|
||||
[--public | --private]
|
||||
|
||||
.. option:: --long
|
||||
|
||||
List additional fields in output
|
||||
|
||||
.. option:: --public
|
||||
|
||||
List only public types
|
||||
|
||||
*Volume version 2 only*
|
||||
|
||||
.. option:: --private
|
||||
|
||||
List only private types (admin only)
|
||||
|
||||
*Volume version 2 only*
|
||||
|
||||
volume type set
|
||||
---------------
|
||||
|
||||
|
@ -176,23 +176,50 @@ class TestTypeList(TestType):
|
||||
def test_type_list_without_options(self):
|
||||
arglist = []
|
||||
verifylist = [
|
||||
("long", False)
|
||||
("long", False),
|
||||
("private", False),
|
||||
("public", False),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.types_mock.list.assert_called_once_with(is_public=None)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
||||
def test_type_list_with_options(self):
|
||||
arglist = ["--long"]
|
||||
verifylist = [("long", True)]
|
||||
arglist = [
|
||||
"--long",
|
||||
"--public",
|
||||
]
|
||||
verifylist = [
|
||||
("long", True),
|
||||
("private", False),
|
||||
("public", True),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.types_mock.list.assert_called_once_with(is_public=True)
|
||||
self.assertEqual(self.columns_long, columns)
|
||||
self.assertEqual(self.data_long, list(data))
|
||||
|
||||
def test_type_list_with_private_option(self):
|
||||
arglist = [
|
||||
"--private",
|
||||
]
|
||||
verifylist = [
|
||||
("long", False),
|
||||
("private", True),
|
||||
("public", False),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.types_mock.list.assert_called_once_with(is_public=False)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
||||
|
||||
class TestTypeSet(TestType):
|
||||
|
||||
|
@ -135,6 +135,17 @@ class ListVolumeType(command.Lister):
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_('List additional fields in output'))
|
||||
public_group = parser.add_mutually_exclusive_group()
|
||||
public_group.add_argument(
|
||||
"--public",
|
||||
action="store_true",
|
||||
help=_("List only public types")
|
||||
)
|
||||
public_group.add_argument(
|
||||
"--private",
|
||||
action="store_true",
|
||||
help=_("List only private types (admin only)")
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -144,7 +155,14 @@ class ListVolumeType(command.Lister):
|
||||
else:
|
||||
columns = ['ID', 'Name']
|
||||
column_headers = columns
|
||||
data = self.app.client_manager.volume.volume_types.list()
|
||||
|
||||
is_public = None
|
||||
if parsed_args.public:
|
||||
is_public = True
|
||||
if parsed_args.private:
|
||||
is_public = False
|
||||
data = self.app.client_manager.volume.volume_types.list(
|
||||
is_public=is_public)
|
||||
return (column_headers,
|
||||
(utils.get_item_properties(
|
||||
s, columns,
|
||||
|
5
releasenotes/notes/bug-1597198-e36b55f3fd185a3a.yaml
Normal file
5
releasenotes/notes/bug-1597198-e36b55f3fd185a3a.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``--public`` and ``--private`` options to ``volume type list`` command.
|
||||
[Bug `1597198 <https://bugs.launchpad.net/bugs/1597198>`_]
|
Loading…
Reference in New Issue
Block a user