"""The Volume Image Metadata API extension.""" import webob from oslo_log import log as logging from cinder.api import common from cinder.api import extensions from cinder.api.openstack import wsgi from cinder import exception from cinder.i18n import _ from cinder import volume LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'volume_image_metadata') class VolumeImageMetadataController(wsgi.Controller): def __init__(self, *args, **kwargs): super(VolumeImageMetadataController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _get_image_metadata(self, context, volume_id): try: volume = self.volume_api.get(context, volume_id) meta = self.volume_api.get_volume_image_metadata(context, volume) except exception.VolumeNotFound: msg = _('Volume with volume id %s does not exist.') % volume_id raise webob.exc.HTTPNotFound(explanation=msg) return (volume, meta)
"""The Extended Snapshot Attributes API extension.""" from webob import exc from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception from cinder.openstack.common import log as logging from cinder import volume LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer( 'volume', 'extended_snapshot_attributes') class ExtendedSnapshotAttributesController(wsgi.Controller): def __init__(self, *args, **kwargs): super(ExtendedSnapshotAttributesController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _get_snapshots(self, context): snapshots = self.volume_api.get_all_snapshots(context) rval = dict((snapshot['id'], snapshot) for snapshot in snapshots) return rval def _extend_snapshot(self, context, snapshot, data):
# License for the specific language governing permissions and limitations # under the License. from oslo_log import log as logging from webob import exc, Response from cinder.api import extensions from cinder.api.openstack import wsgi from cinder import volume from cinder import exception from cinder import db import lunrclient LOG = logging.getLogger(__name__) authorize_update_hostname = extensions.soft_extension_authorizer( 'volume', 'volume_actions:update_hostname') authorize_update_node_id = extensions.soft_extension_authorizer( 'volume', 'volume_actions:update_node_id') authorize_rename_lunr_volume = extensions.soft_extension_authorizer( 'volume', 'volume_actions:rename_lunr_volume') authorize_lock_volume = extensions.soft_extension_authorizer( 'volume', 'volume_actions:lock_volume') class VolumeAdminController(wsgi.Controller): def __init__(self, *args, **kwargs): super(wsgi.Controller, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _get(self, *args, **kwargs): return self.volume_api.get(*args, **kwargs)
import six import webob from cinder.api import common from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception from cinder.i18n import _ from cinder import volume LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer("volume", "volume_image_metadata") class VolumeImageMetadataController(wsgi.Controller): def __init__(self, *args, **kwargs): super(VolumeImageMetadataController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _get_image_metadata(self, context, volume_id): try: volume = self.volume_api.get(context, volume_id) meta = self.volume_api.get_volume_image_metadata(context, volume) except exception.VolumeNotFound: msg = _("Volume with volume id %s does not exist.") % volume_id raise webob.exc.HTTPNotFound(explanation=msg) return (volume, meta)
# 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 cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder.openstack.common import log as logging from cinder import volume LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'volume_host_attribute') class VolumeHostAttributeController(wsgi.Controller): def __init__(self, *args, **kwargs): super(VolumeHostAttributeController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _add_volume_host_attribute(self, context, resp_volume): try: db_volume = self.volume_api.get(context, resp_volume['id']) except Exception: return else: key = "%s:host" % Volume_host_attribute.alias resp_volume[key] = db_volume['host']
# # 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 cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import volume authorize = extensions.soft_extension_authorizer('volume', 'volume_mig_status_attribute') class VolumeMigStatusAttributeController(wsgi.Controller): def __init__(self, *args, **kwargs): super(VolumeMigStatusAttributeController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _add_volume_mig_status_attribute(self, req, context, resp_volume): db_volume = req.cached_resource_by_id(resp_volume['id']) key = "%s:migstat" % Volume_mig_status_attribute.alias resp_volume[key] = db_volume['migration_status'] key = "%s:name_id" % Volume_mig_status_attribute.alias resp_volume[key] = db_volume['_name_id']
import webob from webob import exc from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception from cinder.i18n import _ from cinder.openstack.common import log as logging from cinder import replication as replicationAPI from cinder import volume LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'volume_replication') class VolumeReplicationController(wsgi.Controller): """The Volume Replication API controller for the Openstack API.""" def __init__(self, *args, **kwargs): super(VolumeReplicationController, self).__init__(*args, **kwargs) self.volume_api = volume.API() self.replication_api = replicationAPI.API() def _add_replication_attributes(self, req, context, resp_volume): db_volume = req.cached_resource_by_id(resp_volume['id']) key = "%s:extended_status" % Volume_replication.alias resp_volume[key] = db_volume['replication_extended_status'] key = "%s:driver_data" % Volume_replication.alias
# # 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 cinder.api import extensions from cinder.api.openstack import wsgi from cinder import quota QUOTAS = quota.QUOTAS authorize = extensions.soft_extension_authorizer("limits", "used_limits") class UsedLimitsController(wsgi.Controller): @wsgi.extends def index(self, req, resp_obj): context = req.environ["cinder.context"] if authorize(context): quotas = QUOTAS.get_project_quotas(context, context.project_id, usages=True) quota_map = { "totalVolumesUsed": "volumes", "totalGigabytesUsed": "gigabytes", "totalSnapshotsUsed": "snapshots", "totalBackupsUsed": "backups", "totalBackupGigabytesUsed": "backup_gigabytes",
# License for the specific language governing permissions and limitations # under the License. """The volume type access extension.""" import six import webob from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception from cinder.i18n import _ from cinder.openstack.common import uuidutils from cinder.volume import volume_types soft_authorize = extensions.soft_extension_authorizer('volume', 'volume_type_access') authorize = extensions.extension_authorizer('volume', 'volume_type_access') def make_volume_type(elem): elem.set('{%s}is_public' % Volume_type_access.namespace, '%s:is_public' % Volume_type_access.alias) def make_volume_type_access(elem): elem.set('volume_type_id') elem.set('project_id') class VolumeTypeTemplate(xmlutil.TemplateBuilder): def construct(self):
# 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 cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil authorize = extensions.soft_extension_authorizer("volume", "volume_tenant_attribute") class VolumeTenantAttributeController(wsgi.Controller): def _add_volume_tenant_attribute(self, context, req, resp_volume): db_volume = req.get_db_volume(resp_volume["id"]) key = "%s:tenant_id" % Volume_tenant_attribute.alias resp_volume[key] = db_volume["project_id"] @wsgi.extends def show(self, req, resp_obj, id): context = req.environ["cinder.context"] if authorize(context): resp_obj.attach(xml=VolumeTenantAttributeTemplate()) volume = resp_obj.obj["volume"] self._add_volume_tenant_attribute(context, req, volume)
# # 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_log import log as logging from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder.fh.volume import api LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'extended_volume_trees') class VolumeHostAttributeController(wsgi.Controller): def __init__(self, *args, **kwargs): super(VolumeHostAttributeController, self).__init__(*args, **kwargs) self.volume_api = api.FhAPI() def _add_volume_trees(self, req, context, resp_volume): db_volume = req.get_db_volume(resp_volume['id']) key = "%s:tree" % Extended_volume_trees.alias if not db_volume['host']: return volume_snapshots = self.volume_api.get_volume_snapshots( context, db_volume) resp_volume[key] = {"snapshots": volume_snapshots}
from oslo_log import log as logging import six import webob from webob import exc from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception from cinder.i18n import _, _LI from cinder import replication as replicationAPI from cinder import volume LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer("volume", "volume_replication") class VolumeReplicationController(wsgi.Controller): """The Volume Replication API controller for the Openstack API.""" def __init__(self, *args, **kwargs): super(VolumeReplicationController, self).__init__(*args, **kwargs) self.volume_api = volume.API() self.replication_api = replicationAPI.API() def _add_replication_attributes(self, req, context, resp_volume): db_volume = req.cached_resource_by_id(resp_volume["id"]) key = "%s:extended_status" % Volume_replication.alias resp_volume[key] = db_volume["replication_extended_status"] key = "%s:driver_data" % Volume_replication.alias
# 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_log import log as logging from cinder.api import extensions from cinder.api.openstack import wsgi LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'volume_list_admin_context') class VolumeListAdminContextController(wsgi.Controller): @wsgi.extends def index(self, req): context = req.environ['cinder.context'] if authorize(context): req.environ['cinder.context'] = context.elevated() yield @wsgi.extends def detail(self, req): context = req.environ['cinder.context'] if authorize(context): req.environ['cinder.context'] = context.elevated()
"""The Extended Snapshot Attributes API extension.""" from webob import exc from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception from cinder.openstack.common import log as logging from cinder import volume LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer("volume", "extended_snapshot_attributes") class ExtendedSnapshotAttributesController(wsgi.Controller): def __init__(self, *args, **kwargs): super(ExtendedSnapshotAttributesController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _get_snapshots(self, context): snapshots = self.volume_api.get_all_snapshots(context) rval = dict((snapshot["id"], snapshot) for snapshot in snapshots) return rval def _extend_snapshot(self, context, snapshot, data): for attr in ["project_id", "progress"]: key = "%s:%s" % (Extended_snapshot_attributes.alias, attr)
# License for the specific language governing permissions and limitations # under the License. from oslo_log import log as logging from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from lunrclient import client from lunrclient.base import LunrHttpError from lunrclient.client import LunrClient, StorageClient LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'volume_lunr_sessions') class VolumeLunrSessionsController(wsgi.Controller): def _add_lunr_sessions(self, req, resp_volume): # tenant attribute may not be populated, it's another extension db_volume = req.get_db_volume(resp_volume['id']) project_id = db_volume['project_id'] lunr_sessions = [] lunr_error = '' lunr_client = LunrClient('admin', timeout=5) try: lunr_volume = lunr_client.volumes.get(resp_volume['id']) storage_node = lunr_client.nodes.get(lunr_volume['node_id']) url = 'http://%s:8081' % storage_node['hostname']
from oslo_log import log as logging import six import webob from webob import exc from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception from cinder.i18n import _, _LI from cinder import replication as replicationAPI from cinder import volume LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'volume_replication') class VolumeReplicationController(wsgi.Controller): """The Volume Replication API controller for the Openstack API.""" def __init__(self, *args, **kwargs): super(VolumeReplicationController, self).__init__(*args, **kwargs) self.volume_api = volume.API() self.replication_api = replicationAPI.API() def _add_replication_attributes(self, req, context, resp_volume): db_volume = req.cached_resource_by_id(resp_volume['id']) key = "%s:extended_status" % Volume_replication.alias resp_volume[key] = db_volume['replication_extended_status'] key = "%s:driver_data" % Volume_replication.alias
# 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 cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil authorize = extensions.soft_extension_authorizer( 'volume', 'volume_mig_status_attribute') class VolumeMigStatusAttributeController(wsgi.Controller): def _add_volume_mig_status_attribute(self, req, resp_volume): db_volume = req.get_db_volume(resp_volume['id']) key = "%s:migstat" % Volume_mig_status_attribute.alias resp_volume[key] = db_volume['migration_status'] key = "%s:name_id" % Volume_mig_status_attribute.alias resp_volume[key] = db_volume['_name_id'] @wsgi.extends def show(self, req, resp_obj, id): context = req.environ['cinder.context'] if authorize(context): resp_obj.attach(xml=VolumeMigStatusAttributeTemplate())
# under the License. """The volume type access extension.""" from oslo_utils import uuidutils import six import webob from cinder.api import extensions from cinder.api.openstack import wsgi from cinder import exception from cinder.i18n import _ from cinder.volume import volume_types soft_authorize = extensions.soft_extension_authorizer("volume", "volume_type_access") authorize = extensions.extension_authorizer("volume", "volume_type_access") def _marshall_volume_type_access(vol_type): rval = [] for project_id in vol_type["projects"]: rval.append({"volume_type_id": vol_type["id"], "project_id": project_id}) return {"volume_type_access": rval} class VolumeTypeAccessController(object): """The volume type access API controller for the OpenStack API.""" def index(self, req, type_id):
# 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_log import log as logging from cinder.api import extensions from cinder.api.openstack import wsgi LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('snapshot', 'snapshot_list_admin_context') class SnapshotListAdminContextController(wsgi.Controller): @wsgi.extends def index(self, req): context = req.environ['cinder.context'] if authorize(context): req.environ['cinder.context'] = context.elevated() yield @wsgi.extends def detail(self, req): context = req.environ['cinder.context'] if authorize(context): req.environ['cinder.context'] = context.elevated()
# # 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 cinder.api import extensions from cinder.api.openstack import wsgi from cinder import quota QUOTAS = quota.QUOTAS authorize = extensions.soft_extension_authorizer('limits', 'used_limits') class UsedLimitsController(wsgi.Controller): @wsgi.extends def index(self, req, resp_obj): context = req.environ['cinder.context'] if authorize(context): quotas = QUOTAS.get_project_quotas(context, context.project_id, usages=True) quota_map = { 'totalVolumesUsed': 'volumes', 'totalGigabytesUsed': 'gigabytes', 'totalSnapshotsUsed': 'snapshots',
"""The Extended Snapshot Attributes API extension.""" from webob import exc from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception from cinder.openstack.common import log as logging from cinder import volume LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer( 'volume', 'extended_snapshot_attributes') class ExtendedSnapshotAttributesController(wsgi.Controller): def __init__(self, *args, **kwargs): super(ExtendedSnapshotAttributesController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _get_snapshots(self, context): snapshots = self.volume_api.get_all_snapshots(context) rval = dict((snapshot['id'], snapshot) for snapshot in snapshots) return rval def _extend_snapshot(self, snapshot, data):
# 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. """The Extended Snapshot Tree API extension.""" from oslo_log import log as logging from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder.fh.volume import api LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'extended_snapshot_trees') class ExtendedSnapshotTreesController(wsgi.Controller): def __init__(self, *args, **kwargs): super(ExtendedSnapshotTreesController, self).__init__(*args, **kwargs) self.volume_api = api.FhAPI() def _extend_snapshot(self, req, context, resp_snap): db_snap = req.get_db_snapshot(resp_snap['id']) snap_children = self.volume_api.get_snapshot_children(context, db_snap) resp_snap['%s:tree' % Extended_snapshot_trees.alias] = \ {"child": snap_children} @wsgi.extends def show(self, req, resp_obj, id):
# # 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. """The Volume Image Metadata API extension.""" from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import volume authorize = extensions.soft_extension_authorizer('volume', 'volume_image_metadata') class VolumeImageMetadataController(wsgi.Controller): def __init__(self, *args, **kwargs): super(VolumeImageMetadataController, self).__init__(*args, **kwargs) self.volume_api = volume.API() def _add_image_metadata(self, context, resp_volume): try: image_meta = self.volume_api.get_volume_image_metadata( context, resp_volume) except Exception: return else: if image_meta:
from oslo_log import log as logging from cinder.api import extensions from cinder.api.openstack import wsgi LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'volume_list_admin_context') class VolumeListAdminContextController(wsgi.Controller): @wsgi.extends def index(self, req): context = req.environ['cinder.context'] if authorize(context): req.environ['cinder.context'] = context.elevated() yield @wsgi.extends def detail(self, req): context = req.environ['cinder.context'] if authorize(context): req.environ['cinder.context'] = context.elevated() yield class Volume_list_admin_context(extensions.ExtensionDescriptor): """Elevate volume list context to an admin context.""" name = "VolumeListAdminContext"
# 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 cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder.openstack.common import log as logging LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer('volume', 'volume_host_attribute') class VolumeHostAttributeController(wsgi.Controller): def _add_volume_host_attribute(self, context, req, resp_volume): db_volume = req.get_db_volume(resp_volume['id']) key = "%s:host" % Volume_host_attribute.alias resp_volume[key] = db_volume['host'] @wsgi.extends def show(self, req, resp_obj, id): context = req.environ['cinder.context'] if authorize(context): resp_obj.attach(xml=VolumeHostAttributeTemplate()) volume = resp_obj.obj['volume'] self._add_volume_host_attribute(context, req, volume)
"""The volume type access extension.""" import six import webob from cinder.api import extensions from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception from cinder.i18n import _ from cinder.openstack.common import uuidutils from cinder.volume import volume_types soft_authorize = extensions.soft_extension_authorizer('volume', 'volume_type_access') authorize = extensions.extension_authorizer('volume', 'volume_type_access') def make_volume_type(elem): elem.set('{%s}is_public' % Volume_type_access.namespace, '%s:is_public' % Volume_type_access.alias) def make_volume_type_access(elem): elem.set('volume_type_id') elem.set('project_id') class VolumeTypeTemplate(xmlutil.TemplateBuilder): def construct(self):
# # 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 cinder.api import extensions from cinder.api.openstack import wsgi from cinder import quota QUOTAS = quota.QUOTAS authorize = extensions.soft_extension_authorizer('limits', 'used_limits') class UsedLimitsController(wsgi.Controller): @wsgi.extends def index(self, req, resp_obj): context = req.environ['cinder.context'] if authorize(context): params = req.params.copy() req_version = req.api_version_request # TODO(wangxiyuan): Support "tenant_id" here to keep the backwards # compatibility. Remove it once we drop all support for "tenant". if req_version.matches(None, "3.38") or not context.is_admin: params.pop('project_id', None)
# # 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_log import log as logging from cinder.api import extensions from cinder.api.openstack import wsgi LOG = logging.getLogger(__name__) authorize = extensions.soft_extension_authorizer( 'snapshot', 'snapshot_list_admin_context') class SnapshotListAdminContextController(wsgi.Controller): @wsgi.extends def index(self, req): context = req.environ['cinder.context'] if authorize(context): req.environ['cinder.context'] = context.elevated() yield @wsgi.extends def detail(self, req): context = req.environ['cinder.context'] if authorize(context): req.environ['cinder.context'] = context.elevated()