当前位置: 首页>>代码示例>>Python>>正文


Python extensions.os_compute_soft_authorizer函数代码示例

本文整理汇总了Python中nova.api.openstack.extensions.os_compute_soft_authorizer函数的典型用法代码示例。如果您正苦于以下问题:Python os_compute_soft_authorizer函数的具体用法?Python os_compute_soft_authorizer怎么用?Python os_compute_soft_authorizer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了os_compute_soft_authorizer函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_extensions

    def _get_extensions(self, context):
        """Filter extensions list based on policy."""

        discoverable_extensions = dict()

        for item in hardcoded_extensions:
            discoverable_extensions[item['alias']] = self._create_fake_ext(
                item['name'],
                item['alias'],
                item['description']
            )

        for alias, ext in six.iteritems(self.extension_info.get_extensions()):
            authorize = extensions.os_compute_soft_authorizer(alias)
            if authorize(context, action='discoverable'):
                discoverable_extensions[alias] = ext
            else:
                LOG.debug("Filter out extension %s from discover list",
                          alias)

        # Add fake v2 extensions to list
        extra_exts = {}
        for alias in discoverable_extensions:
            if alias in v21_to_v2_extension_list_mapping:
                for extra_ext in v21_to_v2_extension_list_mapping[alias]:
                    extra_exts[extra_ext["alias"]] = self._create_fake_ext(
                        extra_ext["name"], extra_ext["alias"])
        discoverable_extensions.update(extra_exts)

        # Suppress extensions which we don't want to see in v2
        for suppress_ext in v2_extension_suppress_list:
            try:
                del discoverable_extensions[suppress_ext]
            except KeyError:
                pass

        # v2.1 to v2 extension name mapping
        for rename_ext in v21_to_v2_alias_mapping:
            if rename_ext in discoverable_extensions:
                new_name = v21_to_v2_alias_mapping[rename_ext]
                mod_ext = copy.deepcopy(
                    discoverable_extensions.pop(rename_ext))
                mod_ext.alias = new_name
                discoverable_extensions[new_name] = mod_ext

        return discoverable_extensions
开发者ID:krsacme,项目名称:nova,代码行数:46,代码来源:extension_info.py

示例2: ConfigDriveController

#    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.

"""Config Drive extension."""

from nova.api.openstack.compute.schemas import config_drive as \
                                                  schema_config_drive
from nova.api.openstack import extensions
from nova.api.openstack import wsgi

ALIAS = "os-config-drive"
ATTRIBUTE_NAME = "config_drive"
authorize = extensions.os_compute_soft_authorizer(ALIAS)


class ConfigDriveController(wsgi.Controller):

    def _add_config_drive(self, req, servers):
        for server in servers:
            db_server = req.get_db_instance(server['id'])
            # server['id'] is guaranteed to be in the cache due to
            # the core API adding it in its 'show'/'detail' methods.
            server[ATTRIBUTE_NAME] = db_server['config_drive']

    def _show(self, req, resp_obj):
        if 'server' in resp_obj.obj:
            server = resp_obj.obj['server']
            self._add_config_drive(req, [server])
开发者ID:375670450,项目名称:nova,代码行数:31,代码来源:config_drive.py

示例3: PciServerController

#    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.

import webob.exc

from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova import compute
from nova import exception
from nova import objects


ALIAS = 'os-pci'
soft_authorize = extensions.os_compute_soft_authorizer(ALIAS + ':pci_servers')
authorize = extensions.os_compute_authorizer(ALIAS)

PCI_ADMIN_KEYS = ['id', 'address', 'vendor_id', 'product_id', 'status',
                  'compute_node_id']
PCI_DETAIL_KEYS = ['dev_type', 'label', 'instance_uuid', 'dev_id',
                   'extra_info']


class PciServerController(wsgi.Controller):
    def _extend_server(self, server, instance):
        dev_id = []
        for dev in instance.pci_devices:
            dev_id.append({'id': dev.id})
        server['{0!s}:pci_devices'.format(Pci.alias)] = dev_id
开发者ID:runt18,项目名称:nova,代码行数:30,代码来源:pci.py

示例4: ExtendedServerAttributesController

#
#   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 Extended Server Attributes API extension."""

from nova.api.openstack import api_version_request
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova import compute

ALIAS = "os-extended-server-attributes"
authorize = extensions.os_compute_soft_authorizer(ALIAS)
soft_authorize = extensions.os_compute_soft_authorizer('servers')


class ExtendedServerAttributesController(wsgi.Controller):
    def __init__(self, *args, **kwargs):
        super(ExtendedServerAttributesController, self).__init__(*args,
                                                                 **kwargs)
        self.compute_api = compute.API(skip_policy_check=True)

    def _extend_server(self, context, server, instance, req):
        key = "OS-EXT-SRV-ATTR:hypervisor_hostname"
        server[key] = instance.node

        properties = ['host', 'name']
        if api_version_request.is_supported(req, min_version='2.3'):
开发者ID:amatuerone,项目名称:nova,代码行数:31,代码来源:extended_server_attributes.py


注:本文中的nova.api.openstack.extensions.os_compute_soft_authorizer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。