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

Python constants.interpret_vlan_id函数代码示例

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

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



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

示例1: port_update

    def port_update(self, context, **kwargs):
        '''Update the port in response to a port update message from the
        controlling node.
        '''
        LOG.debug(_("port_update received %s, %s"), context, kwargs)
        # Check port exists on node
        port = kwargs.get('port')
        tap_device_name = self.agent.routing_mgr.get_tap_device_name(port['id'])
        devices = self.agent.routing_mgr.get_tap_devices()
        if tap_device_name not in devices:
            return

        if 'security_groups' in port:
            self.sg_agent.refresh_firewall()
        try:
            if port['admin_state_up']:
                network_type = kwargs.get('network_type')
                if network_type:
                    segmentation_id = kwargs.get('segmentation_id')
                else:
                    # compatibility with pre-Havana RPC vlan_id encoding
                    vlan_id = kwargs.get('vlan_id')
                    (network_type,
                     segmentation_id) = lconst.interpret_vlan_id(vlan_id)
                physical_network = kwargs.get('physical_network')
                # create the networking for the port
                if self.agent.routing_mgr.add_interface(port['network_id'],
                                                        network_type,
                                                        physical_network,
                                                        segmentation_id,
                                                        port['id'],
                                                        port['fixed_ips'],
                                                        port['mac_address']):
                    # update plugin about port status
                    self.agent.plugin_rpc.update_device_up(self.context,
                                                           tap_device_name,
                                                           self.agent.agent_id,
                                                           cfg.CONF.host)
                else:
                    self.agent.plugin_rpc.update_device_down(
                        self.context,
                        tap_device_name,
                        self.agent.agent_id,
                        cfg.CONF.host
                    )
            else:
                self.agent.routing_mgr.remove_interface(port['network_id'],
                                                        None,
                                                        None,
                                                        None,
                                                        port['id'],
                                                        port['fixed_ips'],
                                                        port['mac_address'])
                # update plugin about port status
                self.agent.plugin_rpc.update_device_down(self.context,
                                                         tap_device_name,
                                                         self.agent.agent_id,
                                                         cfg.CONF.host)
        except rpc_common.Timeout:
            LOG.error(_("RPC timeout while updating port %s"), port['id'])
开发者ID:punalpatel,项目名称:calico,代码行数:60,代码来源:calico_neutron_agent.py


示例2: get_device_details

 def get_device_details(self, rpc_context, **kwargs):
     """Agent requests device details."""
     agent_id = kwargs.get("agent_id")
     device = kwargs.get("device")
     LOG.debug(_("Device %(device)s details requested from %(agent_id)s"), {"device": device, "agent_id": agent_id})
     port = self.get_port_from_device(device)
     if port:
         binding = db.get_network_binding(db_api.get_session(), port["network_id"])
         (network_type, segmentation_id) = constants.interpret_vlan_id(binding.vlan_id)
         entry = {
             "device": device,
             "network_type": network_type,
             "physical_network": binding.physical_network,
             "segmentation_id": segmentation_id,
             "network_id": port["network_id"],
             "port_id": port["id"],
             "admin_state_up": port["admin_state_up"],
         }
         if cfg.CONF.AGENT.rpc_support_old_agents:
             entry["vlan_id"] = binding.vlan_id
         new_status = q_const.PORT_STATUS_ACTIVE if port["admin_state_up"] else q_const.PORT_STATUS_DOWN
         if port["status"] != new_status:
             db.set_port_status(port["id"], new_status)
     else:
         entry = {"device": device}
         LOG.debug(_("%s can not be found in database"), device)
     return entry
开发者ID:sukhdevkapur,项目名称:neutron,代码行数:27,代码来源:lb_neutron_plugin.py


