Merge "Enables external network mirroring"
This commit is contained in:
commit
bb995b48d1
@ -19,6 +19,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy.orm import exc
|
||||
|
||||
from neutron.db.models import segment
|
||||
from neutron_lib import constants
|
||||
from neutron_lib.db import api as db_api
|
||||
from neutron_lib.db import model_base
|
||||
@ -143,6 +144,28 @@ class Taas_db_Mixin(taas_extension.TaasPluginBase):
|
||||
|
||||
return db_utils.resource_fields(res, fields)
|
||||
|
||||
@db_api.retry_if_session_inactive()
|
||||
@db_api.CONTEXT_READER
|
||||
def get_port_network_data(self, context, port):
|
||||
ns = context.session.query(
|
||||
segment.NetworkSegment.network_id,
|
||||
segment.NetworkSegment.physical_network,
|
||||
segment.NetworkSegment.network_type
|
||||
).filter(
|
||||
segment.NetworkSegment.network_id == port['network_id']
|
||||
).first()
|
||||
|
||||
if not ns:
|
||||
LOG.debug("No Network Segment found for network_id %s",
|
||||
port['network_id'])
|
||||
return
|
||||
|
||||
ns_data = {
|
||||
'physical_network': ns['physical_network'],
|
||||
'network_type': ns['network_type']
|
||||
}
|
||||
return ns_data
|
||||
|
||||
@db_api.retry_if_session_inactive()
|
||||
@db_api.CONTEXT_WRITER
|
||||
def create_tap_service(self, context, tap_service):
|
||||
|
@ -346,6 +346,10 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
taas_id = tap_flow_msg['taas_id']
|
||||
port = tap_flow_msg['port']
|
||||
direction = tap_flow_msg['tap_flow']['direction']
|
||||
physical_network = tap_flow_msg['tf_nw']['physical_network'] \
|
||||
if 'tf_nw' in tap_flow_msg else None
|
||||
network_type = tap_flow_msg['tf_nw']['network_type'] \
|
||||
if 'tf_nw' in tap_flow_msg else None
|
||||
|
||||
# Get OVS port id for tap flow port
|
||||
ovs_port = self.int_br.get_vif_port_by_id(port['id'])
|
||||
@ -386,13 +390,29 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
# Get VLAN id for tap flow port
|
||||
# port_dict = self.int_br.get_port_tag_dict()
|
||||
# port_vlan_id = port_dict[ovs_port.port_name]
|
||||
if not physical_network:
|
||||
self.int_br.add_flow(
|
||||
table=0,
|
||||
priority=20,
|
||||
# dl_vlan=port_vlan_id,
|
||||
dl_dst=port_mac,
|
||||
actions="normal,mod_vlan_vid:%s,output:%s" %
|
||||
(str(taas_id), str(patch_int_tap_id))
|
||||
)
|
||||
|
||||
self.int_br.add_flow(table=0,
|
||||
priority=20,
|
||||
# dl_vlan=port_vlan_id,
|
||||
dl_dst=port_mac,
|
||||
actions="normal,mod_vlan_vid:%s,output:%s" %
|
||||
(str(taas_id), str(patch_int_tap_id)))
|
||||
else:
|
||||
actions = "output:%s,mod_vlan_vid:%s,output:%s" % (
|
||||
str(ovs_port_id), str(taas_id), str(patch_int_tap_id)
|
||||
)
|
||||
if network_type == 'vlan':
|
||||
actions = 'strip_vlan,' + actions
|
||||
self.int_br.add_flow(
|
||||
table=0,
|
||||
priority=20,
|
||||
# dl_vlan=port_vlan_id,
|
||||
dl_dst=port_mac,
|
||||
actions=actions
|
||||
)
|
||||
|
||||
# self._add_update_ingress_bcmc_flow(port_vlan_id,
|
||||
# taas_id,
|
||||
|
@ -246,14 +246,18 @@ class TaasRpcDriver(service_drivers.TaasBaseDriver):
|
||||
tf['tap_service_id'])
|
||||
ts_port = self.service_plugin.get_port_details(
|
||||
context._plugin_context, ts['port_id'])
|
||||
|
||||
# Get network data where the tap flow port is located
|
||||
tf_nw = self.service_plugin.get_port_network_data(
|
||||
context._plugin_context, port)
|
||||
# Send RPC message to both the source port host and
|
||||
# tap service(destination) port host
|
||||
rpc_msg = {'tap_flow': tf,
|
||||
'port_mac': port_mac,
|
||||
'taas_id': taas_id,
|
||||
'port': port,
|
||||
'tap_service_port': ts_port}
|
||||
'tap_service_port': ts_port,
|
||||
'tf_nw': tf_nw
|
||||
}
|
||||
|
||||
self.agent_rpc.create_tap_flow(context._plugin_context, rpc_msg, host)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user