Merge "Allow images to be filtered by project ID"

This commit is contained in:
Zuul 2017-12-01 02:37:22 +00:00 committed by Gerrit Code Review
commit 1b93ff3dd6
3 changed files with 18 additions and 0 deletions

View File

@ -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))

View File

@ -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

View File

@ -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