Merge "Don't pass config object to send_ip_addr_adv_notif()"

This commit is contained in:
Jenkins 2016-11-09 12:40:48 +00:00 committed by Gerrit Code Review
commit c4c3fbdb5e
7 changed files with 14 additions and 15 deletions

View File

@ -226,7 +226,7 @@ class FipNamespace(namespaces.Namespace):
ip_lib.send_ip_addr_adv_notif(ns_name,
interface_name,
fixed_ip['ip_address'],
self.agent_conf)
self.agent_conf.send_arp_for_ha)
ipd = ip_lib.IPDevice(interface_name, namespace=ns_name)
for subnet in agent_gateway_port['subnets']:

View File

@ -103,7 +103,7 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
ip_lib.send_ip_addr_adv_notif(fip_ns_name,
interface_name,
floating_ip,
self.agent_conf)
self.agent_conf.send_arp_for_ha)
# update internal structures
self.dist_fip_count = self.dist_fip_count + 1

View File

@ -28,5 +28,5 @@ class LegacyRouter(router.RouterInfo):
ip_lib.send_ip_addr_adv_notif(self.ns_name,
interface_name,
fip['floating_ip_address'],
self.agent_conf)
self.agent_conf.send_arp_for_ha)
return lib_constants.FLOATINGIP_STATUS_ACTIVE

View File

@ -410,7 +410,7 @@ class RouterInfo(object):
ip_lib.send_ip_addr_adv_notif(ns_name,
interface_name,
fixed_ip['ip_address'],
self.agent_conf)
self.agent_conf.send_arp_for_ha)
def internal_network_added(self, port):
network_id = port['network_id']
@ -663,7 +663,7 @@ class RouterInfo(object):
ip_lib.send_ip_addr_adv_notif(ns_name,
interface_name,
fixed_ip['ip_address'],
self.agent_conf)
self.agent_conf.send_arp_for_ha)
def is_v6_gateway_set(self, gateway_ips):
"""Check to see if list of gateway_ips has an IPv6 gateway.

View File

@ -1022,7 +1022,7 @@ def _arping(ns_name, iface_name, address, count):
'ns': ns_name})
def send_ip_addr_adv_notif(ns_name, iface_name, address, config):
def send_ip_addr_adv_notif(ns_name, iface_name, address, count=3):
"""Send advance notification of an IP address assignment.
If the address is in the IPv4 family, send gratuitous ARP.
@ -1032,9 +1032,12 @@ def send_ip_addr_adv_notif(ns_name, iface_name, address, config):
Address Discovery (DAD), and (for stateless addresses) router
advertisements (RAs) are sufficient for address resolution and
duplicate address detection.
"""
count = config.send_arp_for_ha
:param ns_name: Namespace name which GARPs are gonna be sent from.
:param iface_name: Name of interface which GARPs are gonna be sent from.
:param address: Advertised IP address.
:param count: (Optional) How many GARPs are gonna be sent. Default is 3.
"""
def arping():
_arping(ns_name, iface_name, address, count)

View File

@ -100,7 +100,7 @@ class TestAddFloatingIpWithMockGarp(BasicRouterTestCaseFramework):
ri.ns_name,
mock.sentinel.interface_name,
ip,
self.agent_conf)
self.agent_conf.send_arp_for_ha)
self.assertEqual(lib_constants.FLOATINGIP_STATUS_ACTIVE, result)
def test_add_floating_ip_error(self, send_ip_addr_adv_notif):

View File

@ -1340,12 +1340,10 @@ class TestArpPing(TestIPCmdBase):
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)
ARPING_COUNT)
self.assertTrue(spawn_n.called)
mIPWrapper.assert_called_once_with(namespace=mock.sentinel.ns_name)
@ -1364,12 +1362,10 @@ class TestArpPing(TestIPCmdBase):
@mock.patch('eventlet.spawn_n')
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)
3)
self.assertFalse(spawn_n.called)