Docstrings formatted according to pep257
Bug #1020184 quantum/plugins/cisco/* Change-Id: Ibb6a865a17de0ea4f1865972624e4c5da0e96b34
This commit is contained in:
parent
58d13eb351
commit
ee3bb94b24
@ -17,9 +17,7 @@
|
||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||
# @author: Rohit Agarwalla, Cisco Systems, Inc.
|
||||
|
||||
"""
|
||||
Exceptions used by the Cisco plugin
|
||||
"""
|
||||
"""Exceptions used by the Cisco plugin."""
|
||||
|
||||
from quantum.common import exceptions
|
||||
|
||||
|
@ -41,8 +41,9 @@ class Fault(webob.exc.HTTPException):
|
||||
|
||||
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
||||
def __call__(self, req):
|
||||
"""Generate a WSGI response based on the
|
||||
exception passed to constructor.
|
||||
"""Generate a WSGI response.
|
||||
|
||||
Response is generated based on the exception passed to constructor.
|
||||
"""
|
||||
# Replace the body with fault details.
|
||||
code = self.wrapped_exc.status_int
|
||||
@ -60,7 +61,8 @@ class Fault(webob.exc.HTTPException):
|
||||
|
||||
|
||||
class PortNotFound(webob.exc.HTTPClientError):
|
||||
"""
|
||||
"""PortNotFound exception.
|
||||
|
||||
subclass of :class:`~HTTPClientError`
|
||||
|
||||
This indicates that the server did not find the port specified
|
||||
@ -74,7 +76,8 @@ class PortNotFound(webob.exc.HTTPClientError):
|
||||
|
||||
|
||||
class CredentialNotFound(webob.exc.HTTPClientError):
|
||||
"""
|
||||
"""CredentialNotFound exception.
|
||||
|
||||
subclass of :class:`~HTTPClientError`
|
||||
|
||||
This indicates that the server did not find the Credential specified
|
||||
@ -89,7 +92,8 @@ class CredentialNotFound(webob.exc.HTTPClientError):
|
||||
|
||||
|
||||
class QosNotFound(webob.exc.HTTPClientError):
|
||||
"""
|
||||
"""QosNotFound exception.
|
||||
|
||||
subclass of :class:`~HTTPClientError`
|
||||
|
||||
This indicates that the server did not find the QoS specified
|
||||
@ -104,7 +108,8 @@ class QosNotFound(webob.exc.HTTPClientError):
|
||||
|
||||
|
||||
class NovatenantNotFound(webob.exc.HTTPClientError):
|
||||
"""
|
||||
"""NovatenantNotFound exception.
|
||||
|
||||
subclass of :class:`~HTTPClientError`
|
||||
|
||||
This indicates that the server did not find the Novatenant specified
|
||||
@ -119,7 +124,8 @@ class NovatenantNotFound(webob.exc.HTTPClientError):
|
||||
|
||||
|
||||
class RequestedStateInvalid(webob.exc.HTTPClientError):
|
||||
"""
|
||||
"""RequestedStateInvalid exception.
|
||||
|
||||
subclass of :class:`~HTTPClientError`
|
||||
|
||||
This indicates that the server could not update the port state to
|
||||
|
@ -26,9 +26,9 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get16ByteUUID(uuid):
|
||||
"""
|
||||
Return a 16 byte has of the UUID, used when smaller unique
|
||||
ID is required.
|
||||
"""Return first 16 bytes of UUID.
|
||||
|
||||
Used when smaller unique ID is required.
|
||||
"""
|
||||
return hashlib.md5(uuid).hexdigest()[:16]
|
||||
|
||||
|
@ -88,13 +88,14 @@ nexus_dictionary = {}
|
||||
|
||||
class CiscoConfigOptions():
|
||||
"""Cisco Configuration Options Class."""
|
||||
|
||||
def __init__(self):
|
||||
self._create_nexus_dictionary()
|
||||
|
||||
def _create_nexus_dictionary(self):
|
||||
"""
|
||||
Create the Nexus dictionary from the cisco_plugins.ini
|
||||
NEXUS_SWITCH section(s).
|
||||
"""Create the Nexus dictionary.
|
||||
|
||||
Reads data from cisco_plugins.ini NEXUS_SWITCH section(s).
|
||||
"""
|
||||
for parsed_file in cfg.CONF._cparser.parsed:
|
||||
for parsed_item in parsed_file.keys():
|
||||
|
@ -30,9 +30,10 @@ BASE = models.BASE
|
||||
|
||||
|
||||
def configure_db(options):
|
||||
"""
|
||||
Establish the database, create an engine if needed, and
|
||||
register the models.
|
||||
"""Configure database.
|
||||
|
||||
Establish the database, create an engine if needed, and register the
|
||||
models.
|
||||
|
||||
:param options: Mapping of configuration options
|
||||
"""
|
||||
|
@ -24,6 +24,7 @@ from quantum.plugins.cisco.db.models import BASE
|
||||
|
||||
class L2NetworkBase(object):
|
||||
"""Base class for L2Network Models."""
|
||||
|
||||
__table_args__ = {'mysql_engine': 'InnoDB'}
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
@ -54,7 +55,8 @@ class L2NetworkBase(object):
|
||||
setattr(self, k, v)
|
||||
|
||||
def iteritems(self):
|
||||
"""Make the model object behave like a dict"
|
||||
"""Make the model object behave like a dict.
|
||||
|
||||
Includes attributes from joins.
|
||||
"""
|
||||
local = dict(self)
|
||||
@ -66,6 +68,7 @@ class L2NetworkBase(object):
|
||||
|
||||
class VlanID(BASE, L2NetworkBase):
|
||||
"""Represents a vlan_id usage."""
|
||||
|
||||
__tablename__ = 'vlan_ids'
|
||||
|
||||
vlan_id = Column(Integer, primary_key=True)
|
||||
@ -81,6 +84,7 @@ class VlanID(BASE, L2NetworkBase):
|
||||
|
||||
class VlanBinding(BASE, L2NetworkBase):
|
||||
"""Represents a binding of vlan_id to network_id."""
|
||||
|
||||
__tablename__ = 'vlan_bindings'
|
||||
|
||||
vlan_id = Column(Integer, primary_key=True)
|
||||
@ -101,6 +105,7 @@ class VlanBinding(BASE, L2NetworkBase):
|
||||
|
||||
class QoS(BASE, L2NetworkBase):
|
||||
"""Represents QoS for a tenant."""
|
||||
|
||||
__tablename__ = 'qoss'
|
||||
|
||||
qos_id = Column(String(255))
|
||||
@ -121,6 +126,7 @@ class QoS(BASE, L2NetworkBase):
|
||||
|
||||
class Credential(BASE, L2NetworkBase):
|
||||
"""Represents credentials for a tenant."""
|
||||
|
||||
__tablename__ = 'credentials'
|
||||
|
||||
credential_id = Column(String(255))
|
||||
|
@ -30,6 +30,7 @@ BASE = declarative_base()
|
||||
|
||||
class QuantumBase(object):
|
||||
"""Base class for Quantum Models."""
|
||||
|
||||
__table_args__ = {'mysql_engine': 'InnoDB'}
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
@ -56,6 +57,7 @@ class QuantumBase(object):
|
||||
|
||||
def iteritems(self):
|
||||
"""Make the model object behave like a dict.
|
||||
|
||||
Includes attributes from joins.
|
||||
"""
|
||||
local = dict(self)
|
||||
@ -67,6 +69,7 @@ class QuantumBase(object):
|
||||
|
||||
class Port(BASE, QuantumBase):
|
||||
"""Represents a port on a quantum network."""
|
||||
|
||||
__tablename__ = 'ports'
|
||||
|
||||
uuid = Column(String(255), primary_key=True)
|
||||
@ -88,6 +91,7 @@ class Port(BASE, QuantumBase):
|
||||
|
||||
class Network(BASE, QuantumBase):
|
||||
"""Represents a quantum network."""
|
||||
|
||||
__tablename__ = 'networks'
|
||||
|
||||
uuid = Column(String(255), primary_key=True)
|
||||
|
@ -26,6 +26,7 @@ from quantum.openstack.common import uuidutils
|
||||
|
||||
class L2NetworkBase(object):
|
||||
"""Base class for L2Network Models."""
|
||||
|
||||
#__table_args__ = {'mysql_engine': 'InnoDB'}
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
@ -56,7 +57,8 @@ class L2NetworkBase(object):
|
||||
setattr(self, k, v)
|
||||
|
||||
def iteritems(self):
|
||||
"""Make the model object behave like a dict"
|
||||
"""Make the model object behave like a dict.
|
||||
|
||||
Includes attributes from joins.
|
||||
"""
|
||||
local = dict(self)
|
||||
@ -103,6 +105,7 @@ class Vlan_Binding(model_base.BASEV2, L2NetworkBase):
|
||||
|
||||
class QoS(model_base.BASEV2, L2NetworkBase):
|
||||
"""Represents QoS for a tenant."""
|
||||
|
||||
__tablename__ = 'qoss'
|
||||
|
||||
qos_id = Column(String(255))
|
||||
@ -123,6 +126,7 @@ class QoS(model_base.BASEV2, L2NetworkBase):
|
||||
|
||||
class Credential(model_base.BASEV2, L2NetworkBase):
|
||||
"""Represents credentials for a tenant."""
|
||||
|
||||
__tablename__ = 'credentials'
|
||||
|
||||
credential_id = Column(String(255))
|
||||
|
@ -23,6 +23,7 @@ from quantum.plugins.cisco.db.l2network_models import L2NetworkBase
|
||||
|
||||
class NexusPortBinding(model_base.BASEV2, L2NetworkBase):
|
||||
"""Represents a binding of VM's to nexus ports."""
|
||||
|
||||
__tablename__ = "nexusport_bindings"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
|
@ -19,18 +19,16 @@
|
||||
|
||||
|
||||
def get_view_builder(req):
|
||||
"""get view builder."""
|
||||
base_url = req.application_url
|
||||
return ViewBuilder(base_url)
|
||||
|
||||
|
||||
class ViewBuilder(object):
|
||||
"""
|
||||
ViewBuilder for Credential,
|
||||
derived from quantum.views.networks
|
||||
"""
|
||||
"""ViewBuilder for Credential, derived from quantum.views.networks."""
|
||||
|
||||
def __init__(self, base_url):
|
||||
"""
|
||||
"""Initialize builder.
|
||||
|
||||
:param base_url: url of the root wsgi application
|
||||
"""
|
||||
self.base_url = base_url
|
||||
|
@ -19,18 +19,16 @@
|
||||
|
||||
|
||||
def get_view_builder(req):
|
||||
"""get view builder."""
|
||||
base_url = req.application_url
|
||||
return ViewBuilder(base_url)
|
||||
|
||||
|
||||
class ViewBuilder(object):
|
||||
"""
|
||||
ViewBuilder for QoS,
|
||||
derived from quantum.views.networks
|
||||
"""
|
||||
"""ViewBuilder for QoS, derived from quantum.views.networks."""
|
||||
|
||||
def __init__(self, base_url):
|
||||
"""
|
||||
"""Initialize builder.
|
||||
|
||||
:param base_url: url of the root wsgi application
|
||||
"""
|
||||
self.base_url = base_url
|
||||
|
@ -31,7 +31,7 @@ from quantum import wsgi
|
||||
|
||||
|
||||
class Credential(extensions.ExtensionDescriptor):
|
||||
"""extension class Credential."""
|
||||
"""Extension class Credential."""
|
||||
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
|
@ -21,8 +21,8 @@ import inspect
|
||||
|
||||
|
||||
class L2DevicePluginBase(object):
|
||||
"""
|
||||
Base class for a device-specific plugin.
|
||||
"""Base class for a device-specific plugin.
|
||||
|
||||
An example of a device-specific plugin is a Nexus switch plugin.
|
||||
The network model relies on device-category-specific plugins to perform
|
||||
the configuration on each device.
|
||||
@ -32,7 +32,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@abstractmethod
|
||||
def get_all_networks(self, tenant_id, **kwargs):
|
||||
"""
|
||||
"""Get newtorks.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -41,7 +42,8 @@ class L2DevicePluginBase(object):
|
||||
@abstractmethod
|
||||
def create_network(self, tenant_id, net_name, net_id, vlan_name, vlan_id,
|
||||
**kwargs):
|
||||
"""
|
||||
"""Create network.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -49,7 +51,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@abstractmethod
|
||||
def delete_network(self, tenant_id, net_id, **kwargs):
|
||||
"""
|
||||
"""Delete network.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -57,7 +60,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@abstractmethod
|
||||
def get_network_details(self, tenant_id, net_id, **kwargs):
|
||||
"""
|
||||
"""Get network details.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -65,7 +69,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@abstractmethod
|
||||
def update_network(self, tenant_id, net_id, name, **kwargs):
|
||||
"""
|
||||
"""Update network.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -73,7 +78,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@abstractmethod
|
||||
def get_all_ports(self, tenant_id, net_id, **kwargs):
|
||||
"""
|
||||
"""Get ports.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -81,7 +87,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@abstractmethod
|
||||
def create_port(self, tenant_id, net_id, port_state, port_id, **kwargs):
|
||||
"""
|
||||
"""Create port.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -89,7 +96,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@abstractmethod
|
||||
def delete_port(self, tenant_id, net_id, port_id, **kwargs):
|
||||
"""
|
||||
"""Delete port.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -97,7 +105,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@abstractmethod
|
||||
def update_port(self, tenant_id, net_id, port_id, **kwargs):
|
||||
"""
|
||||
"""Update port.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -105,7 +114,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@abstractmethod
|
||||
def get_port_details(self, tenant_id, net_id, port_id, **kwargs):
|
||||
"""
|
||||
"""Get port details.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -114,7 +124,8 @@ class L2DevicePluginBase(object):
|
||||
@abstractmethod
|
||||
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id,
|
||||
**kwargs):
|
||||
"""
|
||||
"""Plug interface.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -122,7 +133,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@abstractmethod
|
||||
def unplug_interface(self, tenant_id, net_id, port_id, **kwargs):
|
||||
"""
|
||||
"""Unplug interface.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -130,35 +142,40 @@ class L2DevicePluginBase(object):
|
||||
|
||||
def create_subnet(self, tenant_id, net_id, ip_version,
|
||||
subnet_cidr, **kwargs):
|
||||
"""
|
||||
"""Create subnet.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
pass
|
||||
|
||||
def get_subnets(self, tenant_id, net_id, **kwargs):
|
||||
"""
|
||||
"""Get subnets.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
pass
|
||||
|
||||
def get_subnet(self, tenant_id, net_id, subnet_id, **kwargs):
|
||||
"""
|
||||
"""Get subnet.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
pass
|
||||
|
||||
def update_subnet(self, tenant_id, net_id, subnet_id, **kwargs):
|
||||
"""
|
||||
"""Update subnet.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
pass
|
||||
|
||||
def delete_subnet(self, tenant_id, net_id, subnet_id, **kwargs):
|
||||
"""
|
||||
"""Delete subnet.
|
||||
|
||||
:returns:
|
||||
:raises:
|
||||
"""
|
||||
@ -166,7 +183,8 @@ class L2DevicePluginBase(object):
|
||||
|
||||
@classmethod
|
||||
def __subclasshook__(cls, klass):
|
||||
"""
|
||||
"""Check plugin class.
|
||||
|
||||
The __subclasshook__ method is a class method
|
||||
that will be called everytime a class is tested
|
||||
using issubclass(klass, Plugin).
|
||||
|
@ -40,7 +40,8 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
"""
|
||||
"""Virtual Physical Switch Model.
|
||||
|
||||
This implementation works with OVS and Nexus plugin for the
|
||||
following topology:
|
||||
One or more servers to a nexus switch.
|
||||
@ -58,10 +59,10 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
'get_subnet', 'get_subnets', ]
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize the segmentation manager, check which device plugins are
|
||||
configured, and load the inventories those device plugins for which the
|
||||
inventory is configured
|
||||
"""Initialize the segmentation manager.
|
||||
|
||||
Checks which device plugins are configured, and load the inventories
|
||||
those device plugins for which the inventory is configured.
|
||||
"""
|
||||
conf.CiscoConfigOptions()
|
||||
|
||||
@ -90,7 +91,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
'name': self.__class__.__name__})
|
||||
|
||||
def __getattribute__(self, name):
|
||||
"""
|
||||
"""Delegate calls to OVS sub-plugin.
|
||||
|
||||
This delegates the calls to the methods implemented only by the OVS
|
||||
sub-plugin. Note: Currently, bulking is handled by the caller
|
||||
(PluginV2), and this model class expects to receive only non-bulking
|
||||
@ -118,7 +120,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
return func_name
|
||||
|
||||
def _invoke_plugin_per_device(self, plugin_key, function_name, args):
|
||||
"""
|
||||
"""Invoke plugin per device.
|
||||
|
||||
Invokes a device plugin's relevant functions (based on the
|
||||
plugin implementation) for completing this operation.
|
||||
"""
|
||||
@ -135,7 +138,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
device_params)]
|
||||
|
||||
def _invoke_plugin(self, plugin_key, function_name, args, kwargs):
|
||||
"""
|
||||
"""Invoke plugin.
|
||||
|
||||
Invokes the relevant function on a device plugin's
|
||||
implementation for completing this operation.
|
||||
"""
|
||||
@ -189,7 +193,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
return host
|
||||
|
||||
def create_network(self, context, network):
|
||||
"""
|
||||
"""Create network.
|
||||
|
||||
Perform this operation in the context of the configured device
|
||||
plugins.
|
||||
"""
|
||||
@ -213,7 +218,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
raise
|
||||
|
||||
def update_network(self, context, id, network):
|
||||
"""
|
||||
"""Update network.
|
||||
|
||||
Perform this operation in the context of the configured device
|
||||
plugins.
|
||||
"""
|
||||
@ -235,7 +241,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
return ovs_output[0]
|
||||
|
||||
def delete_network(self, context, id):
|
||||
"""
|
||||
"""Delete network.
|
||||
|
||||
Perform this operation in the context of the configured device
|
||||
plugins.
|
||||
"""
|
||||
@ -286,7 +293,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
return nexus_output
|
||||
|
||||
def create_port(self, context, port):
|
||||
"""
|
||||
"""Create port.
|
||||
|
||||
Perform this operation in the context of the configured device
|
||||
plugins.
|
||||
"""
|
||||
@ -323,7 +331,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
pass
|
||||
|
||||
def update_port(self, context, id, port):
|
||||
"""
|
||||
"""Update port.
|
||||
|
||||
Perform this operation in the context of the configured device
|
||||
plugins.
|
||||
"""
|
||||
@ -354,7 +363,8 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
||||
raise
|
||||
|
||||
def delete_port(self, context, id):
|
||||
"""
|
||||
"""Delete port.
|
||||
|
||||
Perform this operation in the context of the configured device
|
||||
plugins.
|
||||
"""
|
||||
|
@ -34,9 +34,8 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
"""
|
||||
Meta-Plugin with v2 API support for multiple sub-plugins.
|
||||
"""
|
||||
"""Meta-Plugin with v2 API support for multiple sub-plugins."""
|
||||
|
||||
supported_extension_aliases = ["Cisco Credential", "Cisco qos"]
|
||||
_methods_to_delegate = ['create_network',
|
||||
'delete_network', 'update_network', 'get_network',
|
||||
@ -49,9 +48,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
_master = True
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Loads the model class.
|
||||
"""
|
||||
"""Load the model class."""
|
||||
self._model = importutils.import_object(config.CISCO.model_class)
|
||||
if hasattr(self._model, "MANAGE_STATE") and self._model.MANAGE_STATE:
|
||||
self._master = False
|
||||
@ -68,7 +65,8 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
LOG.debug(_("Plugin initialization complete"))
|
||||
|
||||
def __getattribute__(self, name):
|
||||
"""
|
||||
"""Delegate core API calls to the model class.
|
||||
|
||||
When the configured model class offers to manage the state of the
|
||||
logical resources, we delegate the core API calls directly to it.
|
||||
Note: Bulking calls will be handled by this class, and turned into
|
||||
@ -83,7 +81,8 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
return object.__getattribute__(self, name)
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""
|
||||
"""Delegate calls to the extensions.
|
||||
|
||||
This delegates the calls to the extensions explicitly implemented by
|
||||
the model.
|
||||
"""
|
||||
@ -99,10 +98,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
Core API implementation
|
||||
"""
|
||||
def create_network(self, context, network):
|
||||
"""
|
||||
Creates a new Virtual Network, and assigns it
|
||||
a symbolic name.
|
||||
"""
|
||||
"""Create new Virtual Network, and assigns it a symbolic name."""
|
||||
LOG.debug(_("create_network() called"))
|
||||
new_network = super(PluginV2, self).create_network(context,
|
||||
network)
|
||||
@ -116,9 +112,9 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
raise
|
||||
|
||||
def update_network(self, context, id, network):
|
||||
"""
|
||||
Updates the symbolic name belonging to a particular
|
||||
Virtual Network.
|
||||
"""Update network.
|
||||
|
||||
Updates the symbolic name belonging to a particular Virtual Network.
|
||||
"""
|
||||
LOG.debug(_("update_network() called"))
|
||||
upd_net_dict = super(PluginV2, self).update_network(context, id,
|
||||
@ -128,7 +124,8 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
return upd_net_dict
|
||||
|
||||
def delete_network(self, context, id):
|
||||
"""
|
||||
"""Delete network.
|
||||
|
||||
Deletes the network with the specified network identifier
|
||||
belonging to the specified tenant.
|
||||
"""
|
||||
@ -157,23 +154,17 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
raise
|
||||
|
||||
def get_network(self, context, id, fields=None):
|
||||
"""
|
||||
Gets a particular network
|
||||
"""
|
||||
"""Get a particular network."""
|
||||
LOG.debug(_("get_network() called"))
|
||||
return super(PluginV2, self).get_network(context, id, fields)
|
||||
|
||||
def get_networks(self, context, filters=None, fields=None):
|
||||
"""
|
||||
Gets all networks
|
||||
"""
|
||||
"""Get all networks."""
|
||||
LOG.debug(_("get_networks() called"))
|
||||
return super(PluginV2, self).get_networks(context, filters, fields)
|
||||
|
||||
def create_port(self, context, port):
|
||||
"""
|
||||
Creates a port on the specified Virtual Network.
|
||||
"""
|
||||
"""Create a port on the specified Virtual Network."""
|
||||
LOG.debug(_("create_port() called"))
|
||||
new_port = super(PluginV2, self).create_port(context, port)
|
||||
try:
|
||||
@ -184,18 +175,16 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
raise
|
||||
|
||||
def delete_port(self, context, id):
|
||||
"""
|
||||
Deletes a port
|
||||
"""
|
||||
LOG.debug(_("delete_port() called"))
|
||||
port = self._get_port(context, id)
|
||||
"""
|
||||
"""Delete port.
|
||||
|
||||
TODO (Sumit): Disabling this check for now, check later
|
||||
#Allow deleting a port only if the administrative state is down,
|
||||
#and its operation status is also down
|
||||
if port['admin_state_up'] or port['status'] == 'ACTIVE':
|
||||
raise exc.PortInUse(port_id=id, net_id=port['network_id'],
|
||||
att_id=port['device_id'])
|
||||
Allow deleting a port only if the administrative state is down,
|
||||
and its operation status is also down
|
||||
#if port['admin_state_up'] or port['status'] == 'ACTIVE':
|
||||
# raise exc.PortInUse(port_id=id, net_id=port['network_id'],
|
||||
# att_id=port['device_id'])
|
||||
"""
|
||||
try:
|
||||
kwargs = {const.PORT: port}
|
||||
@ -207,9 +196,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
raise
|
||||
|
||||
def update_port(self, context, id, port):
|
||||
"""
|
||||
Updates the state of a port and returns the updated port
|
||||
"""
|
||||
"""Update the state of a port and return the updated port."""
|
||||
LOG.debug(_("update_port() called"))
|
||||
try:
|
||||
self._invoke_device_plugins(self._func_name(), [context, id,
|
||||
@ -219,7 +206,8 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
raise
|
||||
|
||||
def create_subnet(self, context, subnet):
|
||||
"""
|
||||
"""Create subnet.
|
||||
|
||||
Create a subnet, which represents a range of IP addresses
|
||||
that can be allocated to devices.
|
||||
"""
|
||||
@ -234,9 +222,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
raise
|
||||
|
||||
def update_subnet(self, context, id, subnet):
|
||||
"""
|
||||
Updates the state of a subnet and returns the updated subnet
|
||||
"""
|
||||
"""Updates the state of a subnet and returns the updated subnet."""
|
||||
LOG.debug(_("update_subnet() called"))
|
||||
try:
|
||||
self._invoke_device_plugins(self._func_name(), [context, id,
|
||||
@ -246,9 +232,6 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
raise
|
||||
|
||||
def delete_subnet(self, context, id):
|
||||
"""
|
||||
Deletes a subnet
|
||||
"""
|
||||
LOG.debug(_("delete_subnet() called"))
|
||||
with context.session.begin():
|
||||
subnet = self._get_subnet(context, id)
|
||||
@ -372,8 +355,9 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
return host_list
|
||||
|
||||
def associate_port(self, tenant_id, instance_id, instance_desc):
|
||||
"""
|
||||
Get the portprofile name and the device name for the dynamic vnic
|
||||
"""Associate port.
|
||||
|
||||
Get the portprofile name and the device name for the dynamic vnic.
|
||||
"""
|
||||
LOG.debug(_("associate_port() called"))
|
||||
return self._invoke_device_plugins(self._func_name(), [tenant_id,
|
||||
@ -381,9 +365,7 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
instance_desc])
|
||||
|
||||
def detach_port(self, tenant_id, instance_id, instance_desc):
|
||||
"""
|
||||
Remove the association of the VIF with the dynamic vnic
|
||||
"""
|
||||
"""Remove the association of the VIF with the dynamic vnic."""
|
||||
LOG.debug(_("detach_port() called"))
|
||||
return self._invoke_device_plugins(self._func_name(), [tenant_id,
|
||||
instance_id,
|
||||
@ -393,9 +375,9 @@ class PluginV2(db_base_plugin_v2.QuantumDbPluginV2):
|
||||
Private functions
|
||||
"""
|
||||
def _invoke_device_plugins(self, function_name, args):
|
||||
"""
|
||||
Device-specific calls including core API and extensions are
|
||||
delegated to the model.
|
||||
"""Device-specific calls.
|
||||
|
||||
Including core API and extensions are delegated to the model.
|
||||
"""
|
||||
if hasattr(self._model, function_name):
|
||||
return getattr(self._model, function_name)(*args)
|
||||
|
@ -33,66 +33,56 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CiscoNEXUSDriver():
|
||||
"""
|
||||
Nexus Driver Main Class
|
||||
"""
|
||||
"""Nexus Driver Main Class."""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def nxos_connect(self, nexus_host, nexus_ssh_port, nexus_user,
|
||||
nexus_password):
|
||||
"""
|
||||
Makes the SSH connection to the Nexus Switch
|
||||
"""
|
||||
"""Make SSH connection to the Nexus Switch."""
|
||||
man = manager.connect(host=nexus_host, port=nexus_ssh_port,
|
||||
username=nexus_user, password=nexus_password)
|
||||
return man
|
||||
|
||||
def create_xml_snippet(self, cutomized_config):
|
||||
"""
|
||||
Creates the Proper XML structure for the Nexus Switch Configuration
|
||||
"""Create XML snippet.
|
||||
|
||||
Creates the Proper XML structure for the Nexus Switch Configuration.
|
||||
"""
|
||||
conf_xml_snippet = snipp.EXEC_CONF_SNIPPET % (cutomized_config)
|
||||
return conf_xml_snippet
|
||||
|
||||
def enable_vlan(self, mgr, vlanid, vlanname):
|
||||
"""
|
||||
Creates a VLAN on Nexus Switch given the VLAN ID and Name
|
||||
"""
|
||||
"""Creates a VLAN on Nexus Switch given the VLAN ID and Name."""
|
||||
confstr = snipp.CMD_VLAN_CONF_SNIPPET % (vlanid, vlanname)
|
||||
confstr = self.create_xml_snippet(confstr)
|
||||
mgr.edit_config(target='running', config=confstr)
|
||||
|
||||
def disable_vlan(self, mgr, vlanid):
|
||||
"""
|
||||
Delete a VLAN on Nexus Switch given the VLAN ID
|
||||
"""
|
||||
"""Delete a VLAN on Nexus Switch given the VLAN ID."""
|
||||
confstr = snipp.CMD_NO_VLAN_CONF_SNIPPET % vlanid
|
||||
confstr = self.create_xml_snippet(confstr)
|
||||
mgr.edit_config(target='running', config=confstr)
|
||||
|
||||
def enable_port_trunk(self, mgr, interface):
|
||||
"""
|
||||
Enables trunk mode an interface on Nexus Switch
|
||||
"""
|
||||
"""Enable trunk mode an interface on Nexus Switch."""
|
||||
confstr = snipp.CMD_PORT_TRUNK % (interface)
|
||||
confstr = self.create_xml_snippet(confstr)
|
||||
LOG.debug(_("NexusDriver: %s"), confstr)
|
||||
mgr.edit_config(target='running', config=confstr)
|
||||
|
||||
def disable_switch_port(self, mgr, interface):
|
||||
"""
|
||||
Disables trunk mode an interface on Nexus Switch
|
||||
"""
|
||||
"""Disable trunk mode an interface on Nexus Switch."""
|
||||
confstr = snipp.CMD_NO_SWITCHPORT % (interface)
|
||||
confstr = self.create_xml_snippet(confstr)
|
||||
LOG.debug(_("NexusDriver: %s"), confstr)
|
||||
mgr.edit_config(target='running', config=confstr)
|
||||
|
||||
def enable_vlan_on_trunk_int(self, mgr, interface, vlanid):
|
||||
"""
|
||||
"""Enable vlan in trunk interface.
|
||||
|
||||
Enables trunk mode vlan access an interface on Nexus Switch given
|
||||
VLANID
|
||||
VLANID.
|
||||
"""
|
||||
confstr = snipp.CMD_VLAN_INT_SNIPPET % (interface, vlanid)
|
||||
confstr = self.create_xml_snippet(confstr)
|
||||
@ -100,9 +90,10 @@ class CiscoNEXUSDriver():
|
||||
mgr.edit_config(target='running', config=confstr)
|
||||
|
||||
def disable_vlan_on_trunk_int(self, mgr, interface, vlanid):
|
||||
"""
|
||||
Enables trunk mode vlan access an interface on Nexus Switch given
|
||||
VLANID
|
||||
"""Disable VLAN.
|
||||
|
||||
Disables trunk mode vlan access an interface on Nexus Switch given
|
||||
VLANID.
|
||||
"""
|
||||
confstr = snipp.CMD_NO_VLAN_INT_SNIPPET % (interface, vlanid)
|
||||
confstr = self.create_xml_snippet(confstr)
|
||||
@ -112,9 +103,10 @@ class CiscoNEXUSDriver():
|
||||
def create_vlan(self, vlan_name, vlan_id, nexus_host, nexus_user,
|
||||
nexus_password, nexus_ports,
|
||||
nexus_ssh_port, vlan_ids=None):
|
||||
"""
|
||||
"""Create VLAN and enablt in on the interface.
|
||||
|
||||
Creates a VLAN and Enable on trunk mode an interface on Nexus Switch
|
||||
given the VLAN ID and Name and Interface Number
|
||||
given the VLAN ID and Name and Interface Number.
|
||||
"""
|
||||
man = self.nxos_connect(nexus_host, int(nexus_ssh_port),
|
||||
nexus_user, nexus_password)
|
||||
@ -127,9 +119,10 @@ class CiscoNEXUSDriver():
|
||||
|
||||
def delete_vlan(self, vlan_id, nexus_host, nexus_user, nexus_password,
|
||||
nexus_ports, nexus_ssh_port):
|
||||
"""
|
||||
"""Delete vlan.
|
||||
|
||||
Delete a VLAN and Disables trunk mode an interface on Nexus Switch
|
||||
given the VLAN ID and Interface Number
|
||||
given the VLAN ID and Interface Number.
|
||||
"""
|
||||
man = self.nxos_connect(nexus_host, int(nexus_ssh_port),
|
||||
nexus_user, nexus_password)
|
||||
@ -138,9 +131,7 @@ class CiscoNEXUSDriver():
|
||||
self.disable_vlan_on_trunk_int(man, ports, vlan_id)
|
||||
|
||||
def build_vlans_cmd(self):
|
||||
"""
|
||||
Builds a string with all the VLANs on the same Switch
|
||||
"""
|
||||
"""Builds a string with all the VLANs on the same Switch."""
|
||||
assigned_vlan = cdb.get_all_vlanids_used()
|
||||
vlans = ''
|
||||
for vlanid in assigned_vlan:
|
||||
@ -151,8 +142,9 @@ class CiscoNEXUSDriver():
|
||||
|
||||
def add_vlan_int(self, vlan_id, nexus_host, nexus_user, nexus_password,
|
||||
nexus_ports, nexus_ssh_port, vlan_ids=None):
|
||||
"""
|
||||
Adds a vlan from interfaces on the Nexus switch given the VLAN ID
|
||||
"""Add vlan.
|
||||
|
||||
Adds a vlan from interfaces on the Nexus switch given the VLAN ID.
|
||||
"""
|
||||
man = self.nxos_connect(nexus_host, int(nexus_ssh_port),
|
||||
nexus_user, nexus_password)
|
||||
@ -163,8 +155,9 @@ class CiscoNEXUSDriver():
|
||||
|
||||
def remove_vlan_int(self, vlan_id, nexus_host, nexus_user, nexus_password,
|
||||
nexus_ports, nexus_ssh_port):
|
||||
"""
|
||||
Removes a vlan from interfaces on the Nexus switch given the VLAN ID
|
||||
"""Remove vlan.
|
||||
|
||||
Removes a vlan from interfaces on the Nexus switch given the VLAN ID.
|
||||
"""
|
||||
man = self.nxos_connect(nexus_host, int(nexus_ssh_port),
|
||||
nexus_user, nexus_password)
|
||||
|
@ -40,15 +40,11 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NexusPlugin(L2DevicePluginBase):
|
||||
"""
|
||||
Nexus PLugIn Main Class
|
||||
"""
|
||||
"""Nexus PlugIn Main Class."""
|
||||
_networks = {}
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Extracts the configuration parameters from the configuration file
|
||||
"""
|
||||
"""Extract configuration parameters from the configuration file."""
|
||||
self._client = importutils.import_object(conf.CISCO.nexus_driver)
|
||||
LOG.debug(_("Loaded driver %s"), conf.CISCO.nexus_driver)
|
||||
self._nexus_switches = conf.get_nexus_dictionary()
|
||||
@ -65,9 +61,9 @@ class NexusPlugin(L2DevicePluginBase):
|
||||
return self.credentials[nexus_ip]
|
||||
|
||||
def get_all_networks(self, tenant_id):
|
||||
"""
|
||||
Returns a dictionary containing all
|
||||
<network_uuid, network_name> for
|
||||
"""Get all networks.
|
||||
|
||||
Returns a dictionary containing all <network_uuid, network_name> for
|
||||
the specified tenant.
|
||||
"""
|
||||
LOG.debug(_("NexusPlugin:get_all_networks() called"))
|
||||
@ -75,10 +71,10 @@ class NexusPlugin(L2DevicePluginBase):
|
||||
|
||||
def create_network(self, tenant_id, net_name, net_id, vlan_name, vlan_id,
|
||||
host, instance):
|
||||
"""
|
||||
Create a VLAN in the appropriate switch/port,
|
||||
and configure the appropriate interfaces
|
||||
for this VLAN
|
||||
"""Create network.
|
||||
|
||||
Create a VLAN in the appropriate switch/port, and configure the
|
||||
appropriate interfaces for this VLAN.
|
||||
"""
|
||||
LOG.debug(_("NexusPlugin:create_network() called"))
|
||||
# Grab the switch IP and port for this host
|
||||
@ -129,46 +125,44 @@ class NexusPlugin(L2DevicePluginBase):
|
||||
return new_net_dict
|
||||
|
||||
def delete_network(self, tenant_id, net_id, **kwargs):
|
||||
"""
|
||||
"""Delete network.
|
||||
|
||||
Deletes the VLAN in all switches, and removes the VLAN configuration
|
||||
from the relevant interfaces
|
||||
from the relevant interfaces.
|
||||
"""
|
||||
LOG.debug(_("NexusPlugin:delete_network() called"))
|
||||
|
||||
def get_network_details(self, tenant_id, net_id, **kwargs):
|
||||
"""
|
||||
Returns the details of a particular network
|
||||
"""
|
||||
"""Return the details of a particular network."""
|
||||
LOG.debug(_("NexusPlugin:get_network_details() called"))
|
||||
network = self._get_network(tenant_id, net_id)
|
||||
return network
|
||||
|
||||
def update_network(self, tenant_id, net_id, **kwargs):
|
||||
"""
|
||||
Updates the properties of a particular
|
||||
Virtual Network.
|
||||
"""
|
||||
"""Update the properties of a particular Virtual Network."""
|
||||
LOG.debug(_("NexusPlugin:update_network() called"))
|
||||
|
||||
def get_all_ports(self, tenant_id, net_id, **kwargs):
|
||||
"""
|
||||
"""Get all ports.
|
||||
|
||||
This is probably not applicable to the Nexus plugin.
|
||||
Delete if not required.
|
||||
"""
|
||||
LOG.debug(_("NexusPlugin:get_all_ports() called"))
|
||||
|
||||
def create_port(self, tenant_id, net_id, port_state, port_id, **kwargs):
|
||||
"""
|
||||
"""Create port.
|
||||
|
||||
This is probably not applicable to the Nexus plugin.
|
||||
Delete if not required.
|
||||
"""
|
||||
LOG.debug(_("NexusPlugin:create_port() called"))
|
||||
|
||||
def delete_port(self, device_id, vlan_id):
|
||||
"""
|
||||
Delete port bindings from the database and scan
|
||||
whether the network is still required on
|
||||
the interfaces trunked
|
||||
"""Delete port.
|
||||
|
||||
Delete port bindings from the database and scan whether the network
|
||||
is still required on the interfaces trunked.
|
||||
"""
|
||||
LOG.debug(_("NexusPlugin:delete_port() called"))
|
||||
# Delete DB row for this port
|
||||
@ -198,14 +192,16 @@ class NexusPlugin(L2DevicePluginBase):
|
||||
return row['instance_id']
|
||||
|
||||
def update_port(self, tenant_id, net_id, port_id, port_state, **kwargs):
|
||||
"""
|
||||
"""Update port.
|
||||
|
||||
This is probably not applicable to the Nexus plugin.
|
||||
Delete if not required.
|
||||
"""
|
||||
LOG.debug(_("NexusPlugin:update_port() called"))
|
||||
|
||||
def get_port_details(self, tenant_id, net_id, port_id, **kwargs):
|
||||
"""
|
||||
"""Get port details.
|
||||
|
||||
This is probably not applicable to the Nexus plugin.
|
||||
Delete if not required.
|
||||
"""
|
||||
@ -213,14 +209,16 @@ class NexusPlugin(L2DevicePluginBase):
|
||||
|
||||
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id,
|
||||
**kwargs):
|
||||
"""
|
||||
"""Plug interfaces.
|
||||
|
||||
This is probably not applicable to the Nexus plugin.
|
||||
Delete if not required.
|
||||
"""
|
||||
LOG.debug(_("NexusPlugin:plug_interface() called"))
|
||||
|
||||
def unplug_interface(self, tenant_id, net_id, port_id, **kwargs):
|
||||
"""
|
||||
"""Unplug interface.
|
||||
|
||||
This is probably not applicable to the Nexus plugin.
|
||||
Delete if not required.
|
||||
"""
|
||||
@ -228,16 +226,12 @@ class NexusPlugin(L2DevicePluginBase):
|
||||
|
||||
def _get_vlan_id_for_network(self, tenant_id, network_id, context,
|
||||
base_plugin_ref):
|
||||
"""
|
||||
Obtain the VLAN ID given the Network ID
|
||||
"""
|
||||
"""Obtain the VLAN ID given the Network ID."""
|
||||
vlan = cdb.get_vlan_binding(network_id)
|
||||
return vlan.vlan_id
|
||||
|
||||
def _get_network(self, tenant_id, network_id, context, base_plugin_ref):
|
||||
"""
|
||||
Gets the NETWORK ID
|
||||
"""
|
||||
"""Get the Network ID."""
|
||||
network = base_plugin_ref._get_network(context, network_id)
|
||||
if not network:
|
||||
raise exc.NetworkNotFound(net_id=network_id)
|
||||
|
@ -74,7 +74,6 @@ class ExtensionsTestApp(wsgi.Router):
|
||||
super(ExtensionsTestApp, self).__init__(mapper)
|
||||
|
||||
def create_request(self, path, body, content_type, method='GET'):
|
||||
|
||||
"""Test create request."""
|
||||
|
||||
LOG.debug("test_create_request - START")
|
||||
@ -87,7 +86,6 @@ class ExtensionsTestApp(wsgi.Router):
|
||||
return req
|
||||
|
||||
def _create_network(self, name=None):
|
||||
|
||||
"""Test create network."""
|
||||
|
||||
LOG.debug("Creating network - START")
|
||||
@ -107,7 +105,6 @@ class ExtensionsTestApp(wsgi.Router):
|
||||
return network_data['network']['id']
|
||||
|
||||
def _create_port(self, network_id, port_state):
|
||||
|
||||
"""Test create port."""
|
||||
|
||||
LOG.debug("Creating port for network %s - START", network_id)
|
||||
@ -153,7 +150,6 @@ class ExtensionsTestApp(wsgi.Router):
|
||||
class QosExtensionTest(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
"""Set up function."""
|
||||
|
||||
super(QosExtensionTest, self).setUp()
|
||||
@ -180,7 +176,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
self._l2network_plugin = l2network_plugin.L2Network()
|
||||
|
||||
def test_create_qos(self):
|
||||
|
||||
"""Test create qos."""
|
||||
|
||||
LOG.debug("test_create_qos - START")
|
||||
@ -199,7 +194,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_create_qos - END")
|
||||
|
||||
def test_create_qosBADRequest(self):
|
||||
|
||||
"""Test create qos bad request."""
|
||||
|
||||
LOG.debug("test_create_qosBADRequest - START")
|
||||
@ -211,7 +205,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_create_qosBADRequest - END")
|
||||
|
||||
def test_list_qoss(self):
|
||||
|
||||
"""Test list qoss."""
|
||||
|
||||
LOG.debug("test_list_qoss - START")
|
||||
@ -251,7 +244,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_list_qoss - END")
|
||||
|
||||
def test_show_qos(self):
|
||||
|
||||
"""Test show qos."""
|
||||
|
||||
LOG.debug("test_show_qos - START")
|
||||
@ -275,7 +267,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_show_qos - END")
|
||||
|
||||
def test_show_qosDNE(self, qos_id='100'):
|
||||
|
||||
"""Test show qos does not exist."""
|
||||
|
||||
LOG.debug("test_show_qosDNE - START")
|
||||
@ -286,7 +277,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_show_qosDNE - END")
|
||||
|
||||
def test_update_qos(self):
|
||||
|
||||
"""Test update qos."""
|
||||
|
||||
LOG.debug("test_update_qos - START")
|
||||
@ -318,7 +308,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_update_qos - END")
|
||||
|
||||
def test_update_qosDNE(self, qos_id='100'):
|
||||
|
||||
"""Test update qos does not exist."""
|
||||
|
||||
LOG.debug("test_update_qosDNE - START")
|
||||
@ -340,7 +329,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_update_qosDNE - END")
|
||||
|
||||
def test_update_qosBADRequest(self):
|
||||
|
||||
"""Test update qos bad request."""
|
||||
|
||||
LOG.debug("test_update_qosBADRequest - START")
|
||||
@ -361,7 +349,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_update_qosBADRequest - END")
|
||||
|
||||
def test_delete_qos(self):
|
||||
|
||||
"""Test delte qos."""
|
||||
|
||||
LOG.debug("test_delete_qos - START")
|
||||
@ -386,7 +373,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_delete_qos - END")
|
||||
|
||||
def test_delete_qosDNE(self, qos_id='100'):
|
||||
|
||||
"""Test delte qos does not exist."""
|
||||
|
||||
LOG.debug("test_delete_qosDNE - START")
|
||||
@ -397,7 +383,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_delete_qosDNE - END")
|
||||
|
||||
def tearDownQos(self, delete_profile_path):
|
||||
|
||||
"""Tear Down Qos."""
|
||||
|
||||
self.test_app.delete(delete_profile_path)
|
||||
@ -409,7 +394,6 @@ class QosExtensionTest(base.BaseTestCase):
|
||||
class CredentialExtensionTest(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
"""Set up function."""
|
||||
|
||||
super(CredentialExtensionTest, self).setUp()
|
||||
@ -434,7 +418,6 @@ class CredentialExtensionTest(base.BaseTestCase):
|
||||
self._l2network_plugin = l2network_plugin.L2Network()
|
||||
|
||||
def test_list_credentials(self):
|
||||
|
||||
"""Test list credentials."""
|
||||
|
||||
#Create Credential before listing
|
||||
@ -479,7 +462,6 @@ class CredentialExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_list_credentials - END")
|
||||
|
||||
def test_create_credential(self):
|
||||
|
||||
"""Test create credential."""
|
||||
|
||||
LOG.debug("test_create_credential - START")
|
||||
@ -498,7 +480,6 @@ class CredentialExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_create_credential - END")
|
||||
|
||||
def test_create_credentialBADRequest(self):
|
||||
|
||||
"""Test create credential bad request."""
|
||||
|
||||
LOG.debug("test_create_credentialBADRequest - START")
|
||||
@ -509,7 +490,6 @@ class CredentialExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_create_credentialBADRequest - END")
|
||||
|
||||
def test_show_credential(self):
|
||||
|
||||
"""Test show credential."""
|
||||
|
||||
LOG.debug("test_show_credential - START")
|
||||
@ -534,7 +514,6 @@ class CredentialExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_show_credential - END")
|
||||
|
||||
def test_show_credentialDNE(self, credential_id='100'):
|
||||
|
||||
"""Test show credential does not exist."""
|
||||
|
||||
LOG.debug("test_show_credentialDNE - START")
|
||||
@ -545,7 +524,6 @@ class CredentialExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_show_credentialDNE - END")
|
||||
|
||||
def test_update_credential(self):
|
||||
|
||||
"""Test update credential."""
|
||||
|
||||
LOG.debug("test_update_credential - START")
|
||||
@ -581,7 +559,6 @@ class CredentialExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_update_credential - END")
|
||||
|
||||
def test_update_credBADReq(self):
|
||||
|
||||
"""Test update credential bad request."""
|
||||
|
||||
LOG.debug("test_update_credBADReq - START")
|
||||
@ -600,7 +577,6 @@ class CredentialExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_update_credBADReq - END")
|
||||
|
||||
def test_update_credentialDNE(self, credential_id='100'):
|
||||
|
||||
"""Test update credential does not exist."""
|
||||
|
||||
LOG.debug("test_update_credentialDNE - START")
|
||||
@ -620,7 +596,6 @@ class CredentialExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_update_credentialDNE - END")
|
||||
|
||||
def test_delete_credential(self):
|
||||
|
||||
"""Test delete credential."""
|
||||
|
||||
LOG.debug("test_delete_credential - START")
|
||||
@ -638,7 +613,6 @@ class CredentialExtensionTest(base.BaseTestCase):
|
||||
LOG.debug("test_delete_credential - END")
|
||||
|
||||
def test_delete_credentialDNE(self, credential_id='100'):
|
||||
|
||||
"""Test delete credential does not exist."""
|
||||
|
||||
LOG.debug("test_delete_credentialDNE - START")
|
||||
|
@ -32,8 +32,9 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class NexusDB(object):
|
||||
"""Class consisting of methods to call nexus db methods."""
|
||||
|
||||
def get_all_nexusportbindings(self):
|
||||
"""get all nexus port bindings."""
|
||||
"""Get all nexus port bindings."""
|
||||
bindings = []
|
||||
try:
|
||||
for bind in nexus_db.get_all_nexusport_bindings():
|
||||
@ -47,7 +48,7 @@ class NexusDB(object):
|
||||
return bindings
|
||||
|
||||
def get_nexusportbinding(self, vlan_id):
|
||||
"""get nexus port binding."""
|
||||
"""Get nexus port binding."""
|
||||
binding = []
|
||||
try:
|
||||
for bind in nexus_db.get_nexusport_binding(vlan_id):
|
||||
@ -61,7 +62,7 @@ class NexusDB(object):
|
||||
return binding
|
||||
|
||||
def create_nexusportbinding(self, port_id, vlan_id):
|
||||
"""create nexus port binding."""
|
||||
"""Create nexus port binding."""
|
||||
bind_dict = {}
|
||||
try:
|
||||
res = nexus_db.add_nexusport_binding(port_id, vlan_id)
|
||||
@ -73,7 +74,7 @@ class NexusDB(object):
|
||||
LOG.error("Failed to create nexus binding: %s" % str(exc))
|
||||
|
||||
def delete_nexusportbinding(self, vlan_id):
|
||||
"""delete nexus port binding."""
|
||||
"""Delete nexus port binding."""
|
||||
bindings = []
|
||||
try:
|
||||
bind = nexus_db.remove_nexusport_binding(vlan_id)
|
||||
@ -88,7 +89,7 @@ class NexusDB(object):
|
||||
% str(exc))
|
||||
|
||||
def update_nexusport_binding(self, port_id, new_vlan_id):
|
||||
"""update nexus port binding."""
|
||||
"""Update nexus port binding."""
|
||||
try:
|
||||
res = nexus_db.update_nexusport_binding(port_id, new_vlan_id)
|
||||
LOG.debug("Updating nexus port binding : %s" % res.port_id)
|
||||
@ -354,13 +355,13 @@ class NexusDBTest(base.BaseTestCase):
|
||||
LOG.debug("Setup")
|
||||
|
||||
def testa_create_nexusportbinding(self):
|
||||
"""create nexus port binding."""
|
||||
"""Create nexus port binding."""
|
||||
binding1 = self.dbtest.create_nexusportbinding("port1", 10)
|
||||
self.assertTrue(binding1["port-id"] == "port1")
|
||||
self.tearDown_nexusportbinding()
|
||||
|
||||
def testb_getall_nexusportbindings(self):
|
||||
"""get all nexus port binding."""
|
||||
"""Get all nexus port bindings."""
|
||||
self.dbtest.create_nexusportbinding("port1", 10)
|
||||
self.dbtest.create_nexusportbinding("port2", 10)
|
||||
bindings = self.dbtest.get_all_nexusportbindings()
|
||||
@ -372,7 +373,7 @@ class NexusDBTest(base.BaseTestCase):
|
||||
self.tearDown_nexusportbinding()
|
||||
|
||||
def testc_delete_nexusportbinding(self):
|
||||
"""delete nexus port binding."""
|
||||
"""Delete nexus port binding."""
|
||||
self.dbtest.create_nexusportbinding("port1", 10)
|
||||
self.dbtest.delete_nexusportbinding(10)
|
||||
bindings = self.dbtest.get_all_nexusportbindings()
|
||||
@ -384,7 +385,7 @@ class NexusDBTest(base.BaseTestCase):
|
||||
self.tearDown_nexusportbinding()
|
||||
|
||||
def testd_update_nexusportbinding(self):
|
||||
"""update nexus port binding."""
|
||||
"""Update nexus port binding."""
|
||||
binding1 = self.dbtest.create_nexusportbinding("port1", 10)
|
||||
binding1 = self.dbtest.update_nexusport_binding(binding1["port-id"],
|
||||
20)
|
||||
@ -397,7 +398,7 @@ class NexusDBTest(base.BaseTestCase):
|
||||
self.tearDown_nexusportbinding()
|
||||
|
||||
def tearDown_nexusportbinding(self):
|
||||
"""tear down nexusport binding table."""
|
||||
"""Tear down nexus port binding table."""
|
||||
LOG.debug("Tearing Down Nexus port Bindings")
|
||||
binds = self.dbtest.get_all_nexusportbindings()
|
||||
for bind in binds:
|
||||
@ -417,7 +418,7 @@ class L2networkDBTest(base.BaseTestCase):
|
||||
LOG.debug("Setup")
|
||||
|
||||
def testa_create_vlanbinding(self):
|
||||
"""test add vlan binding."""
|
||||
"""Test add vlan binding."""
|
||||
net1 = self.quantum.create_network("t1", "netid1")
|
||||
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
||||
self.assertTrue(vlan1["vlan-id"] == "10")
|
||||
@ -425,7 +426,7 @@ class L2networkDBTest(base.BaseTestCase):
|
||||
self.teardown_network()
|
||||
|
||||
def testb_getall_vlanbindings(self):
|
||||
"""test get all vlan binding."""
|
||||
"""Test get all vlan bindings."""
|
||||
net1 = self.quantum.create_network("t1", "netid1")
|
||||
net2 = self.quantum.create_network("t1", "netid2")
|
||||
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
||||
@ -442,7 +443,7 @@ class L2networkDBTest(base.BaseTestCase):
|
||||
self.teardown_network()
|
||||
|
||||
def testc_delete_vlanbinding(self):
|
||||
"""test delete vlan binding."""
|
||||
"""Test delete vlan binding."""
|
||||
net1 = self.quantum.create_network("t1", "netid1")
|
||||
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
||||
self.assertTrue(vlan1["vlan-id"] == "10")
|
||||
@ -457,7 +458,7 @@ class L2networkDBTest(base.BaseTestCase):
|
||||
self.teardown_network()
|
||||
|
||||
def testd_update_vlanbinding(self):
|
||||
"""test update vlan binding."""
|
||||
"""Test update vlan binding."""
|
||||
net1 = self.quantum.create_network("t1", "netid1")
|
||||
vlan1 = self.dbtest.create_vlan_binding(10, "vlan1", net1["net-id"])
|
||||
self.assertTrue(vlan1["vlan-id"] == "10")
|
||||
@ -472,7 +473,7 @@ class L2networkDBTest(base.BaseTestCase):
|
||||
self.teardown_network()
|
||||
|
||||
def testm_test_vlanids(self):
|
||||
"""test vlanid methods."""
|
||||
"""Test vlanid methods."""
|
||||
l2network_db.create_vlanids()
|
||||
vlanids = l2network_db.get_all_vlanids()
|
||||
self.assertTrue(len(vlanids) > 0)
|
||||
@ -523,13 +524,13 @@ class QuantumDBTest(base.BaseTestCase):
|
||||
LOG.debug("Setup")
|
||||
|
||||
def testa_create_network(self):
|
||||
"""test to create network."""
|
||||
"""Test to create network."""
|
||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||
self.assertTrue(net1["net-name"] == "plugin_test1")
|
||||
self.teardown_network_port()
|
||||
|
||||
def testb_get_networks(self):
|
||||
"""test to get all networks."""
|
||||
"""Test to get all networks."""
|
||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||
self.assertTrue(net1["net-name"] == "plugin_test1")
|
||||
net2 = self.dbtest.create_network(self.tenant_id, "plugin_test2")
|
||||
@ -543,7 +544,7 @@ class QuantumDBTest(base.BaseTestCase):
|
||||
self.teardown_network_port()
|
||||
|
||||
def testc_delete_network(self):
|
||||
"""test to delete network."""
|
||||
"""Test to delete network."""
|
||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||
self.assertTrue(net1["net-name"] == "plugin_test1")
|
||||
self.dbtest.delete_network(net1["net-id"])
|
||||
@ -556,7 +557,7 @@ class QuantumDBTest(base.BaseTestCase):
|
||||
self.teardown_network_port()
|
||||
|
||||
def testd_update_network(self):
|
||||
"""test to update (rename) network."""
|
||||
"""Test to update (rename) network."""
|
||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||
self.assertTrue(net1["net-name"] == "plugin_test1")
|
||||
net = self.dbtest.update_network(self.tenant_id, net1["net-id"],
|
||||
@ -565,7 +566,7 @@ class QuantumDBTest(base.BaseTestCase):
|
||||
self.teardown_network_port()
|
||||
|
||||
def teste_create_port(self):
|
||||
"""test to create port."""
|
||||
"""Test to create port."""
|
||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||
port = self.dbtest.create_port(net1["net-id"])
|
||||
self.assertTrue(port["net-id"] == net1["net-id"])
|
||||
@ -577,7 +578,7 @@ class QuantumDBTest(base.BaseTestCase):
|
||||
self.teardown_network_port()
|
||||
|
||||
def testf_delete_port(self):
|
||||
"""test to delete port."""
|
||||
"""Test to delete port."""
|
||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||
port = self.dbtest.create_port(net1["net-id"])
|
||||
self.assertTrue(port["net-id"] == net1["net-id"])
|
||||
@ -596,7 +597,7 @@ class QuantumDBTest(base.BaseTestCase):
|
||||
self.teardown_network_port()
|
||||
|
||||
def testg_plug_unplug_interface(self):
|
||||
"""test to plug/unplug interface."""
|
||||
"""Test to plug/unplug interface."""
|
||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||
port1 = self.dbtest.create_port(net1["net-id"])
|
||||
self.dbtest.plug_interface(net1["net-id"], port1["port-id"], "vif1.1")
|
||||
@ -608,7 +609,7 @@ class QuantumDBTest(base.BaseTestCase):
|
||||
self.teardown_network_port()
|
||||
|
||||
def testh_joined_test(self):
|
||||
"""test to get network and port."""
|
||||
"""Test to get network and port."""
|
||||
net1 = self.dbtest.create_network("t1", "net1")
|
||||
port1 = self.dbtest.create_port(net1["net-id"])
|
||||
self.assertTrue(port1["net-id"] == net1["net-id"])
|
||||
|
@ -19,95 +19,87 @@
|
||||
|
||||
|
||||
class CiscoNEXUSFakeDriver():
|
||||
"""
|
||||
Nexus Driver Fake Class
|
||||
"""
|
||||
"""Nexus Driver Fake Class."""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def nxos_connect(self, nexus_host, nexus_ssh_port, nexus_user,
|
||||
nexus_password):
|
||||
"""
|
||||
Makes the fake connection to the Nexus Switch
|
||||
"""
|
||||
"""Make the fake connection to the Nexus Switch."""
|
||||
pass
|
||||
|
||||
def create_xml_snippet(self, cutomized_config):
|
||||
"""
|
||||
Creates the Proper XML structure for the Nexus Switch Configuration
|
||||
"""Create XML snippet.
|
||||
|
||||
Creates the Proper XML structure for the Nexus Switch
|
||||
Configuration.
|
||||
"""
|
||||
pass
|
||||
|
||||
def enable_vlan(self, mgr, vlanid, vlanname):
|
||||
"""
|
||||
Creates a VLAN on Nexus Switch given the VLAN ID and Name
|
||||
"""
|
||||
"""Create a VLAN on Nexus Switch given the VLAN ID and Name."""
|
||||
pass
|
||||
|
||||
def disable_vlan(self, mgr, vlanid):
|
||||
"""
|
||||
Delete a VLAN on Nexus Switch given the VLAN ID
|
||||
"""
|
||||
"""Delete a VLAN on Nexus Switch given the VLAN ID."""
|
||||
pass
|
||||
|
||||
def enable_port_trunk(self, mgr, interface):
|
||||
"""
|
||||
Enables trunk mode an interface on Nexus Switch
|
||||
"""
|
||||
"""Enable trunk mode an interface on Nexus Switch."""
|
||||
pass
|
||||
|
||||
def disable_switch_port(self, mgr, interface):
|
||||
"""
|
||||
Disables trunk mode an interface on Nexus Switch
|
||||
"""
|
||||
"""Disable trunk mode an interface on Nexus Switch."""
|
||||
pass
|
||||
|
||||
def enable_vlan_on_trunk_int(self, mgr, interface, vlanid):
|
||||
"""
|
||||
Enables trunk mode vlan access an interface on Nexus Switch given
|
||||
VLANID
|
||||
"""Enable vlan on trunk interface.
|
||||
|
||||
Enable trunk mode vlan access an interface on Nexus Switch given
|
||||
VLANID.
|
||||
"""
|
||||
pass
|
||||
|
||||
def disable_vlan_on_trunk_int(self, mgr, interface, vlanid):
|
||||
"""
|
||||
"""Disables vlan in trunk interface.
|
||||
|
||||
Enables trunk mode vlan access an interface on Nexus Switch given
|
||||
VLANID
|
||||
VLANID.
|
||||
"""
|
||||
pass
|
||||
|
||||
def create_vlan(self, vlan_name, vlan_id, nexus_host, nexus_user,
|
||||
nexus_password, nexus_ports, nexus_ssh_port, vlan_ids):
|
||||
"""
|
||||
"""Create VLAN and enable it on interface.
|
||||
|
||||
Creates a VLAN and Enable on trunk mode an interface on Nexus Switch
|
||||
given the VLAN ID and Name and Interface Number
|
||||
given the VLAN ID and Name and Interface Number.
|
||||
"""
|
||||
pass
|
||||
|
||||
def delete_vlan(self, vlan_id, nexus_host, nexus_user, nexus_password,
|
||||
nexus_ports, nexus_ssh_port):
|
||||
"""
|
||||
"""Delete VLAN.
|
||||
|
||||
Delete a VLAN and Disables trunk mode an interface on Nexus Switch
|
||||
given the VLAN ID and Interface Number
|
||||
given the VLAN ID and Interface Number.
|
||||
"""
|
||||
pass
|
||||
|
||||
def build_vlans_cmd(self):
|
||||
"""
|
||||
Builds a string with all the VLANs on the same Switch
|
||||
"""
|
||||
"""Build a string with all the VLANs on the same Switch."""
|
||||
pass
|
||||
|
||||
def add_vlan_int(self, vlan_id, nexus_host, nexus_user, nexus_password,
|
||||
nexus_ports, nexus_ssh_port, vlan_ids=None):
|
||||
"""
|
||||
Adds a vlan from interfaces on the Nexus switch given the VLAN ID
|
||||
"""
|
||||
"""Add a vlan from interfaces on the Nexus switch given the VLAN ID."""
|
||||
pass
|
||||
|
||||
def remove_vlan_int(self, vlan_id, nexus_host, nexus_user, nexus_password,
|
||||
nexus_ports, nexus_ssh_port):
|
||||
"""
|
||||
Removes a vlan from interfaces on the Nexus switch given the VLAN ID
|
||||
"""Remove vlan from interfaces.
|
||||
|
||||
Removes a vlan from interfaces on the Nexus switch given the VLAN ID.
|
||||
"""
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user