• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python common.raise_feature_not_supported函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create

    def create(self, req, server_id, body):
        context = req.environ['nova.context']
        context.can(rc_policies.BASE_POLICY_NAME)
        instance = common.get_instance(self.compute_api, context, server_id)
        protocol = body['remote_console']['protocol']
        console_type = body['remote_console']['type']
        try:
            handler = self.handlers.get(protocol)
            output = handler(context, instance, console_type)
            return {'remote_console': {'protocol': protocol,
                                       'type': console_type,
                                       'url': output['url']}}

        except exception.InstanceNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
        except exception.InstanceNotReady as e:
            raise webob.exc.HTTPConflict(explanation=e.format_message())
        except (exception.ConsoleTypeInvalid,
                exception.ConsoleTypeUnavailable,
                exception.ImageSerialPortNumberInvalid,
                exception.ImageSerialPortNumberExceedFlavorValue,
                exception.SocketPortRangeExhaustedException) as e:
            raise webob.exc.HTTPBadRequest(explanation=e.format_message())
        except NotImplementedError:
            common.raise_feature_not_supported()
开发者ID:andymcc,项目名称:nova,代码行数:25,代码来源:remote_consoles.py


示例2: create

    def create(self, req, server_id, body):
        context = req.environ["nova.context"]
        authorize(context)
        instance = common.get_instance(self.compute_api, context, server_id)
        protocol = body["remote_console"]["protocol"]
        console_type = body["remote_console"]["type"]
        try:
            handler = self.handlers.get(protocol)
            output = handler(context, instance, console_type)
            return {"remote_console": {"protocol": protocol, "type": console_type, "url": output["url"]}}

        except exception.InstanceNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
        except exception.InstanceNotReady as e:
            raise webob.exc.HTTPConflict(explanation=e.format_message())
        except (
            exception.ConsoleTypeInvalid,
            exception.ConsoleTypeUnavailable,
            exception.ImageSerialPortNumberInvalid,
            exception.ImageSerialPortNumberExceedFlavorValue,
            exception.SocketPortRangeExhaustedException,
        ) as e:
            raise webob.exc.HTTPBadRequest(explanation=e.format_message())
        except NotImplementedError:
            common.raise_feature_not_supported()
开发者ID:coryschwartz,项目名称:nova,代码行数:25,代码来源:remote_consoles.py


示例3: get_serial_console

    def get_serial_console(self, req, id, body):
        """Get connection to a serial console."""
        context = req.environ['nova.context']
        authorize(context)

        # If type is not supplied or unknown get_serial_console below will cope
        console_type = body['os-getSerialConsole'].get('type')
        try:
            instance = common.get_instance(self.compute_api, context, id)
            output = self.compute_api.get_serial_console(context,
                                                         instance,
                                                         console_type)
        except exception.InstanceNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
        except exception.InstanceNotReady as e:
            raise webob.exc.HTTPConflict(explanation=e.format_message())
        except (exception.ConsoleTypeUnavailable,
                exception.ImageSerialPortNumberInvalid,
                exception.ImageSerialPortNumberExceedFlavorValue,
                exception.SocketPortRangeExhaustedException) as e:
            raise webob.exc.HTTPBadRequest(explanation=e.format_message())
        except NotImplementedError:
            common.raise_feature_not_supported()

        return {'console': {'type': console_type, 'url': output['url']}}
开发者ID:Pratyusha9,项目名称:nova,代码行数:25,代码来源:remote_consoles.py


