Enable a bunch of pylint rules, get stuff passing
Change-Id: Ied629ed82de570242441e1a336376fb126351470
This commit is contained in:
parent
606b75488d
commit
09106467e5
37
.pylintrc
37
.pylintrc
@ -15,59 +15,24 @@ ignore=.git,tests,openstack
|
||||
disable=
|
||||
# "F" Fatal errors that prevent further processing
|
||||
import-error,
|
||||
# "I" Informational noise
|
||||
locally-disabled,
|
||||
# "E" Error for important programming issues (likely bugs)
|
||||
access-member-before-definition,
|
||||
bad-super-call,
|
||||
maybe-no-member,
|
||||
no-member,
|
||||
no-method-argument,
|
||||
no-self-argument,
|
||||
not-callable,
|
||||
no-value-for-parameter,
|
||||
super-on-old-class,
|
||||
too-few-format-args,
|
||||
too-many-function-args,
|
||||
# "W" Warnings for stylistic problems or minor programming issues
|
||||
abstract-method,
|
||||
anomalous-backslash-in-string,
|
||||
anomalous-unicode-escape-in-string,
|
||||
arguments-differ,
|
||||
attribute-defined-outside-init,
|
||||
bad-builtin,
|
||||
bad-indentation,
|
||||
broad-except,
|
||||
dangerous-default-value,
|
||||
deprecated-lambda,
|
||||
duplicate-key,
|
||||
expression-not-assigned,
|
||||
fixme,
|
||||
global-statement,
|
||||
global-variable-not-assigned,
|
||||
logging-not-lazy,
|
||||
no-init,
|
||||
non-parent-init-called,
|
||||
pointless-string-statement,
|
||||
protected-access,
|
||||
redefined-builtin,
|
||||
redefined-outer-name,
|
||||
redefine-in-handler,
|
||||
signature-differs,
|
||||
star-args,
|
||||
super-init-not-called,
|
||||
unnecessary-lambda,
|
||||
unnecessary-pass,
|
||||
unpacking-non-sequence,
|
||||
unreachable,
|
||||
unused-argument,
|
||||
unused-import,
|
||||
unused-variable,
|
||||
# "C" Coding convention violations
|
||||
bad-continuation,
|
||||
invalid-name,
|
||||
missing-docstring,
|
||||
old-style-class,
|
||||
superfluous-parens,
|
||||
# "R" Refactor recommendations
|
||||
abstract-class-little-used,
|
||||
abstract-class-not-used,
|
||||
|
@ -134,5 +134,5 @@ class LbaasAgentSchedulerPluginBase(object):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_lbaas_agent_hosting_pool(self, context, pool_id):
|
||||
def get_lbaas_agent_hosting_pool(self, context, pool_id, active=None):
|
||||
pass
|
||||
|
@ -388,7 +388,7 @@ class Loadbalancer(extensions.ExtensionDescriptor):
|
||||
def get_plugin_interface(cls):
|
||||
return LoadBalancerPluginBase
|
||||
|
||||
def update_attributes_map(self, attributes):
|
||||
def update_attributes_map(self, attributes, extension_attrs_map=None):
|
||||
super(Loadbalancer, self).update_attributes_map(
|
||||
attributes, extension_attrs_map=RESOURCE_ATTRIBUTE_MAP)
|
||||
|
||||
|
@ -22,7 +22,7 @@ class AgentDeviceDriver(object):
|
||||
"""Abstract device driver that defines the API required by LBaaS agent."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_name(cls):
|
||||
def get_name(self):
|
||||
"""Returns unique name across all LBaaS device drivers."""
|
||||
pass
|
||||
|
||||
@ -32,7 +32,7 @@ class AgentDeviceDriver(object):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def undeploy_instance(self, pool_id):
|
||||
def undeploy_instance(self, pool_id, **kwargs):
|
||||
"""Fully undeploys the loadbalancer instance."""
|
||||
pass
|
||||
|
||||
|
@ -16,7 +16,7 @@ from neutron.agent import rpc as agent_rpc
|
||||
from neutron.common import constants as n_const
|
||||
from neutron.common import exceptions as n_exc
|
||||
from neutron.common import topics
|
||||
from neutron import context
|
||||
from neutron import context as ncontext
|
||||
from neutron.i18n import _LE, _LI
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.openstack.common import loopingcall
|
||||
@ -61,7 +61,7 @@ class LbaasAgentManager(periodic_task.PeriodicTasks):
|
||||
def __init__(self, conf):
|
||||
super(LbaasAgentManager, self).__init__()
|
||||
self.conf = conf
|
||||
self.context = context.get_admin_context_without_session()
|
||||
self.context = ncontext.get_admin_context_without_session()
|
||||
self.plugin_rpc = agent_api.LbaasAgentApi(
|
||||
topics.LOADBALANCER_PLUGIN,
|
||||
self.context,
|
||||
|
@ -37,7 +37,7 @@ class BaseDataModel(object):
|
||||
|
||||
# NOTE(brandon-logan) This does not discover dicts for relationship
|
||||
# attributes.
|
||||
def to_dict(self):
|
||||
def to_dict(self, **kwargs):
|
||||
ret = {}
|
||||
for attr in self.__dict__:
|
||||
if (attr.startswith('_') or
|
||||
@ -186,9 +186,9 @@ class HealthMonitor(BaseDataModel):
|
||||
return bool(self.pool and self.pool.listener and
|
||||
self.pool.listener.loadbalancer)
|
||||
|
||||
def to_dict(self, pools=False):
|
||||
def to_dict(self, **kwargs):
|
||||
ret_dict = super(HealthMonitor, self).to_dict()
|
||||
if pools:
|
||||
if kwargs.get('pools'):
|
||||
# NOTE(blogan): Returning a list to future proof for M:N objects
|
||||
# that are not yet implemented.
|
||||
pool_list = []
|
||||
@ -223,13 +223,13 @@ class Pool(BaseDataModel):
|
||||
def attached_to_loadbalancer(self):
|
||||
return bool(self.listener and self.listener.loadbalancer)
|
||||
|
||||
def to_dict(self, members=False, listeners=False):
|
||||
def to_dict(self, **kwargs):
|
||||
ret_dict = super(Pool, self).to_dict()
|
||||
if members:
|
||||
if kwargs.get('members', False):
|
||||
ret_dict['members'] = [member.to_dict() for member in self.members]
|
||||
if self.sessionpersistence:
|
||||
ret_dict['session_persistence'] = self.sessionpersistence.to_dict()
|
||||
if listeners:
|
||||
if kwargs.get('listeners', False):
|
||||
# NOTE(blogan): Returning a list to future proof for M:N objects
|
||||
# that are not yet implemented.
|
||||
listener_list = []
|
||||
@ -287,9 +287,9 @@ class Listener(BaseDataModel):
|
||||
def attached_to_loadbalancer(self):
|
||||
return bool(self.loadbalancer)
|
||||
|
||||
def to_dict(self, loadbalancers=False):
|
||||
def to_dict(self, **kwargs):
|
||||
ret_dict = super(Listener, self).to_dict()
|
||||
if loadbalancers:
|
||||
if kwargs.get('loadbalancers', False):
|
||||
# NOTE(blogan): Returning a list to future proof for M:N objects
|
||||
# that are not yet implemented.
|
||||
lbs = []
|
||||
@ -324,9 +324,9 @@ class LoadBalancer(BaseDataModel):
|
||||
def attached_to_loadbalancer(self):
|
||||
return True
|
||||
|
||||
def to_dict(self, listeners=False):
|
||||
def to_dict(self, **kwargs):
|
||||
ret_dict = super(LoadBalancer, self).to_dict()
|
||||
if listeners:
|
||||
if kwargs.get('listeners', False):
|
||||
ret_dict['listeners'] = [listener.to_dict()
|
||||
for listener in self.listeners]
|
||||
return ret_dict
|
||||
|
@ -76,7 +76,7 @@ class ThunderDriver(abstract_driver.LoadBalancerAbstractDriver):
|
||||
ip_address = member['address']
|
||||
if use_float:
|
||||
fip_qry = context.session.query(l3_db.FloatingIP)
|
||||
if (fip_qry.filter_by(fixed_ip_address=ip_address).count() > 0):
|
||||
if fip_qry.filter_by(fixed_ip_address=ip_address).count() > 0:
|
||||
float_address = fip_qry.filter_by(
|
||||
fixed_ip_address=ip_address).first()
|
||||
ip_address = str(float_address.floating_ip_address)
|
||||
|
@ -27,12 +27,12 @@ LOG = logging.getLogger(__name__)
|
||||
handlers = {}
|
||||
|
||||
|
||||
def handler(event, handler):
|
||||
def handler(event, ahandler):
|
||||
def wrap(f):
|
||||
if event not in handler.keys():
|
||||
handler[event] = [f]
|
||||
if event not in ahandler.keys():
|
||||
ahandler[event] = [f]
|
||||
else:
|
||||
handler[event].append(f)
|
||||
ahandler[event].append(f)
|
||||
|
||||
@functools.wraps(f)
|
||||
def wrapped_f(*args, **kwargs):
|
||||
|
@ -32,7 +32,6 @@ from neutron_lbaas.services.loadbalancer import constants as lbcon
|
||||
from neutron_lbaas.services.loadbalancer.drivers import abstract_driver
|
||||
from neutron_lbaas.services.loadbalancer.drivers.embrane.agent \
|
||||
import dispatcher
|
||||
from neutron_lbaas.services.loadbalancer.drivers.embrane import config # noqa
|
||||
from neutron_lbaas.services.loadbalancer.drivers.embrane \
|
||||
import constants as econ
|
||||
from neutron_lbaas.services.loadbalancer.drivers.embrane import db as edb
|
||||
|
@ -120,8 +120,10 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
|
||||
self.pool_to_port_id[pool_id] = logical_config['vip']['port']['id']
|
||||
|
||||
@n_utils.synchronized('haproxy-driver')
|
||||
def undeploy_instance(self, pool_id, cleanup_namespace=False,
|
||||
delete_namespace=False):
|
||||
def undeploy_instance(self, pool_id, **kwargs):
|
||||
cleanup_namespace = kwargs.get('cleanup_namespace', False)
|
||||
delete_namespace = kwargs.get('delete_namespace', False)
|
||||
|
||||
namespace = get_ns_name(pool_id)
|
||||
pid_path = self._get_state_file_path(pool_id, 'pid')
|
||||
|
||||
|
@ -22,7 +22,7 @@ LOG = logging.getLogger(__name__)
|
||||
class LoggingNoopLoadBalancerDriver(driver_base.LoadBalancerBaseDriver):
|
||||
|
||||
def __init__(self, plugin):
|
||||
self.plugin = plugin
|
||||
super(LoggingNoopLoadBalancerDriver, self).__init__(plugin)
|
||||
|
||||
# Each of the major LBaaS objects in the neutron database
|
||||
# need a corresponding manager/handler class.
|
||||
@ -54,10 +54,10 @@ class LoggingNoopCommonManager(object):
|
||||
class LoggingNoopLoadBalancerManager(LoggingNoopCommonManager,
|
||||
driver_base.BaseLoadBalancerManager):
|
||||
|
||||
def refresh(self, context, lb_obj, force=False):
|
||||
def refresh(self, context, obj):
|
||||
# This is intended to trigger the backend to check and repair
|
||||
# the state of this load balancer and all of its dependent objects
|
||||
LOG.debug("LB pool refresh %s, force=%s", lb_obj.id, force)
|
||||
LOG.debug("LB pool refresh %s", obj.id)
|
||||
|
||||
def stats(self, context, lb_obj):
|
||||
LOG.debug("LB stats %s", lb_obj.id)
|
||||
|
@ -25,7 +25,7 @@ eventlet.monkey_patch(thread=True)
|
||||
|
||||
from neutron.api.v2 import attributes
|
||||
from neutron.common import log as call_log
|
||||
from neutron import context
|
||||
from neutron import context as ncontext
|
||||
from neutron.i18n import _LE, _LI, _LW
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.common import constants
|
||||
@ -580,7 +580,7 @@ class LoadBalancerDriver(abstract_driver.LoadBalancerAbstractDriver):
|
||||
create_workflow_params=None):
|
||||
"""Create a WF if it doesn't exists yet."""
|
||||
if not self.workflow_templates_exists:
|
||||
self._verify_workflow_templates()
|
||||
self._verify_workflow_templates()
|
||||
if not self._workflow_exists(wf_name):
|
||||
if not create_workflow_params:
|
||||
create_workflow_params = {}
|
||||
@ -910,8 +910,9 @@ class OperationCompletionHandler(threading.Thread):
|
||||
log_data)
|
||||
|
||||
|
||||
def _rest_wrapper(response, success_codes=[202]):
|
||||
def _rest_wrapper(response, success_codes=None):
|
||||
"""Wrap a REST call and make sure a valid status is returned."""
|
||||
success_codes = success_codes or [202]
|
||||
if not response:
|
||||
raise r_exc.RESTRequestFailure(
|
||||
status=-1,
|
||||
@ -943,7 +944,7 @@ def _update_vip_graph_status(plugin, oper, status):
|
||||
|
||||
"""
|
||||
|
||||
ctx = context.get_admin_context(load_admin_roles=False)
|
||||
ctx = ncontext.get_admin_context(load_admin_roles=False)
|
||||
|
||||
LOG.debug('_update: %s ', oper)
|
||||
if oper.lbaas_entity == lb_db.PoolMonitorAssociation:
|
||||
@ -987,7 +988,7 @@ def _remove_object_from_db(plugin, oper):
|
||||
"""Remove a specific entity from db."""
|
||||
LOG.debug('_remove_object_from_db %s', oper)
|
||||
|
||||
ctx = context.get_admin_context(load_admin_roles=False)
|
||||
ctx = ncontext.get_admin_context(load_admin_roles=False)
|
||||
|
||||
if oper.lbaas_entity == lb_db.PoolMonitorAssociation:
|
||||
plugin._delete_db_pool_health_monitor(ctx,
|
||||
|
@ -27,7 +27,7 @@ from oslo_utils import excutils
|
||||
from neutron_lbaas.db.loadbalancer import loadbalancer_db as ldb
|
||||
from neutron_lbaas.db.loadbalancer import loadbalancer_dbv2 as ldbv2
|
||||
from neutron_lbaas.db.loadbalancer import models
|
||||
from neutron_lbaas.extensions import loadbalancer
|
||||
from neutron_lbaas.extensions import loadbalancer as lb_ext
|
||||
from neutron_lbaas.extensions import loadbalancerv2
|
||||
from neutron_lbaas.services.loadbalancer import agent_scheduler
|
||||
from neutron_lbaas.services.loadbalancer import constants as lb_const
|
||||
@ -166,10 +166,10 @@ class LoadBalancerPlugin(ldb.LoadBalancerPluginDb,
|
||||
# This validation is because the new API version also has a resource
|
||||
# called pool and these attributes have to be optional in the old API
|
||||
# so they are not required attributes of the new. Its complicated.
|
||||
if (pool['pool']['lb_method'] == attrs.ATTR_NOT_SPECIFIED):
|
||||
if pool['pool']['lb_method'] == attrs.ATTR_NOT_SPECIFIED:
|
||||
raise loadbalancerv2.RequiredAttributeNotSpecified(
|
||||
attr_name='lb_method')
|
||||
if (pool['pool']['subnet_id'] == attrs.ATTR_NOT_SPECIFIED):
|
||||
if pool['pool']['subnet_id'] == attrs.ATTR_NOT_SPECIFIED:
|
||||
raise loadbalancerv2.RequiredAttributeNotSpecified(
|
||||
attr_name='subnet_id')
|
||||
|
||||
@ -186,13 +186,13 @@ class LoadBalancerPlugin(ldb.LoadBalancerPluginDb,
|
||||
driver = self.drivers[provider_name]
|
||||
try:
|
||||
driver.create_pool(context, p)
|
||||
except loadbalancer.NoEligibleBackend:
|
||||
except lb_ext.NoEligibleBackend:
|
||||
# that should catch cases when backend of any kind
|
||||
# is not available (agent, appliance, etc)
|
||||
self.update_status(context, ldb.Pool,
|
||||
p['id'], constants.ERROR,
|
||||
"No eligible backend")
|
||||
raise loadbalancer.NoEligibleBackend(pool_id=p['id'])
|
||||
raise lb_ext.NoEligibleBackend(pool_id=p['id'])
|
||||
return p
|
||||
|
||||
def update_pool(self, context, id, pool):
|
||||
@ -262,7 +262,7 @@ class LoadBalancerPlugin(ldb.LoadBalancerPluginDb,
|
||||
|
||||
def _validate_hm_parameters(self, delay, timeout):
|
||||
if delay < timeout:
|
||||
raise loadbalancer.DelayOrTimeoutInvalid()
|
||||
raise lb_ext.DelayOrTimeoutInvalid()
|
||||
|
||||
def create_health_monitor(self, context, health_monitor):
|
||||
new_hm = health_monitor['health_monitor']
|
||||
@ -403,9 +403,9 @@ class LoadBalancerPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2,
|
||||
"""
|
||||
loadbalancers = self.db.get_loadbalancers(context)
|
||||
lost_providers = set(
|
||||
[loadbalancer.provider.provider_name
|
||||
for loadbalancer in loadbalancers
|
||||
if loadbalancer.provider.provider_name not in provider_names])
|
||||
[lb.provider.provider_name
|
||||
for lb in loadbalancers
|
||||
if lb.provider.provider_name not in provider_names])
|
||||
# resources are left without provider - stop the service
|
||||
if lost_providers:
|
||||
msg = _LE("Delete associated load balancers before "
|
||||
@ -422,9 +422,9 @@ class LoadBalancerPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2,
|
||||
"%s") % provider)
|
||||
|
||||
def _get_driver_for_loadbalancer(self, context, loadbalancer_id):
|
||||
loadbalancer = self.db.get_loadbalancer(context, loadbalancer_id)
|
||||
lb = self.db.get_loadbalancer(context, loadbalancer_id)
|
||||
try:
|
||||
return self.drivers[loadbalancer.provider.provider_name]
|
||||
return self.drivers[lb.provider.provider_name]
|
||||
except KeyError:
|
||||
raise n_exc.Invalid(
|
||||
_LE("Error retrieving provider for load balancer. Possible "
|
||||
@ -907,9 +907,9 @@ class LoadBalancerPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2,
|
||||
fields=fields)
|
||||
|
||||
def stats(self, context, loadbalancer_id):
|
||||
loadbalancer = self.db.get_loadbalancer(context, loadbalancer_id)
|
||||
lb = self.db.get_loadbalancer(context, loadbalancer_id)
|
||||
driver = self._get_driver_for_loadbalancer(context, loadbalancer_id)
|
||||
stats_data = driver.load_balancer.stats(context, loadbalancer)
|
||||
stats_data = driver.load_balancer.stats(context, lb)
|
||||
# if we get something from the driver -
|
||||
# update the db and return the value from db
|
||||
# else - return what we have in db
|
||||
@ -927,14 +927,14 @@ class LoadBalancerPluginv2(loadbalancerv2.LoadBalancerPluginBaseV2,
|
||||
def statuses(self, context, loadbalancer_id):
|
||||
PROV = 'provisioning_status'
|
||||
OPER = 'operating_status'
|
||||
loadbalancer = self.db.get_loadbalancer(context, loadbalancer_id)
|
||||
lb = self.db.get_loadbalancer(context, loadbalancer_id)
|
||||
statuses = {'statuses': {}}
|
||||
statuses['statuses']['loadbalancer'] = {
|
||||
PROV: getattr(loadbalancer, PROV),
|
||||
OPER: getattr(loadbalancer, OPER)
|
||||
PROV: getattr(lb, PROV),
|
||||
OPER: getattr(lb, OPER)
|
||||
}
|
||||
listener_statuses = []
|
||||
for lindex, listener in enumerate(loadbalancer.listeners):
|
||||
for lindex, listener in enumerate(lb.listeners):
|
||||
listener_statuses.append({
|
||||
'id': listener.id,
|
||||
PROV: getattr(listener, PROV),
|
||||
|
Loading…
Reference in New Issue
Block a user