Merge "DVR: Fix mac format for backward compatibility with vsctl api"
This commit is contained in:
commit
71427efaae
@ -15,6 +15,7 @@
|
||||
|
||||
import sys
|
||||
|
||||
import netaddr
|
||||
from neutron_lib import constants as n_const
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
@ -198,7 +199,9 @@ class OVSDVRNeutronAgent(object):
|
||||
LOG.debug("L2 Agent DVR: Received response for "
|
||||
"get_dvr_mac_address_by_host() from "
|
||||
"plugin: %r", details)
|
||||
self.dvr_mac_address = details['mac_address']
|
||||
self.dvr_mac_address = (
|
||||
netaddr.EUI(details['mac_address'],
|
||||
dialect=netaddr.mac_unix_expanded))
|
||||
return
|
||||
|
||||
def setup_dvr_flows_on_integ_br(self):
|
||||
@ -307,9 +310,11 @@ class OVSDVRNeutronAgent(object):
|
||||
dvr_macs = self.plugin_rpc.get_dvr_mac_address_list(self.context)
|
||||
LOG.debug("L2 Agent DVR: Received these MACs: %r", dvr_macs)
|
||||
for mac in dvr_macs:
|
||||
if mac['mac_address'] == self.dvr_mac_address:
|
||||
c_mac = netaddr.EUI(mac['mac_address'],
|
||||
dialect=netaddr.mac_unix_expanded)
|
||||
if c_mac == self.dvr_mac_address:
|
||||
continue
|
||||
self._add_dvr_mac(mac['mac_address'])
|
||||
self._add_dvr_mac(c_mac)
|
||||
|
||||
def dvr_mac_address_update(self, dvr_macs):
|
||||
if not self.dvr_mac_address:
|
||||
@ -319,9 +324,11 @@ class OVSDVRNeutronAgent(object):
|
||||
|
||||
dvr_host_macs = set()
|
||||
for entry in dvr_macs:
|
||||
if entry['mac_address'] == self.dvr_mac_address:
|
||||
e_mac = netaddr.EUI(entry['mac_address'],
|
||||
dialect=netaddr.mac_unix_expanded)
|
||||
if e_mac == self.dvr_mac_address:
|
||||
continue
|
||||
dvr_host_macs.add(entry['mac_address'])
|
||||
dvr_host_macs.add(e_mac)
|
||||
|
||||
if dvr_host_macs == self.registered_dvr_macs:
|
||||
LOG.debug("DVR Mac address already up to date")
|
||||
|
@ -3140,9 +3140,9 @@ class TestOvsDvrNeutronAgent(object):
|
||||
mock.patch.object(self.agent.dvr_agent.plugin_rpc,
|
||||
'get_dvr_mac_address_list',
|
||||
return_value=[{'host': 'cn1',
|
||||
'mac_address': 'aa:bb:cc:dd:ee:ff'},
|
||||
'mac_address': 'aa-bb-cc-dd-ee-ff'},
|
||||
{'host': 'cn2',
|
||||
'mac_address': '11:22:33:44:55:66'}]):
|
||||
'mac_address': '11-22-33-44-55-66'}]):
|
||||
self.agent.dvr_agent.setup_dvr_flows_on_integ_br()
|
||||
self.assertTrue(self.agent.dvr_agent.in_distributed_mode())
|
||||
physical_networks = list(
|
||||
@ -3168,7 +3168,7 @@ class TestOvsDvrNeutronAgent(object):
|
||||
with mock.patch.object(self.agent.dvr_agent.plugin_rpc,
|
||||
'get_dvr_mac_address_by_host',
|
||||
return_value={'host': 'cn1',
|
||||
'mac_address': 'aa:22:33:44:55:66'}):
|
||||
'mac_address': 'aa-22-33-44-55-66'}):
|
||||
self.agent.dvr_agent.get_dvr_mac_address()
|
||||
self.assertEqual('aa:22:33:44:55:66',
|
||||
self.agent.dvr_agent.dvr_mac_address)
|
||||
@ -3189,7 +3189,7 @@ class TestOvsDvrNeutronAgent(object):
|
||||
self.assertFalse(self.agent.dvr_agent.in_distributed_mode())
|
||||
|
||||
def test_get_dvr_mac_address_retried(self):
|
||||
valid_entry = {'host': 'cn1', 'mac_address': 'aa:22:33:44:55:66'}
|
||||
valid_entry = {'host': 'cn1', 'mac_address': 'aa-22-33-44-55-66'}
|
||||
raise_timeout = oslo_messaging.MessagingTimeout()
|
||||
# Raise a timeout the first 2 times it calls get_dvr_mac_address()
|
||||
self._setup_for_dvr_test()
|
||||
|
Loading…
Reference in New Issue
Block a user