Merge "Refactor l2_pop code to pass mac/ip info more readably"
This commit is contained in:
commit
a6a464b9dd
@ -21,6 +21,7 @@ import six
|
|||||||
from neutron.common import constants as n_const
|
from neutron.common import constants as n_const
|
||||||
from neutron.common import log
|
from neutron.common import log
|
||||||
from neutron.openstack.common import log as logging
|
from neutron.openstack.common import log as logging
|
||||||
|
from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -38,17 +39,43 @@ class L2populationRpcCallBackMixin(object):
|
|||||||
@log.log
|
@log.log
|
||||||
def add_fdb_entries(self, context, fdb_entries, host=None):
|
def add_fdb_entries(self, context, fdb_entries, host=None):
|
||||||
if not host or host == cfg.CONF.host:
|
if not host or host == cfg.CONF.host:
|
||||||
self.fdb_add(context, fdb_entries)
|
self.fdb_add(context, self._unmarshall_fdb_entries(fdb_entries))
|
||||||
|
|
||||||
@log.log
|
@log.log
|
||||||
def remove_fdb_entries(self, context, fdb_entries, host=None):
|
def remove_fdb_entries(self, context, fdb_entries, host=None):
|
||||||
if not host or host == cfg.CONF.host:
|
if not host or host == cfg.CONF.host:
|
||||||
self.fdb_remove(context, fdb_entries)
|
self.fdb_remove(context, self._unmarshall_fdb_entries(fdb_entries))
|
||||||
|
|
||||||
@log.log
|
@log.log
|
||||||
def update_fdb_entries(self, context, fdb_entries, host=None):
|
def update_fdb_entries(self, context, fdb_entries, host=None):
|
||||||
if not host or host == cfg.CONF.host:
|
if not host or host == cfg.CONF.host:
|
||||||
self.fdb_update(context, fdb_entries)
|
self.fdb_update(context, self._unmarshall_fdb_entries(fdb_entries))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _unmarshall_fdb_entries(fdb_entries):
|
||||||
|
"""Prepares fdb_entries from JSON.
|
||||||
|
|
||||||
|
All methods in this class that receive messages should call this to
|
||||||
|
unmarshall fdb_entries from the wire.
|
||||||
|
|
||||||
|
:param fdb_entries: Original fdb_entries data-structure. Looks like:
|
||||||
|
{
|
||||||
|
<uuid>: {
|
||||||
|
...,
|
||||||
|
'ports': {
|
||||||
|
<ip address>: [ [<mac>, <ip>], ... ],
|
||||||
|
...
|
||||||
|
|
||||||
|
:returns: Deep copy with [<mac>, <ip>] converted to PortInfo
|
||||||
|
"""
|
||||||
|
unmarshalled = dict(fdb_entries)
|
||||||
|
for value in unmarshalled.values():
|
||||||
|
if 'ports' in value:
|
||||||
|
value['ports'] = dict(
|
||||||
|
(address, [l2pop_rpc.PortInfo(*pi) for pi in port_infos])
|
||||||
|
for address, port_infos in value['ports'].items()
|
||||||
|
)
|
||||||
|
return unmarshalled
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def fdb_add(self, context, fdb_entries):
|
def fdb_add(self, context, fdb_entries):
|
||||||
@ -97,9 +124,10 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
|
|||||||
|
|
||||||
:param br: represent the bridge on which add_fdb_flow should be
|
:param br: represent the bridge on which add_fdb_flow should be
|
||||||
applied.
|
applied.
|
||||||
:param port_info: list to include mac and ip.
|
:param port_info: PortInfo instance to include mac and ip.
|
||||||
|
.mac_address
|
||||||
|
.ip_address
|
||||||
|
|
||||||
[mac, ip]
|
|
||||||
:remote_ip: remote ip address.
|
:remote_ip: remote ip address.
|
||||||
:param lvm: a local VLAN map of network.
|
:param lvm: a local VLAN map of network.
|
||||||
:param ofport: a port to add.
|
:param ofport: a port to add.
|
||||||
@ -117,8 +145,10 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
|
|||||||
|
|
||||||
:param br: represent the bridge on which del_fdb_flow should be
|
:param br: represent the bridge on which del_fdb_flow should be
|
||||||
applied.
|
applied.
|
||||||
:param port_info: a list to contain mac and ip.
|
:param port_info: PortInfo instance to include mac and ip.
|
||||||
[mac, ip]
|
.mac_address
|
||||||
|
.ip_address
|
||||||
|
|
||||||
:remote_ip: remote ip address.
|
:remote_ip: remote ip address.
|
||||||
:param lvm: local VLAN map of a network. See add_fdb_flow for
|
:param lvm: local VLAN map of a network. See add_fdb_flow for
|
||||||
more explanation.
|
more explanation.
|
||||||
@ -249,13 +279,16 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
|
|||||||
agent and network.
|
agent and network.
|
||||||
{'net1':
|
{'net1':
|
||||||
{'agent_ip':
|
{'agent_ip':
|
||||||
{'before': [[mac, ip]],
|
{'before': PortInfo,
|
||||||
'after': [[mac, ip]]
|
'after': PortInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'net2':
|
'net2':
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PortInfo has .mac_address and .ip_address attrs.
|
||||||
|
|
||||||
:param local_ip: local IP address of this agent.
|
:param local_ip: local IP address of this agent.
|
||||||
:param local_vlan_map: A dict to map network_id to
|
:param local_vlan_map: A dict to map network_id to
|
||||||
the corresponding lvm entry.
|
the corresponding lvm entry.
|
||||||
@ -271,11 +304,13 @@ class L2populationRpcCallBackTunnelMixin(L2populationRpcCallBackMixin):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
after = state.get('after', [])
|
after = state.get('after', [])
|
||||||
for mac, ip in after:
|
for mac_ip in after:
|
||||||
self.setup_entry_for_arp_reply(br, 'add', lvm.vlan, mac,
|
self.setup_entry_for_arp_reply(br, 'add', lvm.vlan,
|
||||||
ip)
|
mac_ip.mac_address,
|
||||||
|
mac_ip.ip_address)
|
||||||
|
|
||||||
before = state.get('before', [])
|
before = state.get('before', [])
|
||||||
for mac, ip in before:
|
for mac_ip in before:
|
||||||
self.setup_entry_for_arp_reply(br, 'remove', lvm.vlan, mac,
|
self.setup_entry_for_arp_reply(br, 'remove', lvm.vlan,
|
||||||
ip)
|
mac_ip.mac_address,
|
||||||
|
mac_ip.ip_address)
|
||||||
|
@ -70,7 +70,7 @@ MAX_GRE_ID = 2 ** 32 - 1
|
|||||||
MIN_VXLAN_VNI = 1
|
MIN_VXLAN_VNI = 1
|
||||||
MAX_VXLAN_VNI = 2 ** 24 - 1
|
MAX_VXLAN_VNI = 2 ** 24 - 1
|
||||||
|
|
||||||
FLOODING_ENTRY = ['00:00:00:00:00:00', '0.0.0.0']
|
FLOODING_ENTRY = ('00:00:00:00:00:00', '0.0.0.0')
|
||||||
|
|
||||||
TYPE_BOOL = "bool"
|
TYPE_BOOL = "bool"
|
||||||
TYPE_INT = "int"
|
TYPE_INT = "int"
|
||||||
|
@ -40,8 +40,9 @@ class L2populationMechanismDriver(api.MechanismDriver,
|
|||||||
self.migrated_ports = {}
|
self.migrated_ports = {}
|
||||||
|
|
||||||
def _get_port_fdb_entries(self, port):
|
def _get_port_fdb_entries(self, port):
|
||||||
return [[port['mac_address'],
|
return [l2pop_rpc.PortInfo(mac_address=port['mac_address'],
|
||||||
ip['ip_address']] for ip in port['fixed_ips']]
|
ip_address=ip['ip_address'])
|
||||||
|
for ip in port['fixed_ips']]
|
||||||
|
|
||||||
def delete_port_postcommit(self, context):
|
def delete_port_postcommit(self, context):
|
||||||
port = context.current
|
port = context.current
|
||||||
@ -75,8 +76,12 @@ class L2populationMechanismDriver(api.MechanismDriver,
|
|||||||
return
|
return
|
||||||
agent, agent_host, agent_ip, segment, port_fdb_entries = port_infos
|
agent, agent_host, agent_ip, segment, port_fdb_entries = port_infos
|
||||||
|
|
||||||
orig_mac_ip = [[port['mac_address'], ip] for ip in orig_ips]
|
orig_mac_ip = [l2pop_rpc.PortInfo(mac_address=port['mac_address'],
|
||||||
port_mac_ip = [[port['mac_address'], ip] for ip in port_ips]
|
ip_address=ip)
|
||||||
|
for ip in orig_ips]
|
||||||
|
port_mac_ip = [l2pop_rpc.PortInfo(mac_address=port['mac_address'],
|
||||||
|
ip_address=ip)
|
||||||
|
for ip in port_ips]
|
||||||
|
|
||||||
upd_fdb_entries = {port['network_id']: {agent_ip: {}}}
|
upd_fdb_entries = {port['network_id']: {agent_ip: {}}}
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import collections
|
||||||
|
import copy
|
||||||
|
|
||||||
from neutron.common import rpc as n_rpc
|
from neutron.common import rpc as n_rpc
|
||||||
from neutron.common import topics
|
from neutron.common import topics
|
||||||
from neutron.openstack.common import log as logging
|
from neutron.openstack.common import log as logging
|
||||||
@ -21,6 +24,9 @@ from neutron.openstack.common import log as logging
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
PortInfo = collections.namedtuple("PortInfo", "mac_address ip_address")
|
||||||
|
|
||||||
|
|
||||||
class L2populationAgentNotifyAPI(n_rpc.RpcProxy):
|
class L2populationAgentNotifyAPI(n_rpc.RpcProxy):
|
||||||
BASE_RPC_API_VERSION = '1.0'
|
BASE_RPC_API_VERSION = '1.0'
|
||||||
|
|
||||||
@ -39,8 +45,10 @@ class L2populationAgentNotifyAPI(n_rpc.RpcProxy):
|
|||||||
'method': method,
|
'method': method,
|
||||||
'fdb_entries': fdb_entries})
|
'fdb_entries': fdb_entries})
|
||||||
|
|
||||||
|
marshalled_fdb_entries = self._marshall_fdb_entries(fdb_entries)
|
||||||
self.fanout_cast(context,
|
self.fanout_cast(context,
|
||||||
self.make_msg(method, fdb_entries=fdb_entries),
|
self.make_msg(method,
|
||||||
|
fdb_entries=marshalled_fdb_entries),
|
||||||
topic=self.topic_l2pop_update)
|
topic=self.topic_l2pop_update)
|
||||||
|
|
||||||
def _notification_host(self, context, method, fdb_entries, host):
|
def _notification_host(self, context, method, fdb_entries, host):
|
||||||
@ -50,8 +58,10 @@ class L2populationAgentNotifyAPI(n_rpc.RpcProxy):
|
|||||||
'topic': self.topic,
|
'topic': self.topic,
|
||||||
'method': method,
|
'method': method,
|
||||||
'fdb_entries': fdb_entries})
|
'fdb_entries': fdb_entries})
|
||||||
|
marshalled_fdb_entries = self._marshall_fdb_entries(fdb_entries)
|
||||||
self.cast(context,
|
self.cast(context,
|
||||||
self.make_msg(method, fdb_entries=fdb_entries),
|
self.make_msg(method,
|
||||||
|
fdb_entries=marshalled_fdb_entries),
|
||||||
topic='%s.%s' % (self.topic_l2pop_update, host))
|
topic='%s.%s' % (self.topic_l2pop_update, host))
|
||||||
|
|
||||||
def add_fdb_entries(self, context, fdb_entries, host=None):
|
def add_fdb_entries(self, context, fdb_entries, host=None):
|
||||||
@ -80,3 +90,28 @@ class L2populationAgentNotifyAPI(n_rpc.RpcProxy):
|
|||||||
else:
|
else:
|
||||||
self._notification_fanout(context, 'update_fdb_entries',
|
self._notification_fanout(context, 'update_fdb_entries',
|
||||||
fdb_entries)
|
fdb_entries)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _marshall_fdb_entries(fdb_entries):
|
||||||
|
"""Prepares fdb_entries for serialization to JSON for RPC.
|
||||||
|
|
||||||
|
All methods in this class that send messages should call this to
|
||||||
|
marshall fdb_entries for the wire.
|
||||||
|
|
||||||
|
:param fdb_entries: Original fdb_entries data-structure. Looks like:
|
||||||
|
{
|
||||||
|
<uuid>: {
|
||||||
|
...,
|
||||||
|
'ports': {
|
||||||
|
<ip address>: [ PortInfo, ... ],
|
||||||
|
...
|
||||||
|
|
||||||
|
:returns: Deep copy with PortInfo converted to [mac, ip]
|
||||||
|
"""
|
||||||
|
marshalled = copy.deepcopy(fdb_entries)
|
||||||
|
for value in marshalled.values():
|
||||||
|
if 'ports' in value:
|
||||||
|
for address, port_infos in value['ports'].items():
|
||||||
|
value['ports'][address] = [[mac, ip]
|
||||||
|
for mac, ip in port_infos]
|
||||||
|
return marshalled
|
||||||
|
@ -373,8 +373,9 @@ class OFANeutronAgent(n_rpc.RpcCallback,
|
|||||||
for port_info in port_infos:
|
for port_info in port_infos:
|
||||||
if port_info == n_const.FLOODING_ENTRY:
|
if port_info == n_const.FLOODING_ENTRY:
|
||||||
continue
|
continue
|
||||||
self.ryuapp.add_arp_table_entry(
|
self.ryuapp.add_arp_table_entry(lvm.vlan,
|
||||||
lvm.vlan, port_info[1], port_info[0])
|
port_info.ip_address,
|
||||||
|
port_info.mac_address)
|
||||||
|
|
||||||
@log.log
|
@log.log
|
||||||
def _fdb_remove_arp(self, lvm, agent_ports):
|
def _fdb_remove_arp(self, lvm, agent_ports):
|
||||||
@ -382,7 +383,7 @@ class OFANeutronAgent(n_rpc.RpcCallback,
|
|||||||
for port_info in port_infos:
|
for port_info in port_infos:
|
||||||
if port_info == n_const.FLOODING_ENTRY:
|
if port_info == n_const.FLOODING_ENTRY:
|
||||||
continue
|
continue
|
||||||
self.ryuapp.del_arp_table_entry(lvm.vlan, port_info[1])
|
self.ryuapp.del_arp_table_entry(lvm.vlan, port_info.ip_address)
|
||||||
|
|
||||||
def add_fdb_flow(self, br, port_info, remote_ip, lvm, ofport):
|
def add_fdb_flow(self, br, port_info, remote_ip, lvm, ofport):
|
||||||
if port_info == n_const.FLOODING_ENTRY:
|
if port_info == n_const.FLOODING_ENTRY:
|
||||||
@ -393,11 +394,13 @@ class OFANeutronAgent(n_rpc.RpcCallback,
|
|||||||
lvm.tun_ofports, goto_next=True)
|
lvm.tun_ofports, goto_next=True)
|
||||||
else:
|
else:
|
||||||
self.ryuapp.add_arp_table_entry(
|
self.ryuapp.add_arp_table_entry(
|
||||||
lvm.vlan, port_info[1], port_info[0])
|
lvm.vlan,
|
||||||
|
port_info.ip_address,
|
||||||
|
port_info.mac_address)
|
||||||
br.install_tunnel_output(
|
br.install_tunnel_output(
|
||||||
tables.TUNNEL_OUT,
|
tables.TUNNEL_OUT,
|
||||||
lvm.vlan, lvm.segmentation_id,
|
lvm.vlan, lvm.segmentation_id,
|
||||||
set([ofport]), goto_next=False, eth_dst=port_info[0])
|
set([ofport]), goto_next=False, eth_dst=port_info.mac_address)
|
||||||
|
|
||||||
def del_fdb_flow(self, br, port_info, remote_ip, lvm, ofport):
|
def del_fdb_flow(self, br, port_info, remote_ip, lvm, ofport):
|
||||||
if port_info == n_const.FLOODING_ENTRY:
|
if port_info == n_const.FLOODING_ENTRY:
|
||||||
@ -412,9 +415,9 @@ class OFANeutronAgent(n_rpc.RpcCallback,
|
|||||||
tables.TUNNEL_FLOOD[lvm.network_type],
|
tables.TUNNEL_FLOOD[lvm.network_type],
|
||||||
lvm.vlan)
|
lvm.vlan)
|
||||||
else:
|
else:
|
||||||
self.ryuapp.del_arp_table_entry(lvm.vlan, port_info[1])
|
self.ryuapp.del_arp_table_entry(lvm.vlan, port_info.ip_address)
|
||||||
br.delete_tunnel_output(tables.TUNNEL_OUT,
|
br.delete_tunnel_output(tables.TUNNEL_OUT,
|
||||||
lvm.vlan, eth_dst=port_info[0])
|
lvm.vlan, eth_dst=port_info.mac_address)
|
||||||
|
|
||||||
def setup_entry_for_arp_reply(self, br, action, local_vid, mac_address,
|
def setup_entry_for_arp_reply(self, br, action, local_vid, mac_address,
|
||||||
ip_address):
|
ip_address):
|
||||||
|
@ -382,12 +382,13 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
|
|||||||
actions="strip_vlan,set_tunnel:%s,output:%s" %
|
actions="strip_vlan,set_tunnel:%s,output:%s" %
|
||||||
(lvm.segmentation_id, ofports))
|
(lvm.segmentation_id, ofports))
|
||||||
else:
|
else:
|
||||||
self.setup_entry_for_arp_reply(br, 'add', lvm.vlan, port_info[0],
|
self.setup_entry_for_arp_reply(br, 'add', lvm.vlan,
|
||||||
port_info[1])
|
port_info.mac_address,
|
||||||
|
port_info.ip_address)
|
||||||
br.add_flow(table=constants.UCAST_TO_TUN,
|
br.add_flow(table=constants.UCAST_TO_TUN,
|
||||||
priority=2,
|
priority=2,
|
||||||
dl_vlan=lvm.vlan,
|
dl_vlan=lvm.vlan,
|
||||||
dl_dst=port_info[0],
|
dl_dst=port_info.mac_address,
|
||||||
actions="strip_vlan,set_tunnel:%s,output:%s" %
|
actions="strip_vlan,set_tunnel:%s,output:%s" %
|
||||||
(lvm.segmentation_id, ofport))
|
(lvm.segmentation_id, ofport))
|
||||||
|
|
||||||
@ -405,10 +406,11 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
|
|||||||
br.delete_flows(table=constants.FLOOD_TO_TUN, dl_vlan=lvm.vlan)
|
br.delete_flows(table=constants.FLOOD_TO_TUN, dl_vlan=lvm.vlan)
|
||||||
else:
|
else:
|
||||||
self.setup_entry_for_arp_reply(br, 'remove', lvm.vlan,
|
self.setup_entry_for_arp_reply(br, 'remove', lvm.vlan,
|
||||||
port_info[0], port_info[1])
|
port_info.mac_address,
|
||||||
|
port_info.ip_address)
|
||||||
br.delete_flows(table=constants.UCAST_TO_TUN,
|
br.delete_flows(table=constants.UCAST_TO_TUN,
|
||||||
dl_vlan=lvm.vlan,
|
dl_vlan=lvm.vlan,
|
||||||
dl_dst=port_info[0])
|
dl_dst=port_info.mac_address)
|
||||||
|
|
||||||
def _fdb_chg_ip(self, context, fdb_entries):
|
def _fdb_chg_ip(self, context, fdb_entries):
|
||||||
LOG.debug("update chg_ip received")
|
LOG.debug("update chg_ip received")
|
||||||
|
@ -18,6 +18,7 @@ import collections
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from neutron.agent import l2population_rpc
|
from neutron.agent import l2population_rpc
|
||||||
|
from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc
|
||||||
from neutron.plugins.openvswitch.agent import ovs_neutron_agent
|
from neutron.plugins.openvswitch.agent import ovs_neutron_agent
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
|
|
||||||
@ -81,9 +82,9 @@ class TestL2populationRpcCallBackTunnelMixinBase(base.BaseTestCase):
|
|||||||
port='port3')]
|
port='port3')]
|
||||||
|
|
||||||
self.agent_ports = {
|
self.agent_ports = {
|
||||||
self.ports[0].ip: [[self.lvms[0].mac, self.lvms[0].ip]],
|
self.ports[0].ip: [(self.lvms[0].mac, self.lvms[0].ip)],
|
||||||
self.ports[1].ip: [[self.lvms[1].mac, self.lvms[1].ip]],
|
self.ports[1].ip: [(self.lvms[1].mac, self.lvms[1].ip)],
|
||||||
self.ports[2].ip: [[self.lvms[2].mac, self.lvms[2].ip]],
|
self.ports[2].ip: [(self.lvms[2].mac, self.lvms[2].ip)],
|
||||||
}
|
}
|
||||||
|
|
||||||
self.fdb_entries1 = {
|
self.fdb_entries1 = {
|
||||||
@ -92,21 +93,21 @@ class TestL2populationRpcCallBackTunnelMixinBase(base.BaseTestCase):
|
|||||||
'segment_id': self.lvms[0].segid,
|
'segment_id': self.lvms[0].segid,
|
||||||
'ports': {
|
'ports': {
|
||||||
self.local_ip: [],
|
self.local_ip: [],
|
||||||
self.ports[0].ip: [[self.lvms[0].mac, self.lvms[0].ip]]},
|
self.ports[0].ip: [(self.lvms[0].mac, self.lvms[0].ip)]},
|
||||||
},
|
},
|
||||||
self.lvms[1].net: {
|
self.lvms[1].net: {
|
||||||
'network_type': self.type_gre,
|
'network_type': self.type_gre,
|
||||||
'segment_id': self.lvms[1].segid,
|
'segment_id': self.lvms[1].segid,
|
||||||
'ports': {
|
'ports': {
|
||||||
self.local_ip: [],
|
self.local_ip: [],
|
||||||
self.ports[1].ip: [[self.lvms[1].mac, self.lvms[1].ip]]},
|
self.ports[1].ip: [(self.lvms[1].mac, self.lvms[1].ip)]},
|
||||||
},
|
},
|
||||||
self.lvms[2].net: {
|
self.lvms[2].net: {
|
||||||
'network_type': self.type_gre,
|
'network_type': self.type_gre,
|
||||||
'segment_id': self.lvms[2].segid,
|
'segment_id': self.lvms[2].segid,
|
||||||
'ports': {
|
'ports': {
|
||||||
self.local_ip: [],
|
self.local_ip: [],
|
||||||
self.ports[2].ip: [[self.lvms[2].mac, self.lvms[2].ip]]},
|
self.ports[2].ip: [(self.lvms[2].mac, self.lvms[2].ip)]},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,18 +130,24 @@ class TestL2populationRpcCallBackTunnelMixinBase(base.BaseTestCase):
|
|||||||
self.upd_fdb_entry1_val = {
|
self.upd_fdb_entry1_val = {
|
||||||
self.lvms[0].net: {
|
self.lvms[0].net: {
|
||||||
self.ports[0].ip: {
|
self.ports[0].ip: {
|
||||||
'before': [[self.lvms[0].mac, self.lvms[0].ip]],
|
'before': [l2pop_rpc.PortInfo(self.lvms[0].mac,
|
||||||
'after': [[self.lvms[1].mac, self.lvms[1].ip]],
|
self.lvms[0].ip)],
|
||||||
|
'after': [l2pop_rpc.PortInfo(self.lvms[1].mac,
|
||||||
|
self.lvms[1].ip)],
|
||||||
},
|
},
|
||||||
self.ports[1].ip: {
|
self.ports[1].ip: {
|
||||||
'before': [[self.lvms[0].mac, self.lvms[0].ip]],
|
'before': [l2pop_rpc.PortInfo(self.lvms[0].mac,
|
||||||
'after': [[self.lvms[1].mac, self.lvms[1].ip]],
|
self.lvms[0].ip)],
|
||||||
|
'after': [l2pop_rpc.PortInfo(self.lvms[1].mac,
|
||||||
|
self.lvms[1].ip)],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
self.lvms[1].net: {
|
self.lvms[1].net: {
|
||||||
self.ports[2].ip: {
|
self.ports[2].ip: {
|
||||||
'before': [[self.lvms[0].mac, self.lvms[0].ip]],
|
'before': [l2pop_rpc.PortInfo(self.lvms[0].mac,
|
||||||
'after': [[self.lvms[2].mac, self.lvms[2].ip]],
|
self.lvms[0].ip)],
|
||||||
|
'after': [l2pop_rpc.PortInfo(self.lvms[2].mac,
|
||||||
|
self.lvms[2].ip)],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -39,10 +39,10 @@ class TestL2populationRpcCallBackTunnelMixin(
|
|||||||
results[lvm] = agent_ports
|
results[lvm] = agent_ports
|
||||||
expected = {
|
expected = {
|
||||||
self.lvm1: {
|
self.lvm1: {
|
||||||
self.ports[0].ip: [[self.lvms[0].mac, self.lvms[0].ip]],
|
self.ports[0].ip: [(self.lvms[0].mac, self.lvms[0].ip)],
|
||||||
self.local_ip: []},
|
self.local_ip: []},
|
||||||
self.lvm3: {
|
self.lvm3: {
|
||||||
self.ports[2].ip: [[self.lvms[2].mac, self.lvms[2].ip]],
|
self.ports[2].ip: [(self.lvms[2].mac, self.lvms[2].ip)],
|
||||||
self.local_ip: []},
|
self.local_ip: []},
|
||||||
}
|
}
|
||||||
self.assertEqual(expected, results)
|
self.assertEqual(expected, results)
|
||||||
@ -55,11 +55,11 @@ class TestL2populationRpcCallBackTunnelMixin(
|
|||||||
results[lvm] = agent_ports
|
results[lvm] = agent_ports
|
||||||
expected = {
|
expected = {
|
||||||
self.lvm1: {
|
self.lvm1: {
|
||||||
self.ports[0].ip: [[self.lvms[0].mac, self.lvms[0].ip]],
|
self.ports[0].ip: [(self.lvms[0].mac, self.lvms[0].ip)],
|
||||||
self.local_ip: []},
|
self.local_ip: []},
|
||||||
self.lvm2: {},
|
self.lvm2: {},
|
||||||
self.lvm3: {
|
self.lvm3: {
|
||||||
self.ports[2].ip: [[self.lvms[2].mac, self.lvms[2].ip]],
|
self.ports[2].ip: [(self.lvms[2].mac, self.lvms[2].ip)],
|
||||||
self.local_ip: []},
|
self.local_ip: []},
|
||||||
}
|
}
|
||||||
self.assertEqual(expected, results)
|
self.assertEqual(expected, results)
|
||||||
@ -72,11 +72,11 @@ class TestL2populationRpcCallBackTunnelMixin(
|
|||||||
self.fakeagent.fdb_add_tun('context', self.fakebr, self.lvm1,
|
self.fakeagent.fdb_add_tun('context', self.fakebr, self.lvm1,
|
||||||
self.agent_ports, self.ofports)
|
self.agent_ports, self.ofports)
|
||||||
expected = [
|
expected = [
|
||||||
mock.call(self.fakebr, [self.lvms[0].mac, self.lvms[0].ip],
|
mock.call(self.fakebr, (self.lvms[0].mac, self.lvms[0].ip),
|
||||||
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
||||||
mock.call(self.fakebr, [self.lvms[1].mac, self.lvms[1].ip],
|
mock.call(self.fakebr, (self.lvms[1].mac, self.lvms[1].ip),
|
||||||
self.ports[1].ip, self.lvm1, self.ports[1].ofport),
|
self.ports[1].ip, self.lvm1, self.ports[1].ofport),
|
||||||
mock.call(self.fakebr, [self.lvms[2].mac, self.lvms[2].ip],
|
mock.call(self.fakebr, (self.lvms[2].mac, self.lvms[2].ip),
|
||||||
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
||||||
]
|
]
|
||||||
self.assertEqual(sorted(expected),
|
self.assertEqual(sorted(expected),
|
||||||
@ -95,11 +95,11 @@ class TestL2populationRpcCallBackTunnelMixin(
|
|||||||
mock_setup_tunnel_port.assert_called_once_with(
|
mock_setup_tunnel_port.assert_called_once_with(
|
||||||
self.fakebr, self.ports[1].ip, self.lvm1.network_type)
|
self.fakebr, self.ports[1].ip, self.lvm1.network_type)
|
||||||
expected = [
|
expected = [
|
||||||
mock.call(self.fakebr, [self.lvms[0].mac, self.lvms[0].ip],
|
mock.call(self.fakebr, (self.lvms[0].mac, self.lvms[0].ip),
|
||||||
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
||||||
mock.call(self.fakebr, [self.lvms[1].mac, self.lvms[1].ip],
|
mock.call(self.fakebr, (self.lvms[1].mac, self.lvms[1].ip),
|
||||||
self.ports[1].ip, self.lvm1, ofport),
|
self.ports[1].ip, self.lvm1, ofport),
|
||||||
mock.call(self.fakebr, [self.lvms[2].mac, self.lvms[2].ip],
|
mock.call(self.fakebr, (self.lvms[2].mac, self.lvms[2].ip),
|
||||||
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
||||||
]
|
]
|
||||||
self.assertEqual(sorted(expected),
|
self.assertEqual(sorted(expected),
|
||||||
@ -117,9 +117,9 @@ class TestL2populationRpcCallBackTunnelMixin(
|
|||||||
mock_setup_tunnel_port.assert_called_once_with(
|
mock_setup_tunnel_port.assert_called_once_with(
|
||||||
self.fakebr, self.ports[1].ip, self.lvm1.network_type)
|
self.fakebr, self.ports[1].ip, self.lvm1.network_type)
|
||||||
expected = [
|
expected = [
|
||||||
mock.call(self.fakebr, [self.lvms[0].mac, self.lvms[0].ip],
|
mock.call(self.fakebr, (self.lvms[0].mac, self.lvms[0].ip),
|
||||||
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
||||||
mock.call(self.fakebr, [self.lvms[2].mac, self.lvms[2].ip],
|
mock.call(self.fakebr, (self.lvms[2].mac, self.lvms[2].ip),
|
||||||
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
||||||
]
|
]
|
||||||
self.assertEqual(sorted(expected),
|
self.assertEqual(sorted(expected),
|
||||||
@ -131,11 +131,11 @@ class TestL2populationRpcCallBackTunnelMixin(
|
|||||||
self.fakeagent.fdb_remove_tun('context', self.fakebr, self.lvm1,
|
self.fakeagent.fdb_remove_tun('context', self.fakebr, self.lvm1,
|
||||||
self.agent_ports, self.ofports)
|
self.agent_ports, self.ofports)
|
||||||
expected = [
|
expected = [
|
||||||
mock.call(self.fakebr, [self.lvms[0].mac, self.lvms[0].ip],
|
mock.call(self.fakebr, (self.lvms[0].mac, self.lvms[0].ip),
|
||||||
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
||||||
mock.call(self.fakebr, [self.lvms[1].mac, self.lvms[1].ip],
|
mock.call(self.fakebr, (self.lvms[1].mac, self.lvms[1].ip),
|
||||||
self.ports[1].ip, self.lvm1, self.ports[1].ofport),
|
self.ports[1].ip, self.lvm1, self.ports[1].ofport),
|
||||||
mock.call(self.fakebr, [self.lvms[2].mac, self.lvms[2].ip],
|
mock.call(self.fakebr, (self.lvms[2].mac, self.lvms[2].ip),
|
||||||
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
||||||
]
|
]
|
||||||
self.assertEqual(sorted(expected),
|
self.assertEqual(sorted(expected),
|
||||||
@ -150,12 +150,12 @@ class TestL2populationRpcCallBackTunnelMixin(
|
|||||||
self.fakeagent.fdb_remove_tun('context', self.fakebr, self.lvm1,
|
self.fakeagent.fdb_remove_tun('context', self.fakebr, self.lvm1,
|
||||||
self.agent_ports, self.ofports)
|
self.agent_ports, self.ofports)
|
||||||
expected = [
|
expected = [
|
||||||
mock.call(self.fakebr, [self.lvms[0].mac, self.lvms[0].ip],
|
mock.call(self.fakebr, (self.lvms[0].mac, self.lvms[0].ip),
|
||||||
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
||||||
mock.call(self.fakebr,
|
mock.call(self.fakebr,
|
||||||
[n_const.FLOODING_ENTRY[0], n_const.FLOODING_ENTRY[1]],
|
(n_const.FLOODING_ENTRY[0], n_const.FLOODING_ENTRY[1]),
|
||||||
self.ports[1].ip, self.lvm1, self.ports[1].ofport),
|
self.ports[1].ip, self.lvm1, self.ports[1].ofport),
|
||||||
mock.call(self.fakebr, [self.lvms[2].mac, self.lvms[2].ip],
|
mock.call(self.fakebr, (self.lvms[2].mac, self.lvms[2].ip),
|
||||||
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
||||||
]
|
]
|
||||||
self.assertEqual(sorted(expected),
|
self.assertEqual(sorted(expected),
|
||||||
@ -170,9 +170,9 @@ class TestL2populationRpcCallBackTunnelMixin(
|
|||||||
self.fakeagent.fdb_remove_tun('context', self.fakebr, self.lvm1,
|
self.fakeagent.fdb_remove_tun('context', self.fakebr, self.lvm1,
|
||||||
self.agent_ports, self.ofports)
|
self.agent_ports, self.ofports)
|
||||||
expected = [
|
expected = [
|
||||||
mock.call(self.fakebr, [self.lvms[0].mac, self.lvms[0].ip],
|
mock.call(self.fakebr, (self.lvms[0].mac, self.lvms[0].ip),
|
||||||
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
self.ports[0].ip, self.lvm1, self.ports[0].ofport),
|
||||||
mock.call(self.fakebr, [self.lvms[2].mac, self.lvms[2].ip],
|
mock.call(self.fakebr, (self.lvms[2].mac, self.lvms[2].ip),
|
||||||
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
self.ports[2].ip, self.lvm1, self.ports[2].ofport),
|
||||||
]
|
]
|
||||||
self.assertEqual(sorted(expected),
|
self.assertEqual(sorted(expected),
|
||||||
@ -223,8 +223,8 @@ class TestL2populationRpcCallBackTunnelMixin(
|
|||||||
upd_fdb_entry_val = {
|
upd_fdb_entry_val = {
|
||||||
self.lvms[0].net: {
|
self.lvms[0].net: {
|
||||||
self.local_ip: {
|
self.local_ip: {
|
||||||
'before': [[self.lvms[0].mac, self.lvms[0].ip]],
|
'before': [(self.lvms[0].mac, self.lvms[0].ip)],
|
||||||
'after': [[self.lvms[1].mac, self.lvms[1].ip]],
|
'after': [(self.lvms[1].mac, self.lvms[1].ip)],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
from neutron.agent import l2population_rpc
|
||||||
from neutron.common import constants
|
from neutron.common import constants
|
||||||
from neutron.common import topics
|
from neutron.common import topics
|
||||||
from neutron import context
|
from neutron import context
|
||||||
@ -25,6 +26,7 @@ from neutron.extensions import providernet as pnet
|
|||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.openstack.common import timeutils
|
from neutron.openstack.common import timeutils
|
||||||
from neutron.plugins.ml2.drivers.l2pop import mech_driver as l2pop_mech_driver
|
from neutron.plugins.ml2.drivers.l2pop import mech_driver as l2pop_mech_driver
|
||||||
|
from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc
|
||||||
from neutron.plugins.ml2 import managers
|
from neutron.plugins.ml2 import managers
|
||||||
from neutron.plugins.ml2 import rpc
|
from neutron.plugins.ml2 import rpc
|
||||||
from neutron.tests.unit.ml2 import test_ml2_plugin as test_plugin
|
from neutron.tests.unit.ml2 import test_ml2_plugin as test_plugin
|
||||||
@ -90,6 +92,8 @@ L2_AGENT_5 = {
|
|||||||
NOTIFIER = 'neutron.plugins.ml2.rpc.AgentNotifierApi'
|
NOTIFIER = 'neutron.plugins.ml2.rpc.AgentNotifierApi'
|
||||||
DEVICE_OWNER_COMPUTE = 'compute:None'
|
DEVICE_OWNER_COMPUTE = 'compute:None'
|
||||||
|
|
||||||
|
FLOODING_ENTRY_AS_LIST = list(constants.FLOODING_ENTRY)
|
||||||
|
|
||||||
|
|
||||||
class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
||||||
_mechanism_drivers = ['openvswitch', 'linuxbridge',
|
_mechanism_drivers = ['openvswitch', 'linuxbridge',
|
||||||
@ -157,6 +161,48 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
agent_state={'agent_state': L2_AGENT_5},
|
agent_state={'agent_state': L2_AGENT_5},
|
||||||
time=timeutils.strtime())
|
time=timeutils.strtime())
|
||||||
|
|
||||||
|
def test_port_info_compare(self):
|
||||||
|
# An assumption the code makes is that PortInfo compares equal to
|
||||||
|
# equivalent regular tuples.
|
||||||
|
self.assertEqual(("mac", "ip"), l2pop_rpc.PortInfo("mac", "ip"))
|
||||||
|
|
||||||
|
flooding_entry = l2pop_rpc.PortInfo(*constants.FLOODING_ENTRY)
|
||||||
|
self.assertEqual(constants.FLOODING_ENTRY, flooding_entry)
|
||||||
|
|
||||||
|
def test__unmarshall_fdb_entries(self):
|
||||||
|
entries = {'foouuid': {
|
||||||
|
'segment_id': 1001,
|
||||||
|
'ports': {'192.168.0.10': [['00:00:00:00:00:00', '0.0.0.0'],
|
||||||
|
['fa:16:3e:ff:8c:0f', '10.0.0.6']]},
|
||||||
|
'network_type': 'vxlan'}}
|
||||||
|
|
||||||
|
mixin = l2population_rpc.L2populationRpcCallBackMixin
|
||||||
|
entries = mixin._unmarshall_fdb_entries(entries)
|
||||||
|
|
||||||
|
port_info_list = entries['foouuid']['ports']['192.168.0.10']
|
||||||
|
# Check that the lists have been properly converted to PortInfo
|
||||||
|
self.assertIsInstance(port_info_list[0], l2pop_rpc.PortInfo)
|
||||||
|
self.assertIsInstance(port_info_list[1], l2pop_rpc.PortInfo)
|
||||||
|
self.assertEqual(('00:00:00:00:00:00', '0.0.0.0'), port_info_list[0])
|
||||||
|
self.assertEqual(('fa:16:3e:ff:8c:0f', '10.0.0.6'), port_info_list[1])
|
||||||
|
|
||||||
|
def test__marshall_fdb_entries(self):
|
||||||
|
entries = {'foouuid': {
|
||||||
|
'segment_id': 1001,
|
||||||
|
'ports': {'192.168.0.10': [('00:00:00:00:00:00', '0.0.0.0'),
|
||||||
|
('fa:16:3e:ff:8c:0f', '10.0.0.6')]},
|
||||||
|
'network_type': 'vxlan'}}
|
||||||
|
|
||||||
|
entries = l2pop_rpc.L2populationAgentNotifyAPI._marshall_fdb_entries(
|
||||||
|
entries)
|
||||||
|
|
||||||
|
port_info_list = entries['foouuid']['ports']['192.168.0.10']
|
||||||
|
# Check that the PortInfo tuples have been converted to list
|
||||||
|
self.assertIsInstance(port_info_list[0], list)
|
||||||
|
self.assertIsInstance(port_info_list[1], list)
|
||||||
|
self.assertEqual(['00:00:00:00:00:00', '0.0.0.0'], port_info_list[0])
|
||||||
|
self.assertEqual(['fa:16:3e:ff:8c:0f', '10.0.0.6'], port_info_list[1])
|
||||||
|
|
||||||
def test_fdb_add_called(self):
|
def test_fdb_add_called(self):
|
||||||
self._register_ml2_agents()
|
self._register_ml2_agents()
|
||||||
|
|
||||||
@ -183,7 +229,7 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'fdb_entries':
|
{'fdb_entries':
|
||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'ports':
|
{'ports':
|
||||||
{'20.0.0.1': [constants.FLOODING_ENTRY,
|
{'20.0.0.1': [FLOODING_ENTRY_AS_LIST,
|
||||||
[p1['mac_address'],
|
[p1['mac_address'],
|
||||||
p1_ips[0]]]},
|
p1_ips[0]]]},
|
||||||
'network_type': 'vxlan',
|
'network_type': 'vxlan',
|
||||||
@ -243,7 +289,7 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'fdb_entries':
|
{'fdb_entries':
|
||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'ports':
|
{'ports':
|
||||||
{'20.0.0.5': [constants.FLOODING_ENTRY,
|
{'20.0.0.5': [FLOODING_ENTRY_AS_LIST,
|
||||||
[p1['mac_address'],
|
[p1['mac_address'],
|
||||||
p1_ips[0]]]},
|
p1_ips[0]]]},
|
||||||
'network_type': 'vlan',
|
'network_type': 'vlan',
|
||||||
@ -289,7 +335,7 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'fdb_entries':
|
{'fdb_entries':
|
||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'ports':
|
{'ports':
|
||||||
{'20.0.0.2': [constants.FLOODING_ENTRY,
|
{'20.0.0.2': [FLOODING_ENTRY_AS_LIST,
|
||||||
[p2['mac_address'],
|
[p2['mac_address'],
|
||||||
p2_ips[0]]]},
|
p2_ips[0]]]},
|
||||||
'network_type': 'vxlan',
|
'network_type': 'vxlan',
|
||||||
@ -310,7 +356,7 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'fdb_entries':
|
{'fdb_entries':
|
||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'ports':
|
{'ports':
|
||||||
{'20.0.0.1': [constants.FLOODING_ENTRY,
|
{'20.0.0.1': [FLOODING_ENTRY_AS_LIST,
|
||||||
[p1['mac_address'],
|
[p1['mac_address'],
|
||||||
p1_ips[0]]]},
|
p1_ips[0]]]},
|
||||||
'network_type': 'vxlan',
|
'network_type': 'vxlan',
|
||||||
@ -358,7 +404,7 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'ports':
|
{'ports':
|
||||||
{'20.0.0.2':
|
{'20.0.0.2':
|
||||||
[constants.FLOODING_ENTRY,
|
[FLOODING_ENTRY_AS_LIST,
|
||||||
[p1['mac_address'],
|
[p1['mac_address'],
|
||||||
p1_ips[0]]]},
|
p1_ips[0]]]},
|
||||||
'network_type': 'vxlan',
|
'network_type': 'vxlan',
|
||||||
@ -382,7 +428,7 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'ports':
|
{'ports':
|
||||||
{'20.0.0.1':
|
{'20.0.0.1':
|
||||||
[constants.FLOODING_ENTRY,
|
[FLOODING_ENTRY_AS_LIST,
|
||||||
[p3['mac_address'],
|
[p3['mac_address'],
|
||||||
p3_ips[0]]]},
|
p3_ips[0]]]},
|
||||||
'network_type': 'vxlan',
|
'network_type': 'vxlan',
|
||||||
@ -471,7 +517,7 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'fdb_entries':
|
{'fdb_entries':
|
||||||
{p2['network_id']:
|
{p2['network_id']:
|
||||||
{'ports':
|
{'ports':
|
||||||
{'20.0.0.1': [constants.FLOODING_ENTRY,
|
{'20.0.0.1': [FLOODING_ENTRY_AS_LIST,
|
||||||
[p2['mac_address'],
|
[p2['mac_address'],
|
||||||
p2_ips[0]]]},
|
p2_ips[0]]]},
|
||||||
'network_type': 'vxlan',
|
'network_type': 'vxlan',
|
||||||
@ -552,7 +598,7 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'fdb_entries':
|
{'fdb_entries':
|
||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'ports':
|
{'ports':
|
||||||
{'20.0.0.1': [constants.FLOODING_ENTRY,
|
{'20.0.0.1': [FLOODING_ENTRY_AS_LIST,
|
||||||
[p1['mac_address'],
|
[p1['mac_address'],
|
||||||
p1_ips[0]]]},
|
p1_ips[0]]]},
|
||||||
'network_type': 'vxlan',
|
'network_type': 'vxlan',
|
||||||
@ -594,8 +640,8 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'chg_ip':
|
{'chg_ip':
|
||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'20.0.0.1':
|
{'20.0.0.1':
|
||||||
{'after': [[p1['mac_address'],
|
{'after': [(p1['mac_address'],
|
||||||
'10.0.0.10']]}}}}},
|
'10.0.0.10')]}}}}},
|
||||||
'namespace': None,
|
'namespace': None,
|
||||||
'method': 'update_fdb_entries'}
|
'method': 'update_fdb_entries'}
|
||||||
|
|
||||||
@ -616,10 +662,10 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'chg_ip':
|
{'chg_ip':
|
||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'20.0.0.1':
|
{'20.0.0.1':
|
||||||
{'before': [[p1['mac_address'],
|
{'before': [(p1['mac_address'],
|
||||||
'10.0.0.10']],
|
'10.0.0.10')],
|
||||||
'after': [[p1['mac_address'],
|
'after': [(p1['mac_address'],
|
||||||
'10.0.0.16']]}}}}},
|
'10.0.0.16')]}}}}},
|
||||||
'namespace': None,
|
'namespace': None,
|
||||||
'method': 'update_fdb_entries'}
|
'method': 'update_fdb_entries'}
|
||||||
|
|
||||||
@ -639,8 +685,8 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'chg_ip':
|
{'chg_ip':
|
||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'20.0.0.1':
|
{'20.0.0.1':
|
||||||
{'before': [[p1['mac_address'],
|
{'before': [(p1['mac_address'],
|
||||||
'10.0.0.2']]}}}}},
|
'10.0.0.2')]}}}}},
|
||||||
'namespace': None,
|
'namespace': None,
|
||||||
'method': 'update_fdb_entries'}
|
'method': 'update_fdb_entries'}
|
||||||
|
|
||||||
@ -718,7 +764,7 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'fdb_entries':
|
{'fdb_entries':
|
||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'ports':
|
{'ports':
|
||||||
{'20.0.0.1': [constants.FLOODING_ENTRY,
|
{'20.0.0.1': [FLOODING_ENTRY_AS_LIST,
|
||||||
[p1['mac_address'],
|
[p1['mac_address'],
|
||||||
p1_ips[0]]]},
|
p1_ips[0]]]},
|
||||||
'network_type': 'vxlan',
|
'network_type': 'vxlan',
|
||||||
@ -776,7 +822,7 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
{'fdb_entries':
|
{'fdb_entries':
|
||||||
{p1['network_id']:
|
{p1['network_id']:
|
||||||
{'ports':
|
{'ports':
|
||||||
{'20.0.0.1': [constants.FLOODING_ENTRY,
|
{'20.0.0.1': [FLOODING_ENTRY_AS_LIST,
|
||||||
[p1['mac_address'],
|
[p1['mac_address'],
|
||||||
p1_ips[0]]]},
|
p1_ips[0]]]},
|
||||||
'network_type': 'vxlan',
|
'network_type': 'vxlan',
|
||||||
@ -799,4 +845,4 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||||||
'remove_fdb_entries')) as (upd_port_down,
|
'remove_fdb_entries')) as (upd_port_down,
|
||||||
rem_fdb_entries):
|
rem_fdb_entries):
|
||||||
l2pop_mech.delete_port_postcommit(mock.Mock())
|
l2pop_mech.delete_port_postcommit(mock.Mock())
|
||||||
self.assertTrue(upd_port_down.called)
|
self.assertTrue(upd_port_down.called)
|
||||||
|
@ -31,10 +31,12 @@ import testtools
|
|||||||
from neutron.common import constants as n_const
|
from neutron.common import constants as n_const
|
||||||
from neutron.openstack.common import importutils
|
from neutron.openstack.common import importutils
|
||||||
from neutron.plugins.common import constants as p_const
|
from neutron.plugins.common import constants as p_const
|
||||||
|
from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc
|
||||||
from neutron.tests.unit.ofagent import ofa_test_base
|
from neutron.tests.unit.ofagent import ofa_test_base
|
||||||
|
|
||||||
|
|
||||||
NOTIFIER = ('neutron.plugins.ml2.rpc.AgentNotifierApi')
|
NOTIFIER = ('neutron.plugins.ml2.rpc.AgentNotifierApi')
|
||||||
|
FLOODING_ENTRY = l2pop_rpc.PortInfo(*n_const.FLOODING_ENTRY)
|
||||||
|
|
||||||
|
|
||||||
def _mock_port(is_neutron=True, normalized_name=None):
|
def _mock_port(is_neutron=True, normalized_name=None):
|
||||||
@ -512,8 +514,8 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
|
|||||||
'segment_id': 'tun2',
|
'segment_id': 'tun2',
|
||||||
'ports':
|
'ports':
|
||||||
{'agent_ip':
|
{'agent_ip':
|
||||||
[['mac', 'ip'],
|
[l2pop_rpc.PortInfo('mac', 'ip'),
|
||||||
n_const.FLOODING_ENTRY]}}}
|
FLOODING_ENTRY]}}}
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
mock.patch.object(self.agent.ryuapp, "add_arp_table_entry"),
|
mock.patch.object(self.agent.ryuapp, "add_arp_table_entry"),
|
||||||
mock.patch.object(self.agent.ryuapp, "del_arp_table_entry"),
|
mock.patch.object(self.agent.ryuapp, "del_arp_table_entry"),
|
||||||
@ -532,8 +534,8 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
|
|||||||
'segment_id': 'tun1',
|
'segment_id': 'tun1',
|
||||||
'ports':
|
'ports':
|
||||||
{self.lvms[1].ip:
|
{self.lvms[1].ip:
|
||||||
[['mac', 'ip'],
|
[l2pop_rpc.PortInfo('mac', 'ip'),
|
||||||
n_const.FLOODING_ENTRY]}}}
|
FLOODING_ENTRY]}}}
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
mock.patch.object(self.agent, '_setup_tunnel_port'),
|
mock.patch.object(self.agent, '_setup_tunnel_port'),
|
||||||
mock.patch.object(self.agent.int_br, 'install_tunnel_output'),
|
mock.patch.object(self.agent.int_br, 'install_tunnel_output'),
|
||||||
@ -556,8 +558,8 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
|
|||||||
'segment_id': 'tun2',
|
'segment_id': 'tun2',
|
||||||
'ports':
|
'ports':
|
||||||
{self.lvms[1].ip:
|
{self.lvms[1].ip:
|
||||||
[['mac', 'ip'],
|
[l2pop_rpc.PortInfo('mac', 'ip'),
|
||||||
n_const.FLOODING_ENTRY]}}}
|
FLOODING_ENTRY]}}}
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
mock.patch.object(self.agent.int_br, 'install_tunnel_output'),
|
mock.patch.object(self.agent.int_br, 'install_tunnel_output'),
|
||||||
mock.patch.object(self.agent.int_br, 'delete_tunnel_output'),
|
mock.patch.object(self.agent.int_br, 'delete_tunnel_output'),
|
||||||
@ -575,11 +577,13 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
|
|||||||
fdb_entry = {self.lvms[0].net:
|
fdb_entry = {self.lvms[0].net:
|
||||||
{'network_type': self.tunnel_type,
|
{'network_type': self.tunnel_type,
|
||||||
'segment_id': 'tun1',
|
'segment_id': 'tun1',
|
||||||
'ports': {self.lvms[0].ip: [['mac', 'ip']]}}}
|
'ports': {self.lvms[0].ip: [l2pop_rpc.PortInfo('mac',
|
||||||
|
'ip')]}}}
|
||||||
with mock.patch.object(self.agent, '_setup_tunnel_port') as add_tun_fn:
|
with mock.patch.object(self.agent, '_setup_tunnel_port') as add_tun_fn:
|
||||||
self.agent.fdb_add(None, fdb_entry)
|
self.agent.fdb_add(None, fdb_entry)
|
||||||
self.assertFalse(add_tun_fn.called)
|
self.assertFalse(add_tun_fn.called)
|
||||||
fdb_entry[self.lvms[0].net]['ports'][tunnel_ip] = [['mac', 'ip']]
|
fdb_entry[self.lvms[0].net]['ports'][tunnel_ip] = [
|
||||||
|
l2pop_rpc.PortInfo('mac', 'ip')]
|
||||||
self.agent.fdb_add(None, fdb_entry)
|
self.agent.fdb_add(None, fdb_entry)
|
||||||
add_tun_fn.assert_called_with(
|
add_tun_fn.assert_called_with(
|
||||||
self.agent.int_br, tun_name, tunnel_ip, self.tunnel_type)
|
self.agent.int_br, tun_name, tunnel_ip, self.tunnel_type)
|
||||||
@ -589,7 +593,7 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
|
|||||||
fdb_entry = {self.lvms[1].net:
|
fdb_entry = {self.lvms[1].net:
|
||||||
{'network_type': self.tunnel_type,
|
{'network_type': self.tunnel_type,
|
||||||
'segment_id': 'tun2',
|
'segment_id': 'tun2',
|
||||||
'ports': {self.lvms[1].ip: [n_const.FLOODING_ENTRY]}}}
|
'ports': {self.lvms[1].ip: [FLOODING_ENTRY]}}}
|
||||||
with mock.patch.object(self.agent.int_br,
|
with mock.patch.object(self.agent.int_br,
|
||||||
'delete_port') as del_port_fn:
|
'delete_port') as del_port_fn:
|
||||||
self.agent.fdb_remove(None, fdb_entry)
|
self.agent.fdb_remove(None, fdb_entry)
|
||||||
@ -600,11 +604,14 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
|
|||||||
fdb_entry = {self.lvms[0].net:
|
fdb_entry = {self.lvms[0].net:
|
||||||
{'network_type': self.tunnel_type,
|
{'network_type': self.tunnel_type,
|
||||||
'segment_id': 'tun1',
|
'segment_id': 'tun1',
|
||||||
'ports': {self.lvms[0].ip: [n_const.FLOODING_ENTRY,
|
'ports': {self.lvms[0].ip: [
|
||||||
['mac1', 'ip1']],
|
FLOODING_ENTRY,
|
||||||
self.lvms[1].ip: [['mac2', 'ip2']],
|
l2pop_rpc.PortInfo('mac1', 'ip1')],
|
||||||
'192.0.2.1': [n_const.FLOODING_ENTRY,
|
self.lvms[1].ip: [
|
||||||
['mac3', 'ip3']]}}}
|
l2pop_rpc.PortInfo('mac2', 'ip2')],
|
||||||
|
'192.0.2.1': [
|
||||||
|
FLOODING_ENTRY,
|
||||||
|
l2pop_rpc.PortInfo('mac3', 'ip3')]}}}
|
||||||
with mock.patch.object(self.agent,
|
with mock.patch.object(self.agent,
|
||||||
'setup_tunnel_port') as setup_tun_fn:
|
'setup_tunnel_port') as setup_tun_fn:
|
||||||
self.agent.fdb_add(None, fdb_entry)
|
self.agent.fdb_add(None, fdb_entry)
|
||||||
@ -624,11 +631,14 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
|
|||||||
fdb_entry = {self.lvms[0].net:
|
fdb_entry = {self.lvms[0].net:
|
||||||
{'network_type': network_type,
|
{'network_type': network_type,
|
||||||
'segment_id': 'tun1',
|
'segment_id': 'tun1',
|
||||||
'ports': {self.lvms[0].ip: [n_const.FLOODING_ENTRY,
|
'ports': {self.lvms[0].ip: [
|
||||||
['mac1', 'ip1']],
|
FLOODING_ENTRY,
|
||||||
self.lvms[1].ip: [['mac2', 'ip2']],
|
l2pop_rpc.PortInfo('mac1', 'ip1')],
|
||||||
'192.0.2.1': [n_const.FLOODING_ENTRY,
|
self.lvms[1].ip: [
|
||||||
['mac3', 'ip3']]}}}
|
l2pop_rpc.PortInfo('mac2', 'ip2')],
|
||||||
|
'192.0.2.1': [
|
||||||
|
FLOODING_ENTRY,
|
||||||
|
l2pop_rpc.PortInfo('mac3', 'ip3')]}}}
|
||||||
with mock.patch.object(self.agent,
|
with mock.patch.object(self.agent,
|
||||||
'setup_tunnel_port') as setup_tun_fn:
|
'setup_tunnel_port') as setup_tun_fn:
|
||||||
self.agent.fdb_add(None, fdb_entry)
|
self.agent.fdb_add(None, fdb_entry)
|
||||||
@ -656,11 +666,14 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
|
|||||||
fdb_entry = {self.lvms[0].net:
|
fdb_entry = {self.lvms[0].net:
|
||||||
{'network_type': self.tunnel_type,
|
{'network_type': self.tunnel_type,
|
||||||
'segment_id': 'tun1',
|
'segment_id': 'tun1',
|
||||||
'ports': {self.lvms[0].ip: [n_const.FLOODING_ENTRY,
|
'ports': {self.lvms[0].ip: [
|
||||||
['mac1', 'ip1']],
|
FLOODING_ENTRY,
|
||||||
self.lvms[1].ip: [['mac2', 'ip2']],
|
l2pop_rpc.PortInfo('mac1', 'ip1')],
|
||||||
'192.0.2.1': [n_const.FLOODING_ENTRY,
|
self.lvms[1].ip: [
|
||||||
['mac3', 'ip3']]}}}
|
l2pop_rpc.PortInfo('mac2', 'ip2')],
|
||||||
|
'192.0.2.1': [
|
||||||
|
FLOODING_ENTRY,
|
||||||
|
l2pop_rpc.PortInfo('mac3', 'ip3')]}}}
|
||||||
with mock.patch.object(self.agent,
|
with mock.patch.object(self.agent,
|
||||||
'cleanup_tunnel_port') as cleanup_tun_fn:
|
'cleanup_tunnel_port') as cleanup_tun_fn:
|
||||||
self.agent.fdb_remove(None, fdb_entry)
|
self.agent.fdb_remove(None, fdb_entry)
|
||||||
@ -679,11 +692,14 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
|
|||||||
fdb_entry = {self.lvms[0].net:
|
fdb_entry = {self.lvms[0].net:
|
||||||
{'network_type': network_type,
|
{'network_type': network_type,
|
||||||
'segment_id': 'tun1',
|
'segment_id': 'tun1',
|
||||||
'ports': {self.lvms[0].ip: [n_const.FLOODING_ENTRY,
|
'ports': {self.lvms[0].ip: [
|
||||||
['mac1', 'ip1']],
|
FLOODING_ENTRY,
|
||||||
self.lvms[1].ip: [['mac2', 'ip2']],
|
l2pop_rpc.PortInfo('mac1', 'ip1')],
|
||||||
'192.0.2.1': [n_const.FLOODING_ENTRY,
|
self.lvms[1].ip: [
|
||||||
['mac3', 'ip3']]}}}
|
l2pop_rpc.PortInfo('mac2', 'ip2')],
|
||||||
|
'192.0.2.1': [
|
||||||
|
FLOODING_ENTRY,
|
||||||
|
l2pop_rpc.PortInfo('mac3', 'ip3')]}}}
|
||||||
with mock.patch.object(self.agent,
|
with mock.patch.object(self.agent,
|
||||||
'cleanup_tunnel_port') as cleanup_tun_fn:
|
'cleanup_tunnel_port') as cleanup_tun_fn:
|
||||||
self.agent.fdb_remove(None, fdb_entry)
|
self.agent.fdb_remove(None, fdb_entry)
|
||||||
|
@ -28,6 +28,7 @@ from neutron.agent.linux import utils
|
|||||||
from neutron.common import constants as n_const
|
from neutron.common import constants as n_const
|
||||||
from neutron.openstack.common import log
|
from neutron.openstack.common import log
|
||||||
from neutron.plugins.common import constants as p_const
|
from neutron.plugins.common import constants as p_const
|
||||||
|
from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc
|
||||||
from neutron.plugins.openvswitch.agent import ovs_neutron_agent
|
from neutron.plugins.openvswitch.agent import ovs_neutron_agent
|
||||||
from neutron.plugins.openvswitch.common import constants
|
from neutron.plugins.openvswitch.common import constants
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
@ -1092,7 +1093,7 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
|||||||
'segment_id': 'tun2',
|
'segment_id': 'tun2',
|
||||||
'ports':
|
'ports':
|
||||||
{'agent_ip':
|
{'agent_ip':
|
||||||
[[FAKE_MAC, FAKE_IP1],
|
[l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1),
|
||||||
n_const.FLOODING_ENTRY]}}}
|
n_const.FLOODING_ENTRY]}}}
|
||||||
with mock.patch.object(self.agent.tun_br,
|
with mock.patch.object(self.agent.tun_br,
|
||||||
"deferred") as defer_fn:
|
"deferred") as defer_fn:
|
||||||
@ -1109,7 +1110,7 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
|||||||
'segment_id': 'tun1',
|
'segment_id': 'tun1',
|
||||||
'ports':
|
'ports':
|
||||||
{'2.2.2.2':
|
{'2.2.2.2':
|
||||||
[[FAKE_MAC, FAKE_IP1],
|
[l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1),
|
||||||
n_const.FLOODING_ENTRY]}}}
|
n_const.FLOODING_ENTRY]}}}
|
||||||
|
|
||||||
class ActionMatcher(object):
|
class ActionMatcher(object):
|
||||||
@ -1164,7 +1165,7 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
|||||||
'segment_id': 'tun2',
|
'segment_id': 'tun2',
|
||||||
'ports':
|
'ports':
|
||||||
{'2.2.2.2':
|
{'2.2.2.2':
|
||||||
[[FAKE_MAC, FAKE_IP1],
|
[l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1),
|
||||||
n_const.FLOODING_ENTRY]}}}
|
n_const.FLOODING_ENTRY]}}}
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
mock.patch.object(self.agent.tun_br, 'deferred'),
|
mock.patch.object(self.agent.tun_br, 'deferred'),
|
||||||
@ -1194,7 +1195,8 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
|||||||
fdb_entry = {'net1':
|
fdb_entry = {'net1':
|
||||||
{'network_type': 'gre',
|
{'network_type': 'gre',
|
||||||
'segment_id': 'tun1',
|
'segment_id': 'tun1',
|
||||||
'ports': {'1.1.1.1': [[FAKE_MAC, FAKE_IP1]]}}}
|
'ports': {'1.1.1.1': [l2pop_rpc.PortInfo(FAKE_MAC,
|
||||||
|
FAKE_IP1)]}}}
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
mock.patch.object(self.agent.tun_br, 'deferred'),
|
mock.patch.object(self.agent.tun_br, 'deferred'),
|
||||||
mock.patch.object(self.agent.tun_br, 'do_action_flows'),
|
mock.patch.object(self.agent.tun_br, 'do_action_flows'),
|
||||||
@ -1204,7 +1206,8 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
|||||||
deferred_fn.return_value = deferred_br
|
deferred_fn.return_value = deferred_br
|
||||||
self.agent.fdb_add(None, fdb_entry)
|
self.agent.fdb_add(None, fdb_entry)
|
||||||
self.assertFalse(add_tun_fn.called)
|
self.assertFalse(add_tun_fn.called)
|
||||||
fdb_entry['net1']['ports']['10.10.10.10'] = [[FAKE_MAC, FAKE_IP1]]
|
fdb_entry['net1']['ports']['10.10.10.10'] = [
|
||||||
|
l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1)]
|
||||||
self.agent.fdb_add(None, fdb_entry)
|
self.agent.fdb_add(None, fdb_entry)
|
||||||
add_tun_fn.assert_called_with(
|
add_tun_fn.assert_called_with(
|
||||||
deferred_br, 'gre-0a0a0a0a', '10.10.10.10', 'gre')
|
deferred_br, 'gre-0a0a0a0a', '10.10.10.10', 'gre')
|
||||||
@ -1230,8 +1233,8 @@ class TestOvsNeutronAgent(base.BaseTestCase):
|
|||||||
fdb_entries = {'chg_ip':
|
fdb_entries = {'chg_ip':
|
||||||
{'net1':
|
{'net1':
|
||||||
{'agent_ip':
|
{'agent_ip':
|
||||||
{'before': [[FAKE_MAC, FAKE_IP1]],
|
{'before': [l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP1)],
|
||||||
'after': [[FAKE_MAC, FAKE_IP2]]}}}}
|
'after': [l2pop_rpc.PortInfo(FAKE_MAC, FAKE_IP2)]}}}}
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
mock.patch.object(self.agent.tun_br, 'deferred'),
|
mock.patch.object(self.agent.tun_br, 'deferred'),
|
||||||
mock.patch.object(self.agent.tun_br, 'do_action_flows'),
|
mock.patch.object(self.agent.tun_br, 'do_action_flows'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user