本文整理汇总了Python中nova.api.openstack.extensions.soft_extension_authorizer函数的典型用法代码示例。如果您正苦于以下问题:Python soft_extension_authorizer函数的具体用法?Python soft_extension_authorizer怎么用?Python soft_extension_authorizer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了soft_extension_authorizer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _get_extensions
def _get_extensions(self, context):
"""Filter extensions list based on policy"""
discoverable_extensions = dict()
for alias, ext in self.extension_info.get_extensions().iteritems():
authorize = extensions.soft_extension_authorizer("compute", "v3:" + alias)
if authorize(context, action="discoverable"):
discoverable_extensions[alias] = ext
else:
LOG.debug(_("Filter out extension %s from discover list"), alias)
return discoverable_extensions
开发者ID:habuka036,项目名称:nova,代码行数:11,代码来源:extension_info.py
示例2: _get_extensions
def _get_extensions(self, context):
"""Filter extensions list based on policy."""
discoverable_extensions = dict()
for alias, ext in self.extension_info.get_extensions().iteritems():
authorize = extensions.soft_extension_authorizer(
'compute', 'v3:' + 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)
# Supress extensions which we don't want to see in v2
for supress_ext in v2_extension_suppress_list:
try:
del discoverable_extensions[supress_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:dtroyer,项目名称:nova,代码行数:39,代码来源:extension_info.py
示例3: ExtendedStatusController
# 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 Extended Status Admin API extension."""
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import compute
authorize = extensions.soft_extension_authorizer('compute', 'extended_status')
class ExtendedStatusController(wsgi.Controller):
def __init__(self, *args, **kwargs):
super(ExtendedStatusController, self).__init__(*args, **kwargs)
self.compute_api = compute.API()
def _extend_server(self, server, instance):
for state in ['task_state', 'vm_state', 'power_state']:
key = "%s:%s" % (Extended_status.alias, state)
server[key] = instance[state]
@wsgi.extends
def show(self, req, resp_obj, id):
context = req.environ['nova.context']
开发者ID:674009287,项目名称:nova,代码行数:31,代码来源:extended_status.py
示例4: ExtendedAZController
#
# 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 Extended Availability Zone Status API extension."""
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova import availability_zones as avail_zone
authorize = extensions.soft_extension_authorizer('compute',
'extended_availability_zone')
class ExtendedAZController(wsgi.Controller):
def _extend_server(self, context, server, instance):
key = "{0!s}:availability_zone".format(Extended_availability_zone.alias)
az = avail_zone.get_instance_availability_zone(context, instance)
server[key] = az or ''
@wsgi.extends
def show(self, req, resp_obj, id):
context = req.environ['nova.context']
if authorize(context):
server = resp_obj.obj['server']
db_instance = req.get_db_instance(server['id'])
self._extend_server(context, server, db_instance)
开发者ID:runt18,项目名称:nova,代码行数:32,代码来源:extended_availability_zone.py
示例5: disk_config_to_api
# under the License.
"""Disk Config extension."""
from oslo_utils import strutils
from webob import exc
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.i18n import _
ALIAS = 'OS-DCF'
XMLNS_DCF = "http://docs.openstack.org/compute/ext/disk_config/api/v1.1"
API_DISK_CONFIG = "%s:diskConfig" % ALIAS
INTERNAL_DISK_CONFIG = "auto_disk_config"
authorize = extensions.soft_extension_authorizer('compute', 'disk_config')
def disk_config_to_api(value):
return 'AUTO' if value else 'MANUAL'
def disk_config_from_api(value):
if value == 'AUTO':
return True
elif value == 'MANUAL':
return False
else:
msg = _("%s must be either 'MANUAL' or 'AUTO'.") % API_DISK_CONFIG
raise exc.HTTPBadRequest(explanation=msg)
开发者ID:375670450,项目名称:nova,代码行数:30,代码来源:disk_config.py
示例6: ExtendedIpsMacController
#
# 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 Ips API extension."""
import itertools
from nova.api.openstack import common
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
authorize = extensions.soft_extension_authorizer('compute', 'extended_ips_mac')
class ExtendedIpsMacController(wsgi.Controller):
def __init__(self, *args, **kwargs):
super(ExtendedIpsMacController, self).__init__(*args, **kwargs)
def _extend_server(self, context, server, instance):
key = "%s:mac_addr" % Extended_ips_mac.alias
networks = common.get_networks_for_instance(context, instance)
for label, network in networks.items():
# NOTE(vish): ips are hidden in some states via the
# hide_server_addresses extension.
if label in server['addresses']:
all_ips = itertools.chain(network["ips"],
network["floating_ips"])
开发者ID:375670450,项目名称:nova,代码行数:31,代码来源:extended_ips_mac.py
示例7: FlavorRxtxController
# 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 Flavor Rxtx API extension."""
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
authorize = extensions.soft_extension_authorizer('compute', 'flavor_rxtx')
class FlavorRxtxController(wsgi.Controller):
def _extend_flavors(self, req, flavors):
for flavor in flavors:
db_flavor = req.get_db_flavor(flavor['id'])
key = 'rxtx_factor'
flavor[key] = db_flavor['rxtx_factor'] or ""
def _show(self, req, resp_obj):
if not authorize(req.environ['nova.context']):
return
if 'flavor' in resp_obj.obj:
resp_obj.attach(xml=FlavorRxtxTemplate())
self._extend_flavors(req, [resp_obj.obj['flavor']])
开发者ID:AsherBond,项目名称:nova,代码行数:31,代码来源:flavor_rxtx.py
示例8: FlavorDisabledController
#
# 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 Flavor Disabled API extension."""
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
authorize = extensions.soft_extension_authorizer('compute', 'flavor_disabled')
class FlavorDisabledController(wsgi.Controller):
def _extend_flavors(self, req, flavors):
for flavor in flavors:
db_flavor = req.get_db_flavor(flavor['id'])
key = "%s:disabled" % Flavor_disabled.alias
flavor[key] = db_flavor['disabled']
def _show(self, req, resp_obj):
if not authorize(req.environ['nova.context']):
return
if 'flavor' in resp_obj.obj:
self._extend_flavors(req, [resp_obj.obj['flavor']])
开发者ID:venusource,项目名称:nova,代码行数:30,代码来源:flavor_disabled.py
示例9: ExtendedServerAttributesController
# under the License.
"""The Extended Server Attributes API extension."""
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import compute
from nova import db
from nova import flags
from nova import log as logging
FLAGS = flags.FLAGS
LOG = logging.getLogger(__name__)
authorize = extensions.soft_extension_authorizer('compute',
'extended_server_attributes')
class ExtendedServerAttributesController(wsgi.Controller):
def __init__(self, *args, **kwargs):
super(ExtendedServerAttributesController, self).__init__(*args,
**kwargs)
self.compute_api = compute.API()
def _get_hypervisor_hostname(self, context, instance):
compute_node = db.compute_node_get_by_host(context, instance["host"])
try:
return compute_node["hypervisor_hostname"]
except TypeError:
return
开发者ID:A7Zulu,项目名称:nova,代码行数:32,代码来源:extended_server_attributes.py
示例10: AttributeTemplate
"""Attribute management extension."""
import traceback
import webob
import webob.exc
from nova.api.openstack.compute import servers
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova.compute import api as compute_api
from nova import exception
from nova.openstack.common.gettextutils import _
authorize = extensions.extension_authorizer("compute", "attributes")
soft_authorize = extensions.soft_extension_authorizer("compute", "attributes")
class AttributeTemplate(xmlutil.TemplateBuilder):
def construct(self):
return xmlutil.MasterTemplate(xmlutil.make_flat_dict("attribute"), 1)
class AttributesTemplate(xmlutil.TemplateBuilder):
def construct(self):
root = xmlutil.TemplateElement("attributes")
elem = xmlutil.make_flat_dict("attribute", selector="attributes", subselector="attribute")
root.append(elem)
return xmlutil.MasterTemplate(root, 1)
开发者ID:kbijon,项目名称:OpenStack-CVRM,代码行数:30,代码来源:scopes_backup.py
示例11: ScopeTemplate
"""Scope management extension."""
import traceback
import webob
import webob.exc
from nova.api.openstack.compute import servers
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova.compute import api as compute_api
from nova import exception
from nova.openstack.common.gettextutils import _
authorize = extensions.extension_authorizer('compute', 'scopes')
soft_authorize = extensions.soft_extension_authorizer('compute', 'scopes')
class ScopeTemplate(xmlutil.TemplateBuilder):
def construct(self):
return xmlutil.MasterTemplate(xmlutil.make_flat_dict('scope'), 1)
class ScopesTemplate(xmlutil.TemplateBuilder):
def construct(self):
root = xmlutil.TemplateElement('scopes')
elem = xmlutil.make_flat_dict('scope', selector='scopes',
subselector='scope')
root.append(elem)
return xmlutil.MasterTemplate(root, 1)
开发者ID:kbijon,项目名称:OpenStack-CVRM,代码行数:31,代码来源:scopes.py
示例12: ExtendedVolumesController
from webob import exc
from nova.api.openstack import common
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import compute
from nova import exception
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
from nova.openstack.common import uuidutils
from nova import volume
ALIAS = "os-extended-volumes"
LOG = logging.getLogger(__name__)
authorize = extensions.soft_extension_authorizer('compute', 'v3:' + ALIAS)
authorize_attach = extensions.soft_extension_authorizer('compute',
'v3:%s:attach' % ALIAS)
authorize_detach = extensions.soft_extension_authorizer('compute',
'v3:%s:detach' % ALIAS)
class ExtendedVolumesController(wsgi.Controller):
def __init__(self, *args, **kwargs):
super(ExtendedVolumesController, self).__init__(*args, **kwargs)
self.compute_api = compute.API()
self.volume_api = volume.API()
def _extend_server(self, context, server, instance):
bdms = self.compute_api.get_instance_bdms(context, instance)
volume_ids = [bdm['volume_id'] for bdm in bdms if bdm['volume_id']]
开发者ID:DrZaarlon,项目名称:nova,代码行数:31,代码来源:extended_volumes.py
示例13: InstanceActionLogController
# 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
"""Logs actions performed on instances"""
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.db.api import instance_action_log_create
import pprint
ALIAS = 'OS-IAL' # Instance Action Log
XMLNS_DCF = "http://docs.openstack.org/compute/ext/instance_action_log/api/v2.0"
authorize = extensions.soft_extension_authorizer('compute', 'action_instance_log')
class InstanceActionLogController(wsgi.Controller):
def _do_log(self, req, resp_obj, action_name, id, extra=''):
context = req.environ['nova.context']
user_name = req._headers.get('X-Auth-User')
if user_name is None:
# If this system is using noauth, the user name will actually be
# in the auth-token, in the format: username:password
token = req._headers.get('X-Auth-Token')
if token is not None:
user_name = token.split(':', 1)[0] # Don't want the password
if not user_name:
user_name = 'NOT-FOUND'
开发者ID:matiu2,项目名称:nova,代码行数:31,代码来源:instance_action_log.py
示例14: make_rule
from xml.dom import minidom
from nova.api.openstack import common
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import compute
from nova.compute import api as compute_api
from nova import exception
from nova.network.security_group import neutron_driver
from nova.network.security_group import openstack_driver
from nova.virt import netutils
authorize = extensions.extension_authorizer("compute", "security_groups")
softauth = extensions.soft_extension_authorizer("compute", "security_groups")
def make_rule(elem):
elem.set("id")
elem.set("parent_group_id")
proto = xmlutil.SubTemplateElement(elem, "ip_protocol")
proto.text = "ip_protocol"
from_port = xmlutil.SubTemplateElement(elem, "from_port")
from_port.text = "from_port"
to_port = xmlutil.SubTemplateElement(elem, "to_port")
to_port.text = "to_port"
开发者ID:kevinbenton,项目名称:nova,代码行数:30,代码来源:security_groups.py
示例15: ServerActionsController
# 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 webob import exc
from nova.api.openstack import common
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova import compute
from nova.openstack.common.gettextutils import _
ALIAS = "os-server-actions"
authorize_actions = extensions.extension_authorizer('compute',
'v3:' + ALIAS)
authorize_events = extensions.soft_extension_authorizer('compute',
'v3:' + ALIAS + ':events')
ACTION_KEYS = ['action', 'instance_uuid', 'request_id', 'user_id',
'project_id', 'start_time', 'message']
EVENT_KEYS = ['event', 'start_time', 'finish_time', 'result', 'traceback']
class ServerActionsController(wsgi.Controller):
def __init__(self):
super(ServerActionsController, self).__init__()
self.compute_api = compute.API()
self.action_api = compute.InstanceActionAPI()
def _format_action(self, action_raw):
action = {}
开发者ID:B-Rich,项目名称:nova-1,代码行数:32,代码来源:server_actions.py
示例16: ExtendedVolumesController
# 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 Extended Volumes API extension."""
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import compute
authorize = extensions.soft_extension_authorizer('compute', 'extended_volumes')
class ExtendedVolumesController(wsgi.Controller):
def __init__(self, *args, **kwargs):
super(ExtendedVolumesController, self).__init__(*args, **kwargs)
self.compute_api = compute.API()
def _extend_server(self, context, server, instance):
bdms = self.compute_api.get_instance_bdms(context, instance)
volume_ids = [bdm['volume_id'] for bdm in bdms if bdm['volume_id']]
key = "%s:volumes_attached" % Extended_volumes.alias
server[key] = [{'id': volume_id} for volume_id in volume_ids]
@wsgi.extends
def show(self, req, resp_obj, id):
开发者ID:674009287,项目名称:nova,代码行数:31,代码来源:extended_volumes.py
示例17: make_actions
# 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 webob import exc
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova import compute
from nova import exception
authorize_actions = extensions.extension_authorizer('compute',
'instance_actions')
authorize_events = extensions.soft_extension_authorizer('compute',
'instance_actions:events')
ACTION_KEYS = ['action', 'instance_uuid', 'request_id', 'user_id',
'project_id', 'start_time', 'message']
EVENT_KEYS = ['event', 'start_time', 'finish_time', 'result', 'traceback']
def make_actions(elem):
for key in ACTION_KEYS:
elem.set(key)
def make_action(elem):
for key in ACTION_KEYS:
elem.set(key)
event = xmlutil.TemplateElement('events', selector='events')
开发者ID:674009287,项目名称:nova,代码行数:32,代码来源:instance_actions.py
示例18: UsedLimitsTemplate
# under the License
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova.openstack.common import log as logging
from nova import quota
LOG = logging.getLogger(__name__)
QUOTAS = quota.QUOTAS
XMLNS = "http://docs.openstack.org/compute/ext/used_limits/api/v1.1"
ALIAS = "os-used-limits"
authorize = extensions.soft_extension_authorizer('compute', 'used_limits')
class UsedLimitsTemplate(xmlutil.TemplateBuilder):
def construct(self):
root = xmlutil.TemplateElement('limits', selector='limits')
root.set('{%s}usedLimits' % XMLNS, '%s:usedLimits' % ALIAS)
return xmlutil.SlaveTemplate(root, 1, nsmap={ALIAS: XMLNS})
class UsedLimitsController(wsgi.Controller):
@wsgi.extends
def index(self, req, resp_obj):
resp_obj.attach(xml=UsedLimitsTemplate())
context = req.environ['nova.context']
开发者ID:Cerberus98,项目名称:nova,代码行数:31,代码来源:used_limits.py
示例19: KeypairTemplate
"""Keypair management extension."""
import webob
import webob.exc
from nova.api.openstack.compute import servers
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova.compute import api as compute_api
from nova import exception
from nova.openstack.common.gettextutils import _
authorize = extensions.extension_authorizer('compute', 'keypairs')
soft_authorize = extensions.soft_extension_authorizer('compute', 'keypairs')
class KeypairTemplate(xmlutil.TemplateBuilder):
def construct(self):
return xmlutil.MasterTemplate(xmlutil.make_flat_dict('keypair'), 1)
class KeypairsTemplate(xmlutil.TemplateBuilder):
def construct(self):
root = xmlutil.TemplateElement('keypairs')
elem = xmlutil.make_flat_dict('keypair', selector='keypairs',
subselector='keypair')
root.append(elem)
return xmlutil.MasterTemplate(root, 1)
开发者ID:CrazyTeaFs,项目名称:nova,代码行数:31,代码来源:keypairs.py
示例20: ViewBuilder
# 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 nova.api.openstack.compute import servers
from nova.api.openstack.compute import views
from nova.api.openstack import extensions
authorize = extensions.soft_extension_authorizer("compute", "createserverext")
class ViewBuilder(views.servers.ViewBuilder):
"""Adds security group output when viewing server details."""
def show(self, request, instance):
"""Detailed view of a single instance."""
server = super(ViewBuilder, self).show(request, instance)
context = request.environ["nova.context"]
if authorize(context):
server["server"]["security_groups"] = self._get_groups(instance)
return server
def _get_groups(self, instance):
"""Get a list of security groups for this instance."""
开发者ID:danwent,项目名称:nova,代码行数:31,代码来源:createserverext.py
注:本文中的nova.api.openstack.extensions.soft_extension_authorizer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论