diff options
| author | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-07-18 15:14:51 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-07-23 11:26:49 +0800 |
| commit | e31408d2a4c524181c37ef565b021c0b729cbbe3 (patch) | |
| tree | fd4096577a1606bef30620e9b70a6cecc30989b1 /openstackclient | |
| parent | 9f6148132cc21a6f78b5ebb7c1282b30a309ef8a (diff) | |
| download | python-openstackclient-e31408d2a4c524181c37ef565b021c0b729cbbe3.tar.gz | |
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
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/tests/volume/v2/test_type.py | 33 | ||||
| -rw-r--r-- | openstackclient/volume/v2/volume_type.py | 20 |
2 files changed, 49 insertions, 4 deletions
diff --git a/openstackclient/tests/volume/v2/test_type.py b/openstackclient/tests/volume/v2/test_type.py index 174f33f2..e1c2c1db 100644 --- a/openstackclient/tests/volume/v2/test_type.py +++ b/openstackclient/tests/volume/v2/test_type.py @@ -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): diff --git a/openstackclient/volume/v2/volume_type.py b/openstackclient/volume/v2/volume_type.py index 91ac17a1..05597bec 100644 --- a/openstackclient/volume/v2/volume_type.py +++ b/openstackclient/volume/v2/volume_type.py @@ -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, |
