Skip to content

Commit 501745b

Browse files
committed
dhcp/agent: fix 'get_metadata_bind_interface' driver call
The 'get_metadata_bind_interface' driver call has a different behavior than other methods, it is expected to return metadata interface name. When introduced multisegments support this particularity was not taken into account. The fix is making the call acceptable in the purpose of the current driver interface. Closes-bug: #2015090 Signed-off-by: Sahid Orentino Ferdjaoui <[email protected]> Change-Id: I08e686397238685c11b0de818caa399d69da04fd (cherry picked from commit a9323f0)
1 parent 137d313 commit 501745b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

neutron/agent/dhcp/agent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ def call_driver(self, action, network, **action_kwargs):
206206
action, action_kwargs)
207207
# There is nothing we can do.
208208
return
209+
if action == 'get_metadata_bind_interface':
210+
# Special condition, this action returns a string instead of a
211+
# bool.
212+
return self._call_driver(action, network, **action_kwargs)
209213
if 'segments' in network and network.segments:
210214
# In case of multi-segments network, let's group network per
211215
# segments. We can then create DHPC process per segmentation

neutron/tests/unit/agent/dhcp/test_agent.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,17 @@ def test_call_driver_get_metadata_bind_interface_returns(self):
405405
'iface0',
406406
agent.call_driver('get_metadata_bind_interface', network))
407407

408+
def test_call_driver_get_metadata_bind_interface_returns_segments(self):
409+
network = fake_network
410+
network.segments = [
411+
dhcp.DictModel(id='bbbbbbbb-bbbb-bbbb-bbbbbbbbbbbb')]
412+
network.subnets[0] = fake_subnet1
413+
self.driver().get_metadata_bind_interface.return_value = 'iface0'
414+
agent = dhcp_agent.DhcpAgent(cfg.CONF)
415+
self.assertEqual(
416+
'iface0',
417+
agent.call_driver('get_metadata_bind_interface', network))
418+
408419
def _test_sync_state_helper(self, known_net_ids, active_net_ids):
409420
active_networks = set(mock.Mock(id=netid) for netid in active_net_ids)
410421

0 commit comments

Comments
 (0)