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

Python utils.is_extension_supported函数代码示例

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

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



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

示例1: sync_routers

    def sync_routers(self, context, **kwargs):
        """Sync routers according to filters to a specific agent.

        @param context: contain user information
        @param kwargs: host, router_ids
        @return: a list of routers
                 with their interfaces and floating_ips
        """
        router_ids = kwargs.get('router_ids')
        host = kwargs.get('host')
        context = neutron_context.get_admin_context()
        if utils.is_extension_supported(
            self.l3plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
            routers = (
                self.l3plugin.list_active_sync_routers_on_active_l3_agent(
                    context, host, router_ids))
        else:
            routers = self.l3plugin.get_sync_data(context, router_ids)
        if utils.is_extension_supported(
            self.plugin, constants.PORT_BINDING_EXT_ALIAS):
            self._ensure_host_set_on_ports(context, host, routers)
        LOG.debug("Routers returned to l3 agent:\n %s",
                  utils.DelayedStringRenderer(jsonutils.dumps,
                                              routers, indent=5))
        return routers
开发者ID:annp,项目名称:neutron,代码行数:25,代码来源:l3_rpc.py


示例2: sync_routers

    def sync_routers(self, context, **kwargs):
        """Sync routers according to filters to a specific agent.

        @param context: contain user information
        @param kwargs: host, router_ids
        @return: a list of routers
                 with their interfaces and floating_ips
        """
        router_ids = kwargs.get('router_ids')
        host = kwargs.get('host')
        context = neutron_context.get_admin_context()
        if not self.l3plugin:
            routers = {}
            LOG.error(_('No plugin for L3 routing registered! Will reply '
                        'to l3 agent with empty router dictionary.'))
        elif utils.is_extension_supported(
                self.l3plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
            if cfg.CONF.router_auto_schedule:
                self.l3plugin.auto_schedule_routers(context, host, router_ids)
            routers = (
                self.l3plugin.list_active_sync_routers_on_active_l3_agent(
                    context, host, router_ids))
        else:
            routers = self.l3plugin.get_sync_data(context, router_ids)
        if utils.is_extension_supported(
            self.plugin, constants.PORT_BINDING_EXT_ALIAS):
            self._ensure_host_set_on_ports(context, host, routers)
        LOG.debug(_("Routers returned to l3 agent:\n %s"),
                  jsonutils.dumps(routers, indent=5))
        return routers
开发者ID:enlinxu,项目名称:neutron,代码行数:30,代码来源:l3_rpc.py


示例3: _notification

 def _notification(self, context, method, payload, network_id):
     """Notify all the agents that are hosting the network."""
     plugin = manager.NeutronManager.get_plugin()
     if (method != 'network_delete_end' and utils.is_extension_supported(
             plugin, constants.DHCP_AGENT_SCHEDULER_EXT_ALIAS)):
         if method == 'port_create_end':
             # we don't schedule when we create network
             # because we want to give admin a chance to
             # schedule network manually by API
             adminContext = (context if context.is_admin else
                             context.elevated())
             network = plugin.get_network(adminContext, network_id)
             chosen_agents = plugin.schedule_network(adminContext, network)
             if chosen_agents:
                 for agent in chosen_agents:
                     self._notification_host(
                         context, 'network_create_end',
                         {'network': {'id': network_id}},
                         agent['host'])
         for (host, topic) in self._get_dhcp_agents(context, network_id):
             self.cast(
                 context, self.make_msg(method,
                                        payload=payload),
                 topic='%s.%s' % (topic, host))
     else:
         # besides the non-agentscheduler plugin,
         # There is no way to query who is hosting the network
         # when the network is deleted, so we need to fanout
         self._notification_fanout(context, method, payload)
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:29,代码来源:dhcp_rpc_agent_api.py


示例4: add_dvr_arp_rule

 def add_dvr_arp_rule(self, context, port_id, action):
     l3plugin = manager.NeutronManager.get_service_plugins().get(service_constants.L3_ROUTER_NAT)
     if l3plugin and utils.is_extension_supported(l3plugin, q_const.L3_DISTRIBUTED_EXT_ALIAS):
         try:
             l3plugin.dvr_remote_port_vmarp_table_update(context, port_id, action)
         except exceptions.PortNotFound:
             LOG.debug("Port %s not found during ARP update", port_id)
开发者ID:nash-x,项目名称:hws,代码行数:7,代码来源:cascaded_mech_driver.py


示例5: _agent_notification_bulk

    def _agent_notification_bulk(self, context, method, routers,
                                 hosting_device, operation):
        """Notify the Cisco cfg agent handling a particular hosting_device.

        A single notification can contain multiple routers.
        """
        admin_context = context.is_admin and context or context.elevated()
        dmplugin = manager.NeutronManager.get_service_plugins().get(
            cisco_constants.DEVICE_MANAGER)
        if (hosting_device is not None and utils.is_extension_supported(
                dmplugin, CFGAGENT_SCHED)):
            agents = dmplugin.get_cfg_agents_for_hosting_devices(
                admin_context, [hosting_device['id']], admin_state_up=True,
                schedule=True)
            if agents:
                agent = agents[0]
                LOG.debug('Notify %(agent_type)s at %(topic)s.%(host)s the '
                          'message %(method)s [BULK]',
                          {'agent_type': agent.agent_type,
                           'topic': CFG_AGENT_L3_ROUTING,
                           'host': agent.host,
                           'method': method})
                cctxt = self.client.prepare(server=agent.host,
                                            version='1.1')
                cctxt.cast(context, method, routers=routers)
开发者ID:abattye,项目名称:networking-cisco,代码行数:25,代码来源:l3_router_rpc_cfg_agent_api.py


示例6: _extend_router_dict_ha

 def _extend_router_dict_ha(self, router_res, router_db):
     if utils.is_extension_supported(self, ha.HA_ALIAS):
         ha_s = router_db.ha_settings
         rr_b = router_db.redundancy_binding
         if rr_b and rr_b.user_router:
             # include static routes from user visible router
             temp = {}
             self._extend_router_dict_extraroute(temp,
                                                 rr_b.user_router)
             if temp['routes']:
                 router_res['routes'].extend(temp['routes'])
         router_res[ha.ENABLED] = False if ha_s is None else True
         if router_res[ha.ENABLED]:
             ha_details = {ha.TYPE: ha_s.ha_type,
                           ha.PRIORITY: ha_s.priority,
                           ha.STATE: ha_s.state,
                           ha.REDUNDANCY_LEVEL: ha_s.redundancy_level,
                           ha.PROBE_CONNECTIVITY: ha_s.probe_connectivity}
             if ha_details[ha.PROBE_CONNECTIVITY]:
                 ha_details.update({ha.PROBE_TARGET: ha_s.probe_target,
                                    ha.PROBE_INTERVAL: ha_s.probe_interval})
             ha_details[ha.REDUNDANCY_ROUTERS] = (
                 [{'id': b.redundancy_router_id, ha.PRIORITY: b.priority,
                   ha.STATE: b.state}
                  for b in router_db.redundancy_bindings])
             router_res[ha.DETAILS] = ha_details
         else:
             # ensure any router details are removed
             router_res.pop(ha.DETAILS, None)
开发者ID:JoelCapitao,项目名称:networking-cisco,代码行数:29,代码来源:ha_db.py


示例7: get_sync_data_metering

    def get_sync_data_metering(self, context, **kwargs):
        l3_plugin = directory.get_plugin(consts.L3)
        if not l3_plugin:
            return

        metering_data = self.meter_plugin.get_sync_data_metering(context)
        host = kwargs.get('host')
        if not utils.is_extension_supported(
            l3_plugin, consts.L3_AGENT_SCHEDULER_EXT_ALIAS) or not host:
            return metering_data
        else:
            agents = l3_plugin.get_l3_agents(context, filters={'host': [host]})
            if not agents:
                LOG.error(_LE('Unable to find agent %s.'), host)
                return

            routers = l3_plugin.list_routers_on_l3_agent(context, agents[0].id)
            router_ids = [router['id'] for router in routers['routers']]
            if not router_ids:
                return
            else:
                return [
                    router for router in metering_data
                    if router['id'] in router_ids
                ]
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:25,代码来源:metering_rpc.py


示例8: _add_az_to_response

 def _add_az_to_response(router_res, router_db):
     l3_plugin = directory.get_plugin(constants.L3)
     if not utils.is_extension_supported(l3_plugin,
                                         'router_availability_zone'):
         return
     router_res['availability_zones'] = (
         l3_plugin.get_router_availability_zones(router_db))
开发者ID:eayunstack,项目名称:neutron,代码行数:7,代码来源:router.py


示例9: _notify_agents

    def _notify_agents(self, context, method, payload, network_id):
        """Notify all the agents that are hosting the network."""
        # fanout is required as we do not know who is "listening"
        no_agents = not utils.is_extension_supported(
            self.plugin, constants.DHCP_AGENT_SCHEDULER_EXT_ALIAS)
        fanout_required = method == 'network_delete_end' or no_agents

        # we do nothing on network creation because we want to give the
        # admin the chance to associate an agent to the network manually
        cast_required = method != 'network_create_end'

        if fanout_required:
            self._fanout_message(context, method, payload)
        elif cast_required:
            admin_ctx = (context if context.is_admin else context.elevated())
            network = self.plugin.get_network(admin_ctx, network_id)
            agents = self.plugin.get_dhcp_agents_hosting_networks(
                context, [network_id])

            # schedule the network first, if needed
            schedule_required = (
                method == 'port_create_end' and
                not self._is_reserved_dhcp_port(payload['port']))
            if schedule_required:
                agents = self._schedule_network(admin_ctx, network, agents)

            enabled_agents = self._get_enabled_agents(
                context, network, agents, method, payload)
            for agent in enabled_agents:
                self._cast_message(
                    context, method, payload, agent.host, agent.topic)
开发者ID:afori,项目名称:neutron,代码行数:31,代码来源:dhcp_rpc_agent_api.py


示例10: auto_schedule_routers

    def auto_schedule_routers(self, plugin, context, host, router_ids):
        """Schedule non-hosted routers to L3 Agent running on host.

        If router_ids is given, each router in router_ids is scheduled
        if it is not scheduled yet. Otherwise all unscheduled routers
        are scheduled.
        Do not schedule the routers which are hosted already
        by active l3 agents.

        :returns: True if routers have been successfully assigned to host
        """
        l3_agent = plugin.get_enabled_agent_on_host(context, constants.AGENT_TYPE_L3, host)
        if not l3_agent:
            return False

        # NOTE(armando-migliaccio): DVR routers should not be auto
        # scheduled because auto-scheduling may interfere with the
        # placement rules for IR and SNAT namespaces.
        unscheduled_routers = self._get_routers_to_schedule(context, plugin, router_ids, exclude_distributed=True)
        if not unscheduled_routers:
            if utils.is_extension_supported(plugin, constants.L3_HA_MODE_EXT_ALIAS):
                return self._schedule_ha_routers_to_additional_agent(plugin, context, l3_agent)

        target_routers = self._get_routers_can_schedule(context, plugin, unscheduled_routers, l3_agent)
        if not target_routers:
            LOG.warn(_LW("No routers compatible with L3 agent configuration " "on host %s"), host)
            return False

        self._bind_routers(context, plugin, target_routers, l3_agent)
        return True
开发者ID:simudream,项目名称:neutron,代码行数:30,代码来源:l3_agent_scheduler.py


示例11: auto_schedule_routers

    def auto_schedule_routers(self, plugin, context, host, router_ids):
        """Schedule non-hosted routers to L3 Agent running on host.

        If router_ids is given, each router in router_ids is scheduled
        if it is not scheduled yet. Otherwise all unscheduled routers
        are scheduled.
        Do not schedule the routers which are hosted already
        by active l3 agents.

        :returns: True if routers have been successfully assigned to host
        """
        l3_agent = plugin.get_enabled_agent_on_host(
            context, lib_const.AGENT_TYPE_L3, host)
        if not l3_agent:
            return False

        unscheduled_routers = self._get_routers_to_schedule(
            context, plugin, router_ids)
        if not unscheduled_routers:
            if utils.is_extension_supported(
                    plugin, lib_const.L3_HA_MODE_EXT_ALIAS):
                return self._schedule_ha_routers_to_additional_agent(
                    plugin, context, l3_agent)

        target_routers = self._get_routers_can_schedule(
            context, plugin, unscheduled_routers, l3_agent)
        if not target_routers:
            LOG.warning(_LW('No routers compatible with L3 agent '
                            'configuration on host %s'), host)
            return False

        self._bind_routers(context, plugin, target_routers, l3_agent)
        return True
开发者ID:annp,项目名称:neutron,代码行数:33,代码来源:l3_agent_scheduler.py


示例12: update_device_up

    def update_device_up(self, rpc_context, **kwargs):
        """Device is up on agent."""
        agent_id = kwargs.get('agent_id')
        device = kwargs.get('device')
        host = kwargs.get('host')
        LOG.debug(
            _("Device %(device)s up at agent %(agent_id)s"), {
                'device': device,
                'agent_id': agent_id
            })
        plugin = manager.NeutronManager.get_plugin()
        port_id = plugin._device_to_port_id(device)
        if (host
                and not plugin.port_bound_to_host(rpc_context, port_id, host)):
            LOG.debug(
                _("Device %(device)s not bound to the"
                  " agent host %(host)s"), {
                      'device': device,
                      'host': host
                  })
            return

        port_id = plugin.update_port_status(rpc_context, port_id,
                                            q_const.PORT_STATUS_ACTIVE, host)
        l3plugin = manager.NeutronManager.get_service_plugins().get(
            service_constants.L3_ROUTER_NAT)
        if (l3plugin and utils.is_extension_supported(
                l3plugin, q_const.L3_DISTRIBUTED_EXT_ALIAS)):
            try:
                port = plugin._get_port(rpc_context, port_id)
                l3plugin.dvr_vmarp_table_update(rpc_context, port, "add")
            except exceptions.PortNotFound:
                LOG.debug('Port %s not found during ARP update', port_id)
开发者ID:asadoughi,项目名称:neutron,代码行数:33,代码来源:rpc.py


示例13: mgmt_sec_grp_id

 def mgmt_sec_grp_id(cls):
     """Returns id of security group used by the management network."""
     if not utils.is_extension_supported(
             manager.NeutronManager.get_plugin(), "security-group"):
         return
     if cls._mgmt_sec_grp_id is None:
         # Get the id for the _mgmt_security_group_id
         tenant_id = cls.l3_tenant_id()
         res = manager.NeutronManager.get_plugin().get_security_groups(
             neutron_context.get_admin_context(),
             {'tenant_id': [tenant_id],
              'name': [cfg.CONF.general.default_security_group]},
             ['id'])
         if len(res) == 1:
             cls._mgmt_sec_grp_id = res[0].get('id')
         elif len(res) > 1:
             # the mgmt sec group must be unique.
             LOG.error(_LE('The security group for the virtual management '
                         'network does not have unique name. Please ensure '
                         'that it is.'))
         else:
             # CSR Mgmt security group is not present.
             LOG.error(_LE('There is no security group for the virtual '
                         'management network. Please create one.'))
     return cls._mgmt_sec_grp_id
开发者ID:gampel,项目名称:neutron,代码行数:25,代码来源:device_handling_db.py


示例14: _prepare_subports

    def _prepare_subports(self, context):
        """Update subports segmentation details if INHERIT is requested."""
        port_ids = {
            s['port_id']: i
            for i, s in enumerate(self.subports)
            if s.get('segmentation_type') == constants.INHERIT
        }
        core_plugin = directory.get_plugin()
        if not port_ids:
            return
        elif not n_utils.is_extension_supported(core_plugin, provider.ALIAS):
            msg = _("Cannot accept segmentation type %s") % constants.INHERIT
            raise n_exc.InvalidInput(error_message=msg)

        ports = core_plugin.get_ports(context, filters={'id': port_ids})
        # this assumes a user does not try to trunk the same network
        # more than once.
        network_port_map = {
            x['network_id']: {'port_id': x['id']}
            for x in ports
        }
        networks = core_plugin.get_networks(
            context.elevated(), filters={'id': network_port_map})
        for net in networks:
            port = network_port_map[net['id']]
            port.update({'segmentation_id': net[provider.SEGMENTATION_ID],
                         'segmentation_type': net[provider.NETWORK_TYPE]})
            self.subports[port_ids[port['port_id']]] = port
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:28,代码来源:rules.py


示例15: cfg_sync_routers

    def cfg_sync_routers(self, context, host, router_ids=None,
                         hosting_device_ids=None):
        """Sync routers according to filters to a specific Cisco cfg agent.

        @param context: contains user information
        @param host - originator of callback
        @param router_ids - list of router ids to return information about
        @param hosting_device_ids - list of hosting device ids to get
        routers for.
        @return: a list of routers
                 with their hosting devices, interfaces and floating_ips
        """
        context = neutron_context.get_admin_context()
        try:
            routers = (
                self._l3plugin.list_active_sync_routers_on_hosting_devices(
                    context, host, router_ids, hosting_device_ids))
        except AttributeError:
            routers = []
        if routers and utils.is_extension_supported(
                self._core_plugin, constants.PORT_BINDING_EXT_ALIAS):
            self._ensure_host_set_on_ports(context, host, routers)
        LOG.debug('Routers returned to Cisco cfg [email protected]%(agt)s:\n %(routers)s',
                  {'agt': host, 'routers': jsonutils.dumps(routers, indent=5)})
        return routers
开发者ID:bart20073,项目名称:neutron,代码行数:25,代码来源:l3_router_cfgagent_rpc_cb.py


示例16: list_active_sync_routers_on_active_l3_agent

    def list_active_sync_routers_on_active_l3_agent(
            self, context, host, router_ids):
        agent = self._get_agent_by_type_and_host(
            context, constants.AGENT_TYPE_L3, host)
        if not agent.admin_state_up:
            return []
        query = context.session.query(RouterL3AgentBinding.router_id)
        query = query.filter(
            RouterL3AgentBinding.l3_agent_id == agent.id)

        if router_ids:
            query = query.filter(
                RouterL3AgentBinding.router_id.in_(router_ids))
        router_ids = [item[0] for item in query]
        if router_ids:
            if n_utils.is_extension_supported(self,
                                              constants.L3_HA_MODE_EXT_ALIAS):
                return self.get_ha_sync_data_for_host(context, host,
                                                      router_ids=router_ids,
                                                      active=True)
            else:
                return self.get_sync_data(context, router_ids=router_ids,
                                          active=True)
        else:
            return []
开发者ID:leesurezen,项目名称:neutron,代码行数:25,代码来源:l3_agentschedulers_db.py


示例17: update_all_ha_network_port_statuses

    def update_all_ha_network_port_statuses(self, context, host):
        """Set HA network port to DOWN for HA routers hosted on <host>

        This will update HA network port status to down for all HA routers
        hosted on <host>. This is needed to avoid l3 agent spawning keepalived
        when l2 agent not yet wired the port. This can happen after a system
        reboot that has wiped out flows, etc and the L2 agent hasn't started up
        yet. The port will still be ACTIVE in the data model and the L3 agent
        will use that info to mistakenly think that L2 network is ready.
        By forcing into DOWN, we will require the L2 agent to essentially ack
        that the port is indeed ACTIVE by reacting to the port update and
        calling update_device_up.
        """
        if not utils.is_extension_supported(
            self.plugin, constants.PORT_BINDING_EXT_ALIAS):
            return
        device_filter = {
            'device_owner': [constants.DEVICE_OWNER_ROUTER_HA_INTF],
            'status': [constants.PORT_STATUS_ACTIVE]}
        ports = self.plugin.get_ports(context, filters=device_filter)
        ha_ports = [p['id'] for p in ports
                    if p.get(portbindings.HOST_ID) == host]
        if not ha_ports:
            return
        LOG.debug("L3 agent on host %(host)s requested for fullsync, so "
                  "setting HA network ports %(ha_ports)s status to DOWN.",
                  {"host": host, "ha_ports": ha_ports})
        for p in ha_ports:
            self.plugin.update_port(
                context, p, {'port': {'status': constants.PORT_STATUS_DOWN}})
开发者ID:eayunstack,项目名称:neutron,代码行数:30,代码来源:l3_rpc.py


示例18: are_agent_types_available_on_host

def are_agent_types_available_on_host(context, agent_types, host):
    """Return true if agent types are present on the host."""
    core_plugin = manager.NeutronManager.get_plugin()
    if utils.is_extension_supported(core_plugin, 'agent'):
        return bool(core_plugin.get_agents(
            context.elevated(),
            filters={'host': [host], 'agent_type': agent_types}))
    return False
开发者ID:muraliran,项目名称:neutron,代码行数:8,代码来源:utils.py


示例19: _get_active_l3_agent_routers_sync_data

 def _get_active_l3_agent_routers_sync_data(self, context, host, agent,
                                            router_ids):
     if n_utils.is_extension_supported(self, n_const.L3_HA_MODE_EXT_ALIAS):
         return self.get_ha_sync_data_for_host(context, host,
                                               router_ids=router_ids,
                                               active=True)
     return self._get_dvr_sync_data(context, host, agent,
                                    router_ids=router_ids, active=True)
开发者ID:neoareslinux,项目名称:neutron,代码行数:8,代码来源:l3_dvrscheduler_db.py


示例20: get_ha_sync_data_for_host

 def get_ha_sync_data_for_host(self, context, host=None, router_ids=None, active=None):
     if n_utils.is_extension_supported(self, constants.L3_DISTRIBUTED_EXT_ALIAS):
         # DVR has to be handled differently
         agent = self._get_agent_by_type_and_host(context, constants.AGENT_TYPE_L3, host)
         sync_data = self._get_dvr_sync_data(context, host, agent, router_ids, active)
     else:
         sync_data = super(L3_HA_NAT_db_mixin, self).get_sync_data(context, router_ids, active)
     return self._process_sync_ha_data(context, sync_data, host)
开发者ID:tal-nino,项目名称:neutron,代码行数:8,代码来源:l3_hamode_db.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.is_port_trusted函数代码示例发布时间:2022-05-27
下一篇:
Python utils.is_dvr_serviced函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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