Fix filter image snapshot type with glancev2

Change-Id: Iccfcc0b21f500a8c1de8b1efd1d565979f400e18
This commit is contained in:
zhurong 2017-04-14 16:40:25 +08:00 committed by Felipe Monteiro
parent 273ed4797e
commit 17a139b842
2 changed files with 5 additions and 6 deletions

View File

@ -29,7 +29,7 @@ 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)
lambda x: getattr(x, 'image_type', None) != 'snapshot', list(images))
marked_images = []
for image in images:
# Additional properties, whose value is always a string data type, are

View File

@ -40,11 +40,10 @@ 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)
murano_meta = '{"title": "title", "type": "type"}'
mock_snapshot_img = mock.MagicMock(
id=14, murano_image_info=murano_meta, image_type='snapshot')
images = [mock_snapshot_img]
self.assertEqual([],
forms.filter_murano_images(images, self.mock_request))