summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-12-01 02:37:22 +0000
committerGerrit Code Review <review@openstack.org>2017-12-01 02:37:22 +0000
commit1b93ff3dd6e194c38bcc61366a047c7961462a93 (patch)
tree6986f25ee078bde846583b1b8cb6bb32fd2a66c9
parent83e8197867a534d9e8ee282360962a2fac489e93 (diff)
parent09110be37ed524794d3622afb6bb55387313a619 (diff)
Merge "Allow images to be filtered by project ID"
-rw-r--r--muranodashboard/images/forms.py9
-rw-r--r--muranodashboard/local/local_settings.d/_50_murano.py4
-rw-r--r--releasenotes/notes/images-filter-project.yaml-081bffde1b91057f.yaml5
3 files changed, 18 insertions, 0 deletions
diff --git a/muranodashboard/images/forms.py b/muranodashboard/images/forms.py
index 880c4fe..af8eca5 100644
--- a/muranodashboard/images/forms.py
+++ b/muranodashboard/images/forms.py
@@ -14,6 +14,7 @@
14 14
15import json 15import json
16 16
17from django.conf import settings
17from django.core.urlresolvers import reverse 18from django.core.urlresolvers import reverse
18from django import forms 19from django import forms
19from django.utils.translation import ugettext_lazy as _ 20from django.utils.translation import ugettext_lazy as _
@@ -27,6 +28,14 @@ LOG = logging.getLogger(__name__)
27 28
28 29
29def filter_murano_images(images, request=None): 30def filter_murano_images(images, request=None):
31 # filter images by project owner
32 filter_project = getattr(settings, 'MURANO_IMAGE_FILTER_PROJECT_ID', None)
33 if filter_project:
34 project_ids = [filter_project]
35 if request:
36 project_ids.append(request.user.tenant_id)
37 images = filter(
38 lambda x: getattr(x, 'owner', None) in project_ids, list(images))
30 # filter out the snapshot image type 39 # filter out the snapshot image type
31 images = filter( 40 images = filter(
32 lambda x: getattr(x, 'image_type', None) != 'snapshot', list(images)) 41 lambda x: getattr(x, 'image_type', None) != 'snapshot', list(images))
diff --git a/muranodashboard/local/local_settings.d/_50_murano.py b/muranodashboard/local/local_settings.d/_50_murano.py
index d4a8a98..ed02ab5 100644
--- a/muranodashboard/local/local_settings.d/_50_murano.py
+++ b/muranodashboard/local/local_settings.d/_50_murano.py
@@ -15,6 +15,10 @@ DISPLAY_MURANO_REPO_URL = 'http://apps.openstack.org/#tab=murano-apps'
15# in the main accordion navigation 15# in the main accordion navigation
16# MURANO_DASHBOARD_NAME = "App Catalog" 16# MURANO_DASHBOARD_NAME = "App Catalog"
17 17
18# Filter the list of Murano images displayed to be only those owned by this
19# project ID
20# MURANO_IMAGE_FILTER_PROJECT_ID =
21
18# Specify a maximum number of limit packages. 22# Specify a maximum number of limit packages.
19# PACKAGES_LIMIT = 100 23# PACKAGES_LIMIT = 100
20 24
diff --git a/releasenotes/notes/images-filter-project.yaml-081bffde1b91057f.yaml b/releasenotes/notes/images-filter-project.yaml-081bffde1b91057f.yaml
new file mode 100644
index 0000000..8caa65d
--- /dev/null
+++ b/releasenotes/notes/images-filter-project.yaml-081bffde1b91057f.yaml
@@ -0,0 +1,5 @@
1---
2features:
3 - A new parameter MURANO_IMAGE_FILTER_PROJECT_ID has been added which, when
4 given, will filter the list of public Murano images to the given project
5 ID