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 import orm
|
||||||
from sqlalchemy.orm import exc
|
from sqlalchemy.orm import exc
|
||||||
|
|
||||||
|
from neutron.db.models import segment
|
||||||
from neutron_lib import constants
|
from neutron_lib import constants
|
||||||
from neutron_lib.db import api as db_api
|
from neutron_lib.db import api as db_api
|
||||||
from neutron_lib.db import model_base
|
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)
|
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.retry_if_session_inactive()
|
||||||
@db_api.CONTEXT_WRITER
|
@db_api.CONTEXT_WRITER
|
||||||
def create_tap_service(self, context, tap_service):
|
def create_tap_service(self, context, tap_service):
|
||||||
|
@ -346,6 +346,10 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
|||||||
taas_id = tap_flow_msg['taas_id']
|
taas_id = tap_flow_msg['taas_id']
|
||||||
port = tap_flow_msg['port']
|
port = tap_flow_msg['port']
|
||||||
direction = tap_flow_msg['tap_flow']['direction']
|
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
|
# Get OVS port id for tap flow port
|
||||||
ovs_port = self.int_br.get_vif_port_by_id(port['id'])
|
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
|
# Get VLAN id for tap flow port
|
||||||
# port_dict = self.int_br.get_port_tag_dict()
|
# port_dict = self.int_br.get_port_tag_dict()
|
||||||
# port_vlan_id = port_dict[ovs_port.port_name]
|
# port_vlan_id = port_dict[ovs_port.port_name]
|
||||||
|
if not physical_network:
|
||||||
self.int_br.add_flow(table=0,
|
self.int_br.add_flow(
|
||||||
|
table=0,
|
||||||
priority=20,
|
priority=20,
|
||||||
# dl_vlan=port_vlan_id,
|
# dl_vlan=port_vlan_id,
|
||||||
dl_dst=port_mac,
|
dl_dst=port_mac,
|
||||||
actions="normal,mod_vlan_vid:%s,output:%s" %
|
actions="normal,mod_vlan_vid:%s,output:%s" %
|
||||||
(str(taas_id), str(patch_int_tap_id)))
|
(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,
|
# self._add_update_ingress_bcmc_flow(port_vlan_id,
|
||||||
# taas_id,
|
# taas_id,
|
||||||
|
@ -246,14 +246,18 @@ class TaasRpcDriver(service_drivers.TaasBaseDriver):
|
|||||||
tf['tap_service_id'])
|
tf['tap_service_id'])
|
||||||
ts_port = self.service_plugin.get_port_details(
|
ts_port = self.service_plugin.get_port_details(
|
||||||
context._plugin_context, ts['port_id'])
|
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
|
# Send RPC message to both the source port host and
|
||||||
# tap service(destination) port host
|
# tap service(destination) port host
|
||||||
rpc_msg = {'tap_flow': tf,
|
rpc_msg = {'tap_flow': tf,
|
||||||
'port_mac': port_mac,
|
'port_mac': port_mac,
|
||||||
'taas_id': taas_id,
|
'taas_id': taas_id,
|
||||||
'port': port,
|
'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)
|
self.agent_rpc.create_tap_flow(context._plugin_context, rpc_msg, host)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user