当前位置: 首页>>代码示例>>Python>>正文


Python ip_lib.send_ip_addr_adv_notif函数代码示例

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


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

示例1: _gateway_added

    def _gateway_added(self, ex_gw_port, interface_name):
        """Add Floating IP gateway port."""
        LOG.debug("add gateway interface(%s)", interface_name)
        ns_name = self.get_name()
        self.driver.plug(ex_gw_port['network_id'],
                         ex_gw_port['id'],
                         interface_name,
                         ex_gw_port['mac_address'],
                         bridge=self.agent_conf.external_network_bridge,
                         namespace=ns_name,
                         prefix=FIP_EXT_DEV_PREFIX)

        ip_cidrs = common_utils.fixed_ip_cidrs(ex_gw_port['fixed_ips'])
        self.driver.init_l3(interface_name, ip_cidrs, namespace=ns_name,
                            clean_connections=True)

        for fixed_ip in ex_gw_port['fixed_ips']:
            ip_lib.send_ip_addr_adv_notif(ns_name,
                                          interface_name,
                                          fixed_ip['ip_address'],
                                          self.agent_conf)

        for subnet in ex_gw_port['subnets']:
            gw_ip = subnet.get('gateway_ip')
            if gw_ip:
                ipd = ip_lib.IPDevice(interface_name,
                                      namespace=ns_name)
                ipd.route.add_gateway(gw_ip)

        cmd = ['sysctl', '-w', 'net.ipv4.conf.%s.proxy_arp=1' % interface_name]
        # TODO(Carl) mlavelle's work has self.ip_wrapper
        ip_wrapper = ip_lib.IPWrapper(namespace=ns_name)
        ip_wrapper.netns.execute(cmd, check_exit_code=False)
开发者ID:abhilabh,项目名称:neutron,代码行数:33,代码来源:dvr_fip_ns.py

示例2: floating_ip_added_dist

 def floating_ip_added_dist(self, fip, fip_cidr):
     """Add floating IP to FIP namespace."""
     floating_ip = fip['floating_ip_address']
     fixed_ip = fip['fixed_ip_address']
     rule_pr = self.fip_ns.allocate_rule_priority()
     self.floating_ips_dict[floating_ip] = rule_pr
     fip_2_rtr_name = self.fip_ns.get_int_device_name(self.router_id)
     ip_rule = ip_lib.IPRule(namespace=self.ns_name)
     ip_rule.rule.add(ip=fixed_ip,
                      table=dvr_fip_ns.FIP_RT_TBL,
                      priority=rule_pr)
     #Add routing rule in fip namespace
     fip_ns_name = self.fip_ns.get_name()
     rtr_2_fip, _ = self.rtr_fip_subnet.get_pair()
     device = ip_lib.IPDevice(fip_2_rtr_name, namespace=fip_ns_name)
     device.route.add_route(fip_cidr, str(rtr_2_fip.ip))
     interface_name = (
         self.fip_ns.get_ext_device_name(
             self.fip_ns.agent_gateway_port['id']))
     ip_lib.send_ip_addr_adv_notif(fip_ns_name,
                                   interface_name,
                                   floating_ip,
                                   self.agent_conf)
     # update internal structures
     self.dist_fip_count = self.dist_fip_count + 1
开发者ID:BenoitKnecht,项目名称:neutron,代码行数:25,代码来源:dvr_local_router.py

示例3: update_gateway_port

    def update_gateway_port(self, agent_gateway_port):
        gateway_ip_not_changed = self.agent_gateway_port and (
            not self._check_for_gateway_ip_change(agent_gateway_port))
        self.agent_gateway_port = agent_gateway_port
        if gateway_ip_not_changed:
            return

        ns_name = self.get_name()
        interface_name = self.get_ext_device_name(agent_gateway_port['id'])
        for fixed_ip in agent_gateway_port['fixed_ips']:
            ip_lib.send_ip_addr_adv_notif(ns_name,
                                          interface_name,
                                          fixed_ip['ip_address'],
                                          self.agent_conf)

        ipd = ip_lib.IPDevice(interface_name, namespace=ns_name)
        for subnet in agent_gateway_port['subnets']:
            gw_ip = subnet.get('gateway_ip')
            if gw_ip:
                is_gateway_not_in_subnet = not ipam_utils.check_subnet_ip(
                                                subnet.get('cidr'), gw_ip)
                if is_gateway_not_in_subnet:
                    ipd.route.add_route(gw_ip, scope='link')
                ipd.route.add_gateway(gw_ip)
            else:
                current_gateway = ipd.route.get_gateway()
                if current_gateway and current_gateway.get('gateway'):
                    ipd.route.delete_gateway(current_gateway.get('gateway'))
开发者ID:annp,项目名称:neutron,代码行数:28,代码来源:dvr_fip_ns.py

