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

Python ip_lib.device_exists函数代码示例

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

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



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

示例1: internal_network_removed

    def internal_network_removed(self, ri, port):
        port_id = port['id']
        interface_name = self.get_internal_device_name(port_id)
        if ri.router['distributed'] and ri.ex_gw_port:
            # DVR handling code for SNAT
            self._snat_redirect_remove(ri, port, interface_name)
            if (self.conf.agent_mode == l3_constants.L3_AGENT_MODE_DVR_SNAT
                and ri.ex_gw_port['binding:host_id'] == self.host):
                snat_port = self._map_internal_interfaces(ri, port,
                                                          ri.snat_ports)
                if snat_port:
                    snat_interface = (
                        self.get_snat_int_device_name(snat_port['id'])
                    )
                    ns_name = self.get_snat_ns_name(ri.router['id'])
                    prefix = dvr.SNAT_INT_DEV_PREFIX
                    if ip_lib.device_exists(snat_interface,
                                            namespace=ns_name):
                        self.driver.unplug(snat_interface, namespace=ns_name,
                                           prefix=prefix)

        if ip_lib.device_exists(interface_name, namespace=ri.ns_name):
            if ri.is_ha:
                ri._clear_vips(interface_name)
            self.driver.unplug(interface_name, namespace=ri.ns_name,
                               prefix=INTERNAL_DEV_PREFIX)
开发者ID:bradleyjones,项目名称:neutron,代码行数:26,代码来源:agent.py


示例2: _assert_dvr_floating_ips

    def _assert_dvr_floating_ips(self, router):
        # in the fip namespace:
        # Check that the fg-<port-id> (floatingip_agent_gateway)
        # is created with the ip address of the external gateway port
        floating_ips = router.router[l3_constants.FLOATINGIP_KEY]
        self.assertTrue(floating_ips)

        external_port = self.agent._get_ex_gw_port(router)
        fip_ns = self.agent.get_fip_ns(floating_ips[0]['floating_network_id'])
        fip_ns_name = fip_ns.get_name()
        fg_port_created_succesfully = ip_lib.device_exists_with_ip_mac(
            fip_ns.get_ext_device_name(external_port['id']),
            external_port['ip_cidr'],
            external_port['mac_address'],
            fip_ns_name, self.root_helper)
        self.assertTrue(fg_port_created_succesfully)
        # Check fpr-router device has been created
        device_name = fip_ns.get_int_device_name(router.router_id)
        fpr_router_device_created_succesfully = ip_lib.device_exists(
            device_name, self.root_helper, fip_ns_name)
        self.assertTrue(fpr_router_device_created_succesfully)

        # In the router namespace
        # Check rfp-<router-id> is created correctly
        for fip in floating_ips:
            device_name = fip_ns.get_rtr_ext_device_name(router.router_id)
            self.assertTrue(ip_lib.device_exists(
                device_name, self.root_helper, router.ns_name))
开发者ID:noironetworks,项目名称:neutron2,代码行数:28,代码来源:test_l3_agent.py