示例4: get_console_output

    def get_console_output(self, req, id, body):
        """Get text console output."""
        context = req.environ['nova.context']
        authorize(context)

        instance = common.get_instance(self.compute_api, context, id)
        length = body['os-getConsoleOutput'].get('length')
        # TODO(cyeoh): In a future API update accept a length of -1
        # as meaning unlimited length (convert to None)

        try:
            output = self.compute_api.get_console_output(context,
                                                         instance,
                                                         length)
        # NOTE(cyeoh): This covers race conditions where the instance is
        # deleted between common.get_instance and get_console_output
        # being called
        except exception.InstanceNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
        except exception.InstanceNotReady as e:
            raise webob.exc.HTTPConflict(explanation=e.format_message())
        except NotImplementedError:
            common.raise_feature_not_supported()

        # XML output is not correctly escaped, so remove invalid characters
        # NOTE(cyeoh): We don't support XML output with V2.1, but for
        # backwards compatibility reasons we continue to filter the output
        # We should remove this in the future
        remove_re = re.compile('[\x00-\x08\x0B-\x1F]')
        output = remove_re.sub('', output)

        return {'output': output}
开发者ID:Francis-Liu,项目名称:animated-broccoli,代码行数:32,代码来源:console_output.py


示例5: get_rdp_console

    def get_rdp_console(self, req, id, body):
        """Get text console output."""
        context = req.environ['nova.context']
        authorize(context)

        # If type is not supplied or unknown, get_rdp_console below will cope
        console_type = body['os-getRDPConsole'].get('type')

        instance = common.get_instance(self.compute_api, context, id)
        try:
            # NOTE(mikal): get_rdp_console() can raise InstanceNotFound, so
            # we still need to catch it here.
            output = self.compute_api.get_rdp_console(context,
                                                      instance,
                                                      console_type)
        except exception.ConsoleTypeUnavailable as e:
            raise webob.exc.HTTPBadRequest(explanation=e.format_message())
        except exception.InstanceNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
        except exception.InstanceNotReady as e:
            raise webob.exc.HTTPConflict(explanation=e.format_message())
        except NotImplementedError:
            common.raise_feature_not_supported()

        return {'console': {'type': console_type, 'url': output['url']}}
开发者ID:Pratyusha9,项目名称:nova,代码行数:25,代码来源:remote_consoles.py


示例6: index

    def index(self, req, server_id):
        context = req.environ["nova.context"]
        context.can(sd_policies.BASE_POLICY_NAME)

        instance = common.get_instance(self.compute_api, context, server_id)

        try:
            if api_version_request.is_supported(req, min_version='2.48'):
                diagnostics = self.compute_api.get_instance_diagnostics(
                    context, instance)
                return self._view_builder.instance_diagnostics(diagnostics)

            return self.compute_api.get_diagnostics(context, instance)
        except exception.InstanceInvalidState as state_error:
            common.raise_http_conflict_for_instance_invalid_state(state_error,
                    'get_diagnostics', server_id)
        except exception.InstanceNotReady as e:
            raise webob.exc.HTTPConflict(explanation=e.format_message())
        except exception.InstanceDiagnosticsNotSupported:
            # NOTE(snikitin): During upgrade we may face situation when env
            # has new API and old compute. New compute returns a
            # Diagnostics object. Old compute returns a dictionary. So we
            # can't perform a request correctly if compute is too old.
            msg = _('Compute node is too old. You must complete the '
                    'upgrade process to be able to get standardized '
                    'diagnostics data which is available since v2.48. However '
                    'you are still able to get diagnostics data in '
                    'non-standardized format which is available until v2.47.')
            raise webob.exc.HTTPBadRequest(explanation=msg)
        except NotImplementedError:
            common.raise_feature_not_supported()
开发者ID:Juniper,项目名称:nova,代码行数:31,代码来源:server_diagnostics.py


