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',
|
'virtual_size',
|
||||||
'min_ram',
|
'min_ram',
|
||||||
'schema',
|
'schema',
|
||||||
|
'is_hidden',
|
||||||
|
'hash_algo',
|
||||||
|
'hash_value',
|
||||||
]
|
]
|
||||||
|
|
||||||
# TODO(gtema/anybody): actually it should be possible to drop this method,
|
# TODO(gtema/anybody): actually it should be possible to drop this method,
|
||||||
@@ -903,6 +906,8 @@ class ListImage(command.Lister):
|
|||||||
'visibility',
|
'visibility',
|
||||||
'is_protected',
|
'is_protected',
|
||||||
'owner_id',
|
'owner_id',
|
||||||
|
'hash_algo',
|
||||||
|
'hash_value',
|
||||||
'tags',
|
'tags',
|
||||||
)
|
)
|
||||||
column_headers: tuple[str, ...] = (
|
column_headers: tuple[str, ...] = (
|
||||||
@@ -916,6 +921,8 @@ class ListImage(command.Lister):
|
|||||||
'Visibility',
|
'Visibility',
|
||||||
'Protected',
|
'Protected',
|
||||||
'Project',
|
'Project',
|
||||||
|
'Hash Algorithm',
|
||||||
|
'Hash Value',
|
||||||
'Tags',
|
'Tags',
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@@ -218,17 +218,39 @@ class ImageTests(base.BaseImageTests):
|
|||||||
'image remove project ' + self.name + ' ' + my_project_id
|
'image remove project ' + self.name + ' ' + my_project_id
|
||||||
)
|
)
|
||||||
|
|
||||||
# else:
|
def test_image_hidden(self):
|
||||||
# # Test not shared
|
# Test image is shown in list
|
||||||
# self.assertRaises(
|
output = self.openstack(
|
||||||
# image_exceptions.HTTPForbidden,
|
'image list',
|
||||||
# self.openstack,
|
parse_output=True,
|
||||||
# 'image add project ' +
|
)
|
||||||
# self.name + ' ' +
|
self.assertIn(
|
||||||
# my_project_id
|
self.name,
|
||||||
# )
|
[img['Name'] for img in output],
|
||||||
# self.openstack(
|
)
|
||||||
# 'image set ' +
|
|
||||||
# '--share ' +
|
# Hide the image and test image not show in the list
|
||||||
# self.name
|
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',
|
'Visibility',
|
||||||
'Protected',
|
'Protected',
|
||||||
'Project',
|
'Project',
|
||||||
|
'Hash Algorithm',
|
||||||
|
'Hash Value',
|
||||||
'Tags',
|
'Tags',
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -830,14 +832,16 @@ class TestImageList(TestImage):
|
|||||||
(
|
(
|
||||||
self._image.id,
|
self._image.id,
|
||||||
self._image.name,
|
self._image.name,
|
||||||
None,
|
self._image.disk_format,
|
||||||
None,
|
self._image.container_format,
|
||||||
None,
|
self._image.size,
|
||||||
None,
|
self._image.checksum,
|
||||||
None,
|
self._image.status,
|
||||||
self._image.visibility,
|
self._image.visibility,
|
||||||
self._image.is_protected,
|
self._image.is_protected,
|
||||||
self._image.owner_id,
|
self._image.owner_id,
|
||||||
|
self._image.hash_algo,
|
||||||
|
self._image.hash_value,
|
||||||
format_columns.ListColumn(self._image.tags),
|
format_columns.ListColumn(self._image.tags),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -1356,15 +1360,17 @@ class TestImageSet(TestImage):
|
|||||||
exceptions.CommandError, self.cmd.take_action, parsed_args
|
exceptions.CommandError, self.cmd.take_action, parsed_args
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_image_set_bools1(self):
|
def test_image_set_bools_true(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--protected',
|
'--protected',
|
||||||
'--private',
|
'--private',
|
||||||
|
'--hidden',
|
||||||
'graven',
|
'graven',
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('is_protected', True),
|
('is_protected', True),
|
||||||
('visibility', 'private'),
|
('visibility', 'private'),
|
||||||
|
('is_hidden', True),
|
||||||
('image', 'graven'),
|
('image', 'graven'),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@@ -1374,6 +1380,7 @@ class TestImageSet(TestImage):
|
|||||||
kwargs = {
|
kwargs = {
|
||||||
'is_protected': True,
|
'is_protected': True,
|
||||||
'visibility': 'private',
|
'visibility': 'private',
|
||||||
|
'is_hidden': True,
|
||||||
}
|
}
|
||||||
# ImageManager.update(image, **kwargs)
|
# ImageManager.update(image, **kwargs)
|
||||||
self.image_client.update_image.assert_called_with(
|
self.image_client.update_image.assert_called_with(
|
||||||
@@ -1381,15 +1388,17 @@ class TestImageSet(TestImage):
|
|||||||
)
|
)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_image_set_bools2(self):
|
def test_image_set_bools_false(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--unprotected',
|
'--unprotected',
|
||||||
'--public',
|
'--public',
|
||||||
|
'--unhidden',
|
||||||
'graven',
|
'graven',
|
||||||
]
|
]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('is_protected', False),
|
('is_protected', False),
|
||||||
('visibility', 'public'),
|
('visibility', 'public'),
|
||||||
|
('is_hidden', False),
|
||||||
('image', 'graven'),
|
('image', 'graven'),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
@@ -1399,6 +1408,7 @@ class TestImageSet(TestImage):
|
|||||||
kwargs = {
|
kwargs = {
|
||||||
'is_protected': False,
|
'is_protected': False,
|
||||||
'visibility': 'public',
|
'visibility': 'public',
|
||||||
|
'is_hidden': False,
|
||||||
}
|
}
|
||||||
# ImageManager.update(image, **kwargs)
|
# ImageManager.update(image, **kwargs)
|
||||||
self.image_client.update_image.assert_called_with(
|
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