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

Python utils.get_interface_mac函数代码示例

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

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



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

示例1: setup_rpc

    def setup_rpc(self, physical_interfaces):
        if physical_interfaces:
            mac = utils.get_interface_mac(physical_interfaces[0])
        else:
            devices = ip_lib.IPWrapper(self.root_helper).get_devices(True)
            if devices:
                mac = utils.get_interface_mac(devices[0].name)
            else:
                LOG.error(_("Unable to obtain MAC address for unique ID. "
                          "Agent terminated!"))
                exit(1)
        self.agent_id = '%s%s' % ('lb', (mac.replace(":", "")))
        LOG.info(_("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.plugin_rpc = LinuxBridgePluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
        # RPC network init
        self.context = context.get_admin_context_without_session()
        # Handle updates from service
        self.callbacks = LinuxBridgeRpcCallbacks(self.context,
                                                 self)
        self.dispatcher = self.callbacks.create_rpc_dispatcher()
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic,
                                                     consumers)
        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
开发者ID:fyafighter,项目名称:neutron,代码行数:35,代码来源:linuxbridge_neutron_agent.py


示例2: setup_rpc

    def setup_rpc(self, physical_interfaces):
        if physical_interfaces:
            mac = utils.get_interface_mac(physical_interfaces[0])
        else:
            devices = ip_lib.IPWrapper().get_devices(True)
            if devices:
                mac = utils.get_interface_mac(devices[0].name)
            else:
                LOG.error(_LE("Unable to obtain MAC address for unique ID. "
                              "Agent terminated!"))
                exit(1)
        self.agent_id = '%s%s' % ('lb', (mac.replace(":", "")))
        LOG.info(_LI("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
        # RPC network init
        # Handle updates from service
        self.endpoints = [LinuxBridgeRpcCallbacks(self.context, self,
                                                  self.sg_agent)]
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        if cfg.CONF.VXLAN.l2_population:
            consumers.append([topics.L2POPULATION,
                              topics.UPDATE, cfg.CONF.host])
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers)
        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
开发者ID:rajeshmohan,项目名称:neutron,代码行数:35,代码来源:linuxbridge_neutron_agent.py


示例3: setup_rpc

    def setup_rpc(self, physical_interfaces):
        if physical_interfaces:
            mac = utils.get_interface_mac(physical_interfaces[0])
        else:
            devices = ip_lib.IPWrapper().get_devices(True)
            if devices:
                mac = utils.get_interface_mac(devices[0].name)
            else:
                LOG.error(_LE("Unable to obtain MAC address for unique ID. " "Agent terminated!"))
                exit(1)

        self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
        self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context, self.sg_plugin_rpc, defer_refresh_firewall=True)

        self.agent_id = "%s%s" % ("lb", (mac.replace(":", "")))
        LOG.info(_LI("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
        # RPC network init
        # Handle updates from service
        self.endpoints = [LinuxBridgeRpcCallbacks(self.context, self, self.sg_agent)]
        # Define the listening consumers for the agent
        consumers = [
            [topics.PORT, topics.UPDATE],
            [topics.NETWORK, topics.DELETE],
            [topics.NETWORK, topics.UPDATE],
            [topics.SECURITY_GROUP, topics.UPDATE],
        ]

        if cfg.CONF.VXLAN.l2_population:
            consumers.append([topics.L2POPULATION, topics.UPDATE])
        self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers)
开发者ID:rkukura,项目名称:neutron,代码行数:34,代码来源:linuxbridge_neutron_agent.py


示例4: get_agent_id

 def get_agent_id(self):
     if self.bridge_mappings:
         mac = utils.get_interface_mac(list(self.bridge_mappings.values())[0])
     else:
         devices = ip_lib.IPWrapper().get_devices(True)
         if devices:
             mac = utils.get_interface_mac(devices[0].name)
         else:
             LOG.error(_LE("Unable to obtain MAC address for unique ID. " "Agent terminated!"))
             sys.exit(1)
     return "lb%s" % mac.replace(":", "")
开发者ID:FedericoRessi,项目名称:neutron,代码行数:11,代码来源:linuxbridge_neutron_agent.py


示例5: test_get_interface_mac

 def test_get_interface_mac(self):
     expect_val = '01:02:03:04:05:06'
     with mock.patch('fcntl.ioctl') as ioctl:
         ioctl.return_value = ''.join(['\x00' * 18,
                                       '\x01\x02\x03\x04\x05\x06',
                                       '\x00' * 232])
         actual_val = utils.get_interface_mac('eth0')
     self.assertEqual(actual_val, expect_val)
开发者ID:bradleyjones,项目名称:neutron,代码行数:8,代码来源:test_utils.py


示例6: get_agent_id

 def get_agent_id(self):
     devices = ip_lib.IPWrapper().get_devices(True)
     if devices:
         mac = utils.get_interface_mac(devices[0].name)
         return 'macvtap%s' % mac.replace(":", "")
     else:
         LOG.error(_LE("Unable to obtain MAC address for unique ID. "
                       "Agent terminated!"))
         sys.exit(1)
开发者ID:21atlas,项目名称:neutron,代码行数:9,代码来源:macvtap_neutron_agent.py


示例7: get_all_devices

 def get_all_devices(self):
     devices = set()
     all_device_names = os.listdir(MACVTAP_FS)
     # Refresh the mac_device_name mapping
     self.mac_device_name_mappings = dict()
     for device_name in all_device_names:
         if device_name.startswith(constants.MACVTAP_DEVICE_PREFIX):
             mac = utils.get_interface_mac(device_name)
             self.mac_device_name_mappings[mac] = device_name
             devices.add(mac)
     return devices
开发者ID:21atlas,项目名称:neutron,代码行数:11,代码来源:macvtap_neutron_agent.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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