murano/murano/context.py
Alexander Tivelkov 2858689767 'GetPackageUI' API can now be called even if Glare is used
Since Glare support was introduced the 'catalog/packages' part of
Murano API (/v1/catalog/packages) became obsolete and was intended to
be used for "legacy" (i.e. non-glare-based) package storage. The
murano client was supposed to directly call glare to retrieve the
packages.

However, the "GetPackageUI" call (GET
/v1/catalog/packages/%pkg_id%/ui) is different: not all the packages
bundle the UI definitions, some require Murano to generate them based
on the contents of the package. This is true for HOT-based packages
and others, plugin-based ones. In future this will be true for 100% of
the packages when the dynamic ui and object model generation is added.

Because of this that API should be callable even if Glare is
configured as a package storage backend. It should fetch the artifact
from glare, unpack it and use whatever plugin-specific logic required
to generate the UI definitions for this particular package.

This patch introduces appropriate change while maintaining the
backwards compatibility: in the legacy mode (i.e. when murano's DB
acts as package storage) the UI is read directly from an appropriate
DB table without fetching the whole package.

This fixes the issue when the HOT-based packages could not be
deplpoyed properly with murano-dashboard, but the murano-client has to
be updated as well to properly call the modified API even if Glare is
enabled.

Change-Id: Id9327e4015e1c0a1553c0b1a0151a94ee4da2928
Partial-bug: #1565805
2016-04-08 15:27:10 +00:00

37 lines
1.3 KiB
Python

# Copyright (c) 2013 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_context import context
from murano.common import policy
class RequestContext(context.RequestContext):
"""Class that stores context info about an API request.
Stores creditentials of the user, that is accessing API
as well as additional request information.
"""
def __init__(self, session=None,
roles=None, is_admin=None, service_catalog=None,
**kwargs):
super(RequestContext, self).__init__(**kwargs)
self.session = session
self.roles = roles or []
self.service_catalog = service_catalog
self.is_admin = is_admin
if self.is_admin is None:
self.is_admin = policy.check_is_admin(self)