示例4: _gateway_added

    def _gateway_added(self, ex_gw_port, interface_name):
        """Add Floating IP gateway port."""
        LOG.debug("add gateway interface(%s)", interface_name)
        ns_name = self.get_name()
        self.driver.plug(
            ex_gw_port["network_id"],
            ex_gw_port["id"],
            interface_name,
            ex_gw_port["mac_address"],
            bridge=self.agent_conf.external_network_bridge,
            namespace=ns_name,
            prefix=FIP_EXT_DEV_PREFIX,
        )

        ip_cidrs = common_utils.fixed_ip_cidrs(ex_gw_port["fixed_ips"])
        self.driver.init_l3(interface_name, ip_cidrs, namespace=ns_name, clean_connections=True)

        for fixed_ip in ex_gw_port["fixed_ips"]:
            ip_lib.send_ip_addr_adv_notif(ns_name, interface_name, fixed_ip["ip_address"], self.agent_conf)

        for subnet in ex_gw_port["subnets"]:
            gw_ip = subnet.get("gateway_ip")
            if gw_ip:
                is_gateway_not_in_subnet = not ipam_utils.check_subnet_ip(subnet.get("cidr"), gw_ip)
                ipd = ip_lib.IPDevice(interface_name, namespace=ns_name)
                if is_gateway_not_in_subnet:
                    ipd.route.add_route(gw_ip, scope="link")
                ipd.route.add_gateway(gw_ip)

        cmd = ["sysctl", "-w", "net.ipv4.conf.%s.proxy_arp=1" % interface_name]
        # TODO(Carl) mlavelle's work has self.ip_wrapper
        ip_wrapper = ip_lib.IPWrapper(namespace=ns_name)
        ip_wrapper.netns.execute(cmd, check_exit_code=False)
开发者ID:dims,项目名称:neutron,代码行数:33,代码来源:dvr_fip_ns.py

示例5: _external_gateway_added

    def _external_gateway_added(self, ex_gw_port, interface_name,
                                ns_name, preserve_ips):
        self._plug_external_gateway(ex_gw_port, interface_name, ns_name)

        # Build up the interface and gateway IP addresses that
        # will be added to the interface.
        ip_cidrs = common_utils.fixed_ip_cidrs(ex_gw_port['fixed_ips'])

        gateway_ips = self._get_external_gw_ips(ex_gw_port)
        enable_ra_on_gw = False
        if self.use_ipv6 and not self.is_v6_gateway_set(gateway_ips):
            # There is no IPv6 gw_ip, use RouterAdvt for default route.
            enable_ra_on_gw = True
        self.driver.init_l3(interface_name,
                            ip_cidrs,
                            namespace=ns_name,
                            gateway_ips=gateway_ips,
                            extra_subnets=ex_gw_port.get('extra_subnets', []),
                            preserve_ips=preserve_ips,
                            enable_ra_on_gw=enable_ra_on_gw)
        for fixed_ip in ex_gw_port['fixed_ips']:
            ip_lib.send_ip_addr_adv_notif(ns_name,
                                          interface_name,
                                          fixed_ip['ip_address'],
                                          self.agent_conf)
开发者ID:kongseokhwan,项目名称:kulcloud-iitp-neutron,代码行数:25,代码来源:router_info.py

示例6: _external_gateway_added

    def _external_gateway_added(self, ex_gw_port, interface_name, ns_name, preserve_ips):
        LOG.debug("External gateway added: port(%s), interface(%s), ns(%s)", ex_gw_port, interface_name, ns_name)
        self._plug_external_gateway(ex_gw_port, interface_name, ns_name)

        # Build up the interface and gateway IP addresses that
        # will be added to the interface.
        ip_cidrs = common_utils.fixed_ip_cidrs(ex_gw_port["fixed_ips"])

        gateway_ips = self._get_external_gw_ips(ex_gw_port)
        enable_ra_on_gw = False
        if self.use_ipv6 and not self.is_v6_gateway_set(gateway_ips):
            # There is no IPv6 gw_ip, use RouterAdvt for default route.
            enable_ra_on_gw = True

        self.driver.init_router_port(
            interface_name,
            ip_cidrs,
            namespace=ns_name,
            gateway_ips=gateway_ips,
            extra_subnets=ex_gw_port.get("extra_subnets", []),
            preserve_ips=preserve_ips,
            enable_ra_on_gw=enable_ra_on_gw,
            clean_connections=True,
        )
        for fixed_ip in ex_gw_port["fixed_ips"]:
            ip_lib.send_ip_addr_adv_notif(ns_name, interface_name, fixed_ip["ip_address"], self.agent_conf)
开发者ID:takeshineshiro,项目名称:neutron,代码行数:26,代码来源:router_info.py

