diff --git a/muranodashboard/images/forms.py b/muranodashboard/images/forms.py index 880c4fe38..af8eca536 100644 --- a/muranodashboard/images/forms.py +++ b/muranodashboard/images/forms.py @@ -14,6 +14,7 @@ import json +from django.conf import settings from django.core.urlresolvers import reverse from django import forms from django.utils.translation import ugettext_lazy as _ @@ -27,6 +28,14 @@ LOG = logging.getLogger(__name__) def filter_murano_images(images, request=None): + # filter images by project owner + filter_project = getattr(settings, 'MURANO_IMAGE_FILTER_PROJECT_ID', None) + if filter_project: + project_ids = [filter_project] + if request: + project_ids.append(request.user.tenant_id) + images = filter( + lambda x: getattr(x, 'owner', None) in project_ids, list(images)) # filter out the snapshot image type images = filter( 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 d4a8a9857..ed02ab585 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' # in the main accordion navigation # MURANO_DASHBOARD_NAME = "App Catalog" +# Filter the list of Murano images displayed to be only those owned by this +# project ID +# MURANO_IMAGE_FILTER_PROJECT_ID = + # Specify a maximum number of limit packages. # PACKAGES_LIMIT = 100 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 000000000..8caa65d61 --- /dev/null +++ b/releasenotes/notes/images-filter-project.yaml-081bffde1b91057f.yaml @@ -0,0 +1,5 @@ +--- +features: + - A new parameter MURANO_IMAGE_FILTER_PROJECT_ID has been added which, when + given, will filter the list of public Murano images to the given project + ID