示例3: setup_physical_bridges

    def setup_physical_bridges(self, bridge_mappings):
        """Setup the physical network bridges.

        Creates physical network bridges and links them to the
        integration bridge using veths.

        :param bridge_mappings: map physical network names to bridge names.
        """
        self.phys_brs = {}
        self.int_ofports = {}
        self.phys_ofports = {}
        ip_wrapper = ip_lib.IPWrapper(self.root_helper)
        for physical_network, bridge in bridge_mappings.iteritems():
            LOG.info(
                _("Mapping physical network %(physical_network)s to " "bridge %(bridge)s"),
                {"physical_network": physical_network, "bridge": bridge},
            )
            # setup physical bridge
            if not ip_lib.device_exists(bridge, self.root_helper):
                LOG.error(
                    _(
                        "Bridge %(bridge)s for physical network "
                        "%(physical_network)s does not exist. Agent "
                        "terminated!"
                    ),
                    {"physical_network": physical_network, "bridge": bridge},
                )
                sys.exit(1)
            br = ovs_lib.OVSBridge(bridge, self.root_helper)
            br.remove_all_flows()
            br.add_flow(priority=1, actions="normal")
            self.phys_brs[physical_network] = br

            # create veth to patch physical bridge with integration bridge
            int_veth_name = constants.VETH_INTEGRATION_PREFIX + bridge
            self.int_br.delete_port(int_veth_name)
            phys_veth_name = constants.VETH_PHYSICAL_PREFIX + bridge
            br.delete_port(phys_veth_name)
            if ip_lib.device_exists(int_veth_name, self.root_helper):
                ip_lib.IPDevice(int_veth_name, self.root_helper).link.delete()
                # Give udev a chance to process its rules here, to avoid
                # race conditions between commands launched by udev rules
                # and the subsequent call to ip_wrapper.add_veth
                utils.execute(["/sbin/udevadm", "settle", "--timeout=10"])
            int_veth, phys_veth = ip_wrapper.add_veth(int_veth_name, phys_veth_name)
            self.int_ofports[physical_network] = self.int_br.add_port(int_veth)
            self.phys_ofports[physical_network] = br.add_port(phys_veth)

            # block all untranslated traffic over veth between bridges
            self.int_br.add_flow(priority=2, in_port=self.int_ofports[physical_network], actions="drop")
            br.add_flow(priority=2, in_port=self.phys_ofports[physical_network], actions="drop")

            # enable veth to pass traffic
            int_veth.link.set_up()
            phys_veth.link.set_up()

            if self.veth_mtu:
                # set up mtu size for veth interfaces
                int_veth.link.set_mtu(self.veth_mtu)
                phys_veth.link.set_mtu(self.veth_mtu)
开发者ID:vnaum,项目名称:neutron,代码行数:60,代码来源:ovs_neutron_agent.py


示例4: _assert_dvr_floating_ips

    def _assert_dvr_floating_ips(self, router):
        # in the fip namespace:
        # Check that the fg-<port-id> (floatingip_agent_gateway)
        # is created with the ip address of the external gateway port
        floating_ips = router.router[l3_constants.FLOATINGIP_KEY]
        self.assertTrue(floating_ips)
        # We need to fetch the floatingip agent gateway port info
        # from the router_info
        floating_agent_gw_port = (
            router.router[l3_constants.FLOATINGIP_AGENT_INTF_KEY])
        self.assertTrue(floating_agent_gw_port)

        external_gw_port = floating_agent_gw_port[0]
        fip_ns = self.agent.get_fip_ns(floating_ips[0]['floating_network_id'])
        fip_ns_name = fip_ns.get_name()
        fg_port_created_successfully = ip_lib.device_exists_with_ips_and_mac(
            fip_ns.get_ext_device_name(external_gw_port['id']),
            [self._port_first_ip_cidr(external_gw_port)],
            external_gw_port['mac_address'],
            namespace=fip_ns_name)
        self.assertTrue(fg_port_created_successfully)
        # Check fpr-router device has been created
        device_name = fip_ns.get_int_device_name(router.router_id)
        fpr_router_device_created_successfully = ip_lib.device_exists(
            device_name, namespace=fip_ns_name)
        self.assertTrue(fpr_router_device_created_successfully)

        # In the router namespace
        # Check rfp-<router-id> is created correctly
        for fip in floating_ips:
            device_name = fip_ns.get_rtr_ext_device_name(router.router_id)
            self.assertTrue(ip_lib.device_exists(
                device_name, namespace=router.ns_name))
开发者ID:manjeetbhatia,项目名称:test_l3,代码行数:33,代码来源:test_dvr_router.py


示例5: _get_dvr_snat_namespace_device_status

 def _get_dvr_snat_namespace_device_status(self, router, internal_dev_name=None):
     """Function returns the internal and external device status."""
     snat_ns = dvr_snat_ns.SnatNamespace.get_snat_ns_name(router.router_id)
     external_port = router.get_ex_gw_port()
     external_device_name = router.get_external_device_name(external_port["id"])
     qg_device_created_successfully = ip_lib.device_exists(external_device_name, namespace=snat_ns)
     sg_device_created_successfully = ip_lib.device_exists(internal_dev_name, namespace=snat_ns)
     return qg_device_created_successfully, sg_device_created_successfully