示例7: uptime

    def uptime(self, req, id):
        context = req.environ['nova.context']
        context.can(hv_policies.BASE_POLICY_NAME)
        try:
            hyp = self.host_api.compute_node_get(context, id)
            req.cache_db_compute_node(hyp)
        except (ValueError, exception.ComputeHostNotFound):
            msg = _("Hypervisor with ID '%s' could not be found.") % id
            raise webob.exc.HTTPNotFound(explanation=msg)

        # Get the uptime
        try:
            host = hyp.host
            uptime = self.host_api.get_host_uptime(context, host)
            service = self.host_api.service_get_by_compute_host(context, host)
        except NotImplementedError:
            common.raise_feature_not_supported()
        except exception.ComputeServiceUnavailable as e:
            raise webob.exc.HTTPBadRequest(explanation=e.format_message())
        except exception.HostMappingNotFound:
            # NOTE(danms): This mirrors the compute_node_get() behavior
            # where the node is missing, resulting in NotFound instead of
            # BadRequest if we fail on the map lookup.
            msg = _("Hypervisor with ID '%s' could not be found.") % id
            raise webob.exc.HTTPNotFound(explanation=msg)

        return dict(hypervisor=self._view_hypervisor(hyp, service, False, req,
                                                     uptime=uptime))
开发者ID:andymcc,项目名称:nova,代码行数:28,代码来源:hypervisors.py


示例8: update

    def update(self, req, id, body):
        """Add or modify domain entry."""
        context = req.environ['nova.context']
        authorize(context, action="domain:update")
        fqdomain = _unquote_domain(id)
        entry = body['domain_entry']
        scope = entry['scope']
        project = entry.get('project', None)
        av_zone = entry.get('availability_zone', None)

        if scope == 'private' and project:
            msg = _("you can not pass project if the scope is private")
            raise webob.exc.HTTPBadRequest(explanation=msg)
        if scope == 'public' and av_zone:
            msg = _("you can not pass av_zone if the scope is public")
            raise webob.exc.HTTPBadRequest(explanation=msg)

        if scope == 'private':
            create_dns_domain = self.network_api.create_private_dns_domain
            area_name, area = 'availability_zone', av_zone
        else:
            create_dns_domain = self.network_api.create_public_dns_domain
            area_name, area = 'project', project

        try:
            create_dns_domain(context, fqdomain, area)
        except NotImplementedError:
            common.raise_feature_not_supported()

        return _translate_domain_entry_view({'domain': fqdomain,
                                             'scope': scope,
                                             area_name: area})
开发者ID:hanbaoying,项目名称:nova,代码行数:32,代码来源:floating_ip_dns.py


示例9: show

    def show(self, req, domain_id, id):
        """Return the DNS entry that corresponds to domain_id and id."""
        context = req.environ['nova.context']
        authorize(context)
        domain = _unquote_domain(domain_id)

        floating_ip = None
        # Check whether id is a valid ipv4/ipv6 address.
        if netutils.is_valid_ip(id):
            floating_ip = id

        try:
            if floating_ip:
                entries = self.network_api.get_dns_entries_by_address(context,
                                                                  floating_ip,
                                                                  domain)
            else:
                entries = self.network_api.get_dns_entries_by_name(context,
                                                                   id,
                                                                   domain)
        except NotImplementedError:
            common.raise_feature_not_supported()

        if not entries:
            explanation = _("DNS entries not found.")
            raise webob.exc.HTTPNotFound(explanation=explanation)

        if floating_ip:
            entrylist = [_create_dns_entry(floating_ip, entry, domain)
                         for entry in entries]
            dns_entries = _translate_dns_entries_view(entrylist)
            return wsgi.ResponseObject(dns_entries)

        entry = _create_dns_entry(entries[0], id, domain)
        return _translate_dns_entry_view(entry)
开发者ID:hanbaoying,项目名称:nova,代码行数:35,代码来源:floating_ip_dns.py


示例10: _disassociate_project_only

 def _disassociate_project_only(self, req, id, body):
     context = req.environ['nova.context']
     authorize(context)
     try:
         self.network_api.associate(context, id, project=None)
     except exception.NetworkNotFound:
         msg = _("Network not found")
         raise exc.HTTPNotFound(explanation=msg)
     except NotImplementedError:
         common.raise_feature_not_supported()
