diff options
author | Liang Fang <liang.a.fang@intel.com> | 2018-09-25 16:53:40 +0800 |
---|---|---|
committer | Liang Fang <liang.a.fang@intel.com> | 2018-11-08 17:50:26 -0800 |
commit | 5fb14f5ebbea044ce63e49f5feec26d4c1c91730 (patch) | |
tree | 70fffdf6bb889ef47f902a4147a815fbf72e7fc8 /glanceclient/tests/unit | |
parent | a4ea9f0720214bd4aa6d72e81776e1260b30ad2f (diff) | |
download | python-glanceclient-5fb14f5ebbea044ce63e49f5feec26d4c1c91730.tar.gz |
Show the backend store info
When running "glance -v image-list" there's no store info listed, so
user cannot know the type of the backend. This patch added an new option
"--include-stores" and is to add the store id to the output of "glance
image-list --include-stores".
The final output may like:
+-----+------+-------------+-----+----------+--------+-----+------+
| ID | Name | Disk_format | ... | Size | Status |Owner|Stores|
+-----+------+-------------+-----+----------+--------+-----+------+
| xxx | img1 | raw | ... | 10737418 | active | xxx | ceph |
| xxx | img2 | raw | ... | 5086345 | active | xxx | file |
+-----+------+-------------+-----+----------+--------+-----+------+
Change-Id: If86ef714c3aa03ce43ef29f26892f431f4766560
Co-authored-by: Jack Ding <jack.ding@windriver.com>
Signed-off-by: Liang Fang <liang.a.fang@intel.com>
Diffstat (limited to 'glanceclient/tests/unit')
-rw-r--r-- | glanceclient/tests/unit/v2/test_shell_v2.py | 82 |
1 files changed, 82 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) |