diff options
author | Zuul <zuul@review.openstack.org> | 2018-11-15 07:31:18 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2018-11-15 07:31:18 +0000 |
commit | c4c92ecb51f4a7b93c1a84d5084006fed15c6945 (patch) | |
tree | 061954cfb99fd2f258c1021e764766b8db66af89 /glanceclient | |
parent | 1156346dc243dc46bcc7c78a64454ff4bae7ddc5 (diff) | |
parent | 5fb14f5ebbea044ce63e49f5feec26d4c1c91730 (diff) | |
download | python-glanceclient-c4c92ecb51f4a7b93c1a84d5084006fed15c6945.tar.gz |
Merge "Show the backend store info"2.15.0
Diffstat (limited to 'glanceclient')
-rw-r--r-- | glanceclient/tests/unit/v2/test_shell_v2.py | 82 | ||||
-rw-r--r-- | glanceclient/v2/shell.py | 10 |
2 files changed, 92 insertions, 0 deletions
diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py index acf93bf..919e645 100644 --- a/glanceclient/tests/unit/v2/test_shell_v2.py +++ b/glanceclient/tests/unit/v2/test_shell_v2.py @@ -264,6 +264,7 @@ class ShellV2Test(testtools.TestCase): 'sort_dir': ['desc', 'asc'], 'sort': None, 'verbose': False, + 'include_stores': False, 'os_hidden': False } args = self._make_args(input) @@ -286,6 +287,83 @@ class ShellV2Test(testtools.TestCase): filters=exp_img_filters) utils.print_list.assert_called_once_with({}, ['ID', 'Name']) + def test_do_image_list_verbose(self): + input = { + 'limit': None, + 'page_size': 18, + 'visibility': True, + 'member_status': 'Fake', + 'owner': 'test', + 'checksum': 'fake_checksum', + 'tag': 'fake tag', + 'properties': [], + 'sort_key': ['name', 'id'], + 'sort_dir': ['desc', 'asc'], + 'sort': None, + 'verbose': True, + 'include_stores': False, + 'os_hidden': False + } + args = self._make_args(input) + with mock.patch.object(self.gc.images, 'list') as mocked_list: + mocked_list.return_value = {} + + test_shell.do_image_list(self.gc, args) + utils.print_list.assert_called_once_with( + {}, ['ID', 'Name', 'Disk_format', 'Container_format', + 'Size', 'Status', 'Owner']) + + def test_do_image_list_with_include_stores_true(self): + input = { + 'limit': None, + 'page_size': 18, + 'visibility': True, + 'member_status': 'Fake', + 'owner': 'test', + 'checksum': 'fake_checksum', + 'tag': 'fake tag', + 'properties': [], + 'sort_key': ['name', 'id'], + 'sort_dir': ['desc', 'asc'], + 'sort': None, + 'verbose': False, + 'include_stores': True, + 'os_hidden': False + } + args = self._make_args(input) + with mock.patch.object(self.gc.images, 'list') as mocked_list: + mocked_list.return_value = {} + + test_shell.do_image_list(self.gc, args) + utils.print_list.assert_called_once_with( + {}, ['ID', 'Name', 'Stores']) + + def test_do_image_list_verbose_with_include_stores_true(self): + input = { + 'limit': None, + 'page_size': 18, + 'visibility': True, + 'member_status': 'Fake', + 'owner': 'test', + 'checksum': 'fake_checksum', + 'tag': 'fake tag', + 'properties': [], + 'sort_key': ['name', 'id'], + 'sort_dir': ['desc', 'asc'], + 'sort': None, + 'verbose': True, + 'include_stores': True, + 'os_hidden': False + } + args = self._make_args(input) + with mock.patch.object(self.gc.images, 'list') as mocked_list: + mocked_list.return_value = {} + + test_shell.do_image_list(self.gc, args) + utils.print_list.assert_called_once_with( + {}, ['ID', 'Name', 'Disk_format', 'Container_format', + 'Size', 'Status', 'Owner', 'Stores']) + def test_do_image_list_with_hidden_true(self): input = { 'limit': None, @@ -300,6 +378,7 @@ class ShellV2Test(testtools.TestCase): 'sort_dir': ['desc', 'asc'], 'sort': None, 'verbose': False, + 'include_stores': False, 'os_hidden': True } args = self._make_args(input) @@ -336,6 +415,7 @@ class ShellV2Test(testtools.TestCase): 'sort_dir': ['desc'], 'sort': None, 'verbose': False, + 'include_stores': False, 'os_hidden': False } args = self._make_args(input) @@ -372,6 +452,7 @@ class ShellV2Test(testtools.TestCase): 'sort_key': [], 'sort_dir': [], 'verbose': False, + 'include_stores': False, 'os_hidden': False } args = self._make_args(input) @@ -408,6 +489,7 @@ class ShellV2Test(testtools.TestCase): 'sort_dir': ['desc'], 'sort': None, 'verbose': False, + 'include_stores': False, 'os_hidden': False } args = self._make_args(input) diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py index 54dd789..544416a 100644 --- a/glanceclient/v2/shell.py +++ b/glanceclient/v2/shell.py @@ -348,6 +348,13 @@ def do_image_update(gc, args): const=True, nargs='?', help="Filters results by hidden status. Default=None.") +@utils.arg('--include-stores', + metavar='[True|False]', + default=None, + type=strutils.bool_from_string, + const=True, + nargs='?', + help="Print backend store id.") def do_image_list(gc, args): """List images you can access.""" filter_keys = ['visibility', 'member_status', 'owner', 'checksum', 'tag', @@ -384,6 +391,9 @@ def do_image_list(gc, args): columns += ['Disk_format', 'Container_format', 'Size', 'Status', 'Owner'] + if args.include_stores: + columns += ['Stores'] + images = gc.images.list(**kwargs) utils.print_list(images, columns) |