开发者ID:klmitch,项目名称:neutron,代码行数:8,代码来源:test_dvr_router.py


示例6: setup_physical_bridges

    def setup_physical_bridges(self, bridge_mappings):
        '''Setup the physical network bridges.

        Creates physical network bridges and links them to the
        integration bridge using veths.

        :param bridge_mappings: map physical network names to bridge names.
        '''
        self.phys_brs = {}
        self.int_ofports = {}
        self.phys_ofports = {}
        ip_wrapper = ip_lib.IPWrapper(self.root_helper)
        for physical_network, bridge in bridge_mappings.iteritems():
            LOG.info(_("Mapping physical network %(physical_network)s to "
                       "bridge %(bridge)s"),
                     {'physical_network': physical_network,
                      'bridge': bridge})
            # setup physical bridge
            if not ip_lib.device_exists(bridge, self.root_helper):
                LOG.error(_("Bridge %(bridge)s for physical network "
                            "%(physical_network)s does not exist. Agent "
                            "terminated!"),
                          {'physical_network': physical_network,
                           'bridge': bridge})
                sys.exit(1)
            br = ovs_lib.OVSBridge(bridge, self.root_helper)
            br.remove_all_flows()
            br.add_flow(priority=1, actions="normal")
            self.phys_brs[physical_network] = br

            # create veth to patch physical bridge with integration bridge
            int_veth_name = constants.VETH_INTEGRATION_PREFIX + bridge
            self.int_br.delete_port(int_veth_name)
            phys_veth_name = constants.VETH_PHYSICAL_PREFIX + bridge
            br.delete_port(phys_veth_name)
            if ip_lib.device_exists(int_veth_name, self.root_helper):
                ip_lib.IPDevice(int_veth_name, self.root_helper).link.delete()
            int_veth, phys_veth = ip_wrapper.add_veth(int_veth_name,
                                                      phys_veth_name)
            self.int_ofports[physical_network] = self.int_br.add_port(int_veth)
            self.phys_ofports[physical_network] = br.add_port(phys_veth)

            # block all untranslated traffic over veth between bridges
            self.int_br.add_flow(priority=2,
                                 in_port=self.int_ofports[physical_network],
                                 actions="drop")
            br.add_flow(priority=2,
                        in_port=self.phys_ofports[physical_network],
                        actions="drop")

            # enable veth to pass traffic
            int_veth.link.set_up()
            phys_veth.link.set_up()

            if self.veth_mtu:
                # set up mtu size for veth interfaces
                int_veth.link.set_mtu(self.veth_mtu)
                phys_veth.link.set_mtu(self.veth_mtu)
开发者ID:kobtea,项目名称:neutron,代码行数:58,代码来源:ovs_neutron_agent.py


示例7: test_device_exists

    def test_device_exists(self):
        attr = self.generate_device_details()

        self.assertFalse(ip_lib.device_exists(attr.name, namespace=attr.namespace))

        device = self.manage_device(attr)

        self.assertTrue(ip_lib.device_exists(device.name, namespace=attr.namespace))

        device.link.delete()

        self.assertFalse(ip_lib.device_exists(attr.name, namespace=attr.namespace))
开发者ID:davidcusatis,项目名称:neutron,代码行数:12,代码来源:test_ip_lib.py


