Merge "Enable hacking H301 check"

This commit is contained in:
Jenkins 2014-04-02 20:39:05 +00:00 committed by Gerrit Code Review
commit a86bc415b6
11 changed files with 119 additions and 123 deletions

View File

@ -26,7 +26,7 @@ from neutron.debug.debug_agent import NeutronDebugAgent
from neutron.openstack.common import importutils from neutron.openstack.common import importutils
from neutronclient.common import exceptions as exc from neutronclient.common import exceptions as exc
from neutronclient.common import utils from neutronclient.common import utils
from neutronclient.shell import env, NeutronShell, NEUTRON_API_VERSION from neutronclient import shell
COMMAND_V2 = { COMMAND_V2 = {
'probe-create': utils.import_class( 'probe-create': utils.import_class(
@ -46,7 +46,7 @@ COMMAND_V2 = {
COMMANDS = {'2.0': COMMAND_V2} COMMANDS = {'2.0': COMMAND_V2}
class NeutronDebugShell(NeutronShell): class NeutronDebugShell(shell.NeutronShell):
def __init__(self, api_version): def __init__(self, api_version):
super(NeutronDebugShell, self).__init__(api_version) super(NeutronDebugShell, self).__init__(api_version)
for k, v in COMMANDS[api_version].items(): for k, v in COMMANDS[api_version].items():
@ -56,7 +56,8 @@ class NeutronDebugShell(NeutronShell):
parser = super(NeutronDebugShell, self).build_option_parser( parser = super(NeutronDebugShell, self).build_option_parser(
description, version) description, version)
default = ( default = (
env('NEUTRON_TEST_CONFIG_FILE') or env('QUANTUM_TEST_CONFIG_FILE') shell.env('NEUTRON_TEST_CONFIG_FILE') or
shell.env('QUANTUM_TEST_CONFIG_FILE')
) )
parser.add_argument( parser.add_argument(
'--config-file', '--config-file',
@ -85,4 +86,5 @@ class NeutronDebugShell(NeutronShell):
def main(argv=None): def main(argv=None):
return NeutronDebugShell(NEUTRON_API_VERSION).run(argv or sys.argv[1:]) return NeutronDebugShell(shell.NEUTRON_API_VERSION).run(
argv or sys.argv[1:])

View File

@ -20,15 +20,14 @@ v2 Neutron Plug-in API specification.
methods that needs to be implemented by a v2 Neutron Plug-in. methods that needs to be implemented by a v2 Neutron Plug-in.
""" """
from abc import ABCMeta, abstractmethod import abc
import six import six
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class NeutronPluginBaseV2(object): class NeutronPluginBaseV2(object):
@abstractmethod @abc.abstractmethod
def create_subnet(self, context, subnet): def create_subnet(self, context, subnet):
"""Create a subnet. """Create a subnet.
@ -43,7 +42,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def update_subnet(self, context, id, subnet): def update_subnet(self, context, id, subnet):
"""Update values of a subnet. """Update values of a subnet.
@ -57,7 +56,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def get_subnet(self, context, id, fields=None): def get_subnet(self, context, id, fields=None):
"""Retrieve a subnet. """Retrieve a subnet.
@ -71,7 +70,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def get_subnets(self, context, filters=None, fields=None, def get_subnets(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None, page_reverse=False): sorts=None, limit=None, marker=None, page_reverse=False):
"""Retrieve a list of subnets. """Retrieve a list of subnets.
@ -119,7 +118,7 @@ class NeutronPluginBaseV2(object):
""" """
raise NotImplementedError raise NotImplementedError
@abstractmethod @abc.abstractmethod
def delete_subnet(self, context, id): def delete_subnet(self, context, id):
"""Delete a subnet. """Delete a subnet.
@ -128,7 +127,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def create_network(self, context, network): def create_network(self, context, network):
"""Create a network. """Create a network.
@ -144,7 +143,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def update_network(self, context, id, network): def update_network(self, context, id, network):
"""Update values of a network. """Update values of a network.
@ -158,7 +157,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def get_network(self, context, id, fields=None): def get_network(self, context, id, fields=None):
"""Retrieve a network. """Retrieve a network.
@ -172,7 +171,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def get_networks(self, context, filters=None, fields=None, def get_networks(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None, page_reverse=False): sorts=None, limit=None, marker=None, page_reverse=False):
"""Retrieve a list of networks. """Retrieve a list of networks.
@ -220,7 +219,7 @@ class NeutronPluginBaseV2(object):
""" """
raise NotImplementedError raise NotImplementedError
@abstractmethod @abc.abstractmethod
def delete_network(self, context, id): def delete_network(self, context, id):
"""Delete a network. """Delete a network.
@ -229,7 +228,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def create_port(self, context, port): def create_port(self, context, port):
"""Create a port. """Create a port.
@ -244,7 +243,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def update_port(self, context, id, port): def update_port(self, context, id, port):
"""Update values of a port. """Update values of a port.
@ -257,7 +256,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def get_port(self, context, id, fields=None): def get_port(self, context, id, fields=None):
"""Retrieve a port. """Retrieve a port.
@ -271,7 +270,7 @@ class NeutronPluginBaseV2(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def get_ports(self, context, filters=None, fields=None, def get_ports(self, context, filters=None, fields=None,
sorts=None, limit=None, marker=None, page_reverse=False): sorts=None, limit=None, marker=None, page_reverse=False):
"""Retrieve a list of ports. """Retrieve a list of ports.
@ -316,7 +315,7 @@ class NeutronPluginBaseV2(object):
""" """
raise NotImplementedError raise NotImplementedError
@abstractmethod @abc.abstractmethod
def delete_port(self, context, id): def delete_port(self, context, id):
"""Delete a port. """Delete a port.

View File

@ -16,13 +16,12 @@
# #
# @author: Sumit Naiksatam, Cisco Systems, Inc. # @author: Sumit Naiksatam, Cisco Systems, Inc.
from abc import ABCMeta, abstractmethod import abc
import inspect import inspect
import six import six
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class L2DevicePluginBase(object): class L2DevicePluginBase(object):
"""Base class for a device-specific plugin. """Base class for a device-specific plugin.
@ -31,7 +30,7 @@ class L2DevicePluginBase(object):
the configuration on each device. the configuration on each device.
""" """
@abstractmethod @abc.abstractmethod
def create_network(self, tenant_id, net_name, net_id, vlan_name, vlan_id, def create_network(self, tenant_id, net_name, net_id, vlan_name, vlan_id,
**kwargs): **kwargs):
"""Create network. """Create network.
@ -41,7 +40,7 @@ class L2DevicePluginBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def delete_network(self, tenant_id, net_id, **kwargs): def delete_network(self, tenant_id, net_id, **kwargs):
"""Delete network. """Delete network.
@ -50,7 +49,7 @@ class L2DevicePluginBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def update_network(self, tenant_id, net_id, name, **kwargs): def update_network(self, tenant_id, net_id, name, **kwargs):
"""Update network. """Update network.
@ -59,7 +58,7 @@ class L2DevicePluginBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def create_port(self, tenant_id, net_id, port_state, port_id, **kwargs): def create_port(self, tenant_id, net_id, port_state, port_id, **kwargs):
"""Create port. """Create port.
@ -68,7 +67,7 @@ class L2DevicePluginBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def delete_port(self, tenant_id, net_id, port_id, **kwargs): def delete_port(self, tenant_id, net_id, port_id, **kwargs):
"""Delete port. """Delete port.
@ -77,7 +76,7 @@ class L2DevicePluginBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def update_port(self, tenant_id, net_id, port_id, **kwargs): def update_port(self, tenant_id, net_id, port_id, **kwargs):
"""Update port. """Update port.
@ -86,7 +85,7 @@ class L2DevicePluginBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id, def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id,
**kwargs): **kwargs):
"""Plug interface. """Plug interface.
@ -96,7 +95,7 @@ class L2DevicePluginBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def unplug_interface(self, tenant_id, net_id, port_id, **kwargs): def unplug_interface(self, tenant_id, net_id, port_id, **kwargs):
"""Unplug interface. """Unplug interface.

View File

@ -26,13 +26,12 @@ from neutron.db import external_net_db
from neutron.db import extraroute_db from neutron.db import extraroute_db
from neutron.db import l3_db from neutron.db import l3_db
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.extensions.flavor import (FLAVOR_NETWORK, FLAVOR_ROUTER) from neutron.extensions import flavor as ext_flavor
from neutron.openstack.common import importutils from neutron.openstack.common import importutils
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.metaplugin.common import config # noqa from neutron.plugins.metaplugin.common import config # noqa
from neutron.plugins.metaplugin import meta_db_v2 from neutron.plugins.metaplugin import meta_db_v2
from neutron.plugins.metaplugin.meta_models_v2 import (NetworkFlavor, from neutron.plugins.metaplugin import meta_models_v2
RouterFlavor)
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -40,19 +39,21 @@ LOG = logging.getLogger(__name__)
# Hooks used to select records which belong a target plugin. # Hooks used to select records which belong a target plugin.
def _meta_network_model_hook(context, original_model, query): def _meta_network_model_hook(context, original_model, query):
return query.outerjoin(NetworkFlavor, return query.outerjoin(meta_models_v2.NetworkFlavor,
NetworkFlavor.network_id == models_v2.Network.id) meta_models_v2.NetworkFlavor.network_id ==
models_v2.Network.id)
def _meta_port_model_hook(context, original_model, query): def _meta_port_model_hook(context, original_model, query):
return query.join(NetworkFlavor, return query.join(meta_models_v2.NetworkFlavor,
NetworkFlavor.network_id == models_v2.Port.network_id) meta_models_v2.NetworkFlavor.network_id ==
models_v2.Port.network_id)
def _meta_flavor_filter_hook(query, filters): def _meta_flavor_filter_hook(query, filters):
if FLAVOR_NETWORK in filters: if ext_flavor.FLAVOR_NETWORK in filters:
return query.filter(NetworkFlavor.flavor == return query.filter(meta_models_v2.NetworkFlavor.flavor ==
filters[FLAVOR_NETWORK][0]) filters[ext_flavor.FLAVOR_NETWORK][0])
return query return query
@ -200,11 +201,11 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
def _extend_network_dict(self, context, network): def _extend_network_dict(self, context, network):
flavor = self._get_flavor_by_network_id(context, network['id']) flavor = self._get_flavor_by_network_id(context, network['id'])
network[FLAVOR_NETWORK] = flavor network[ext_flavor.FLAVOR_NETWORK] = flavor
def create_network(self, context, network): def create_network(self, context, network):
n = network['network'] n = network['network']
flavor = n.get(FLAVOR_NETWORK) flavor = n.get(ext_flavor.FLAVOR_NETWORK)
if str(flavor) not in self.plugins: if str(flavor) not in self.plugins:
flavor = self.default_flavor flavor = self.default_flavor
plugin = self._get_plugin(flavor) plugin = self._get_plugin(flavor)
@ -238,7 +239,7 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
plugin = self._get_plugin(flavor) plugin = self._get_plugin(flavor)
net = plugin.get_network(context, id, fields) net = plugin.get_network(context, id, fields)
net['id'] = id net['id'] = id
if not fields or FLAVOR_NETWORK in fields: if not fields or ext_flavor.FLAVOR_NETWORK in fields:
self._extend_network_dict(context, net) self._extend_network_dict(context, net)
if fields and 'id' not in fields: if fields and 'id' not in fields:
del net['id'] del net['id']
@ -247,8 +248,8 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
def get_networks(self, context, filters=None, fields=None): def get_networks(self, context, filters=None, fields=None):
nets = [] nets = []
for flavor, plugin in self.plugins.items(): for flavor, plugin in self.plugins.items():
if (filters and FLAVOR_NETWORK in filters and if (filters and ext_flavor.FLAVOR_NETWORK in filters and
not flavor in filters[FLAVOR_NETWORK]): not flavor in filters[ext_flavor.FLAVOR_NETWORK]):
continue continue
if filters: if filters:
#NOTE: copy each time since a target plugin may modify #NOTE: copy each time since a target plugin may modify
@ -256,11 +257,11 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
plugin_filters = filters.copy() plugin_filters = filters.copy()
else: else:
plugin_filters = {} plugin_filters = {}
plugin_filters[FLAVOR_NETWORK] = [flavor] plugin_filters[ext_flavor.FLAVOR_NETWORK] = [flavor]
plugin_nets = plugin.get_networks(context, plugin_filters, fields) plugin_nets = plugin.get_networks(context, plugin_filters, fields)
for net in plugin_nets: for net in plugin_nets:
if not fields or FLAVOR_NETWORK in fields: if not fields or ext_flavor.FLAVOR_NETWORK in fields:
net[FLAVOR_NETWORK] = flavor net[ext_flavor.FLAVOR_NETWORK] = flavor
nets.append(net) nets.append(net)
return nets return nets
@ -316,7 +317,7 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
plugin_filters = filters.copy() plugin_filters = filters.copy()
else: else:
plugin_filters = {} plugin_filters = {}
plugin_filters[FLAVOR_NETWORK] = [flavor] plugin_filters[ext_flavor.FLAVOR_NETWORK] = [flavor]
ports = plugin.get_ports(context, plugin_filters, fields) ports = plugin.get_ports(context, plugin_filters, fields)
all_ports += ports all_ports += ports
return all_ports return all_ports
@ -343,11 +344,11 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
def _extend_router_dict(self, context, router): def _extend_router_dict(self, context, router):
flavor = self._get_flavor_by_router_id(context, router['id']) flavor = self._get_flavor_by_router_id(context, router['id'])
router[FLAVOR_ROUTER] = flavor router[ext_flavor.FLAVOR_ROUTER] = flavor
def create_router(self, context, router): def create_router(self, context, router):
r = router['router'] r = router['router']
flavor = r.get(FLAVOR_ROUTER) flavor = r.get(ext_flavor.FLAVOR_ROUTER)
if str(flavor) not in self.l3_plugins: if str(flavor) not in self.l3_plugins:
flavor = self.default_l3_flavor flavor = self.default_l3_flavor
plugin = self._get_l3_plugin(flavor) plugin = self._get_l3_plugin(flavor)
@ -381,20 +382,20 @@ class MetaPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
flavor = meta_db_v2.get_flavor_by_router(context.session, id) flavor = meta_db_v2.get_flavor_by_router(context.session, id)
plugin = self._get_l3_plugin(flavor) plugin = self._get_l3_plugin(flavor)
router = plugin.get_router(context, id, fields) router = plugin.get_router(context, id, fields)
if not fields or FLAVOR_ROUTER in fields: if not fields or ext_flavor.FLAVOR_ROUTER in fields:
self._extend_router_dict(context, router) self._extend_router_dict(context, router)
return router return router
def get_routers_with_flavor(self, context, filters=None, def get_routers_with_flavor(self, context, filters=None,
fields=None): fields=None):
collection = self._model_query(context, l3_db.Router) collection = self._model_query(context, l3_db.Router)
r_model = RouterFlavor r_model = meta_models_v2.RouterFlavor
collection = collection.join(r_model, collection = collection.join(r_model,
l3_db.Router.id == r_model.router_id) l3_db.Router.id == r_model.router_id)
if filters: if filters:
for key, value in filters.iteritems(): for key, value in filters.iteritems():
if key == FLAVOR_ROUTER: if key == ext_flavor.FLAVOR_ROUTER:
column = RouterFlavor.flavor column = meta_models_v2.RouterFlavor.flavor
else: else:
column = getattr(l3_db.Router, key, None) column = getattr(l3_db.Router, key, None)
if column: if column:

View File

@ -13,8 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from abc import ABCMeta, abstractmethod, abstractproperty import abc
import six import six
# The following keys are used in the segment dictionaries passed via # The following keys are used in the segment dictionaries passed via
@ -28,7 +27,7 @@ PHYSICAL_NETWORK = 'physical_network'
SEGMENTATION_ID = 'segmentation_id' SEGMENTATION_ID = 'segmentation_id'
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class TypeDriver(object): class TypeDriver(object):
"""Define stable abstract interface for ML2 type drivers. """Define stable abstract interface for ML2 type drivers.
@ -46,7 +45,7 @@ class TypeDriver(object):
either be excluded or stored as None. either be excluded or stored as None.
""" """
@abstractmethod @abc.abstractmethod
def get_type(self): def get_type(self):
"""Get driver's network type. """Get driver's network type.
@ -54,7 +53,7 @@ class TypeDriver(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def initialize(self): def initialize(self):
"""Perform driver initialization. """Perform driver initialization.
@ -64,7 +63,7 @@ class TypeDriver(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def validate_provider_segment(self, segment): def validate_provider_segment(self, segment):
"""Validate attributes of a provider network segment. """Validate attributes of a provider network segment.
@ -84,7 +83,7 @@ class TypeDriver(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def reserve_provider_segment(self, session, segment): def reserve_provider_segment(self, session, segment):
"""Reserve resource associated with a provider network segment. """Reserve resource associated with a provider network segment.
@ -98,7 +97,7 @@ class TypeDriver(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def allocate_tenant_segment(self, session): def allocate_tenant_segment(self, session):
"""Allocate resource for a new tenant network segment. """Allocate resource for a new tenant network segment.
@ -114,7 +113,7 @@ class TypeDriver(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def release_segment(self, session, segment): def release_segment(self, session, segment):
"""Release network segment. """Release network segment.
@ -129,7 +128,7 @@ class TypeDriver(object):
pass pass
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class NetworkContext(object): class NetworkContext(object):
"""Context passed to MechanismDrivers for changes to network resources. """Context passed to MechanismDrivers for changes to network resources.
@ -139,7 +138,7 @@ class NetworkContext(object):
MechanismDrivers can freely access the same information. MechanismDrivers can freely access the same information.
""" """
@abstractproperty @abc.abstractproperty
def current(self): def current(self):
"""Return the current state of the network. """Return the current state of the network.
@ -149,7 +148,7 @@ class NetworkContext(object):
""" """
pass pass
@abstractproperty @abc.abstractproperty
def original(self): def original(self):
"""Return the original state of the network. """Return the original state of the network.
@ -159,13 +158,13 @@ class NetworkContext(object):
""" """
pass pass
@abstractproperty @abc.abstractproperty
def network_segments(self): def network_segments(self):
"""Return the segments associated with this network resource.""" """Return the segments associated with this network resource."""
pass pass
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class SubnetContext(object): class SubnetContext(object):
"""Context passed to MechanismDrivers for changes to subnet resources. """Context passed to MechanismDrivers for changes to subnet resources.
@ -175,7 +174,7 @@ class SubnetContext(object):
MechanismDrivers can freely access the same information. MechanismDrivers can freely access the same information.
""" """
@abstractproperty @abc.abstractproperty
def current(self): def current(self):
"""Return the current state of the subnet. """Return the current state of the subnet.
@ -185,7 +184,7 @@ class SubnetContext(object):
""" """
pass pass
@abstractproperty @abc.abstractproperty
def original(self): def original(self):
"""Return the original state of the subnet. """Return the original state of the subnet.
@ -196,7 +195,7 @@ class SubnetContext(object):
pass pass
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class PortContext(object): class PortContext(object):
"""Context passed to MechanismDrivers for changes to port resources. """Context passed to MechanismDrivers for changes to port resources.
@ -206,7 +205,7 @@ class PortContext(object):
freely access the same information. freely access the same information.
""" """
@abstractproperty @abc.abstractproperty
def current(self): def current(self):
"""Return the current state of the port. """Return the current state of the port.
@ -216,7 +215,7 @@ class PortContext(object):
""" """
pass pass
@abstractproperty @abc.abstractproperty
def original(self): def original(self):
"""Return the original state of the port. """Return the original state of the port.
@ -226,17 +225,17 @@ class PortContext(object):
""" """
pass pass
@abstractproperty @abc.abstractproperty
def network(self): def network(self):
"""Return the NetworkContext associated with this port.""" """Return the NetworkContext associated with this port."""
pass pass
@abstractproperty @abc.abstractproperty
def bound_segment(self): def bound_segment(self):
"""Return the currently bound segment dictionary.""" """Return the currently bound segment dictionary."""
pass pass
@abstractproperty @abc.abstractproperty
def original_bound_segment(self): def original_bound_segment(self):
"""Return the original bound segment dictionary. """Return the original bound segment dictionary.
@ -246,12 +245,12 @@ class PortContext(object):
""" """
pass pass
@abstractproperty @abc.abstractproperty
def bound_driver(self): def bound_driver(self):
"""Return the currently bound mechanism driver name.""" """Return the currently bound mechanism driver name."""
pass pass
@abstractproperty @abc.abstractproperty
def original_bound_driver(self): def original_bound_driver(self):
"""Return the original bound mechanism driver name. """Return the original bound mechanism driver name.
@ -261,7 +260,7 @@ class PortContext(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def host_agents(self, agent_type): def host_agents(self, agent_type):
"""Get agents of the specified type on port's host. """Get agents of the specified type on port's host.
@ -270,7 +269,7 @@ class PortContext(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def set_binding(self, segment_id, vif_type, vif_details): def set_binding(self, segment_id, vif_type, vif_details):
"""Set the binding for the port. """Set the binding for the port.
@ -285,7 +284,7 @@ class PortContext(object):
pass pass
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class MechanismDriver(object): class MechanismDriver(object):
"""Define stable abstract interface for ML2 mechanism drivers. """Define stable abstract interface for ML2 mechanism drivers.
@ -307,7 +306,7 @@ class MechanismDriver(object):
methods that are part of the database transaction. methods that are part of the database transaction.
""" """
@abstractmethod @abc.abstractmethod
def initialize(self): def initialize(self):
"""Perform driver initialization. """Perform driver initialization.

View File

@ -13,8 +13,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from abc import ABCMeta, abstractmethod import abc
import six import six
from neutron.extensions import portbindings from neutron.extensions import portbindings
@ -24,7 +23,7 @@ from neutron.plugins.ml2 import driver_api as api
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class AgentMechanismDriverBase(api.MechanismDriver): class AgentMechanismDriverBase(api.MechanismDriver):
"""Base class for drivers that attach to networks using an L2 agent. """Base class for drivers that attach to networks using an L2 agent.
@ -74,7 +73,7 @@ class AgentMechanismDriverBase(api.MechanismDriver):
LOG.warning(_("Attempting to bind with dead agent: %s"), LOG.warning(_("Attempting to bind with dead agent: %s"),
agent) agent)
@abstractmethod @abc.abstractmethod
def try_to_bind_segment_for_agent(self, context, segment, agent): def try_to_bind_segment_for_agent(self, context, segment, agent):
"""Try to bind with segment for agent. """Try to bind with segment for agent.
@ -94,7 +93,7 @@ class AgentMechanismDriverBase(api.MechanismDriver):
""" """
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class SimpleAgentMechanismDriverBase(AgentMechanismDriverBase): class SimpleAgentMechanismDriverBase(AgentMechanismDriverBase):
"""Base class for simple drivers using an L2 agent. """Base class for simple drivers using an L2 agent.
@ -134,7 +133,7 @@ class SimpleAgentMechanismDriverBase(AgentMechanismDriverBase):
else: else:
return False return False
@abstractmethod @abc.abstractmethod
def check_segment_for_agent(self, segment, agent): def check_segment_for_agent(self, segment, agent):
"""Check if segment can be bound for agent. """Check if segment can be bound for agent.

View File

@ -12,8 +12,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from abc import ABCMeta, abstractmethod import abc
import six import six
from neutron.common import exceptions as exc from neutron.common import exceptions as exc
@ -26,7 +25,7 @@ LOG = log.getLogger(__name__)
TUNNEL = 'tunnel' TUNNEL = 'tunnel'
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class TunnelTypeDriver(api.TypeDriver): class TunnelTypeDriver(api.TypeDriver):
"""Define stable abstract interface for ML2 type drivers. """Define stable abstract interface for ML2 type drivers.
@ -34,7 +33,7 @@ class TunnelTypeDriver(api.TypeDriver):
methods to manage these endpoints. methods to manage these endpoints.
""" """
@abstractmethod @abc.abstractmethod
def add_endpoint(self, ip): def add_endpoint(self, ip):
"""Register the endpoint in the type_driver database. """Register the endpoint in the type_driver database.
@ -42,7 +41,7 @@ class TunnelTypeDriver(api.TypeDriver):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def get_endpoints(self): def get_endpoints(self):
"""Get every endpoint managed by the type_driver """Get every endpoint managed by the type_driver

View File

@ -16,12 +16,11 @@
# @author: Ryota MIBU # @author: Ryota MIBU
# @author: Akihiro MOTOKI # @author: Akihiro MOTOKI
from abc import ABCMeta, abstractmethod import abc
import six import six
@six.add_metaclass(ABCMeta) @six.add_metaclass(abc.ABCMeta)
class OFCDriverBase(object): class OFCDriverBase(object):
"""OpenFlow Controller (OFC) Driver Specification. """OpenFlow Controller (OFC) Driver Specification.
@ -29,7 +28,7 @@ class OFCDriverBase(object):
It would be better that other methods like update_* are implemented. It would be better that other methods like update_* are implemented.
""" """
@abstractmethod @abc.abstractmethod
def create_tenant(self, description, tenant_id=None): def create_tenant(self, description, tenant_id=None):
"""Create a new tenant at OpenFlow Controller. """Create a new tenant at OpenFlow Controller.
@ -41,7 +40,7 @@ class OFCDriverBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def delete_tenant(self, ofc_tenant_id): def delete_tenant(self, ofc_tenant_id):
"""Delete a tenant at OpenFlow Controller. """Delete a tenant at OpenFlow Controller.
@ -49,7 +48,7 @@ class OFCDriverBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def create_network(self, ofc_tenant_id, description, network_id=None): def create_network(self, ofc_tenant_id, description, network_id=None):
"""Create a new network on specified OFC tenant at OpenFlow Controller. """Create a new network on specified OFC tenant at OpenFlow Controller.
@ -64,7 +63,7 @@ class OFCDriverBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def delete_network(self, ofc_network_id): def delete_network(self, ofc_network_id):
"""Delete a netwrok at OpenFlow Controller. """Delete a netwrok at OpenFlow Controller.
@ -72,7 +71,7 @@ class OFCDriverBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def create_port(self, ofc_network_id, portinfo, def create_port(self, ofc_network_id, portinfo,
port_id=None, filters=None): port_id=None, filters=None):
"""Create a new port on specified network at OFC. """Create a new port on specified network at OFC.
@ -97,7 +96,7 @@ class OFCDriverBase(object):
""" """
pass pass
@abstractmethod @abc.abstractmethod
def delete_port(self, ofc_port_id): def delete_port(self, ofc_port_id):
"""Delete a port at OpenFlow Controller. """Delete a port at OpenFlow Controller.

View File

@ -27,7 +27,7 @@ from neutron import context
from neutron.db import api as db from neutron.db import api as db
from neutron.db import db_base_plugin_v2 from neutron.db import db_base_plugin_v2
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.extensions.flavor import (FLAVOR_NETWORK, FLAVOR_ROUTER) from neutron.extensions import flavor as ext_flavor
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.metaplugin.meta_neutron_plugin import ( from neutron.plugins.metaplugin.meta_neutron_plugin import (
FaildToAddFlavorBinding) FaildToAddFlavorBinding)
@ -130,7 +130,7 @@ class MetaNeutronPluginV2Test(base.BaseTestCase):
'shared': False, 'shared': False,
'router:external': [], 'router:external': [],
'tenant_id': self.fake_tenant_id, 'tenant_id': self.fake_tenant_id,
FLAVOR_NETWORK: flavor}} ext_flavor.FLAVOR_NETWORK: flavor}}
return data return data
def _fake_port(self, net_id): def _fake_port(self, net_id):
@ -162,22 +162,22 @@ class MetaNeutronPluginV2Test(base.BaseTestCase):
def _fake_router(self, flavor): def _fake_router(self, flavor):
data = {'router': {'name': flavor, 'admin_state_up': True, data = {'router': {'name': flavor, 'admin_state_up': True,
'tenant_id': self.fake_tenant_id, 'tenant_id': self.fake_tenant_id,
FLAVOR_ROUTER: flavor, ext_flavor.FLAVOR_ROUTER: flavor,
'external_gateway_info': None}} 'external_gateway_info': None}}
return data return data
def test_create_delete_network(self): def test_create_delete_network(self):
network1 = self._fake_network('fake1') network1 = self._fake_network('fake1')
ret1 = self.plugin.create_network(self.context, network1) ret1 = self.plugin.create_network(self.context, network1)
self.assertEqual('fake1', ret1[FLAVOR_NETWORK]) self.assertEqual('fake1', ret1[ext_flavor.FLAVOR_NETWORK])
network2 = self._fake_network('fake2') network2 = self._fake_network('fake2')
ret2 = self.plugin.create_network(self.context, network2) ret2 = self.plugin.create_network(self.context, network2)
self.assertEqual('fake2', ret2[FLAVOR_NETWORK]) self.assertEqual('fake2', ret2[ext_flavor.FLAVOR_NETWORK])
network3 = self._fake_network('proxy') network3 = self._fake_network('proxy')
ret3 = self.plugin.create_network(self.context, network3) ret3 = self.plugin.create_network(self.context, network3)
self.assertEqual('proxy', ret3[FLAVOR_NETWORK]) self.assertEqual('proxy', ret3[ext_flavor.FLAVOR_NETWORK])
db_ret1 = self.plugin.get_network(self.context, ret1['id']) db_ret1 = self.plugin.get_network(self.context, ret1['id'])
self.assertEqual('fake1', db_ret1['name']) self.assertEqual('fake1', db_ret1['name'])
@ -191,8 +191,9 @@ class MetaNeutronPluginV2Test(base.BaseTestCase):
db_ret4 = self.plugin.get_networks(self.context) db_ret4 = self.plugin.get_networks(self.context)
self.assertEqual(3, len(db_ret4)) self.assertEqual(3, len(db_ret4))
db_ret5 = self.plugin.get_networks(self.context, db_ret5 = self.plugin.get_networks(
{FLAVOR_NETWORK: ['fake1']}) self.context,
{ext_flavor.FLAVOR_NETWORK: ['fake1']})
self.assertEqual(1, len(db_ret5)) self.assertEqual(1, len(db_ret5))
self.assertEqual('fake1', db_ret5[0]['name']) self.assertEqual('fake1', db_ret5[0]['name'])
self.plugin.delete_network(self.context, ret1['id']) self.plugin.delete_network(self.context, ret1['id'])
@ -307,14 +308,14 @@ class MetaNeutronPluginV2Test(base.BaseTestCase):
router2 = self._fake_router('fake2') router2 = self._fake_router('fake2')
router_ret2 = self.plugin.create_router(self.context, router2) router_ret2 = self.plugin.create_router(self.context, router2)
self.assertEqual('fake1', router_ret1[FLAVOR_ROUTER]) self.assertEqual('fake1', router_ret1[ext_flavor.FLAVOR_ROUTER])
self.assertEqual('fake2', router_ret2[FLAVOR_ROUTER]) self.assertEqual('fake2', router_ret2[ext_flavor.FLAVOR_ROUTER])
router_in_db1 = self.plugin.get_router(self.context, router_ret1['id']) router_in_db1 = self.plugin.get_router(self.context, router_ret1['id'])
router_in_db2 = self.plugin.get_router(self.context, router_ret2['id']) router_in_db2 = self.plugin.get_router(self.context, router_ret2['id'])
self.assertEqual('fake1', router_in_db1[FLAVOR_ROUTER]) self.assertEqual('fake1', router_in_db1[ext_flavor.FLAVOR_ROUTER])
self.assertEqual('fake2', router_in_db2[FLAVOR_ROUTER]) self.assertEqual('fake2', router_in_db2[ext_flavor.FLAVOR_ROUTER])
self.plugin.delete_router(self.context, router_ret1['id']) self.plugin.delete_router(self.context, router_ret1['id'])
self.plugin.delete_router(self.context, router_ret2['id']) self.plugin.delete_router(self.context, router_ret2['id'])

View File

@ -15,9 +15,8 @@
import mock import mock
import requests import requests
from neutron.services.loadbalancer.drivers.netscaler import ( from neutron.services.loadbalancer.drivers.netscaler import ncc_client
ncc_client, netscaler_driver from neutron.services.loadbalancer.drivers.netscaler import netscaler_driver
)
from neutron.tests.unit import testlib_api from neutron.tests.unit import testlib_api
NCC_CLIENT_CLASS = ('neutron.services.loadbalancer.drivers' NCC_CLIENT_CLASS = ('neutron.services.loadbalancer.drivers'

View File

@ -41,10 +41,9 @@ commands = {posargs}
# E711/E712 comparison to False should be 'if cond is False:' or 'if not cond:' # E711/E712 comparison to False should be 'if cond is False:' or 'if not cond:'
# query = query.filter(Component.disabled == False) # query = query.filter(Component.disabled == False)
# E125 continuation line does not distinguish itself from next logical line # E125 continuation line does not distinguish itself from next logical line
# H301 one import per line
# H302 import only modules # H302 import only modules
# TODO(marun) H404 multi line docstring should start with a summary # TODO(marun) H404 multi line docstring should start with a summary
ignore = E711,E712,E125,H301,H302,H404 ignore = E711,E712,E125,H302,H404
show-source = true show-source = true
builtins = _ builtins = _
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools