]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix H302 violations in db package and services
authorJakub Libosvar <libosvar@redhat.com>
Fri, 18 Apr 2014 13:22:45 +0000 (15:22 +0200)
committerJakub Libosvar <libosvar@redhat.com>
Tue, 22 Apr 2014 13:31:00 +0000 (15:31 +0200)
Change-Id: If5e07fa4529430ba90d9c7dd81d28ceeee00ebe0
Partial-Bug: #1291032

12 files changed:
neutron/db/l3_agentschedulers_db.py
neutron/db/loadbalancer/loadbalancer_db.py
neutron/db/migration/alembic_migrations/env.py
neutron/db/sqlalchemyutils.py
neutron/db/vpn/vpn_db.py
neutron/service.py
neutron/services/loadbalancer/drivers/embrane/agent/lb_operations.py
neutron/services/loadbalancer/drivers/embrane/models.py
neutron/services/loadbalancer/drivers/haproxy/cfg.py
neutron/services/vpn/device_drivers/cisco_ipsec.py
neutron/tests/unit/test_wsgi.py
neutron/wsgi.py

index 698a786fa6fd48cdb3bd1e0e49b019baf228ce55..19969cb6000ae2fd7978a9f8f48564ba4701f4d2 100644 (file)
@@ -22,7 +22,7 @@ from sqlalchemy.orm import joinedload
 
 from neutron.common import constants
 from neutron.db import agents_db
-from neutron.db.agentschedulers_db import AgentSchedulerDbMixin
+from neutron.db import agentschedulers_db
 from neutron.db import model_base
 from neutron.db import models_v2
 from neutron.extensions import l3agentscheduler
@@ -52,7 +52,7 @@ class RouterL3AgentBinding(model_base.BASEV2, models_v2.HasId):
 
 
 class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
-                              AgentSchedulerDbMixin):
+                              agentschedulers_db.AgentSchedulerDbMixin):
     """Mixin class to add l3 agent scheduler extension to plugins
     using the l3 agent for routing.
     """
@@ -237,7 +237,8 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
 
         return [l3_agent
                 for l3_agent in query
-                if AgentSchedulerDbMixin.is_eligible_agent(active, l3_agent)]
+                if agentschedulers_db.AgentSchedulerDbMixin.is_eligible_agent(
+                    active, l3_agent)]
 
     def get_l3_agent_candidates(self, sync_router, l3_agents):
         """Get the valid l3 agents for the router from a list of l3_agents."""
index 9f1c9b6157a5e31f2076c593ea51e1d2a48f117d..9c81a0664b28cdbd9f40902dc4290c72f1a8cf91 100644 (file)
@@ -27,7 +27,6 @@ from neutron.db import model_base
 from neutron.db import models_v2
 from neutron.db import servicetype_db as st_db
 from neutron.extensions import loadbalancer
-from neutron.extensions.loadbalancer import LoadBalancerPluginBase
 from neutron import manager
 from neutron.openstack.common.db import exception
 from neutron.openstack.common import excutils
@@ -177,7 +176,7 @@ class PoolMonitorAssociation(model_base.BASEV2,
                            primary_key=True)
 
 