示例3: get_device_details

 def get_device_details(self, rpc_context, **kwargs):
     """Agent requests device details."""
     agent_id = kwargs.get('agent_id')
     device = kwargs.get('device')
     LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
               {'device': device, 'agent_id': agent_id})
     port = self.get_port_from_device(device)
     if port:
         binding = db.get_network_binding(db_api.get_session(),
                                          port['network_id'])
         (network_type,
          segmentation_id) = constants.interpret_vlan_id(binding.vlan_id)
         entry = {'device': device,
                  'network_type': network_type,
                  'physical_network': binding.physical_network,
                  'segmentation_id': segmentation_id,
                  'network_id': port['network_id'],
                  'port_id': port['id'],
                  'admin_state_up': port['admin_state_up']}
         if cfg.CONF.AGENT.rpc_support_old_agents:
             entry['vlan_id'] = binding.vlan_id
         new_status = (q_const.PORT_STATUS_ACTIVE if port['admin_state_up']
                       else q_const.PORT_STATUS_DOWN)
         if port['status'] != new_status:
             db.set_port_status(port['id'], new_status)
     else:
         entry = {'device': device}
         LOG.debug(_("%s can not be found in database"), device)
     return entry
开发者ID:kavonm,项目名称:neutron,代码行数:29,代码来源:lb_neutron_plugin.py


示例4: port_update

    def port_update(self, context, **kwargs):
        LOG.debug(_("port_update received"))
        # Check port exists on node
        port = kwargs.get('port')
        tap_device_name = self.agent.br_mgr.get_tap_device_name(port['id'])
        devices = self.agent.br_mgr.get_tap_devices()
        if tap_device_name not in devices:
            return

        if 'security_groups' in port:
            self.sg_agent.refresh_firewall()
        try:
            LOG.debug('Update of port %s' % port)
            updown = self.agent.br_mgr.update_device_link(port_id=port['id'],
                                                          dom_id=port.get('device_id'),
                                                          hw_addr=port.get('mac_address'),
                                                          owner=port.get('device_owner'), 
                                                          state=port['admin_state_up'])
            if port['admin_state_up']:
                network_type = kwargs.get('network_type')
                if network_type:
                    segmentation_id = kwargs.get('segmentation_id')
                else:
                    # compatibility with pre-Havana RPC vlan_id encoding
                    vlan_id = kwargs.get('vlan_id')
                    (network_type,
                     segmentation_id) = lconst.interpret_vlan_id(vlan_id)
                physical_network = kwargs.get('physical_network')
                # create the networking for the port
                if self.agent.br_mgr.add_interface(port['network_id'],
                                                   network_type,
                                                   physical_network,
                                                   segmentation_id,
                                                   port['id']):
                    # update plugin about port status
                    self.agent.plugin_rpc.update_device_up(self.context,
                                                           tap_device_name,
                                                           self.agent.agent_id,
                                                           cfg.CONF.host)
                else:
                    self.agent.plugin_rpc.update_device_down(
                        self.context,
                        tap_device_name,
                        self.agent.agent_id,
                        cfg.CONF.host
                    )
            else:
                bridge_name = self.agent.br_mgr.get_bridge_name(
                    port['network_id'])
                self.agent.br_mgr.remove_interface(bridge_name,
                                                   tap_device_name)
                # update plugin about port status
                self.agent.plugin_rpc.update_device_down(self.context,
                                                         tap_device_name,
                                                         self.agent.agent_id,
                                                         cfg.CONF.host)
        except rpc_common.Timeout:
            LOG.error(_("RPC timeout while updating port %s"), port['id'])
开发者ID:peresadam,项目名称:virl-salt,代码行数:58,代码来源:linuxbridge_neutron_agent.py


示例5: treat_devices_added

    def treat_devices_added(self, devices):
        resync = False
        self.prepare_devices_filter(devices)
        for device in devices:
            LOG.debug(_("Port %s added"), device)
            try:
                details = self.plugin_rpc.get_device_details(self.context,
                                                             device,
                                                             self.agent_id)
            except Exception as e:
                LOG.debug(_("Unable to get port details for "
                            "%(device)s: %(e)s"),
                          {'device': device, 'e': e})
                resync = True
                continue
            if 'port_id' in details:
                LOG.info(_("Port %(device)s updated. Details: %(details)s"),
                         {'device': device, 'details': details})
                updown = self.br_mgr.update_device_link(
                    port_id=details['port_id'],
                    dom_id=details.get('device_id'),
                    hw_addr=details.get('mac_address'),
                    owner=details.get('device_owner'),
                    state=details['admin_state_up'])
                if details['admin_state_up']:
                    # create the networking for the port
                    network_type = details.get('network_type')
                    if network_type:
                        segmentation_id = details.get('segmentation_id')
                    else:
                        # compatibility with pre-Havana RPC vlan_id encoding
                        vlan_id = details.get('vlan_id')
                        (network_type,
                         segmentation_id) = lconst.interpret_vlan_id(vlan_id)
                    if self.br_mgr.add_interface(details['network_id'],
                                                 network_type,
                                                 details['physical_network'],
                                                 segmentation_id,
                                                 details['port_id']):

                        # update plugin about port status
                        self.plugin_rpc.update_device_up(self.context,
                                                         device,
                                                         self.agent_id,
                                                         cfg.CONF.host)
                    else:
                        self.plugin_rpc.update_device_down(self.context,
                                                           device,
                                                           self.agent_id,
                                                           cfg.CONF.host)
                else:
                    self.remove_port_binding(details['network_id'],
                                             details['port_id'])
            else:
                LOG.info(_("Device %s not defined on plugin"), device)
        return resync
