image: Add hashing-related fields
Add support for the 'os_hash_algo' and 'os_hash_value' image attributes added with Image API 2.7. Change-Id: Id8fe6f3fecf77f537587e9088b207ef2077a9def Signed-off-by: Artem Goncharov <artem.goncharov@gmail.com>
This commit is contained in:

committed by
Stephen Finucane

parent
37228ae2d3
commit
a73698490a
@@ -98,6 +98,9 @@ def _format_image(image, human_readable=False):
|
||||
'virtual_size',
|
||||
'min_ram',
|
||||
'schema',
|
||||
'is_hidden',
|
||||
'hash_algo',
|
||||
'hash_value',
|
||||
]
|
||||
|
||||
# TODO(gtema/anybody): actually it should be possible to drop this method,
|
||||
@@ -903,6 +906,8 @@ class ListImage(command.Lister):
|
||||
'visibility',
|
||||
'is_protected',
|
||||
'owner_id',
|
||||
'hash_algo',
|
||||
'hash_value',
|
||||
'tags',
|
||||
)
|
||||
column_headers: tuple[str, ...] = (
|
||||
@@ -916,6 +921,8 @@ class ListImage(command.Lister):
|
||||
'Visibility',
|
||||
'Protected',
|
||||
'Project',
|
||||
'Hash Algorithm',
|
||||
'Hash Value',
|
||||
'Tags',
|
||||
)
|
||||
else:
|
||||
|
@@ -218,17 +218,39 @@ class ImageTests(base.BaseImageTests):
|
||||
'image remove project ' + self.name + ' ' + my_project_id
|
||||
)
|
||||
|
||||
# else:
|
||||
# # Test not shared
|
||||
# self.assertRaises(
|
||||
# image_exceptions.HTTPForbidden,
|
||||
# self.openstack,
|
||||
# 'image add project ' +
|
||||
# self.name + ' ' +
|
||||
# my_project_id
|
||||
# )
|
||||
# self.openstack(
|
||||
# 'image set ' +
|
||||
# '--share ' +
|
||||
# self.name
|
||||
# )
|
||||
def test_image_hidden(self):
|
||||
# Test image is shown in list
|
||||
output = self.openstack(
|
||||
'image list',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn(
|
||||
self.name,
|
||||
[img['Name'] for img in output],
|
||||
)
|
||||
|
||||
# Hide the image and test image not show in the list
|
||||
self.openstack('image set ' + '--hidden ' + self.name)
|
||||
output = self.openstack(
|
||||
'image list',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertNotIn(self.name, [img['Name'] for img in output])
|
||||
|
||||
# Test image show in the list with flag
|
||||
output = self.openstack(
|
||||
'image list',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertNotIn(self.name, [img['Name'] for img in output])
|
||||
|
||||
# Unhide the image and test image is again visible in regular list
|
||||
self.openstack('image set ' + '--unhidden ' + self.name)
|
||||
output = self.openstack(
|
||||
'image list',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIn(
|
||||
self.name,
|
||||
[img['Name'] for img in output],
|
||||
)
|
||||
|
@@ -822,6 +822,8 @@ class TestImageList(TestImage):
|
||||
'Visibility',
|
||||
'Protected',
|
||||
'Project',
|
||||
'Hash Algorithm',
|
||||
'Hash Value',
|
||||
'Tags',
|
||||
)
|
||||
|
||||
@@ -830,14 +832,16 @@ class TestImageList(TestImage):
|
||||
(
|
||||
self._image.id,
|
||||
self._image.name,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
self._image.disk_format,
|
||||
self._image.container_format,
|
||||
self._image.size,
|
||||
self._image.checksum,
|
||||
self._image.status,
|
||||
self._image.visibility,
|
||||
self._image.is_protected,
|
||||
self._image.owner_id,
|
||||
self._image.hash_algo,
|
||||
self._image.hash_value,
|
||||
format_columns.ListColumn(self._image.tags),
|
||||
),
|
||||
)
|
||||
@@ -1356,15 +1360,17 @@ class TestImageSet(TestImage):
|
||||
exceptions.CommandError, self.cmd.take_action, parsed_args
|
||||
)
|
||||
|
||||
def test_image_set_bools1(self):
|
||||
def test_image_set_bools_true(self):
|
||||
arglist = [
|
||||
'--protected',
|
||||
'--private',
|
||||
'--hidden',
|
||||
'graven',
|
||||
]
|
||||
verifylist = [
|
||||
('is_protected', True),
|
||||
('visibility', 'private'),
|
||||
('is_hidden', True),
|
||||
('image', 'graven'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -1374,6 +1380,7 @@ class TestImageSet(TestImage):
|
||||
kwargs = {
|
||||
'is_protected': True,
|
||||
'visibility': 'private',
|
||||
'is_hidden': True,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
@@ -1381,15 +1388,17 @@ class TestImageSet(TestImage):
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_image_set_bools2(self):
|
||||
def test_image_set_bools_false(self):
|
||||
arglist = [
|
||||
'--unprotected',
|
||||
'--public',
|
||||
'--unhidden',
|
||||
'graven',
|
||||
]
|
||||
verifylist = [
|
||||
('is_protected', False),
|
||||
('visibility', 'public'),
|
||||
('is_hidden', False),
|
||||
('image', 'graven'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@@ -1399,6 +1408,7 @@ class TestImageSet(TestImage):
|
||||
kwargs = {
|
||||
'is_protected': False,
|
||||
'visibility': 'public',
|
||||
'is_hidden': False,
|
||||
}
|
||||
# ImageManager.update(image, **kwargs)
|
||||
self.image_client.update_image.assert_called_with(
|
||||
|
@@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- The ``os_hash_algo`` and ``os_hash_value image`` attributes are now shown
|
||||
in the ``image list --long`` output.
|
Reference in New Issue
Block a user