Merge "Add pylint to pep8 and adopt code to the results"
This commit is contained in:
commit
8868e486ae
125
.pylintrc
Normal file
125
.pylintrc
Normal file
@ -0,0 +1,125 @@
|
||||
# The format of this file isn't really documented; just use --generate-rcfile
|
||||
[MASTER]
|
||||
# Add <file or directory> to the black list. It should be a base name, not a
|
||||
# path. You may set this option multiple times.
|
||||
ignore=.git,tests
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
# NOTE(gus): This is a long list. A number of these are important and
|
||||
# should be re-enabled once the offending code is fixed (or marked
|
||||
# with a local disable)
|
||||
disable=
|
||||
# "F" Fatal errors that prevent further processing
|
||||
import-error,
|
||||
# "I" Informational noise
|
||||
c-extension-no-member,
|
||||
locally-disabled,
|
||||
# "E" Error for important programming issues (likely bugs)
|
||||
access-member-before-definition,
|
||||
no-member,
|
||||
no-method-argument,
|
||||
no-self-argument,
|
||||
not-an-iterable,
|
||||
# "W" Warnings for stylistic problems or minor programming issues
|
||||
abstract-method,
|
||||
arguments-differ,
|
||||
attribute-defined-outside-init,
|
||||
bad-indentation,
|
||||
broad-except,
|
||||
dangerous-default-value,
|
||||
expression-not-assigned,
|
||||
fixme,
|
||||
global-statement,
|
||||
keyword-arg-before-vararg,
|
||||
literal-comparison,
|
||||
non-parent-init-called,
|
||||
not-callable,
|
||||
protected-access,
|
||||
raise-missing-from,
|
||||
redefined-builtin,
|
||||
redefined-outer-name,
|
||||
signature-differs,
|
||||
super-init-not-called,
|
||||
unpacking-non-sequence,
|
||||
unused-argument,
|
||||
unused-import,
|
||||
unused-variable,
|
||||
useless-super-delegation,
|
||||
# TODO(dougwig) - disable nonstandard-exception while we have neutron_lib shims
|
||||
# "C" Coding convention violations
|
||||
consider-iterating-dictionary,
|
||||
consider-using-enumerate,
|
||||
consider-using-f-string,
|
||||
invalid-name,
|
||||
len-as-condition,
|
||||
missing-docstring,
|
||||
multiple-statements,
|
||||
singleton-comparison,
|
||||
superfluous-parens,
|
||||
ungrouped-imports,
|
||||
wrong-import-order,
|
||||
# "R" Refactor recommendations
|
||||
consider-merging-isinstance,
|
||||
consider-using-ternary,
|
||||
duplicate-code,
|
||||
inconsistent-return-statements,
|
||||
no-else-return,
|
||||
redefined-argument-from-local,
|
||||
simplifiable-if-statement,
|
||||
too-few-public-methods,
|
||||
too-many-ancestors,
|
||||
too-many-arguments,
|
||||
too-many-branches,
|
||||
too-many-instance-attributes,
|
||||
too-many-lines,
|
||||
too-many-locals,
|
||||
too-many-nested-blocks,
|
||||
too-many-public-methods,
|
||||
too-many-return-statements,
|
||||
too-many-statements,
|
||||
# new for python3 version of pylint
|
||||
consider-using-set-comprehension,
|
||||
unnecessary-pass,
|
||||
useless-object-inheritance
|
||||
|
||||
[BASIC]
|
||||
# Variable names can be 1 to 31 characters long, with lowercase and underscores
|
||||
variable-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
|
||||
# Argument names can be 2 to 31 characters long, with lowercase and underscores
|
||||
argument-rgx=[a-z_][a-z0-9_]{1,30}$
|
||||
|
||||
# Method names should be at least 3 characters long
|
||||
# and be lowercased with underscores
|
||||
method-rgx=([a-z_][a-z0-9_]{2,}|setUp|tearDown)$
|
||||
|
||||
# Module names matching neutron-* are ok (files in bin/)
|
||||
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+)|(neutron-[a-z0-9_-]+))$
|
||||
|
||||
# Don't require docstrings on tests.
|
||||
no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$
|
||||
|
||||
[FORMAT]
|
||||
# Maximum number of characters on a single line.
|
||||
max-line-length=79
|
||||
|
||||
[VARIABLES]
|
||||
# List of additional names supposed to be defined in builtins. Remember that
|
||||
# you should avoid to define new builtins when possible.
|
||||
# _ is used by our localization
|
||||
additional-builtins=_
|
||||
|
||||
[IMPORTS]
|
||||
# Deprecated modules which should not be used, separated by a comma
|
||||
deprecated-modules=
|
||||
# should use oslo_serialization.jsonutils
|
||||
json,
|
||||
six
|
||||
|
||||
[TYPECHECK]
|
||||
# List of module names for which member attributes should not be checked
|
||||
ignored-modules=_MovedItems
|
||||
|
||||
[REPORTS]
|
||||
# Tells whether to display a full report or only the messages
|
||||
reports=no
|
@ -25,7 +25,7 @@ def get_list_from_ranges_str(ranges_str):
|
||||
return sum(((list(range(*[int(range_start) + range_index
|
||||
for range_index, range_start in
|
||||
enumerate(range_item.split('-'))]))
|
||||
if '-' in range_item else [int(range_item)])
|
||||
if '-' in range_item else [int(range_item)])
|
||||
for range_item in ranges_str.split(',')), [])
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ def set_mysql_engine():
|
||||
def run_migrations_offline():
|
||||
set_mysql_engine()
|
||||
|
||||
kwargs = dict()
|
||||
kwargs = {}
|
||||
if neutron_config.database.connection:
|
||||
kwargs['url'] = neutron_config.database.connection
|
||||
else:
|
||||
|
@ -37,15 +37,14 @@ LOG = logging.getLogger(__name__)
|
||||
class TaasPluginApi(api.TaasPluginApiMixin):
|
||||
|
||||
def __init__(self, topic, host):
|
||||
super(TaasPluginApi, self).__init__(topic, host)
|
||||
super().__init__(topic, host)
|
||||
target = messaging.Target(topic=topic, version='1.0')
|
||||
self.client = n_rpc.get_client(target)
|
||||
return
|
||||
|
||||
def sync_tap_resources(self, sync_tap_res, host):
|
||||
"""Send Rpc to plugin to recreate pre-existing tap resources."""
|
||||
LOG.debug("In RPC Call for Sync Tap Resources: Host=%s, MSG=%s" %
|
||||
(host, sync_tap_res))
|
||||
LOG.debug("In RPC Call for Sync Tap Resources: Host=%s, MSG=%s",
|
||||
host, sync_tap_res)
|
||||
|
||||
context = neutron_context.get_admin_context()
|
||||
|
||||
@ -53,12 +52,9 @@ class TaasPluginApi(api.TaasPluginApiMixin):
|
||||
cctxt.cast(context, 'sync_tap_resources', sync_tap_res=sync_tap_res,
|
||||
host=host)
|
||||
|
||||
return
|
||||
|
||||
def set_tap_service_status(self, msg, status, host):
|
||||
LOG.debug("In RPC Call for set tap service status: Host=%s, MSG=%s, "
|
||||
"Status=%s" %
|
||||
(host, msg, status))
|
||||
"Status=%s", host, msg, status)
|
||||
|
||||
context = neutron_context.get_admin_context()
|
||||
|
||||
@ -66,12 +62,9 @@ class TaasPluginApi(api.TaasPluginApiMixin):
|
||||
cctxt.cast(context, 'set_tap_service_status', msg=msg, status=status,
|
||||
host=host)
|
||||
|
||||
return
|
||||
|
||||
def set_tap_flow_status(self, msg, status, host):
|
||||
LOG.debug("In RPC Call for set tap flow status: Host=%s, MSG=%s, "
|
||||
"Status=%s" %
|
||||
(host, msg, status))
|
||||
"Status=%s", host, msg, status)
|
||||
|
||||
context = neutron_context.get_admin_context()
|
||||
|
||||
@ -79,8 +72,6 @@ class TaasPluginApi(api.TaasPluginApiMixin):
|
||||
cctxt.cast(context, 'set_tap_flow_status', msg=msg, status=status,
|
||||
host=host)
|
||||
|
||||
return
|
||||
|
||||
|
||||
class TaasAgentRpcCallback(api.TaasAgentRpcCallbackMixin):
|
||||
|
||||
@ -91,7 +82,7 @@ class TaasAgentRpcCallback(api.TaasAgentRpcCallbackMixin):
|
||||
self.conf = conf
|
||||
self.driver_type = driver_type
|
||||
|
||||
super(TaasAgentRpcCallback, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
def initialize(self):
|
||||
self.taas_driver = manager.NeutronManager.load_class_for_provider(
|
||||
@ -140,37 +131,39 @@ class TaasAgentRpcCallback(api.TaasAgentRpcCallbackMixin):
|
||||
status_msg = {'id': args[func_dict['msg_name']]['id']}
|
||||
|
||||
try:
|
||||
self.taas_driver.__getattribute__(func_name)(args)
|
||||
driver_func = getattr(self.taas_driver, func_name)
|
||||
driver_func(args)
|
||||
except Exception:
|
||||
LOG.error("Failed to invoke the driver")
|
||||
|
||||
self.taas_plugin_rpc.__getattribute__(
|
||||
self.func_dict[func_name]['set_status_func_name'])(
|
||||
status_msg,
|
||||
self.func_dict[func_name]['fail_status'],
|
||||
self.conf.host)
|
||||
rpc_func = getattr(
|
||||
self.taas_plugin_rpc,
|
||||
self.func_dict[func_name]['set_status_func_name'])
|
||||
rpc_func(status_msg, self.func_dict[func_name]['fail_status'],
|
||||
self.conf.host)
|
||||
return
|
||||
|
||||
if func_name != 'periodic_tasks':
|
||||
self.taas_plugin_rpc.__getattribute__(
|
||||
self.func_dict[func_name]['set_status_func_name'])(
|
||||
status_msg,
|
||||
self.func_dict[func_name]['succ_status'],
|
||||
self.conf.host)
|
||||
rpc_func = getattr(
|
||||
self.taas_plugin_rpc,
|
||||
self.func_dict[func_name]['set_status_func_name'])
|
||||
rpc_func(status_msg, self.func_dict[func_name]['succ_status'],
|
||||
self.conf.host)
|
||||
|
||||
def create_tap_service(self, context, tap_service, host):
|
||||
def create_tap_service(self, context, tap_service_msg, host):
|
||||
"""Handle Rpc from plugin to create a tap_service."""
|
||||
if not self._driver_and_host_verification(host, tap_service['port']):
|
||||
if not self._driver_and_host_verification(
|
||||
host, tap_service_msg['port']):
|
||||
LOG.debug("RPC Call for Create Tap Serv. Either Host value [%s]"
|
||||
"(received in RPC) doesn't match the host value "
|
||||
"stored in agent [%s], or incompatible driver type. "
|
||||
"Ignoring the message." % (host, self.conf.host))
|
||||
"Ignoring the message.", host, self.conf.host)
|
||||
return
|
||||
LOG.debug("In RPC Call for Create Tap Service: MSG=%s" % tap_service)
|
||||
LOG.debug("In RPC Call for Create Tap Service: MSG=%s",
|
||||
tap_service_msg)
|
||||
|
||||
return self._invoke_driver_for_plugin_api(
|
||||
context,
|
||||
tap_service,
|
||||
tap_service_msg,
|
||||
'create_tap_service')
|
||||
|
||||
def create_tap_flow(self, context, tap_flow_msg, host):
|
||||
@ -178,30 +171,31 @@ class TaasAgentRpcCallback(api.TaasAgentRpcCallbackMixin):
|
||||
LOG.debug("RPC Call for Create Tap Flow. Either Host value [%s]"
|
||||
"(received in RPC) doesn't match the host value "
|
||||
"stored in agent [%s], or incompatible driver type. "
|
||||
"Ignoring the message." % (host, self.conf.host))
|
||||
"Ignoring the message.", host, self.conf.host)
|
||||
return
|
||||
LOG.debug("In RPC Call for Create Tap Flow: MSG=%s" % tap_flow_msg)
|
||||
LOG.debug("In RPC Call for Create Tap Flow: MSG=%s", tap_flow_msg)
|
||||
|
||||
return self._invoke_driver_for_plugin_api(
|
||||
context,
|
||||
tap_flow_msg,
|
||||
'create_tap_flow')
|
||||
|
||||
def delete_tap_service(self, context, tap_service, host):
|
||||
def delete_tap_service(self, context, tap_service_msg, host):
|
||||
#
|
||||
# Cleanup operations must be performed by all hosts
|
||||
# where the source and/or destination ports associated
|
||||
# with this tap service were residing.
|
||||
#
|
||||
if not self._is_driver_port_type_compatible(tap_service['port']):
|
||||
if not self._is_driver_port_type_compatible(tap_service_msg['port']):
|
||||
LOG.debug("RPC Call for Delete Tap Service. Incompatible driver "
|
||||
"type. Ignoring the message. Host=[%s]" % (host))
|
||||
return
|
||||
LOG.debug("In RPC Call for Delete Tap Service: MSG=%s" % tap_service)
|
||||
LOG.debug("In RPC Call for Delete Tap Service: MSG=%s",
|
||||
tap_service_msg)
|
||||
|
||||
return self._invoke_driver_for_plugin_api(
|
||||
context,
|
||||
tap_service,
|
||||
tap_service_msg,
|
||||
'delete_tap_service')
|
||||
|
||||
def delete_tap_flow(self, context, tap_flow_msg, host):
|
||||
@ -211,7 +205,7 @@ class TaasAgentRpcCallback(api.TaasAgentRpcCallbackMixin):
|
||||
"stored in agent [%s], or incompatible driver type. "
|
||||
"Ignoring the message." % (host, self.conf.host))
|
||||
return
|
||||
LOG.debug("In RPC Call for Delete Tap Flow: MSG=%s" % tap_flow_msg)
|
||||
LOG.debug("In RPC Call for Delete Tap Flow: MSG=%s", tap_flow_msg)
|
||||
|
||||
return self._invoke_driver_for_plugin_api(
|
||||
context,
|
||||
@ -250,11 +244,11 @@ class TaasAgentRpcCallback(api.TaasAgentRpcCallbackMixin):
|
||||
|
||||
class TaasAgentService(service.Service):
|
||||
def __init__(self, driver):
|
||||
super(TaasAgentService, self).__init__()
|
||||
super().__init__()
|
||||
self.driver = driver
|
||||
|
||||
def start(self, taas_plugin_rpc, host):
|
||||
super(TaasAgentService, self).start()
|
||||
super().start()
|
||||
|
||||
if self.driver.get_driver_type() == \
|
||||
taas_ovs_consts.EXTENSION_DRIVER_TYPE:
|
||||
|
@ -81,8 +81,8 @@ class TaasAgentExtension(l2_extension.L2AgentExtension):
|
||||
"""
|
||||
self.agent_api = agent_api
|
||||
|
||||
def handle_port(self, context, port):
|
||||
def handle_port(self, context, data):
|
||||
pass
|
||||
|
||||
def delete_port(self, context, port):
|
||||
def delete_port(self, context, data):
|
||||
pass
|
||||
|
@ -25,15 +25,14 @@ class TaasPluginApiMixin(object):
|
||||
self.host = host
|
||||
target = messaging.Target(topic=topic, version='1.0')
|
||||
self.client = n_rpc.get_client(target)
|
||||
super(TaasPluginApiMixin, self).__init__()
|
||||
return
|
||||
super().__init__()
|
||||
|
||||
|
||||
class TaasAgentRpcCallbackMixin(object):
|
||||
"""Mixin for Taas agent Implementations."""
|
||||
|
||||
def __init__(self):
|
||||
super(TaasAgentRpcCallbackMixin, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
def consume_api(self, agent_api):
|
||||
"""Receive neutron agent API object
|
||||
|
@ -35,12 +35,12 @@ TaaS_DRIVER_NAME = 'Taas OVS driver'
|
||||
|
||||
class OVSBridge_tap_extension(ovs_lib.OVSBridge):
|
||||
def __init__(self, br_name, root_helper):
|
||||
super(OVSBridge_tap_extension, self).__init__(br_name)
|
||||
super().__init__(br_name)
|
||||
|
||||
|
||||
class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
def __init__(self):
|
||||
super(OvsTaasDriver, self).__init__()
|
||||
super().__init__()
|
||||
LOG.debug("Initializing Taas OVS Driver")
|
||||
self.agent_api = None
|
||||
self.root_helper = common.get_root_helper(cfg.CONF)
|
||||
@ -196,8 +196,6 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
"output:NXM_OF_IN_PORT[])" %
|
||||
taas_ovs_consts.TAAS_SEND_UCAST))
|
||||
|
||||
return
|
||||
|
||||
def consume_api(self, agent_api):
|
||||
self.agent_api = agent_api
|
||||
|
||||
@ -283,8 +281,6 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
utils.execute(['brctl', 'setageing', linux_br_name, 0],
|
||||
run_as_root=True, privsep_exec=True)
|
||||
|
||||
return
|
||||
|
||||
@log_helpers.log_method_call
|
||||
def delete_tap_service(self, tap_service_msg):
|
||||
"""Delete a tap service
|
||||
@ -323,8 +319,6 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
self.tun_br.delete_flows(table=taas_ovs_consts.TAAS_SRC_CHECK,
|
||||
tun_id=taas_id)
|
||||
|
||||
return
|
||||
|
||||
@log_helpers.log_method_call
|
||||
def create_tap_flow(self, tap_flow_msg):
|
||||
"""Create a tap flow
|
||||
@ -350,14 +344,14 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
patch_int_tap_id = self.int_br.get_port_ofport('patch-int-tap')
|
||||
|
||||
# Add flow(s) in br-int
|
||||
if direction == 'OUT' or direction == 'BOTH':
|
||||
if direction in ('OUT', 'BOTH'):
|
||||
self.int_br.add_flow(table=0,
|
||||
priority=20,
|
||||
in_port=ovs_port_id,
|
||||
actions="normal,mod_vlan_vid:%s,output:%s" %
|
||||
(str(taas_id), str(patch_int_tap_id)))
|
||||
|
||||
if direction == 'IN' or direction == 'BOTH':
|
||||
if direction in ('IN', 'BOTH'):
|
||||
port_mac = tap_flow_msg['port_mac']
|
||||
|
||||
#
|
||||
@ -411,8 +405,6 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
actions="resubmit(,%s)" %
|
||||
taas_ovs_consts.TAAS_SRC_RESPOND)
|
||||
|
||||
return
|
||||
|
||||
@log_helpers.log_method_call
|
||||
def delete_tap_flow(self, tap_flow_msg):
|
||||
"""Delete a tap flow
|
||||
@ -436,11 +428,11 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
ovs_port_id = ovs_port.ofport
|
||||
|
||||
# Delete flow(s) from br-int
|
||||
if direction == 'OUT' or direction == 'BOTH':
|
||||
if direction in ('OUT', 'BOTH'):
|
||||
self.int_br.delete_flows(table=0,
|
||||
in_port=ovs_port_id)
|
||||
|
||||
if direction == 'IN' or direction == 'BOTH':
|
||||
if direction in ('IN', 'BOTH'):
|
||||
port_mac = tap_flow_msg['port_mac']
|
||||
|
||||
#
|
||||
@ -465,8 +457,6 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
# taas_id,
|
||||
# patch_int_tap_id)
|
||||
|
||||
return
|
||||
|
||||
def update_tunnel_flood_flow(self):
|
||||
flow_action = self._create_tunnel_flood_flow_action()
|
||||
if flow_action != "":
|
||||
@ -482,7 +472,7 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
tunnel_ports_exist = False
|
||||
|
||||
for port_name in port_name_list:
|
||||
if (port_name != 'patch-int') and (port_name != 'patch-tun-tap'):
|
||||
if port_name not in ('patch-int', 'patch-tun-tap'):
|
||||
flow_action += (",output:%d" %
|
||||
self.tun_br.get_port_ofport(port_name))
|
||||
tunnel_ports_exist = True
|
||||
@ -524,8 +514,6 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
dl_dst="01:00:00:00:00:00/01:00:00:00:00:00",
|
||||
actions=flow_action)
|
||||
|
||||
return
|
||||
|
||||
#
|
||||
# Removes or updates a special flow in br-int to mirror (duplicate
|
||||
# and redirect to 'out_port_id') all ingress broadcast/multicast
|
||||
@ -557,5 +545,3 @@ class OvsTaasDriver(taas_base.TaasAgentDriver):
|
||||
dl_vlan=vlan_id,
|
||||
dl_dst=("01:00:00:00:00:00/"
|
||||
"01:00:00:00:00:00"))
|
||||
|
||||
return
|
||||
|
@ -31,8 +31,6 @@ class key_value_mgr(object):
|
||||
for i in range(nr_keys):
|
||||
self.key_list.append([])
|
||||
|
||||
return
|
||||
|
||||
#
|
||||
# Returns specified key-value affilation, if it exists.
|
||||
#
|
||||
@ -63,8 +61,6 @@ class key_value_mgr(object):
|
||||
# Increment affiliation reference count
|
||||
aff['refcnt'] += 1
|
||||
|
||||
return
|
||||
|
||||
#
|
||||
# Removes an affiliation of 'value' with 'key'
|
||||
#
|
||||
|
@ -23,6 +23,9 @@ class SriovNicSwitchDriverInvocationError(qexception.Invalid):
|
||||
"%(source_vf_index)s, %(vlan_filter)s, "
|
||||
"%(vf_to_vf_all_vlans)s, %(direction)s")
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
|
||||
class PciDeviceNotFoundById(qexception.NotFound):
|
||||
message = _("PCI device %(id)s not found")
|
||||
|
@ -35,7 +35,7 @@ TaaS_DRIVER_NAME = 'Taas SRIOV NIC Switch driver'
|
||||
|
||||
class SriovNicTaasDriver(taas_base.TaasAgentDriver):
|
||||
def __init__(self):
|
||||
super(SriovNicTaasDriver, self).__init__()
|
||||
super().__init__()
|
||||
LOG.debug("Initializing Taas SRIOV NIC Switch Driver")
|
||||
self.agent_api = None
|
||||
self.root_helper = common.get_root_helper(cfg.CONF)
|
||||
@ -44,7 +44,6 @@ class SriovNicTaasDriver(taas_base.TaasAgentDriver):
|
||||
def initialize(self):
|
||||
LOG.debug("Initialize routine called for Taas SRIOV NIC Switch Driver")
|
||||
self.sriov_utils = sriov_utils.SriovNicUtils()
|
||||
return
|
||||
|
||||
def consume_api(self, agent_api):
|
||||
self.agent_api = agent_api
|
||||
@ -78,8 +77,6 @@ class SriovNicTaasDriver(taas_base.TaasAgentDriver):
|
||||
'pf_device': port_params['pf_device'],
|
||||
'src_vlans': port_params['src_vlans']})
|
||||
|
||||
return
|
||||
|
||||
@log_helpers.log_method_call
|
||||
def delete_tap_service(self, tap_service_msg):
|
||||
"""Delete a tap service
|
||||
@ -109,8 +106,6 @@ class SriovNicTaasDriver(taas_base.TaasAgentDriver):
|
||||
'pf_device': port_params['pf_device'],
|
||||
'src_vlans': port_params['src_vlans']})
|
||||
|
||||
return
|
||||
|
||||
@log_helpers.log_method_call
|
||||
def create_tap_flow(self, tap_flow_msg):
|
||||
"""Create a tap flow
|
||||
@ -241,10 +236,10 @@ class SriovNicTaasDriver(taas_base.TaasAgentDriver):
|
||||
LOG.error("TaaS error in invoking execute_sysfs_command")
|
||||
with excutils.save_and_reraise_exception():
|
||||
raise taas_exc.SriovNicSwitchDriverInvocationError(
|
||||
ts_pf_dev=ts_port_params['pf_device'],
|
||||
ts_vf_index=ts_port_params['vf_index'],
|
||||
tap_service_pf_device=ts_port_params['pf_device'],
|
||||
tap_service_vf_index=ts_port_params['vf_index'],
|
||||
source_vf_index=src_port_params['vf_index'],
|
||||
common_vlans_rng_str=common_vlans_rng_str,
|
||||
vlan_filter=common_vlans_rng_str,
|
||||
vf_to_vf_all_vlans=vf_to_vf_all_vlans,
|
||||
direction=direction)
|
||||
return
|
||||
@ -405,5 +400,3 @@ class SriovNicTaasDriver(taas_base.TaasAgentDriver):
|
||||
common_vlans_rng_str=common_vlans_rng_str,
|
||||
vf_to_vf_all_vlans=vf_to_vf_all_vlans,
|
||||
direction=direction)
|
||||
|
||||
return
|
||||
|
@ -36,7 +36,6 @@ class SriovNicUtils(object):
|
||||
#
|
||||
def __init__(self):
|
||||
LOG.debug("SriovNicUtils: init called")
|
||||
return
|
||||
|
||||
#
|
||||
# Returns specified key-value affilation, if it exists.
|
||||
@ -167,7 +166,7 @@ class SriovNicUtils(object):
|
||||
addr_file = os.path.join(dev_path, if_name, 'address')
|
||||
|
||||
try:
|
||||
with open(addr_file) as f:
|
||||
with open(addr_file, encoding="utf-8") as f:
|
||||
mac = next(f).strip()
|
||||
return mac
|
||||
except (IOError, StopIteration) as e:
|
||||
|
@ -29,7 +29,7 @@ class ServiceDriverContext(object):
|
||||
class TapServiceContext(ServiceDriverContext):
|
||||
|
||||
def __init__(self, service_plugin, plugin_context, tap_service):
|
||||
super(TapServiceContext, self).__init__(service_plugin, plugin_context)
|
||||
super().__init__(service_plugin, plugin_context)
|
||||
self._tap_service = tap_service
|
||||
self._tap_id_association = None
|
||||
self._setup_tap_id_association(tap_service['id'])
|
||||
@ -59,7 +59,7 @@ class TapServiceContext(ServiceDriverContext):
|
||||
class TapFlowContext(ServiceDriverContext):
|
||||
|
||||
def __init__(self, service_plugin, plugin_context, tap_flow):
|
||||
super(TapFlowContext, self).__init__(service_plugin, plugin_context)
|
||||
super().__init__(service_plugin, plugin_context)
|
||||
self._tap_flow = tap_flow
|
||||
|
||||
@property
|
||||
|
@ -28,7 +28,6 @@ class TaasAgentApi(object):
|
||||
self.host = host
|
||||
target = messaging.Target(topic=topic, version='1.0')
|
||||
self.client = n_rpc.get_client(target)
|
||||
return
|
||||
|
||||
def create_tap_service(self, context, tap_service_msg, host):
|
||||
LOG.debug("In RPC Call for Create Tap Service: Host=%s, MSG=%s" %
|
||||
@ -36,9 +35,7 @@ class TaasAgentApi(object):
|
||||
|
||||
cctxt = self.client.prepare(fanout=True)
|
||||
cctxt.cast(context, 'create_tap_service',
|
||||
tap_service=tap_service_msg, host=host)
|
||||
|
||||
return
|
||||
tap_service_msg=tap_service_msg, host=host)
|
||||
|
||||
def create_tap_flow(self, context, tap_flow_msg, host):
|
||||
LOG.debug("In RPC Call for Create Tap Flow: Host=%s, MSG=%s" %
|
||||
@ -48,17 +45,13 @@ class TaasAgentApi(object):
|
||||
cctxt.cast(context, 'create_tap_flow', tap_flow_msg=tap_flow_msg,
|
||||
host=host)
|
||||
|
||||
return
|
||||
|
||||
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_msg))
|
||||
|
||||
cctxt = self.client.prepare(fanout=True)
|
||||
cctxt.cast(context, 'delete_tap_service',
|
||||
tap_service=tap_service_msg, host=host)
|
||||
|
||||
return
|
||||
tap_service_msg=tap_service_msg, host=host)
|
||||
|
||||
def delete_tap_flow(self, context, tap_flow_msg, host):
|
||||
LOG.debug("In RPC Call for Delete Tap Flow: Host=%s, MSG=%s" %
|
||||
@ -67,5 +60,3 @@ class TaasAgentApi(object):
|
||||
cctxt = self.client.prepare(fanout=True)
|
||||
cctxt.cast(context, 'delete_tap_flow', tap_flow_msg=tap_flow_msg,
|
||||
host=host)
|
||||
|
||||
return
|
||||
|
@ -27,7 +27,7 @@ from neutron_taas.services.taas import service_drivers
|
||||
from neutron_taas.services.taas.service_drivers import (service_driver_context
|
||||
as sd_context)
|
||||
from neutron_taas.services.taas.service_drivers import taas_agent_api
|
||||
from neutron_taas.services.taas.taas_plugin import TaasPlugin
|
||||
from neutron_taas.services.taas import taas_plugin
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
@ -39,10 +39,9 @@ LOG = logging.getLogger(__name__)
|
||||
class TaasCallbacks(object):
|
||||
|
||||
def __init__(self, rpc_driver, plugin):
|
||||
super(TaasCallbacks, self).__init__()
|
||||
super().__init__()
|
||||
self.rpc_driver = rpc_driver
|
||||
self.plugin = plugin
|
||||
return
|
||||
|
||||
def sync_tap_resources(self, context, sync_tap_res, host):
|
||||
"""Handle Rpc from Agent to sync up Tap resources."""
|
||||
@ -69,8 +68,9 @@ class TaasCallbacks(object):
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Failed to create tap service on driver,"
|
||||
"deleting tap_service %s", ts['id'])
|
||||
super(TaasPlugin, self.plugin).delete_tap_service(
|
||||
context, ts['id'])
|
||||
# pylint: disable=E1003
|
||||
super(taas_plugin.TaasPlugin,
|
||||
self.plugin).delete_tap_service(context, ts['id'])
|
||||
|
||||
# Get all the active tap flows for current tap-service
|
||||
active_tfs = self.plugin.get_tap_flows(
|
||||
@ -88,8 +88,9 @@ class TaasCallbacks(object):
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Failed to create tap flow on driver,"
|
||||
"deleting tap_flow %s", tf['id'])
|
||||
super(TaasPlugin, self.plugin).delete_tap_flow(
|
||||
context, tf['id'])
|
||||
# pylint: disable=E1003
|
||||
super(taas_plugin.TaasPlugin,
|
||||
self.plugin).delete_tap_flow(context, tf['id'])
|
||||
|
||||
@db_api.CONTEXT_WRITER
|
||||
def set_tap_service_status(self, context, msg, status, host=None):
|
||||
@ -104,15 +105,17 @@ class TaasCallbacks(object):
|
||||
driver_context = sd_context.TapServiceContext(self.plugin,
|
||||
context,
|
||||
ts)
|
||||
super(TaasPlugin, self.plugin).delete_tap_service(context,
|
||||
msg['id'])
|
||||
# pylint: disable=E1003
|
||||
super(taas_plugin.TaasPlugin,
|
||||
self.plugin).delete_tap_service(context, msg['id'])
|
||||
self.plugin.driver.delete_tap_service_postcommit(
|
||||
driver_context)
|
||||
return
|
||||
|
||||
ts = self.plugin.get_tap_service(context, msg['id'])
|
||||
ts['status'] = status
|
||||
super(TaasPlugin, self.plugin).update_tap_service(
|
||||
# pylint: disable=E1003
|
||||
super(taas_plugin.TaasPlugin, self.plugin).update_tap_service(
|
||||
context,
|
||||
msg['id'],
|
||||
{'tap_service': ts})
|
||||
@ -130,16 +133,17 @@ class TaasCallbacks(object):
|
||||
driver_context = sd_context.TapFlowContext(self.plugin,
|
||||
context,
|
||||
tf)
|
||||
super(TaasPlugin, self.plugin).delete_tap_flow(context,
|
||||
msg['id'])
|
||||
# pylint: disable=E1003
|
||||
super(taas_plugin.TaasPlugin, self.plugin).delete_tap_flow(
|
||||
context, msg['id'])
|
||||
self.plugin.driver.delete_tap_flow_postcommit(driver_context)
|
||||
return
|
||||
|
||||
tf = self.plugin.get_tap_flow(context, msg['id'])
|
||||
tf['status'] = status
|
||||
super(TaasPlugin, self.plugin).update_tap_flow(context,
|
||||
msg['id'],
|
||||
{'tap_flow': tf})
|
||||
# pylint: disable=E1003
|
||||
super(taas_plugin.TaasPlugin, self.plugin).update_tap_flow(
|
||||
context, msg['id'], {'tap_flow': tf})
|
||||
|
||||
|
||||
class TaasRpcDriver(service_drivers.TaasBaseDriver):
|
||||
@ -147,7 +151,7 @@ class TaasRpcDriver(service_drivers.TaasBaseDriver):
|
||||
|
||||
def __init__(self, service_plugin):
|
||||
LOG.debug("Loading TaasRpcDriver.")
|
||||
super(TaasRpcDriver, self).__init__(service_plugin)
|
||||
super().__init__(service_plugin)
|
||||
self.endpoints = [TaasCallbacks(self, service_plugin)]
|
||||
self.conn = n_rpc.Connection()
|
||||
self.conn.create_consumer(topics.TAAS_PLUGIN,
|
||||
@ -160,8 +164,6 @@ class TaasRpcDriver(service_drivers.TaasBaseDriver):
|
||||
cfg.CONF.host
|
||||
)
|
||||
|
||||
return
|
||||
|
||||
def _get_taas_id(self, context, tf):
|
||||
ts = self.service_plugin.get_tap_service(context,
|
||||
tf['tap_service_id'])
|
||||
@ -196,7 +198,6 @@ class TaasRpcDriver(service_drivers.TaasBaseDriver):
|
||||
|
||||
self.agent_rpc.create_tap_service(context._plugin_context,
|
||||
rpc_msg, host)
|
||||
return
|
||||
|
||||
def delete_tap_service_precommit(self, context):
|
||||
"""Send tap service deletion RPC message to agent.
|
||||
@ -224,7 +225,6 @@ class TaasRpcDriver(service_drivers.TaasBaseDriver):
|
||||
|
||||
self.agent_rpc.delete_tap_service(context._plugin_context,
|
||||
rpc_msg, host)
|
||||
return
|
||||
|
||||
def delete_tap_service_postcommit(self, context):
|
||||
pass
|
||||
@ -256,7 +256,6 @@ class TaasRpcDriver(service_drivers.TaasBaseDriver):
|
||||
'tap_service_port': ts_port}
|
||||
|
||||
self.agent_rpc.create_tap_flow(context._plugin_context, rpc_msg, host)
|
||||
return
|
||||
|
||||
def delete_tap_flow_precommit(self, context):
|
||||
"""Send tap flow deletion RPC message to agent."""
|
||||
@ -322,7 +321,6 @@ class TaasRpcDriver(service_drivers.TaasBaseDriver):
|
||||
'vlan_filter_list': vlan_filter_list}
|
||||
|
||||
self.agent_rpc.delete_tap_flow(context._plugin_context, rpc_msg, host)
|
||||
return
|
||||
|
||||
def delete_tap_flow_postcommit(self, context):
|
||||
pass
|
||||
|
@ -58,8 +58,6 @@ class TaasPlugin(taas_db.Taas_db_Mixin):
|
||||
self._load_drivers()
|
||||
self.driver = self._get_driver_for_provider(self.default_provider)
|
||||
|
||||
return
|
||||
|
||||
def _load_drivers(self):
|
||||
"""Loads plugin-drivers specified in configuration."""
|
||||
self.drivers, self.default_provider = service_base.load_drivers(
|
||||
@ -95,8 +93,7 @@ class TaasPlugin(taas_db.Taas_db_Mixin):
|
||||
LOG.debug("Host could not be found, Port Binding disbaled!")
|
||||
|
||||
# Create tap service in the db model
|
||||
ts = super(TaasPlugin, self).create_tap_service(context,
|
||||
tap_service)
|
||||
ts = super().create_tap_service(context, tap_service)
|
||||
driver_context = sd_context.TapServiceContext(self, context, ts)
|
||||
self.driver.create_tap_service_precommit(driver_context)
|
||||
|
||||
@ -106,7 +103,7 @@ class TaasPlugin(taas_db.Taas_db_Mixin):
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Failed to create tap service on driver,"
|
||||
"deleting tap_service %s", ts['id'])
|
||||
super(TaasPlugin, self).delete_tap_service(context, ts['id'])
|
||||
super().delete_tap_service(context, ts['id'])
|
||||
|
||||
return ts
|
||||
|
||||
@ -127,11 +124,11 @@ class TaasPlugin(taas_db.Taas_db_Mixin):
|
||||
driver_context = sd_context.TapServiceContext(self, context, ts)
|
||||
if ts['status'] == constants.ACTIVE:
|
||||
ts['status'] = constants.PENDING_DELETE
|
||||
super(TaasPlugin, self).update_tap_service(
|
||||
super().update_tap_service(
|
||||
context, id, {'tap_service': ts})
|
||||
method = self.driver.delete_tap_service_precommit
|
||||
else:
|
||||
super(TaasPlugin, self).delete_tap_service(context, id)
|
||||
super().delete_tap_service(context, id)
|
||||
method = self.driver.delete_tap_service_postcommit
|
||||
|
||||
try:
|
||||
@ -158,7 +155,7 @@ class TaasPlugin(taas_db.Taas_db_Mixin):
|
||||
raise taas_exc.TapServiceNotBelongToTenant()
|
||||
|
||||
# create tap flow in the db model
|
||||
tf = super(TaasPlugin, self).create_tap_flow(context, tap_flow)
|
||||
tf = super().create_tap_flow(context, tap_flow)
|
||||
driver_context = sd_context.TapFlowContext(self, context, tf)
|
||||
self.driver.create_tap_flow_precommit(driver_context)
|
||||
|
||||
@ -168,7 +165,7 @@ class TaasPlugin(taas_db.Taas_db_Mixin):
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error("Failed to create tap flow on driver,"
|
||||
"deleting tap_flow %s", tf['id'])
|
||||
super(TaasPlugin, self).delete_tap_flow(context, tf['id'])
|
||||
super().delete_tap_flow(context, tf['id'])
|
||||
|
||||
return tf
|
||||
|
||||
@ -180,11 +177,10 @@ class TaasPlugin(taas_db.Taas_db_Mixin):
|
||||
driver_context = sd_context.TapFlowContext(self, context, tf)
|
||||
if tf['status'] == constants.ACTIVE:
|
||||
tf['status'] = constants.PENDING_DELETE
|
||||
super(TaasPlugin, self).update_tap_flow(context, id,
|
||||
{'tap_flow': tf})
|
||||
super().update_tap_flow(context, id, {'tap_flow': tf})
|
||||
method = self.driver.delete_tap_flow_precommit
|
||||
else:
|
||||
super(TaasPlugin, self).delete_tap_flow(context, id)
|
||||
super().delete_tap_flow(context, id)
|
||||
method = self.driver.delete_tap_flow_postcommit
|
||||
|
||||
try:
|
||||
|
@ -61,7 +61,7 @@ class CreateTapFlow(command.ShowOne):
|
||||
_description = _("Create a tap flow")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(CreateTapFlow, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
nc_osc_utils.add_project_owner_option_to_parser(parser)
|
||||
_add_updatable_args(parser)
|
||||
parser.add_argument(
|
||||
@ -127,7 +127,7 @@ class ListTapFlow(command.Lister):
|
||||
_description = _("List tap flows that belong to a given tenant")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ListTapFlow, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
nc_osc_utils.add_project_owner_option_to_parser(parser)
|
||||
|
||||
return parser
|
||||
@ -154,7 +154,7 @@ class ShowTapFlow(command.ShowOne):
|
||||
_description = _("Show information of a given tap flow")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ShowTapFlow, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
TAP_FLOW,
|
||||
metavar="<%s>" % TAP_FLOW,
|
||||
@ -175,7 +175,7 @@ class DeleteTapFlow(command.Command):
|
||||
_description = _("Delete a tap flow")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteTapFlow, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
TAP_FLOW,
|
||||
metavar="<%s>" % TAP_FLOW,
|
||||
@ -207,7 +207,7 @@ class UpdateTapFlow(command.ShowOne):
|
||||
_description = _("Update a tap flow.")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(UpdateTapFlow, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
TAP_FLOW,
|
||||
metavar="<%s>" % TAP_FLOW,
|
||||
|
@ -59,7 +59,7 @@ class CreateTapService(command.ShowOne):
|
||||
_description = _("Create a tap service")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(CreateTapService, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
nc_osc_utils.add_project_owner_option_to_parser(parser)
|
||||
_add_updatable_args(parser)
|
||||
parser.add_argument(
|
||||
@ -99,7 +99,7 @@ class ListTapService(command.Lister):
|
||||
_description = _("List tap services that belong to a given tenant")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ListTapService, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
nc_osc_utils.add_project_owner_option_to_parser(parser)
|
||||
|
||||
return parser
|
||||
@ -126,7 +126,7 @@ class ShowTapService(command.ShowOne):
|
||||
_description = _("Show information of a given tap service")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ShowTapService, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
TAP_SERVICE,
|
||||
metavar="<%s>" % TAP_SERVICE,
|
||||
@ -147,7 +147,7 @@ class DeleteTapService(command.Command):
|
||||
_description = _("Delete a tap service")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteTapService, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
TAP_SERVICE,
|
||||
metavar="<%s>" % TAP_SERVICE,
|
||||
@ -179,7 +179,7 @@ class UpdateTapService(command.ShowOne):
|
||||
_description = _("Update a tap service.")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(UpdateTapService, self).get_parser(prog_name)
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
TAP_SERVICE,
|
||||
metavar="<%s>" % TAP_SERVICE,
|
||||
|
@ -14,11 +14,8 @@ stestr>=3.0.1 # Apache-2.0
|
||||
testresources>=2.0.1 # Apache-2.0/BSD
|
||||
testscenarios>=0.5.0 # Apache-2.0/BSD
|
||||
testtools>=2.4.0 # MIT
|
||||
# This is necessary as in lower-constraints job neutron
|
||||
# imports it
|
||||
mock>=3.0.0 # BSD
|
||||
|
||||
astroid==2.1.0 # LGPLv2.1
|
||||
pylint==2.2.0 # GPLv2
|
||||
isort==4.3.21 # MIT
|
||||
astroid>=2.12.4 # LGPLv2.1
|
||||
pylint==2.15.6 # GPLv2
|
||||
isort==5.10.1 # MIT
|
||||
WebTest>=2.0.27 # MIT
|
||||
|
4
tox.ini
4
tox.ini
@ -12,7 +12,7 @@ setenv = VIRTUAL_ENV={envdir}
|
||||
EDITOR=vi
|
||||
PYTHONWARNINGS=default::DeprecationWarning
|
||||
usedevelop = True
|
||||
deps = -c{env:TOX_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt}
|
||||
deps = -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||
-r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands = find . -type f -name "*.py[c|o]" -delete
|
||||
@ -27,6 +27,8 @@ sitepackages = True
|
||||
[testenv:pep8]
|
||||
commands =
|
||||
flake8
|
||||
pylint --version
|
||||
pylint --rcfile=.pylintrc --output-format=colorized {posargs:neutron_taas}
|
||||
neutron-db-manage --subproject tap-as-a-service --database-connection sqlite:// check_migration
|
||||
{[testenv:genpolicy]commands}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user