开发者ID:Snergster,项目名称:virl-salt,代码行数:56,代码来源:linuxbridge_neutron_agent.py


示例6: treat_devices_added_updated

    def treat_devices_added_updated(self, devices):
        try:
            devices_details_list = self.plugin_rpc.get_devices_details_list(
                self.context, devices, self.agent_id)
        except Exception as e:
            LOG.debug("Unable to get port details for "
                      "%(devices)s: %(e)s",
                      {'devices': devices, 'e': e})
            # resync is needed
            return True

        for device_details in devices_details_list:
            device = device_details['device']
            LOG.debug("Port %s added", device)

            if 'port_id' in device_details:
                LOG.info(_LI("Port %(device)s updated. Details: %(details)s"),
                         {'device': device, 'details': device_details})
                if self.prevent_arp_spoofing:
                    port = self.br_mgr.get_tap_device_name(
                        device_details['port_id'])
                    arp_protect.setup_arp_spoofing_protection(port,
                                                              device_details)
                if device_details['admin_state_up']:
                    # create the networking for the port
                    network_type = device_details.get('network_type')
                    if network_type:
                        segmentation_id = device_details.get('segmentation_id')
                    else:
                        # compatibility with pre-Havana RPC vlan_id encoding
                        vlan_id = device_details.get('vlan_id')
                        (network_type,
                         segmentation_id) = lconst.interpret_vlan_id(vlan_id)
                    if self.br_mgr.add_interface(
                        device_details['network_id'],
                        network_type,
                        device_details['physical_network'],
                        segmentation_id,
                        device_details['port_id']):

                        # update plugin about port status
                        self.plugin_rpc.update_device_up(self.context,
                                                         device,
                                                         self.agent_id,
                                                         cfg.CONF.host)
                    else:
                        self.plugin_rpc.update_device_down(self.context,
                                                           device,
                                                           self.agent_id,
                                                           cfg.CONF.host)
                else:
                    self.remove_port_binding(device_details['network_id'],
                                             device_details['port_id'])
            else:
                LOG.info(_LI("Device %s not defined on plugin"), device)
        return False
开发者ID:kongseokhwan,项目名称:kulcloud-iitp-neutron,代码行数:56,代码来源:linuxbridge_neutron_agent.py


示例7: port_update

 def port_update(self, context, port, physical_network, vlan_id):
     network_type, segmentation_id = constants.interpret_vlan_id(vlan_id)
     kwargs = {'port': port,
               'network_type': network_type,
               'physical_network': physical_network,
               'segmentation_id': segmentation_id}
     if cfg.CONF.AGENT.rpc_support_old_agents:
         kwargs['vlan_id'] = vlan_id
     msg = self.make_msg('port_update', **kwargs)
     self.fanout_cast(context, msg,
                      topic=self.topic_port_update)
开发者ID:kavonm,项目名称:neutron,代码行数:11,代码来源:lb_neutron_plugin.py


示例8: port_update

 def port_update(self, context, port, physical_network, vlan_id):
     network_type, segmentation_id = constants.interpret_vlan_id(vlan_id)
     kwargs = {
         "port": port,
         "network_type": network_type,
         "physical_network": physical_network,
         "segmentation_id": segmentation_id,
     }
     if cfg.CONF.AGENT.rpc_support_old_agents:
         kwargs["vlan_id"] = vlan_id
     msg = self.make_msg("port_update", **kwargs)
     self.fanout_cast(context, msg, topic=self.topic_port_update)
