summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-04-13 09:07:04 +0000
committerGerrit Code Review <review@openstack.org>2017-04-13 09:07:04 +0000
commitc7ac310af958063d74b4a918f83d0232fff8f6ce (patch)
tree2f0b39ff1074a4aa4d932a842e1826028bf0763c
parentcb4ebb4b47d98fc005e12e9b9af73a0c8b3326b8 (diff)
parentf9e18f725caae0e5c745a4a1a24d05a8a3df213d (diff)
Merge "Filter out the snapshot image type"4.0.0.0b1
-rw-r--r--muranodashboard/dynamic_ui/fields.py3
-rw-r--r--muranodashboard/images/forms.py7
-rw-r--r--muranodashboard/tests/unit/images/test_forms.py9
3 files changed, 19 insertions, 0 deletions
diff --git a/muranodashboard/dynamic_ui/fields.py b/muranodashboard/dynamic_ui/fields.py
index 0347d5e..6aa6f1f 100644
--- a/muranodashboard/dynamic_ui/fields.py
+++ b/muranodashboard/dynamic_ui/fields.py
@@ -115,6 +115,9 @@ def get_murano_images(request):
115 LOG.error("Error to request image list from glance ") 115 LOG.error("Error to request image list from glance ")
116 exceptions.handle(request, _("Unable to retrieve public images.")) 116 exceptions.handle(request, _("Unable to retrieve public images."))
117 murano_images = [] 117 murano_images = []
118 # filter out the snapshot image type
119 images = filter(
120 lambda x: x.properties.get("image_type", '') != 'snapshot', images)
118 for image in images: 121 for image in images:
119 murano_property = image.properties.get('murano_image_info') 122 murano_property = image.properties.get('murano_image_info')
120 if murano_property: 123 if murano_property:
diff --git a/muranodashboard/images/forms.py b/muranodashboard/images/forms.py
index e83a952..5ca1bb2 100644
--- a/muranodashboard/images/forms.py
+++ b/muranodashboard/images/forms.py
@@ -27,6 +27,9 @@ LOG = logging.getLogger(__name__)
27 27
28 28
29def filter_murano_images(images, request=None): 29def filter_murano_images(images, request=None):
30 # filter out the snapshot image type
31 images = filter(
32 lambda x: x.properties.get("image_type", '') != 'snapshot', images)
30 marked_images = [] 33 marked_images = []
31 for image in images: 34 for image in images:
32 metadata = image.properties.get('murano_image_info') 35 metadata = image.properties.get('murano_image_info')
@@ -92,6 +95,10 @@ class MarkImageForm(horizon_forms.SelfHandlingForm):
92 images = filter( 95 images = filter(
93 lambda x: x.container_format not in ('aki', 'ari'), images) 96 lambda x: x.container_format not in ('aki', 'ari'), images)
94 97
98 # filter out the snapshot image type
99 images = filter(
100 lambda x: x.properties.get("image_type", '') != 'snapshot', images)
101
95 self.fields['image'].choices = [(i.id, i.name) for i in images] 102 self.fields['image'].choices = [(i.id, i.name) for i in images]
96 self.fields['existing_titles'].initial = \ 103 self.fields['existing_titles'].initial = \
97 [image.title for image in filter_murano_images(images)] 104 [image.title for image in filter_murano_images(images)]
diff --git a/muranodashboard/tests/unit/images/test_forms.py b/muranodashboard/tests/unit/images/test_forms.py
index fc28797..9aac49a 100644
--- a/muranodashboard/tests/unit/images/test_forms.py
+++ b/muranodashboard/tests/unit/images/test_forms.py
@@ -40,6 +40,15 @@ class TestImagesForms(testtools.TestCase):
40 images = [self.mock_img] 40 images = [self.mock_img]
41 self.assertEqual(images, forms.filter_murano_images(images)) 41 self.assertEqual(images, forms.filter_murano_images(images))
42 42
43 snapshot_meta = {'image_type': u'snapshot',
44 'murano_image_info': '{"title": "title",\
45 "type": "type"}'}
46 mock_snapshot_img = \
47 mock.MagicMock(id=14, properties=snapshot_meta)
48 images = [mock_snapshot_img]
49 self.assertEqual([],
50 forms.filter_murano_images(images, self.mock_request))
51
43 52
44class TestMarkImageForm(testtools.TestCase): 53class TestMarkImageForm(testtools.TestCase):
45 def setUp(self): 54 def setUp(self):