示例8: ensure_vxlan

 def ensure_vxlan(self, segmentation_id):
     """Create a vxlan unless it already exists."""
     interface = self.get_vxlan_device_name(segmentation_id)
     if not ip_lib.device_exists(interface):
         LOG.debug("Creating vxlan interface %(interface)s for "
                   "VNI %(segmentation_id)s",
                   {'interface': interface,
                    'segmentation_id': segmentation_id})
         args = {'dev': self.local_int}
         if self.vxlan_mode == lconst.VXLAN_MCAST:
             args['group'] = self.get_vxlan_group(segmentation_id)
         if cfg.CONF.VXLAN.ttl:
             args['ttl'] = cfg.CONF.VXLAN.ttl
         if cfg.CONF.VXLAN.tos:
             args['tos'] = cfg.CONF.VXLAN.tos
         if cfg.CONF.VXLAN.l2_population:
             args['proxy'] = True
         try:
             int_vxlan = self.ip.add_vxlan(interface, segmentation_id,
                                           **args)
         except RuntimeError:
             with excutils.save_and_reraise_exception() as ctxt:
                 # perform this check after an attempt rather than before
                 # to avoid excessive lookups and a possible race condition.
                 if ip_lib.vxlan_in_use(segmentation_id):
                     ctxt.reraise = False
                     LOG.error(_LE("Unable to create VXLAN interface for "
                                   "VNI %s because it is in use by another "
                                   "interface."), segmentation_id)
                     return None
         int_vxlan.link.set_up()
         LOG.debug("Done creating vxlan interface %s", interface)
     return interface
开发者ID:dims,项目名称:neutron,代码行数:33,代码来源:linuxbridge_neutron_agent.py


示例9: plug

    def plug(self, network_id, port_id, device_name, mac_address,
             bridge=None, namespace=None, prefix=None):
        """Plugin the interface."""
        if not ip_lib.device_exists(device_name,
                                    self.root_helper,
                                    namespace=namespace):
            ip = ip_lib.IPWrapper(self.root_helper)

            # Enable agent to define the prefix
            tap_name = device_name.replace(prefix or self.DEV_NAME_PREFIX,
                                        n_const.TAP_DEVICE_PREFIX)
            # Create ns_veth in a namespace if one is configured.
            root_veth, ns_veth = ip.add_veth(tap_name, device_name,
                                             namespace2=namespace)
            ns_veth.link.set_address(mac_address)

            if self.conf.network_device_mtu:
                root_veth.link.set_mtu(self.conf.network_device_mtu)
                ns_veth.link.set_mtu(self.conf.network_device_mtu)

            root_veth.link.set_up()
            ns_veth.link.set_up()

        else:
            LOG.info(_LI("Device %s already exists"), device_name)
开发者ID:noironetworks,项目名称:neutron2,代码行数:25,代码来源:interface.py


示例10: delete_vxlan

 def delete_vxlan(self, interface):
     if ip_lib.device_exists(interface):
         LOG.debug("Deleting vxlan interface %s for vlan", interface)
         int_vxlan = self.ip.device(interface)
         int_vxlan.link.set_down()
         int_vxlan.link.delete()
         LOG.debug("Done deleting vxlan interface %s", interface)
开发者ID:jmartign,项目名称:virl-salt,代码行数:7,代码来源:linuxbridge_neutron_agent.py


示例11: internal_network_removed

 def internal_network_removed(self, port):
     interface_name = self.get_internal_device_name(port['id'])
     LOG.debug("removing internal network: port(%s) interface(%s)",
               port['id'], interface_name)
     if ip_lib.device_exists(interface_name, namespace=self.ns_name):
         self.driver.unplug(interface_name, namespace=self.ns_name,
                            prefix=INTERNAL_DEV_PREFIX)
开发者ID:MODITDC,项目名称:neutron,代码行数:7,代码来源:router_info.py