开发者ID:sukhdevkapur,项目名称:neutron,代码行数:12,代码来源:lb_neutron_plugin.py


示例9: treat_devices_added_updated

    def treat_devices_added_updated(self, devices):
        try:
            devices_details_list = self.plugin_rpc.get_devices_details_list(self.context, devices, self.agent_id)
        except Exception as e:
            LOG.debug("Unable to get port details for " "%(devices)s: %(e)s", {"devices": devices, "e": e})
            # resync is needed
            return True

        for device_details in devices_details_list:
            device = device_details["device"]
            LOG.debug("Port %s added", device)

            if "port_id" in device_details:
                LOG.info(
                    _("Port %(device)s updated. Details: %(details)s"), {"device": device, "details": device_details}
                )
                if device_details["admin_state_up"]:
                    # create the networking for the port
                    network_type = device_details.get("network_type")
                    if network_type:
                        segmentation_id = device_details.get("segmentation_id")
                    else:
                        # compatibility with pre-Havana RPC vlan_id encoding
                        vlan_id = device_details.get("vlan_id")
                        (network_type, segmentation_id) = lconst.interpret_vlan_id(vlan_id)
                    if self.br_mgr.add_interface(
                        device_details["network_id"],
                        network_type,
                        device_details["physical_network"],
                        segmentation_id,
                        device_details["port_id"],
                    ):

                        # update plugin about port status
                        self.plugin_rpc.update_device_up(self.context, device, self.agent_id, cfg.CONF.host)
                    else:
                        self.plugin_rpc.update_device_down(self.context, device, self.agent_id, cfg.CONF.host)
                else:
                    self.remove_port_binding(device_details["network_id"], device_details["port_id"])
            else:
                LOG.info(_("Device %s not defined on plugin"), device)
        return False
开发者ID:cboling,项目名称:SDNdbg,代码行数:42,代码来源:linuxbridge_neutron_agent.py


示例10: treat_devices_added

    def treat_devices_added(self, devices):
        """
        Called by the polling loop when we discover new devices have appeared.
        Checks if the new devices are known to OpenStack and configures them if
        needed.

        """
        LOG.info(_("treat_devices_added %s"), devices)
        resync = False
        self.prepare_devices_filter(devices)
        for device in devices:
            LOG.debug(_("Port %s added"), device)
            try:
                details = self.plugin_rpc.get_device_details(self.context,
                                                             device,
                                                             self.agent_id)
            except Exception as e:
                LOG.debug(_("Unable to get port details for "
                            "%(device)s: %(e)s"),
                          {'device': device, 'e': e})
                resync = True
                continue
            if 'port_id' in details:
                LOG.info(_("Port %(device)s updated. Details: %(details)s"),
                         {'device': device, 'details': details})
                # If a device has been added but it's not active, don't
                # do anything with it. We'll add it later. Otherwise, configure
                # it.
                if details['admin_state_up']:
                    # create the networking for the port
                    network_type = details.get('network_type')
                    if network_type:
                        segmentation_id = details.get('segmentation_id')
                    else:
                        # compatibility with pre-Havana RPC vlan_id encoding
                        vlan_id = details.get('vlan_id')
                        (network_type,
                         segmentation_id) = lconst.interpret_vlan_id(vlan_id)

                    if self.routing_mgr.add_interface(details['network_id'],
                                                      network_type,
                                                      details['physical_network'],
                                                      segmentation_id,
                                                      details['port_id'],
                                                      details['fixed_ips'],
                                                      details['mac_address']):

                        # update plugin about port status
                        resp = self.plugin_rpc.update_device_up(self.context,
                                                                device,
                                                                self.agent_id,
                                                                cfg.CONF.host)
                    else:
                        resp = self.plugin_rpc.update_device_down(self.context,
                                                                  device,
                                                                  self.agent_id,
                                                                  cfg.CONF.host)
                    LOG.info(_("Update device response: %s"), resp)
            else:
                LOG.info(_("Device %s not defined on plugin"), device)
        return resync
开发者ID:punalpatel,项目名称:calico,代码行数:61,代码来源:calico_neutron_agent.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python l2network_db_v2.get_network_binding函数代码示例发布时间:2022-05-27
下一篇:
Python utils.parse_network_vlan_ranges函数代码示例发布时间: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