开发者ID:Pratyusha9,项目名称:nova,代码行数:10,代码来源:networks_associate.py


示例11: _disassociate_host_only

 def _disassociate_host_only(self, req, id, body):
     context = req.environ['nova.context']
     context.can(na_policies.BASE_POLICY_NAME)
     try:
         self.network_api.associate(context, id, host=None)
     except exception.NetworkNotFound:
         msg = _("Network not found")
         raise exc.HTTPNotFound(explanation=msg)
     except NotImplementedError:
         common.raise_feature_not_supported()
开发者ID:Juniper,项目名称:nova,代码行数:10,代码来源:networks_associate.py


示例12: _associate_host

    def _associate_host(self, req, id, body):
        context = req.environ["nova.context"]
        authorize(context)

        try:
            self.network_api.associate(context, id, host=body["associate_host"])
        except exception.NetworkNotFound:
            msg = _("Network not found")
            raise exc.HTTPNotFound(explanation=msg)
        except NotImplementedError:
            common.raise_feature_not_supported()
开发者ID:j-carpentier,项目名称:nova,代码行数:11,代码来源:networks_associate.py


示例13: _host_power_action

 def _host_power_action(self, req, host_name, action):
     """Reboots, shuts down or powers up the host."""
     context = req.environ['nova.context']
     context.can(hosts_policies.BASE_POLICY_NAME)
     try:
         result = self.api.host_power_action(context, host_name, action)
     except NotImplementedError:
         common.raise_feature_not_supported()
     except (exception.HostNotFound, exception.HostMappingNotFound) as e:
         raise webob.exc.HTTPNotFound(explanation=e.format_message())
     except exception.ComputeServiceUnavailable as e:
         raise webob.exc.HTTPBadRequest(explanation=e.format_message())
     return {"host": host_name, "power_action": result}
开发者ID:andymcc,项目名称:nova,代码行数:13,代码来源:hosts.py


示例14: delete

    def delete(self, req, id):
        """Delete the domain identified by id."""
        context = req.environ['nova.context']
        authorize(context, action="domain:delete")
        domain = _unquote_domain(id)

        # Delete the whole domain
        try:
            self.network_api.delete_dns_domain(context, domain)
        except NotImplementedError:
            common.raise_feature_not_supported()
        except exception.NotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
开发者ID:hanbaoying,项目名称:nova,代码行数:13,代码来源:floating_ip_dns.py


示例15: add

    def add(self, req, body):
        context = req.environ["nova.context"]
        context.can(net_policies.BASE_POLICY_NAME)

        network_id = body["id"]
        project_id = context.project_id

        try:
            self.network_api.add_network_to_project(context, project_id, network_id)
        except NotImplementedError:
            common.raise_feature_not_supported()
        except (exception.NoMoreNetworks, exception.NetworkNotFoundForUUID) as e:
            raise exc.HTTPBadRequest(explanation=e.format_message())
开发者ID:cyx1231st,项目名称:nova,代码行数:13,代码来源:networks.py


示例16: _host_power_action

 def _host_power_action(self, req, host_name, action):
     """Reboots, shuts down or powers up the host."""
     context = req.environ["nova.context"]
     authorize(context)
     try:
         result = self.api.host_power_action(context, host_name=host_name, action=action)
     except NotImplementedError:
         common.raise_feature_not_supported()
     except exception.HostNotFound as e:
         raise webob.exc.HTTPNotFound(explanation=e.format_message())
     except exception.ComputeServiceUnavailable as e:
         raise webob.exc.HTTPBadRequest(explanation=e.format_message())
     return {"host": host_name, "power_action": result}
开发者ID:isyippee,项目名称:nova,代码行数:13,代码来源:hosts.py