示例12: delete_vlan_bridge

    def delete_vlan_bridge(self, bridge_name):
        if ip_lib.device_exists(bridge_name):
            interfaces_on_bridge = self.get_interfaces_on_bridge(bridge_name)
            for interface in interfaces_on_bridge:
                self.remove_interface(bridge_name, interface)

                if interface.startswith(VXLAN_INTERFACE_PREFIX):
                    self.delete_vxlan(interface)
                    continue

                for physical_interface in self.interface_mappings.values():
                    if (interface.startswith(physical_interface)):
                        ips, gateway = self.get_interface_details(bridge_name)
                        if ips:
                            # This is a flat network or a VLAN interface that
                            # was setup outside of neutron => return IP's from
                            # bridge to interface
                            self.update_interface_ip_details(interface,
                                                             bridge_name,
                                                             ips, gateway)
                        elif physical_interface != interface:
                            self.delete_vlan(interface)

            LOG.debug("Deleting bridge %s", bridge_name)
            if utils.execute(['ip', 'link', 'set', bridge_name, 'down'],
                             run_as_root=True):
                return
            if utils.execute(['brctl', 'delbr', bridge_name],
                             run_as_root=True):
                return
            LOG.debug("Done deleting bridge %s", bridge_name)

        else:
            LOG.error(_LE("Cannot delete bridge %s, does not exist"),
                      bridge_name)
开发者ID:rajeshmohan,项目名称:neutron,代码行数:35,代码来源:linuxbridge_neutron_agent.py


示例13: internal_network_removed

 def internal_network_removed(self, ri, port_id, internal_cidr):
     interface_name = self.get_internal_device_name(port_id)
     if ip_lib.device_exists(interface_name,
                             root_helper=self.root_helper,
                             namespace=ri.ns_name()):
         self.driver.unplug(interface_name, namespace=ri.ns_name(),
                            prefix=INTERNAL_DEV_PREFIX)
开发者ID:674009287,项目名称:neutron,代码行数:7,代码来源:l3_agent.py


示例14: create_rtr_2_fip_link

    def create_rtr_2_fip_link(self, ri):
        """Create interface between router and Floating IP namespace."""
        rtr_2_fip_name = self.get_rtr_ext_device_name(ri.router_id)
        fip_2_rtr_name = self.get_int_device_name(ri.router_id)
        fip_ns_name = self.get_name()

        # add link local IP to interface
        if ri.rtr_fip_subnet is None:
            ri.rtr_fip_subnet = self.local_subnets.allocate(ri.router_id)
        rtr_2_fip, fip_2_rtr = ri.rtr_fip_subnet.get_pair()
        ip_wrapper = ip_lib.IPWrapper(namespace=ri.ns_name)
        device_exists = ip_lib.device_exists(rtr_2_fip_name,
                                             namespace=ri.ns_name)
        if not device_exists:
            int_dev = ip_wrapper.add_veth(rtr_2_fip_name,
                                          fip_2_rtr_name,
                                          fip_ns_name)
            self._internal_ns_interface_added(str(rtr_2_fip),
                                              rtr_2_fip_name,
                                              ri.ns_name)
            self._internal_ns_interface_added(str(fip_2_rtr),
                                              fip_2_rtr_name,
                                              fip_ns_name)
            if self.agent_conf.network_device_mtu:
                int_dev[0].link.set_mtu(self.agent_conf.network_device_mtu)
                int_dev[1].link.set_mtu(self.agent_conf.network_device_mtu)
            int_dev[0].link.set_up()
            int_dev[1].link.set_up()

        # add default route for the link local interface
        device = ip_lib.IPDevice(rtr_2_fip_name, namespace=ri.ns_name)
        device.route.add_gateway(str(fip_2_rtr.ip), table=FIP_RT_TBL)
        #setup the NAT rules and chains
        ri._handle_fip_nat_rules(rtr_2_fip_name, 'add_rules')
开发者ID:varunarya10,项目名称:neutron,代码行数:34,代码来源:dvr_fip_ns.py


