Merge "Filter out the snapshot image type"
This commit is contained in:
commit
c7ac310af9
muranodashboard
@ -115,6 +115,9 @@ def get_murano_images(request):
|
||||
LOG.error("Error to request image list from glance ")
|
||||
exceptions.handle(request, _("Unable to retrieve public images."))
|
||||
murano_images = []
|
||||
# filter out the snapshot image type
|
||||
images = filter(
|
||||
lambda x: x.properties.get("image_type", '') != 'snapshot', images)
|
||||
for image in images:
|
||||
murano_property = image.properties.get('murano_image_info')
|
||||
if murano_property:
|
||||
|
@ -27,6 +27,9 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def filter_murano_images(images, request=None):
|
||||
# filter out the snapshot image type
|
||||
images = filter(
|
||||
lambda x: x.properties.get("image_type", '') != 'snapshot', images)
|
||||
marked_images = []
|
||||
for image in images:
|
||||
metadata = image.properties.get('murano_image_info')
|
||||
@ -92,6 +95,10 @@ class MarkImageForm(horizon_forms.SelfHandlingForm):
|
||||
images = filter(
|
||||
lambda x: x.container_format not in ('aki', 'ari'), images)
|
||||
|
||||
# filter out the snapshot image type
|
||||
images = filter(
|
||||
lambda x: x.properties.get("image_type", '') != 'snapshot', images)
|
||||
|
||||
self.fields['image'].choices = [(i.id, i.name) for i in images]
|
||||
self.fields['existing_titles'].initial = \
|
||||
[image.title for image in filter_murano_images(images)]
|
||||
|
@ -40,6 +40,15 @@ class TestImagesForms(testtools.TestCase):
|
||||
images = [self.mock_img]
|
||||
self.assertEqual(images, forms.filter_murano_images(images))
|
||||
|
||||
snapshot_meta = {'image_type': u'snapshot',
|
||||
'murano_image_info': '{"title": "title",\
|
||||
"type": "type"}'}
|
||||
mock_snapshot_img = \
|
||||
mock.MagicMock(id=14, properties=snapshot_meta)
|
||||
images = [mock_snapshot_img]
|
||||
self.assertEqual([],
|
||||
forms.filter_murano_images(images, self.mock_request))
|
||||
|
||||
|
||||
class TestMarkImageForm(testtools.TestCase):
|
||||
def setUp(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user