-class LoadBalancerPluginDb(LoadBalancerPluginBase,
+class LoadBalancerPluginDb(loadbalancer.LoadBalancerPluginBase,
                            base_db.CommonDbMixin):
     """Wraps loadbalancer with SQLAlchemy models.
 
index 92fe6b45fd660642094c06057153e47a25fe2699..98352ffb75a865ee0cb4f193d7cf7341b4c7349e 100644 (file)
@@ -14,7 +14,7 @@
 #
 # @author: Mark McClain, DreamHost
 
-from logging.config import fileConfig
+from logging import config as logging_config
 
 from alembic import context
 from sqlalchemy import create_engine, pool
@@ -32,7 +32,7 @@ neutron_config = config.neutron_config
 
 # Interpret the config file for Python logging.
 # This line sets up loggers basically.
-fileConfig(config.config_file_name)
+logging_config.fileConfig(config.config_file_name)
 
 plugin_class_path = neutron_config.core_plugin
 active_plugins = [plugin_class_path]
index e1d525391a62801a0978d97ca1bf2df32c5b6e32..adf034432684fab3c9db349bb074234e1a3e4016 100644 (file)
@@ -13,7 +13,7 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-from six.moves import xrange
+from six import moves
 import sqlalchemy
 from sqlalchemy.orm.properties import RelationshipProperty
 
@@ -88,7 +88,7 @@ def paginate_query(query, model, limit, sorts, marker_obj=None):
         criteria_list = []
         for i, sort in enumerate(sorts):
             crit_attrs = [(getattr(model, sorts[j][0]) == marker_values[j])
-                          for j in xrange(i)]
+                          for j in moves.xrange(i)]
             model_attr = getattr(model, sort[0])
             if sort[1]:
                 crit_attrs.append((model_attr > marker_values[i]))
index 056d956f3927ff7285784f19f4c6aed6c5bfc7c3..a434b26bab273f1904ccd0235fc489043e062bfa 100644 (file)
@@ -30,7 +30,6 @@ from neutron.db import l3_db
 from neutron.db import model_base
 from neutron.db import models_v2
 from neutron.extensions import vpnaas
-from neutron.extensions.vpnaas import VPNPluginBase
 from neutron import manager
 from neutron.openstack.common import excutils
 from neutron.openstack.common import log as logging
@@ -163,7 +162,7 @@ class VPNService(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
         cascade="all, delete-orphan")
 
 
-class VPNPluginDb(VPNPluginBase, base_db.CommonDbMixin):
+class VPNPluginDb(vpnaas.VPNPluginBase, base_db.CommonDbMixin):
     """VPN plugin database class using SQLAlchemy models."""
 
     def __init__(self):
index 3258245d10f89a68e64c4b012e1bbd11c23875e3..8e4d5f514736e9e8fc3734b8fcee801af3241059 100644 (file)
@@ -30,7 +30,7 @@ from neutron.openstack.common import importutils
 from neutron.openstack.common import log as logging
 from neutron.openstack.common import loopingcall
 from neutron.openstack.common.rpc import service
-from neutron.openstack.common.service import ProcessLauncher
+from neutron.openstack.common import service as common_service
 from neutron import wsgi
 
 
@@ -153,7 +153,7 @@ def serve_rpc():
             rpc.start()
             return rpc
         else:
-            launcher = ProcessLauncher(wait_interval=1.0)
+            launcher = common_service.ProcessLauncher(wait_interval=1.0)
             launcher.launch_service(rpc, workers=cfg.CONF.rpc_workers)
             return launcher
     except Exception:
index 15ac419f58cbf52eebf72a44d614197ee5b93508..f31caf77775dd25ced644b5cf462e41271e93708 100644 (file)
@@ -15,7 +15,7 @@
 #
 # @author:  Ivar Lazzaro, Embrane, Inc. ivar@embrane.com
 
-from functools import wraps
+import functools
 
 from heleosapi import exceptions as h_exc
 
@@ -34,7 +34,7 @@ def handler(event, handler):
         else:
             handler[event].append(f)
 
-        @wraps(f)
+        @functools.wraps(f)
         def wrapped_f(*args, **kwargs):
             return f(*args, **kwargs)
 
index e092c00310a560251558344a52497a4411f0ef57..51adfcf248c42b0c560661fd1cce5462d8775c62 100644 (file)
@@ -17,7 +17,7 @@
 
 import sqlalchemy as sql
 
-from neutron.db.models_v2 import model_base
+from neutron.db import model_base
 
 
 class PoolPort(model_base.BASEV2):
index 2944e456a6dcc5984bd659f1fc398de6ed1f6d9e..d740cb6c02911f08f3ee8c288a781a6fa3ed6432 100644 (file)
@@ -17,7 +17,7 @@
 # @author: Mark McClain, DreamHost
 
 import itertools
-from six.moves import xrange
+from six import moves
 
 from neutron.agent.linux import utils
 from neutron.plugins.common import constants as qconstants
@@ -231,7 +231,7 @@ def _expand_expected_codes(codes):
             continue
         elif '-' in code:
             low, hi = code.split('-')[:2]
-            retval.update(str(i) for i in xrange(int(low), int(hi) + 1))
+            retval.update(str(i) for i in moves.xrange(int(low), int(hi) + 1))
         else:
             retval.add(code)
     return retval
index 63eb9c094500d81806af1c3968c41444e129e7fd..a7d38ba504e4ae5c66b5d85de8cef854faf89bc0 100644 (file)
@@ -15,7 +15,7 @@
 # @author: Paul Michali, Cisco Systems, Inc.
 
 import abc
-from collections import namedtuple
+import collections
 import requests
 
 import netaddr
@@ -46,7 +46,8 @@ cfg.CONF.register_opts(ipsec_opts, 'cisco_csr_ipsec')
 
 LOG = logging.getLogger(__name__)
 
-RollbackStep = namedtuple('RollbackStep', ['action', 'resource_id', 'title'])
+RollbackStep = collections.namedtuple('RollbackStep',
+                                      ['action', 'resource_id', 'title'])
 
 
 class CsrResourceCreateFailure(exceptions.NeutronException):
index 4e1101ba3aace72823e1923de164da5326a83898..1de0d53f850e960283568c5bc3c7c1f2a229e657 100644 (file)
@@ -47,7 +47,7 @@ class TestWSGIServer(base.BaseTestCase):
         server.stop()
         server.wait()
 
-    @mock.patch('neutron.wsgi.ProcessLauncher')
+    @mock.patch('neutron.openstack.common.service.ProcessLauncher')
     def test_start_multiple_workers(self, ProcessLauncher):
         launcher = ProcessLauncher.return_value
 
index 5895eee9d04a5d73da1d17bc7dca0dffd0e6b418..e3b5262405319825e59168825d62d0273d4d2f35 100644 (file)
@@ -44,7 +44,7 @@ from neutron.openstack.common import excutils
 from neutron.openstack.common import gettextutils
 from neutron.openstack.common import jsonutils
 from neutron.openstack.common import log as logging
-from neutron.openstack.common.service import ProcessLauncher
+from neutron.openstack.common import service as common_service
 
 socket_opts = [
     cfg.IntOpt('backlog',
@@ -216,7 +216,7 @@ class Server(object):
         else:
             # Minimize the cost of checking for child exit by extending the
             # wait interval past the default of 0.01s.
-            self._launcher = ProcessLauncher(wait_interval=1.0)
+            self._launcher = common_service.ProcessLauncher(wait_interval=1.0)
             self._server = WorkerService(self, application)
             self._launcher.launch_service(self._server, workers=workers)