示例17: create

    def create(self, req, server_id, body):
        """Attach an interface to an instance."""
        context = req.environ['nova.context']
        authorize(context)

        network_id = None
        port_id = None
        req_ip = None
        if body:
            attachment = body['interfaceAttachment']
            network_id = attachment.get('net_id', None)
            port_id = attachment.get('port_id', None)
            try:
                req_ip = attachment['fixed_ips'][0]['ip_address']
            except Exception:
                pass

        if network_id and port_id:
            msg = _("Must not input both network_id and port_id")
            raise exc.HTTPBadRequest(explanation=msg)
        if req_ip and not network_id:
            msg = _("Must input network_id when request IP address")
            raise exc.HTTPBadRequest(explanation=msg)

        instance = common.get_instance(self.compute_api, context, server_id)
        try:
            vif = self.compute_api.attach_interface(context,
                instance, network_id, port_id, req_ip)
        except (exception.InterfaceAttachFailedNoNetwork,
                exception.NetworkDuplicated,
                exception.NetworkAmbiguous,
                exception.NoMoreFixedIps,
                exception.PortNotUsable) as e:
            raise exc.HTTPBadRequest(explanation=e.format_message())
        except (exception.InstanceIsLocked,
                exception.FixedIpAlreadyInUse,
                exception.PortInUse) as e:
            raise exc.HTTPConflict(explanation=e.format_message())
        except (exception.PortNotFound,
                exception.NetworkNotFound) as e:
            raise exc.HTTPNotFound(explanation=e.format_message())
        except NotImplementedError:
            common.raise_feature_not_supported()
        except exception.InterfaceAttachFailed as e:
            raise webob.exc.HTTPInternalServerError(
                explanation=e.format_message())
        except exception.InstanceInvalidState as state_error:
            common.raise_http_conflict_for_instance_invalid_state(state_error,
                    'attach_interface', server_id)

        return self.show(req, server_id, vif['id'])
开发者ID:375670450,项目名称:nova,代码行数:51,代码来源:attach_interfaces.py


示例18: add

    def add(self, req, body):
        context = req.environ['nova.context']
        authorize(context)

        network_id = body['id']
        project_id = context.project_id

        try:
            self.network_api.add_network_to_project(
                context, project_id, network_id)
        except NotImplementedError:
            common.raise_feature_not_supported()
        except (exception.NoMoreNetworks,
                exception.NetworkNotFoundForUUID) as e:
            raise exc.HTTPBadRequest(explanation=e.format_message())
开发者ID:binarycode,项目名称:nova,代码行数:15,代码来源:networks.py


示例19: show

 def show(self, req, id):
     """Return certificate information."""
     context = req.environ["nova.context"]
     authorize(context, action="show")
     if id != "root":
         msg = _("Only root certificate can be retrieved.")
         # TODO(oomichi): This seems a HTTPBadRequest case because of the
         # above message. This will be changed with a microversion in the
         # future.
         common.raise_feature_not_supported(msg=msg)
     try:
         cert = self.cert_rpcapi.fetch_ca(context, project_id=context.project_id)
     except exception.CryptoCAFileNotFound as e:
         raise webob.exc.HTTPNotFound(explanation=e.format_message())
     return {"certificate": _translate_certificate_view(cert)}
开发者ID:coryschwartz,项目名称:nova,代码行数:15,代码来源:certificates.py


示例20: change_password

    def change_password(self, req, id, body):
        context = req.environ['nova.context']
        authorize(context)

        password = body['changePassword']['adminPass']
        instance = common.get_instance(self.compute_api, context, id)
        try:
            self.compute_api.set_admin_password(context, instance, password)
        except exception.InstancePasswordSetFailed as e:
            raise exc.HTTPConflict(explanation=e.format_message())
        except exception.InstanceInvalidState as e:
            raise common.raise_http_conflict_for_instance_invalid_state(
                e, 'changePassword', id)
        except NotImplementedError:
            msg = _("Unable to set password on instance")
            common.raise_feature_not_supported(msg=msg)
开发者ID:hanbaoying,项目名称:nova,代码行数:16,代码来源:admin_password.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap