Code cleaning: make RPC method signatures more meaningful

Change RPC calls like create_tap_service or create_tap_flow signature
to avoid parameter names like tap_service which is really a dict of
values.

Change-Id: I0ec7fef934e63eff76dd30bb1fb28c8277f1a749
This commit is contained in:
elajkat 2022-03-11 16:33:06 +01:00 committed by Lajos Katona
parent 1066701ced
commit 002de24695
5 changed files with 134 additions and 44 deletions

View File

@ -50,19 +50,19 @@ class TaasAgentDriver(object):
"""
@abc.abstractmethod
def create_tap_service(self, tap_service):
def create_tap_service(self, tap_service_msg):
"""Create a Tap Service request in driver."""
@abc.abstractmethod
def create_tap_flow(self, tap_flow):
def create_tap_flow(self, tap_flow_msg):
"""Create a tap flow request in driver."""
@abc.abstractmethod
def delete_tap_service(self, tap_service):
def delete_tap_service(self, tap_service_msg):
"""delete a Tap Service request in driver."""
@abc.abstractmethod
def delete_tap_flow(self, tap_flow):
def delete_tap_flow(self, tap_flow_msg):
"""Delete a tap flow request in driver."""

View File

@ -43,11 +43,11 @@ class TaasAgentRpcCallbackMixin(object):
"""
self.agent_api = agent_api
def create_tap_service(self, context, tap_service, host):
def create_tap_service(self, context, tap_service_msg, host):
"""Handle RPC cast from plugin to create a tap service."""
pass
def delete_tap_service(self, context, tap_service, host):
def delete_tap_service(self, context, tap_service_msg, host):
"""Handle RPC cast from plugin to delete a tap service."""
pass

View File

@ -24,6 +24,7 @@ import neutron_taas.services.taas.drivers.linux.ovs_constants \
as taas_ovs_consts
import neutron_taas.services.taas.drivers.linux.ovs_utils as taas_ovs_utils
from oslo_config import cfg
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
@ -200,9 +201,18 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
def consume_api(self, agent_api):
self.agent_api = agent_api
def create_tap_service(self, tap_service):
taas_id = tap_service['taas_id']
port = tap_service['port']
@log_helpers.log_method_call
def create_tap_service(self, tap_service_msg):
"""Create a tap service
:param tap_service_msg: a dict of the tap_service,
taas_id which is the VLAN Id reserved for
mirroring for this tap-service and the neutron
port of the tap-service:
{tap_service: {}, taas_id: VID, port: {}}
"""
taas_id = tap_service_msg['taas_id']
port = tap_service_msg['port']
# Get OVS port id for tap service port
ovs_port = self.int_br.get_vif_port_by_id(port['id'])
@ -275,8 +285,17 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
return
def delete_tap_service(self, tap_service):
taas_id = tap_service['taas_id']
@log_helpers.log_method_call
def delete_tap_service(self, tap_service_msg):
"""Delete a tap service
:param tap_service_msg: a dict of the tap_service,
taas_id which is the VLAN Id reserved for
mirroring for this tap-service and the neutron
port of the tap-service:
{tap_service: {}, taas_id: VID, port: {}}
"""
taas_id = tap_service_msg['taas_id']
# Get patch port ID
patch_int_tap_id = self.int_br.get_port_ofport('patch-int-tap')
@ -306,10 +325,22 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
return
def create_tap_flow(self, tap_flow):
taas_id = tap_flow['taas_id']
port = tap_flow['port']
direction = tap_flow['tap_flow']['direction']
@log_helpers.log_method_call
def create_tap_flow(self, tap_flow_msg):
"""Create a tap flow
:param tap_flow_msg: a dict of the tap_flow, the mac of the port of
the tap-flow, taas_id which is the VLAN Id
reserved for mirroring for the tap-service
associated with this tap-flow, the neutron port
of the tap-flow, and the port of the
tap-service:
{tap_flow: {}, port_mac: '', taas_id: VID,
port: {}, tap_service_port: {}}
"""
taas_id = tap_flow_msg['taas_id']
port = tap_flow_msg['port']
direction = tap_flow_msg['tap_flow']['direction']
# Get OVS port id for tap flow port
ovs_port = self.int_br.get_vif_port_by_id(port['id'])
@ -327,7 +358,7 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
(str(taas_id), str(patch_int_tap_id)))
if direction == 'IN' or direction == 'BOTH':
port_mac = tap_flow['port_mac']
port_mac = tap_flow_msg['port_mac']
#
# Note: The ingress side flow (for unicast traffic) should
@ -382,9 +413,23 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
return
def delete_tap_flow(self, tap_flow):
port = tap_flow['port']
direction = tap_flow['tap_flow']['direction']
@log_helpers.log_method_call
def delete_tap_flow(self, tap_flow_msg):
"""Delete a tap flow
:param tap_flow_msg: a dict of the tap_flow, the mac of the port of
the tap-flow, taas_id which is the VLAN Id
reserved for mirroring for the tap-service
associated with this tap-flow, the neutron port
of the tap-flow, the port of the
tap-service, the list of source VLAN IDs, and
VLAN filter list.
{tap_flow: {}, port_mac: '', taas_id: VID,
port: {}, tap_service_port: {},
source_vlans_list: [], vlan_filter_list: []}
"""
port = tap_flow_msg['port']
direction = tap_flow_msg['tap_flow']['direction']
# Get OVS port id for tap flow port
ovs_port = self.int_br.get_vif_port_by_id(port['id'])
@ -396,7 +441,7 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
in_port=ovs_port_id)
if direction == 'IN' or direction == 'BOTH':
port_mac = tap_flow['port_mac']
port_mac = tap_flow_msg['port_mac']
#
# The VLAN id related checks have been temporarily disabled.

View File

@ -23,6 +23,7 @@ from neutron_taas.services.taas.drivers.linux import sriov_nic_utils \
as sriov_utils
from oslo_config import cfg
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import excutils
import threading
@ -48,8 +49,17 @@ class SriovNicTaasDriver(taas_base.TaasAgentDriver):
def consume_api(self, agent_api):
self.agent_api = agent_api
def create_tap_service(self, tap_service):
ts_port = tap_service['port']
@log_helpers.log_method_call
def create_tap_service(self, tap_service_msg):
"""Create a tap service
:param tap_service_msg: a dict of the tap_service,
taas_id which is the VLAN Id reserved for
mirroring for this tap-service and the neutron
port of the tap-service:
{tap_service: {}, taas_id: VID, port: {}}
"""
ts_port = tap_service_msg['port']
LOG.debug("SRIOV Driver: Inside create_tap_service: "
"Port-id: %(port_id)s",
@ -70,8 +80,17 @@ class SriovNicTaasDriver(taas_base.TaasAgentDriver):
return
def delete_tap_service(self, tap_service):
ts_port = tap_service['port']
@log_helpers.log_method_call
def delete_tap_service(self, tap_service_msg):
"""Delete a tap service
:param tap_service_msg: a dict of the tap_service,
taas_id which is the VLAN Id reserved for
mirroring for this tap-service and the neutron
port of the tap-service:
{tap_service: {}, taas_id: VID, port: {}}
"""
ts_port = tap_service_msg['port']
LOG.debug("SRIOV Driver: Inside delete_tap_service: "
"Port-id: %(port_id)s",
@ -92,11 +111,23 @@ class SriovNicTaasDriver(taas_base.TaasAgentDriver):
return
def create_tap_flow(self, tap_flow):
source_port = tap_flow['port']
ts_port = tap_flow['tap_service_port']
direction = tap_flow['tap_flow']['direction']
vlan_filter = tap_flow['tap_flow']['vlan_filter']
@log_helpers.log_method_call
def create_tap_flow(self, tap_flow_msg):
"""Create a tap flow
:param tap_flow_msg: a dict of the tap_flow, the mac of the port of
the tap-flow, taas_id which is the VLAN Id
reserved for mirroring for the tap-service
associated with this tap-flow, the neutron port
of the tap-flow, and the port of the
tap-service:
{tap_flow: {}, port_mac: '', taas_id: '',
port: {}, tap_service_port: {}}
"""
source_port = tap_flow_msg['port']
ts_port = tap_flow_msg['tap_service_port']
direction = tap_flow_msg['tap_flow']['direction']
vlan_filter = tap_flow_msg['tap_flow']['vlan_filter']
vf_to_vf_all_vlans = False
LOG.debug("SRIOV Driver: Inside create_tap_flow: "
@ -218,11 +249,25 @@ class SriovNicTaasDriver(taas_base.TaasAgentDriver):
direction=direction)
return
def delete_tap_flow(self, tap_flow):
source_port = tap_flow['port']
ts_port = tap_flow['tap_service_port']
vlan_filter = tap_flow['tap_flow']['vlan_filter']
direction = tap_flow['tap_flow']['direction']
@log_helpers.log_method_call
def delete_tap_flow(self, tap_flow_msg):
"""Delete a tap flow
:param tap_flow_msg: a dict of the tap_flow, the mac of the port of
the tap-flow, taas_id which is the VLAN Id
reserved for mirroring for the tap-service
associated with this tap-flow, the neutron port
of the tap-flow, the port of the
tap-service, the list of source VLAN IDs, and
VLAN filter list.
{tap_flow: {}, port_mac: '', taas_id: '',
port: {}, tap_service_port: {},
source_vlans_list: [], vlan_filter_list: []}
"""
source_port = tap_flow_msg['port']
ts_port = tap_flow_msg['tap_service_port']
vlan_filter = tap_flow_msg['tap_flow']['vlan_filter']
direction = tap_flow_msg['tap_flow']['direction']
LOG.debug("SRIOV Driver: Inside delete_tap_flow: "
"SRC Port-id: %(src_port_id)s, "
@ -286,14 +331,14 @@ class SriovNicTaasDriver(taas_base.TaasAgentDriver):
# Fetch common VLAN tags
src_vlans_list = []
for src_vlans_str in tap_flow['source_vlans_list']:
for src_vlans_str in tap_flow_msg['source_vlans_list']:
src_vlans_list.extend(common_utils.get_list_from_ranges_str(
src_vlans_str))
src_vlans_list = sorted(set(src_vlans_list))
vlan_filter_list = []
for vlan_filter_str in tap_flow['vlan_filter_list']:
for vlan_filter_str in tap_flow_msg['vlan_filter_list']:
vlan_filter_list.extend(common_utils.get_list_from_ranges_str(
vlan_filter_str))

View File

@ -30,13 +30,13 @@ class TaasAgentApi(object):
self.client = n_rpc.get_client(target)
return
def create_tap_service(self, context, tap_service, host):
def create_tap_service(self, context, tap_service_msg, host):
LOG.debug("In RPC Call for Create Tap Service: Host=%s, MSG=%s" %
(host, tap_service))
(host, tap_service_msg))
cctxt = self.client.prepare(fanout=True)
cctxt.cast(context, 'create_tap_service', tap_service=tap_service,
host=host)
cctxt.cast(context, 'create_tap_service',
tap_service=tap_service_msg, host=host)
return
@ -50,13 +50,13 @@ class TaasAgentApi(object):
return
def delete_tap_service(self, context, tap_service, host):
def delete_tap_service(self, context, tap_service_msg, host):
LOG.debug("In RPC Call for Delete Tap Service: Host=%s, MSG=%s" %
(host, tap_service))
(host, tap_service_msg))
cctxt = self.client.prepare(fanout=True)
cctxt.cast(context, 'delete_tap_service', tap_service=tap_service,
host=host)
cctxt.cast(context, 'delete_tap_service',
tap_service=tap_service_msg, host=host)
return