示例7: _external_gateway_added

    def _external_gateway_added(self, ex_gw_port, interface_name,
                                ns_name, preserve_ips):
        LOG.debug("External gateway added: port(%s), interface(%s), ns(%s)",
                  ex_gw_port, interface_name, ns_name)
        self._plug_external_gateway(ex_gw_port, interface_name, ns_name)

        # Build up the interface and gateway IP addresses that
        # will be added to the interface.
        ip_cidrs = common_utils.fixed_ip_cidrs(ex_gw_port['fixed_ips'])

        gateway_ips, enable_ra_on_gw = self._get_external_gw_ips(ex_gw_port)
        self.driver.init_router_port(
            interface_name,
            ip_cidrs,
            namespace=ns_name,
            gateway_ips=gateway_ips,
            extra_subnets=ex_gw_port.get('extra_subnets', []),
            preserve_ips=preserve_ips,
            enable_ra_on_gw=enable_ra_on_gw,
            clean_connections=True)
        for fixed_ip in ex_gw_port['fixed_ips']:
            ip_lib.send_ip_addr_adv_notif(ns_name,
                                          interface_name,
                                          fixed_ip['ip_address'],
                                          self.agent_conf)
开发者ID:javaos74,项目名称:neutron,代码行数:25,代码来源:router_info.py

示例8: _update_gateway_route

    def _update_gateway_route(self, agent_gateway_port,
                             interface_name, tbl_index):
        ns_name = self.get_name()
        ipd = ip_lib.IPDevice(interface_name, namespace=ns_name)
        # If the 'fg-' device doesn't exist in the namespace then trying
        # to send advertisements or configure the default route will just
        # throw exceptions.  Unsubscribe this external network so that
        # the next call will trigger the interface to be plugged.
        if not ipd.exists():
            LOG.warning('DVR: FIP gateway port with interface '
                        'name: %(device)s does not exist in the given '
                        'namespace: %(ns)s', {'device': interface_name,
                                              'ns': ns_name})
            msg = _('DVR: Gateway update route in FIP namespace failed, retry '
                    'should be attempted on next call')
            raise l3_exc.FloatingIpSetupException(msg)

        for fixed_ip in agent_gateway_port['fixed_ips']:
            ip_lib.send_ip_addr_adv_notif(ns_name,
                                          interface_name,
                                          fixed_ip['ip_address'])

        for subnet in agent_gateway_port['subnets']:
            gw_ip = subnet.get('gateway_ip')
            if gw_ip:
                is_gateway_not_in_subnet = not ipam_utils.check_subnet_ip(
                                                subnet.get('cidr'), gw_ip)
                if is_gateway_not_in_subnet:
                    ipd.route.add_route(gw_ip, scope='link')
                self._add_default_gateway_for_fip(gw_ip, ipd, tbl_index)
            else:
                current_gateway = ipd.route.get_gateway()
                if current_gateway and current_gateway.get('gateway'):
                    ipd.route.delete_gateway(current_gateway.get('gateway'))
开发者ID:igordcard,项目名称:neutron,代码行数:34,代码来源:dvr_fip_ns.py

示例9: _internal_network_added

    def _internal_network_added(self, ns_name, network_id, port_id, fixed_ips, mac_address, interface_name, prefix):
        LOG.debug("adding internal network: prefix(%s), port(%s)", prefix, port_id)
        self.driver.plug(network_id, port_id, interface_name, mac_address, namespace=ns_name, prefix=prefix)

        ip_cidrs = common_utils.fixed_ip_cidrs(fixed_ips)
        self.driver.init_router_port(interface_name, ip_cidrs, namespace=ns_name)
        for fixed_ip in fixed_ips:
            ip_lib.send_ip_addr_adv_notif(ns_name, interface_name, fixed_ip["ip_address"], self.agent_conf)
开发者ID:takeshineshiro,项目名称:neutron,代码行数:8,代码来源:router_info.py

示例10: send_garp

 def send_garp(self, event):
     """Send gratuitous ARP for given event."""
     ip_lib.send_ip_addr_adv_notif(
         self.namespace,
         event.interface,
         str(netaddr.IPNetwork(event.cidr).ip),
         log_exception=False
     )
开发者ID:cloudbase,项目名称:neutron,代码行数:8,代码来源:keepalived_state_change.py

示例11: test_no_ipv6_addr_notif

 def test_no_ipv6_addr_notif(self, spawn_n):
     ipv6_addr = 'fd00::1'
     config = mock.Mock()
     config.send_arp_for_ha = 3
     ip_lib.send_ip_addr_adv_notif(mock.sentinel.ns_name,
                                   mock.sentinel.iface_name,
                                   ipv6_addr,
                                   config)
     self.assertFalse(spawn_n.called)