示例15: test_plug_with_namespace_sets_mtu_higher_than_bridge

    def test_plug_with_namespace_sets_mtu_higher_than_bridge(self):
        device_mtu = 1450

        # Create a new OVS bridge
        ovs_bridge = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
        self.assertFalse(ovs_bridge.get_port_name_list())

        # Add a new linuxbridge port with reduced MTU to OVS bridge
        lb_bridge = self.useFixture(
            net_helpers.LinuxBridgeFixture()).bridge
        lb_bridge_port = self.useFixture(
            net_helpers.LinuxBridgePortFixture(lb_bridge))
        lb_bridge_port.port.link.set_mtu(device_mtu - 1)
        ovs_bridge.add_port(lb_bridge_port.port.name)

        # Now plug a device with intended MTU that is higher than for the port
        # above and validate that its MTU is not reduced to the least MTU on
        # the bridge
        device_name = utils.get_rand_name()
        mac_address = utils.get_random_mac('fa:16:3e:00:00:00'.split(':'))
        namespace = self.useFixture(net_helpers.NamespaceFixture()).name
        self.interface.plug(network_id=uuidutils.generate_uuid(),
                            port_id=uuidutils.generate_uuid(),
                            device_name=device_name,
                            mac_address=mac_address,
                            bridge=ovs_bridge.br_name,
                            namespace=namespace,
                            mtu=device_mtu)

        self.assertIn(device_name, ovs_bridge.get_port_name_list())
        self.assertTrue(ip_lib.device_exists(device_name, namespace))
        self.assertEqual(
            device_mtu,
            ip_lib.IPDevice(device_name, namespace=namespace).link.mtu
        )
开发者ID:sebrandon1,项目名称:neutron,代码行数:35,代码来源:test_interface.py


示例16: _get_router_info_list_for_tenant

    def _get_router_info_list_for_tenant(self, router_ids, tenant_id):
        """Returns the list of router info objects on which to apply the fw."""
        root_ip = ip_lib.IPWrapper(self.root_helper)
        local_ns_list = root_ip.get_namespaces(
            self.root_helper) if self.conf.use_namespaces else []

        router_info_list = []
        # Pick up namespaces for Tenant Routers
        for rid in router_ids:
            # for routers without an interface - get_routers returns
            # the router - but this is not yet populated in router_info
            if rid not in self.router_info:
                continue
            self.router_info[rid].fip_exist = False
            rtr_2_fip_name = self.get_rtr_int_device_name(rid)
            if ip_lib.device_exists(rtr_2_fip_name, self.root_helper,
                                    namespace=self.router_info[rid].ns_name):
                self.router_info[rid].fip_exist = True
            if self.router_info[rid].use_namespaces:
                router_ns = self.router_info[rid].ns_name
                if router_ns in local_ns_list:
                    router_info_list.append(self.router_info[rid])
            else:
                router_info_list.append(self.router_info[rid])
        return router_info_list
开发者ID:HybridCloud-dew,项目名称:hws,代码行数:25,代码来源:firewall_l3_agent.py


示例17: _check_rtr_2_fip_connect

 def _check_rtr_2_fip_connect(self):
     """Checks if the rtr to fip connect exists, if not sets to false."""
     fip_ns_name = self.fip_ns.get_name()
     if ip_lib.network_namespace_exists(fip_ns_name):
         fip_2_rtr_name = self.fip_ns.get_int_device_name(self.router_id)
         if not ip_lib.device_exists(fip_2_rtr_name, namespace=fip_ns_name):
             self.rtr_fip_connect = False
开发者ID:openstack,项目名称:neutron,代码行数:7,代码来源:dvr_local_router.py


示例18: vxlan_ucast_supported

    def vxlan_ucast_supported(self):
        if not cfg.CONF.VXLAN.l2_population:
            return False
        if not ip_lib.iproute_arg_supported(
                ['bridge', 'fdb'], 'append'):
            LOG.warning('Option "%(option)s" must be supported by command '
                        '"%(command)s" to enable %(mode)s mode',
                        {'option': 'append',
                         'command': 'bridge fdb',
                         'mode': 'VXLAN UCAST'})
            return False

        test_iface = None
        for seg_id in moves.range(1, constants.MAX_VXLAN_VNI + 1):
            if (ip_lib.device_exists(self.get_vxlan_device_name(seg_id)) or
                    ip_lib.vxlan_in_use(seg_id)):
                continue
            test_iface = self.ensure_vxlan(seg_id)
            break
        else:
            LOG.error('No valid Segmentation ID to perform UCAST test.')
            return False

        try:
            bridge_lib.FdbInterface.append(constants.FLOODING_ENTRY[0],
                                           test_iface, '1.1.1.1',
                                           log_fail_as_error=False)
            return True
        except RuntimeError:
            return False
        finally:
            self.delete_interface(test_iface)
