Merge "Do not try and iterate [None] in l3-agent network_update()" into stable/pike
This commit is contained in:
commit
ecfdb791e5
@ -13,8 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
import itertools
|
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
import netaddr
|
import netaddr
|
||||||
from neutron_lib.callbacks import events
|
from neutron_lib.callbacks import events
|
||||||
@ -441,7 +439,9 @@ class L3NATAgent(ha.AgentMixin,
|
|||||||
def network_update(self, context, **kwargs):
|
def network_update(self, context, **kwargs):
|
||||||
network_id = kwargs['network']['id']
|
network_id = kwargs['network']['id']
|
||||||
for ri in self.router_info.values():
|
for ri in self.router_info.values():
|
||||||
ports = itertools.chain(ri.internal_ports, [ri.ex_gw_port])
|
ports = list(ri.internal_ports)
|
||||||
|
if ri.ex_gw_port:
|
||||||
|
ports.append(ri.ex_gw_port)
|
||||||
port_belongs = lambda p: p['network_id'] == network_id
|
port_belongs = lambda p: p['network_id'] == network_id
|
||||||
if any(port_belongs(p) for p in ports):
|
if any(port_belongs(p) for p in ports):
|
||||||
update = queue.RouterUpdate(
|
update = queue.RouterUpdate(
|
||||||
|
@ -2302,6 +2302,26 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||||||
agent.router_added_to_agent(None, [FAKE_ID])
|
agent.router_added_to_agent(None, [FAKE_ID])
|
||||||
self.assertEqual(1, agent._queue.add.call_count)
|
self.assertEqual(1, agent._queue.add.call_count)
|
||||||
|
|
||||||
|
def test_network_update_not_called(self):
|
||||||
|
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||||
|
agent._queue = mock.Mock()
|
||||||
|
network = {'id': _uuid()}
|
||||||
|
agent.network_update(None, network=network)
|
||||||
|
self.assertFalse(agent._queue.add.called)
|
||||||
|
|
||||||
|
def test_network_update(self):
|
||||||
|
router = l3_test_common.prepare_router_data(num_internal_ports=2)
|
||||||
|
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||||
|
agent._process_added_router(router)
|
||||||
|
ri = l3router.RouterInfo(agent, router['id'],
|
||||||
|
router, **self.ri_kwargs)
|
||||||
|
internal_ports = ri.router.get(lib_constants.INTERFACE_KEY, [])
|
||||||
|
network_id = internal_ports[0]['network_id']
|
||||||
|
agent._queue = mock.Mock()
|
||||||
|
network = {'id': network_id}
|
||||||
|
agent.network_update(None, network=network)
|
||||||
|
self.assertEqual(1, agent._queue.add.call_count)
|
||||||
|
|
||||||
def test_create_router_namespace(self):
|
def test_create_router_namespace(self):
|
||||||
self.mock_ip.ensure_namespace.return_value = self.mock_ip
|
self.mock_ip.ensure_namespace.return_value = self.mock_ip
|
||||||
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||||
|
Loading…
Reference in New Issue
Block a user