From d1c0e73bc6247d4f4e7093eadb0df6186ae2546e Mon Sep 17 00:00:00 2001 From: Jakub Libosvar Date: Fri, 18 Apr 2014 15:31:55 +0200 Subject: [PATCH] Fix H302 violations in extensions package H302 violation is reported by flake8 when importing separated objects from modules instead of importing the whole module. e.g. from package.module import function function() is changed to from package import module module.function() Change-Id: I570eeee2a7633c1590b54ac98b411a71fc9d4f4e Partial-Bug: #1291032 --- neutron/extensions/agent.py | 10 ++++----- neutron/extensions/dhcpagentscheduler.py | 10 ++++----- neutron/extensions/firewall.py | 4 ++-- neutron/extensions/l3.py | 26 +++++++++++----------- neutron/extensions/l3agentscheduler.py | 10 ++++----- neutron/extensions/lbaas_agentscheduler.py | 6 ++--- neutron/extensions/loadbalancer.py | 4 ++-- neutron/extensions/quotasv2.py | 18 +++++++-------- neutron/extensions/securitygroup.py | 23 +++++++++---------- neutron/extensions/vpnaas.py | 4 ++-- 10 files changed, 57 insertions(+), 58 deletions(-) diff --git a/neutron/extensions/agent.py b/neutron/extensions/agent.py index 35c843ad61..0dc0acd056 100644 --- a/neutron/extensions/agent.py +++ b/neutron/extensions/agent.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from abc import abstractmethod +import abc from neutron.api import extensions from neutron.api.v2 import attributes as attr @@ -132,7 +132,7 @@ class AgentPluginBase(object): """ raise exceptions.BadRequest - @abstractmethod + @abc.abstractmethod def delete_agent(self, context, id): """Delete agent. @@ -144,7 +144,7 @@ class AgentPluginBase(object): """ pass - @abstractmethod + @abc.abstractmethod def update_agent(self, context, agent): """Disable or Enable the agent. @@ -154,10 +154,10 @@ class AgentPluginBase(object): """ pass - @abstractmethod + @abc.abstractmethod def get_agents(self, context, filters=None, fields=None): pass - @abstractmethod + @abc.abstractmethod def get_agent(self, context, id, fields=None): pass diff --git a/neutron/extensions/dhcpagentscheduler.py b/neutron/extensions/dhcpagentscheduler.py index 90e26b06db..d86ba614f9 100644 --- a/neutron/extensions/dhcpagentscheduler.py +++ b/neutron/extensions/dhcpagentscheduler.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from abc import abstractmethod +import abc from neutron.api import extensions from neutron.api.v2 import base @@ -135,18 +135,18 @@ class DhcpAgentSchedulerPluginBase(object): All of method must be in an admin context. """ - @abstractmethod + @abc.abstractmethod def add_network_to_dhcp_agent(self, context, id, network_id): pass - @abstractmethod + @abc.abstractmethod def remove_network_from_dhcp_agent(self, context, id, network_id): pass - @abstractmethod + @abc.abstractmethod def list_networks_on_dhcp_agent(self, context, id): pass - @abstractmethod + @abc.abstractmethod def list_dhcp_agents_hosting_network(self, context, network_id): pass diff --git a/neutron/extensions/firewall.py b/neutron/extensions/firewall.py index 922bec3605..8ac534ce43 100644 --- a/neutron/extensions/firewall.py +++ b/neutron/extensions/firewall.py @@ -26,7 +26,7 @@ from neutron.api.v2 import resource_helper from neutron.common import exceptions as qexception from neutron.openstack.common import log as logging from neutron.plugins.common import constants -from neutron.services.service_base import ServicePluginBase +from neutron.services import service_base LOG = logging.getLogger(__name__) @@ -346,7 +346,7 @@ class Firewall(extensions.ExtensionDescriptor): @six.add_metaclass(abc.ABCMeta) -class FirewallPluginBase(ServicePluginBase): +class FirewallPluginBase(service_base.ServicePluginBase): def get_plugin_name(self): return constants.FIREWALL diff --git a/neutron/extensions/l3.py b/neutron/extensions/l3.py index 6c4de41cfd..b02c9337b6 100644 --- a/neutron/extensions/l3.py +++ b/neutron/extensions/l3.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from abc import abstractmethod +import abc from oslo.config import cfg @@ -196,52 +196,52 @@ class L3(extensions.ExtensionDescriptor): class RouterPluginBase(object): - @abstractmethod + @abc.abstractmethod def create_router(self, context, router): pass - @abstractmethod + @abc.abstractmethod def update_router(self, context, id, router): pass - @abstractmethod + @abc.abstractmethod def get_router(self, context, id, fields=None): pass - @abstractmethod + @abc.abstractmethod def delete_router(self, context, id): pass - @abstractmethod + @abc.abstractmethod def get_routers(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False): pass - @abstractmethod + @abc.abstractmethod def add_router_interface(self, context, router_id, interface_info): pass - @abstractmethod + @abc.abstractmethod def remove_router_interface(self, context, router_id, interface_info): pass - @abstractmethod + @abc.abstractmethod def create_floatingip(self, context, floatingip): pass - @abstractmethod + @abc.abstractmethod def update_floatingip(self, context, id, floatingip): pass - @abstractmethod + @abc.abstractmethod def get_floatingip(self, context, id, fields=None): pass - @abstractmethod + @abc.abstractmethod def delete_floatingip(self, context, id): pass - @abstractmethod + @abc.abstractmethod def get_floatingips(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False): diff --git a/neutron/extensions/l3agentscheduler.py b/neutron/extensions/l3agentscheduler.py index 36f731d2cb..689cc9ba91 100644 --- a/neutron/extensions/l3agentscheduler.py +++ b/neutron/extensions/l3agentscheduler.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from abc import abstractmethod +import abc import webob.exc @@ -177,18 +177,18 @@ class L3AgentSchedulerPluginBase(object): All of method must be in an admin context. """ - @abstractmethod + @abc.abstractmethod def add_router_to_l3_agent(self, context, id, router_id): pass - @abstractmethod + @abc.abstractmethod def remove_router_from_l3_agent(self, context, id, router_id): pass - @abstractmethod + @abc.abstractmethod def list_routers_on_l3_agent(self, context, id): pass - @abstractmethod + @abc.abstractmethod def list_l3_agents_hosting_router(self, context, router_id): pass diff --git a/neutron/extensions/lbaas_agentscheduler.py b/neutron/extensions/lbaas_agentscheduler.py index 2a776fc90d..a821cb6e8e 100644 --- a/neutron/extensions/lbaas_agentscheduler.py +++ b/neutron/extensions/lbaas_agentscheduler.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from abc import abstractmethod +import abc from neutron.api import extensions from neutron.api.v2 import base @@ -128,10 +128,10 @@ class LbaasAgentSchedulerPluginBase(object): All of method must be in an admin context. """ - @abstractmethod + @abc.abstractmethod def list_pools_on_lbaas_agent(self, context, id): pass - @abstractmethod + @abc.abstractmethod def get_lbaas_agent_hosting_pool(self, context, pool_id): pass diff --git a/neutron/extensions/loadbalancer.py b/neutron/extensions/loadbalancer.py index 536bff5abd..841e3f094e 100644 --- a/neutron/extensions/loadbalancer.py +++ b/neutron/extensions/loadbalancer.py @@ -25,7 +25,7 @@ from neutron.api.v2 import resource_helper from neutron.common import exceptions as qexception from neutron import manager from neutron.plugins.common import constants -from neutron.services.service_base import ServicePluginBase +from neutron.services import service_base # Loadbalancer Exceptions @@ -393,7 +393,7 @@ class Loadbalancer(extensions.ExtensionDescriptor): @six.add_metaclass(abc.ABCMeta) -class LoadBalancerPluginBase(ServicePluginBase): +class LoadBalancerPluginBase(service_base.ServicePluginBase): def get_plugin_name(self): return constants.LOADBALANCER diff --git a/neutron/extensions/quotasv2.py b/neutron/extensions/quotasv2.py index ea29884bcf..4fa9bf2805 100644 --- a/neutron/extensions/quotasv2.py +++ b/neutron/extensions/quotasv2.py @@ -19,11 +19,11 @@ from oslo.config import cfg import webob from neutron.api import extensions -from neutron.api.v2.attributes import convert_to_int +from neutron.api.v2 import attributes from neutron.api.v2 import base from neutron.api.v2 import resource from neutron.common import exceptions as n_exc -from neutron.manager import NeutronManager +from neutron import manager from neutron.openstack.common import importutils from neutron import quota from neutron import wsgi @@ -51,12 +51,12 @@ class QuotaSetsController(wsgi.Controller): def _update_attributes(self): for quota_resource in QUOTAS.resources.iterkeys(): attr_dict = EXTENDED_ATTRIBUTES_2_0[RESOURCE_COLLECTION] - attr_dict[quota_resource] = {'allow_post': False, - 'allow_put': True, - 'convert_to': convert_to_int, - 'validate': {'type:range': - [-1, sys.maxsize]}, - 'is_visible': True} + attr_dict[quota_resource] = { + 'allow_post': False, + 'allow_put': True, + 'convert_to': attributes.convert_to_int, + 'validate': {'type:range': [-1, sys.maxsize]}, + 'is_visible': True} self._update_extended_attributes = False def _get_quotas(self, request, tenant_id): @@ -138,7 +138,7 @@ class Quotasv2(extensions.ExtensionDescriptor): def get_resources(cls): """Returns Ext Resources.""" controller = resource.Resource( - QuotaSetsController(NeutronManager.get_plugin()), + QuotaSetsController(manager.NeutronManager.get_plugin()), faults=base.FAULT_MAP) return [extensions.ResourceExtension( Quotasv2.get_alias(), diff --git a/neutron/extensions/securitygroup.py b/neutron/extensions/securitygroup.py index 1450b69448..5f004af48c 100644 --- a/neutron/extensions/securitygroup.py +++ b/neutron/extensions/securitygroup.py @@ -13,8 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from abc import ABCMeta -from abc import abstractmethod +import abc import netaddr from oslo.config import cfg @@ -311,45 +310,45 @@ class Securitygroup(extensions.ExtensionDescriptor): return {} -@six.add_metaclass(ABCMeta) +@six.add_metaclass(abc.ABCMeta) class SecurityGroupPluginBase(object): - @abstractmethod + @abc.abstractmethod def create_security_group(self, context, security_group): pass - @abstractmethod + @abc.abstractmethod def update_security_group(self, context, id, security_group): pass - @abstractmethod + @abc.abstractmethod def delete_security_group(self, context, id): pass - @abstractmethod + @abc.abstractmethod def get_security_groups(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False): pass - @abstractmethod + @abc.abstractmethod def get_security_group(self, context, id, fields=None): pass - @abstractmethod + @abc.abstractmethod def create_security_group_rule(self, context, security_group_rule): pass - @abstractmethod + @abc.abstractmethod def delete_security_group_rule(self, context, id): pass - @abstractmethod + @abc.abstractmethod def get_security_group_rules(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False): pass - @abstractmethod + @abc.abstractmethod def get_security_group_rule(self, context, id, fields=None): pass diff --git a/neutron/extensions/vpnaas.py b/neutron/extensions/vpnaas.py index 7c44725cea..5c7cd46bfa 100644 --- a/neutron/extensions/vpnaas.py +++ b/neutron/extensions/vpnaas.py @@ -24,7 +24,7 @@ from neutron.api.v2 import attributes as attr from neutron.api.v2 import resource_helper from neutron.common import exceptions as qexception from neutron.plugins.common import constants -from neutron.services.service_base import ServicePluginBase +from neutron.services import service_base class VPNServiceNotFound(qexception.NotFound): @@ -386,7 +386,7 @@ class Vpnaas(extensions.ExtensionDescriptor): @six.add_metaclass(abc.ABCMeta) -class VPNPluginBase(ServicePluginBase): +class VPNPluginBase(service_base.ServicePluginBase): def get_plugin_name(self): return constants.VPN