开发者ID:noironetworks,项目名称:neutron,代码行数:32,代码来源:linuxbridge_neutron_agent.py


示例19: ensure_vxlan

    def ensure_vxlan(self, segmentation_id, mtu=None):
        """Create a vxlan unless it already exists."""
        interface = self.get_vxlan_device_name(segmentation_id)
        if not ip_lib.device_exists(interface):
            LOG.debug("Creating vxlan interface %(interface)s for "
                      "VNI %(segmentation_id)s",
                      {'interface': interface,
                       'segmentation_id': segmentation_id})
            args = {'dev': self.local_int,
                    'srcport': (cfg.CONF.VXLAN.udp_srcport_min,
                                cfg.CONF.VXLAN.udp_srcport_max),
                    'dstport': cfg.CONF.VXLAN.udp_dstport,
                    'ttl': cfg.CONF.VXLAN.ttl}
            if cfg.CONF.VXLAN.tos:
                args['tos'] = cfg.CONF.VXLAN.tos
                if cfg.CONF.AGENT.dscp or cfg.CONF.AGENT.dscp_inherit:
                    LOG.warning('The deprecated tos option in group VXLAN '
                                'is set and takes precedence over dscp and '
                                'dscp_inherit in group AGENT.')
            elif cfg.CONF.AGENT.dscp_inherit:
                args['tos'] = 'inherit'
            elif cfg.CONF.AGENT.dscp:
                args['tos'] = int(cfg.CONF.AGENT.dscp) << 2

            if self.vxlan_mode == lconst.VXLAN_MCAST:
                args['group'] = self.get_vxlan_group(segmentation_id)
            if cfg.CONF.VXLAN.l2_population:
                args['proxy'] = cfg.CONF.VXLAN.arp_responder

            try:
                int_vxlan = self.ip.add_vxlan(interface, segmentation_id,
                                              **args)
            except RuntimeError:
                with excutils.save_and_reraise_exception() as ctxt:
                    # perform this check after an attempt rather than before
                    # to avoid excessive lookups and a possible race condition.
                    if ip_lib.vxlan_in_use(segmentation_id):
                        ctxt.reraise = False
                        LOG.error("Unable to create VXLAN interface for "
                                  "VNI %s because it is in use by another "
                                  "interface.", segmentation_id)
                        return None
            if mtu:
                try:
                    int_vxlan.link.set_mtu(mtu)
                except ip_lib.InvalidArgument:
                    phys_dev_mtu = ip_lib.get_device_mtu(self.local_int)
                    LOG.error("Provided MTU value %(mtu)s for VNI "
                              "%(segmentation_id)s is too high according "
                              "to physical device %(dev)s MTU=%(phys_mtu)s.",
                              {'mtu': mtu,
                               'segmentation_id': segmentation_id,
                               'dev': self.local_int,
                               'phys_mtu': phys_dev_mtu})
                    int_vxlan.link.delete()
                    return None
            int_vxlan.disable_ipv6()
            int_vxlan.link.set_up()
            LOG.debug("Done creating vxlan interface %s", interface)
        return interface
开发者ID:noironetworks,项目名称:neutron,代码行数:60,代码来源:linuxbridge_neutron_agent.py


示例20: validate_interface_mappings

 def validate_interface_mappings(self):
     for physnet, interface in self.interface_mappings.items():
         if not ip_lib.device_exists(interface):
             LOG.error(_LE("Interface %(intf)s for physical network %(net)s"
                           " does not exist. Agent terminated!"),
                       {'intf': interface, 'net': physnet})
             sys.exit(1)
开发者ID:dims,项目名称:neutron,代码行数:7,代码来源:linuxbridge_neutron_agent.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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