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 <sahid.ferdjaoui@industrialdiscipline.com> Change-Id: I08e686397238685c11b0de818caa399d69da04fd
This commit is contained in:
@@ -206,6 +206,10 @@ class DhcpAgent(manager.Manager):
|
||||
action, action_kwargs)
|
||||
# There is nothing we can do.
|
||||
return
|
||||
if action == 'get_metadata_bind_interface':
|
||||
# Special condition, this action returns a string instead of a
|
||||
# bool.
|
||||
return self._call_driver(action, network, **action_kwargs)
|
||||
if 'segments' in network and network.segments:
|
||||
# In case of multi-segments network, let's group network per
|
||||
# segments. We can then create DHPC process per segmentation
|
||||
|
||||
@@ -405,6 +405,17 @@ class TestDhcpAgent(base.BaseTestCase):
|
||||
'iface0',
|
||||
agent.call_driver('get_metadata_bind_interface', network))
|
||||
|
||||
def test_call_driver_get_metadata_bind_interface_returns_segments(self):
|
||||
network = fake_network
|
||||
network.segments = [
|
||||
dhcp.DictModel(id='bbbbbbbb-bbbb-bbbb-bbbbbbbbbbbb')]
|
||||
network.subnets[0] = fake_subnet1
|
||||
self.driver().get_metadata_bind_interface.return_value = 'iface0'
|
||||
agent = dhcp_agent.DhcpAgent(cfg.CONF)
|
||||
self.assertEqual(
|
||||
'iface0',
|
||||
agent.call_driver('get_metadata_bind_interface', network))
|
||||
|
||||
def _test_sync_state_helper(self, known_net_ids, active_net_ids):
|
||||
active_networks = set(mock.Mock(id=netid) for netid in active_net_ids)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user