开发者ID:kongseokhwan,项目名称:kulcloud-iitp-neutron,代码行数:9,代码来源:test_ip_lib.py

示例12: add_floating_ip

    def add_floating_ip(self, fip, interface_name, device):
        if not self._add_fip_addr_to_device(fip, device):
            return lib_constants.FLOATINGIP_STATUS_ERROR

        # As GARP is processed in a distinct thread the call below
        # won't raise an exception to be handled.
        ip_lib.send_ip_addr_adv_notif(
            self.ns_name, interface_name, fip["floating_ip_address"], self.agent_conf.send_arp_for_ha
        )
        return lib_constants.FLOATINGIP_STATUS_ACTIVE
开发者ID:openstack,项目名称:neutron,代码行数:10,代码来源:legacy_router.py

示例13: _internal_network_added

    def _internal_network_added(self, ns_name, network_id, port_id,
                                fixed_ips, mac_address,
                                interface_name, prefix):
        self.driver.plug(network_id, port_id, interface_name, mac_address,
                         namespace=ns_name,
                         prefix=prefix)

        ip_cidrs = common_utils.fixed_ip_cidrs(fixed_ips)
        self.driver.init_l3(interface_name, ip_cidrs, namespace=ns_name)
        for fixed_ip in fixed_ips:
            ip_lib.send_ip_addr_adv_notif(ns_name,
                                          interface_name,
                                          fixed_ip['ip_address'],
                                          self.agent_conf)
开发者ID:bgxavier,项目名称:neutron,代码行数:14,代码来源:router_info.py

示例14: test_send_ipv4_addr_adv_notif

    def test_send_ipv4_addr_adv_notif(self, spawn_n, mIPWrapper):
        spawn_n.side_effect = lambda f: f()
        ARPING_COUNT = 3
        address = "20.0.0.1"
        config = mock.Mock()
        config.send_arp_for_ha = ARPING_COUNT
        ip_lib.send_ip_addr_adv_notif(mock.sentinel.ns_name, mock.sentinel.iface_name, address, config)

        self.assertTrue(spawn_n.called)
        mIPWrapper.assert_called_once_with(namespace=mock.sentinel.ns_name)

        ip_wrapper = mIPWrapper(namespace=mock.sentinel.ns_name)

        # Just test that arping is called with the right arguments
        arping_cmd = ["arping", "-A", "-I", mock.sentinel.iface_name, "-c", ARPING_COUNT, "-w", mock.ANY, address]
        ip_wrapper.netns.execute.assert_any_call(arping_cmd, check_exit_code=True)
开发者ID:tealover,项目名称:neutron,代码行数:16,代码来源:test_ip_lib.py

示例15: _external_gateway_added

    def _external_gateway_added(self, ex_gw_port, interface_name,
                                ns_name, preserve_ips):
        LOG.debug("External gateway added: port(%s), interface(%s), ns(%s)",
                  ex_gw_port, interface_name, ns_name)
        self._plug_external_gateway(ex_gw_port, interface_name, ns_name)

        # Build up the interface and gateway IP addresses that
        # will be added to the interface.
        ip_cidrs = common_utils.fixed_ip_cidrs(ex_gw_port['fixed_ips'])

        gateway_ips = self._get_external_gw_ips(ex_gw_port)
        enable_ra_on_gw = False
        if self.use_ipv6 and not self.is_v6_gateway_set(gateway_ips):
            # There is no IPv6 gw_ip, use RouterAdvt for default route.
            enable_ra_on_gw = True

        self._add_route_to_gw(ex_gw_port, device_name=interface_name,
                              namespace=ns_name, preserve_ips=preserve_ips)
        self.driver.init_router_port(
            interface_name,
            ip_cidrs,
            namespace=ns_name,
            extra_subnets=ex_gw_port.get('extra_subnets', []),
            preserve_ips=preserve_ips,
            clean_connections=True)

        device = ip_lib.IPDevice(interface_name, namespace=ns_name)
        current_gateways = set()
        for ip_version in (l3_constants.IP_VERSION_4,
                           l3_constants.IP_VERSION_6):
            gateway = device.route.get_gateway(ip_version=ip_version)
            if gateway and gateway.get('gateway'):
                current_gateways.add(gateway.get('gateway'))
        for ip in current_gateways - set(gateway_ips):
            device.route.delete_gateway(ip)
        for ip in gateway_ips:
            device.route.add_gateway(ip)

        if enable_ra_on_gw:
            self.driver.configure_ipv6_ra(ns_name, interface_name)

        for fixed_ip in ex_gw_port['fixed_ips']:
            ip_lib.send_ip_addr_adv_notif(ns_name,
                                          interface_name,
                                          fixed_ip['ip_address'],
                                          self.agent_conf)
开发者ID:biruce-openstack,项目名称:neutron,代码行数:46,代码来源:router_info.py


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