Update codebase for HACKING compliance.
* This is a massive patch that aims to clean up the codebase and bring it into compliance with HACKING.rst and PEP8 in one fell swoop. * Cleaned up use of gettext. * Updated log usage for consistency. * The tests run successfully against all plugins except cisco and nicira (due to dependency issues with these plugins). * Addresses bug 981208 Change-Id: I4d8c7ab138d8f7bb906d18dc34f88f8bd0581c19
This commit is contained in:
parent
f6c71b52e9
commit
6c97b81bf3
@ -14,3 +14,8 @@
|
|||||||
# 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.
|
||||||
|
|
||||||
|
import gettext
|
||||||
|
|
||||||
|
|
||||||
|
gettext.install('quantum', unicode=1)
|
||||||
|
@ -60,6 +60,9 @@ class APIRouter(wsgi.Router):
|
|||||||
plugin = manager.QuantumManager.get_plugin(options)
|
plugin = manager.QuantumManager.get_plugin(options)
|
||||||
|
|
||||||
uri_prefix = '/tenants/{tenant_id}/'
|
uri_prefix = '/tenants/{tenant_id}/'
|
||||||
|
attachment_path = (
|
||||||
|
'%snetworks/{network_id}/ports/{id}/attachment{.format}' %
|
||||||
|
uri_prefix)
|
||||||
mapper.resource('network', 'networks',
|
mapper.resource('network', 'networks',
|
||||||
controller=networks.create_resource(plugin, version),
|
controller=networks.create_resource(plugin, version),
|
||||||
collection={'detail': 'GET'},
|
collection={'detail': 'GET'},
|
||||||
@ -69,25 +72,22 @@ class APIRouter(wsgi.Router):
|
|||||||
controller=ports.create_resource(plugin, version),
|
controller=ports.create_resource(plugin, version),
|
||||||
collection={'detail': 'GET'},
|
collection={'detail': 'GET'},
|
||||||
member={'detail': 'GET'},
|
member={'detail': 'GET'},
|
||||||
parent_resource=dict(member_name='network',
|
parent_resource=dict(
|
||||||
collection_name=uri_prefix +\
|
member_name='network',
|
||||||
'networks'))
|
collection_name='%snetworks' % uri_prefix))
|
||||||
attachments_ctrl = attachments.create_resource(plugin, version)
|
attachments_ctrl = attachments.create_resource(plugin, version)
|
||||||
mapper.connect("get_resource",
|
mapper.connect("get_resource",
|
||||||
uri_prefix + 'networks/{network_id}/' \
|
attachment_path,
|
||||||
'ports/{id}/attachment{.format}',
|
|
||||||
controller=attachments_ctrl,
|
controller=attachments_ctrl,
|
||||||
action="get_resource",
|
action="get_resource",
|
||||||
conditions=dict(method=['GET']))
|
conditions=dict(method=['GET']))
|
||||||
mapper.connect("attach_resource",
|
mapper.connect("attach_resource",
|
||||||
uri_prefix + 'networks/{network_id}/' \
|
attachment_path,
|
||||||
'ports/{id}/attachment{.format}',
|
|
||||||
controller=attachments_ctrl,
|
controller=attachments_ctrl,
|
||||||
action="attach_resource",
|
action="attach_resource",
|
||||||
conditions=dict(method=['PUT']))
|
conditions=dict(method=['PUT']))
|
||||||
mapper.connect("detach_resource",
|
mapper.connect("detach_resource",
|
||||||
uri_prefix + 'networks/{network_id}/' \
|
attachment_path,
|
||||||
'ports/{id}/attachment{.format}',
|
|
||||||
controller=attachments_ctrl,
|
controller=attachments_ctrl,
|
||||||
action="detach_resource",
|
action="detach_resource",
|
||||||
conditions=dict(method=['DELETE']))
|
conditions=dict(method=['DELETE']))
|
||||||
|
@ -22,6 +22,7 @@ from webob import exc
|
|||||||
from quantum import wsgi
|
from quantum import wsgi
|
||||||
from quantum.api import faults
|
from quantum.api import faults
|
||||||
|
|
||||||
|
|
||||||
XML_NS_V10 = 'http://openstack.org/quantum/api/v1.0'
|
XML_NS_V10 = 'http://openstack.org/quantum/api/v1.0'
|
||||||
XML_NS_V11 = 'http://openstack.org/quantum/api/v1.1'
|
XML_NS_V11 = 'http://openstack.org/quantum/api/v1.1'
|
||||||
LOG = logging.getLogger('quantum.api.api_common')
|
LOG = logging.getLogger('quantum.api.api_common')
|
||||||
|
@ -25,28 +25,33 @@ LOG = logging.getLogger('quantum.api.ports')
|
|||||||
|
|
||||||
def create_resource(plugin, version):
|
def create_resource(plugin, version):
|
||||||
controller_dict = {
|
controller_dict = {
|
||||||
'1.0': [ControllerV10(plugin),
|
'1.0': [ControllerV10(plugin),
|
||||||
ControllerV10._serialization_metadata,
|
ControllerV10._serialization_metadata,
|
||||||
common.XML_NS_V10],
|
common.XML_NS_V10],
|
||||||
'1.1': [ControllerV11(plugin),
|
'1.1': [ControllerV11(plugin),
|
||||||
ControllerV11._serialization_metadata,
|
ControllerV11._serialization_metadata,
|
||||||
common.XML_NS_V11]}
|
common.XML_NS_V11],
|
||||||
|
}
|
||||||
return common.create_resource(version, controller_dict)
|
return common.create_resource(version, controller_dict)
|
||||||
|
|
||||||
|
|
||||||
class Controller(common.QuantumController):
|
class Controller(common.QuantumController):
|
||||||
""" Port API controller for Quantum API """
|
""" Port API controller for Quantum API """
|
||||||
|
|
||||||
_attachment_ops_param_list = [{
|
_attachment_ops_param_list = [
|
||||||
'param-name': 'id',
|
{
|
||||||
'required': True}, ]
|
'param-name': 'id',
|
||||||
|
'required': True,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"attachment": ["id"], }
|
"attachment": ["id"],
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self._resource_name = 'attachment'
|
self._resource_name = 'attachment'
|
||||||
@ -55,8 +60,7 @@ class Controller(common.QuantumController):
|
|||||||
@common.APIFaultWrapper([exception.NetworkNotFound,
|
@common.APIFaultWrapper([exception.NetworkNotFound,
|
||||||
exception.PortNotFound])
|
exception.PortNotFound])
|
||||||
def get_resource(self, request, tenant_id, network_id, id):
|
def get_resource(self, request, tenant_id, network_id, id):
|
||||||
att_data = self._plugin.get_port_details(
|
att_data = self._plugin.get_port_details(tenant_id, network_id, id)
|
||||||
tenant_id, network_id, id)
|
|
||||||
builder = attachments_view.get_view_builder(request)
|
builder = attachments_view.get_view_builder(request)
|
||||||
result = builder.build(att_data)['attachment']
|
result = builder.build(att_data)['attachment']
|
||||||
return dict(attachment=result)
|
return dict(attachment=result)
|
||||||
@ -74,8 +78,7 @@ class Controller(common.QuantumController):
|
|||||||
@common.APIFaultWrapper([exception.NetworkNotFound,
|
@common.APIFaultWrapper([exception.NetworkNotFound,
|
||||||
exception.PortNotFound])
|
exception.PortNotFound])
|
||||||
def detach_resource(self, request, tenant_id, network_id, id):
|
def detach_resource(self, request, tenant_id, network_id, id):
|
||||||
self._plugin.unplug_interface(tenant_id,
|
self._plugin.unplug_interface(tenant_id, network_id, id)
|
||||||
network_id, id)
|
|
||||||
|
|
||||||
|
|
||||||
class ControllerV10(Controller):
|
class ControllerV10(Controller):
|
||||||
|
@ -20,6 +20,7 @@ import webob.exc
|
|||||||
|
|
||||||
from quantum.common import exceptions
|
from quantum.common import exceptions
|
||||||
|
|
||||||
|
|
||||||
_NETNOTFOUND_EXPL = 'Unable to find a network with the specified identifier.'
|
_NETNOTFOUND_EXPL = 'Unable to find a network with the specified identifier.'
|
||||||
_NETINUSE_EXPL = 'Unable to remove the network: attachments still plugged.'
|
_NETINUSE_EXPL = 'Unable to remove the network: attachments still plugged.'
|
||||||
_PORTNOTFOUND_EXPL = 'Unable to find a port with the specified identifier.'
|
_PORTNOTFOUND_EXPL = 'Unable to find a port with the specified identifier.'
|
||||||
@ -39,13 +40,15 @@ def fault_body_function_v10(wrapped_exc):
|
|||||||
:rtype: tuple
|
:rtype: tuple
|
||||||
"""
|
"""
|
||||||
code = wrapped_exc.status_int
|
code = wrapped_exc.status_int
|
||||||
fault_name = hasattr(wrapped_exc, 'title') and \
|
fault_name = (hasattr(wrapped_exc, 'title') and
|
||||||
wrapped_exc.title or "quantumServiceFault"
|
wrapped_exc.title or "quantumServiceFault")
|
||||||
fault_data = {
|
fault_data = {
|
||||||
fault_name: {
|
fault_name: {
|
||||||
'code': code,
|
'code': code,
|
||||||
'message': wrapped_exc.explanation,
|
'message': wrapped_exc.explanation,
|
||||||
'detail': str(wrapped_exc.detail)}}
|
'detail': str(wrapped_exc.detail),
|
||||||
|
},
|
||||||
|
}
|
||||||
metadata = {'attributes': {fault_name: ['code']}}
|
metadata = {'attributes': {fault_name: ['code']}}
|
||||||
return fault_data, metadata
|
return fault_data, metadata
|
||||||
|
|
||||||
@ -59,15 +62,17 @@ def fault_body_function_v11(wrapped_exc):
|
|||||||
:returns: response body contents and serialization metadata
|
:returns: response body contents and serialization metadata
|
||||||
:rtype: tuple
|
:rtype: tuple
|
||||||
"""
|
"""
|
||||||
fault_name = hasattr(wrapped_exc, 'type') and \
|
fault_name = (hasattr(wrapped_exc, 'type') and
|
||||||
wrapped_exc.type or "QuantumServiceFault"
|
wrapped_exc.type or "QuantumServiceFault")
|
||||||
# Ensure first letter is capital
|
# Ensure first letter is capital
|
||||||
fault_name = fault_name[0].upper() + fault_name[1:]
|
fault_name = fault_name[0].upper() + fault_name[1:]
|
||||||
fault_data = {
|
fault_data = {
|
||||||
'QuantumError': {
|
'QuantumError': {
|
||||||
'type': fault_name,
|
'type': fault_name,
|
||||||
'message': wrapped_exc.explanation,
|
'message': wrapped_exc.explanation,
|
||||||
'detail': str(wrapped_exc.detail)}}
|
'detail': str(wrapped_exc.detail),
|
||||||
|
},
|
||||||
|
}
|
||||||
# Metadata not required for v11
|
# Metadata not required for v11
|
||||||
return fault_data, None
|
return fault_data, None
|
||||||
|
|
||||||
|
@ -19,30 +19,32 @@ from webob import exc
|
|||||||
|
|
||||||
from quantum.api import api_common as common
|
from quantum.api import api_common as common
|
||||||
from quantum.api import faults
|
from quantum.api import faults
|
||||||
from quantum.api.views import networks as networks_view
|
|
||||||
from quantum.api.views import filters
|
from quantum.api.views import filters
|
||||||
|
from quantum.api.views import networks as networks_view
|
||||||
from quantum.common import exceptions as exception
|
from quantum.common import exceptions as exception
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum.api.networks')
|
LOG = logging.getLogger('quantum.api.networks')
|
||||||
|
|
||||||
|
|
||||||
def create_resource(plugin, version):
|
def create_resource(plugin, version):
|
||||||
controller_dict = {
|
controller_dict = {
|
||||||
'1.0': [ControllerV10(plugin),
|
'1.0': [ControllerV10(plugin),
|
||||||
ControllerV10._serialization_metadata,
|
ControllerV10._serialization_metadata,
|
||||||
common.XML_NS_V10],
|
common.XML_NS_V10],
|
||||||
'1.1': [ControllerV11(plugin),
|
'1.1': [ControllerV11(plugin),
|
||||||
ControllerV11._serialization_metadata,
|
ControllerV11._serialization_metadata,
|
||||||
common.XML_NS_V11]}
|
common.XML_NS_V11],
|
||||||
|
}
|
||||||
return common.create_resource(version, controller_dict)
|
return common.create_resource(version, controller_dict)
|
||||||
|
|
||||||
|
|
||||||
class Controller(common.QuantumController):
|
class Controller(common.QuantumController):
|
||||||
""" Network API controller for Quantum API """
|
""" Network API controller for Quantum API """
|
||||||
|
|
||||||
_network_ops_param_list = [{
|
_network_ops_param_list = [
|
||||||
'param-name': 'name',
|
{'param-name': 'name', 'required': True},
|
||||||
'required': True}, ]
|
]
|
||||||
|
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self._resource_name = 'network'
|
self._resource_name = 'network'
|
||||||
@ -52,17 +54,17 @@ class Controller(common.QuantumController):
|
|||||||
net_details=True, port_details=False):
|
net_details=True, port_details=False):
|
||||||
# We expect get_network_details to return information
|
# We expect get_network_details to return information
|
||||||
# concerning logical ports as well.
|
# concerning logical ports as well.
|
||||||
network = self._plugin.get_network_details(
|
network = self._plugin.get_network_details(tenant_id, network_id)
|
||||||
tenant_id, network_id)
|
|
||||||
# Doing this in the API is inefficient
|
# Doing this in the API is inefficient
|
||||||
# TODO(salvatore-orlando): This should be fixed with Bug #834012
|
# TODO(salvatore-orlando): This should be fixed with Bug #834012
|
||||||
# Don't pass filter options
|
# Don't pass filter options
|
||||||
ports_data = None
|
ports_data = None
|
||||||
if port_details:
|
if port_details:
|
||||||
port_list = self._plugin.get_all_ports(tenant_id, network_id)
|
port_list = self._plugin.get_all_ports(tenant_id, network_id)
|
||||||
ports_data = [self._plugin.get_port_details(
|
ports_data = [
|
||||||
tenant_id, network_id, port['port-id'])
|
self._plugin.get_port_details(tenant_id, network_id,
|
||||||
for port in port_list]
|
port['port-id'])
|
||||||
|
for port in port_list]
|
||||||
builder = networks_view.get_view_builder(request, self.version)
|
builder = networks_view.get_view_builder(request, self.version)
|
||||||
result = builder.build(network, net_details,
|
result = builder.build(network, net_details,
|
||||||
ports_data, port_details)['network']
|
ports_data, port_details)['network']
|
||||||
@ -128,10 +130,9 @@ class Controller(common.QuantumController):
|
|||||||
# request_params but that would mean all the plugins would need to
|
# request_params but that would mean all the plugins would need to
|
||||||
# change.
|
# change.
|
||||||
body = self._prepare_request_body(body, self._network_ops_param_list)
|
body = self._prepare_request_body(body, self._network_ops_param_list)
|
||||||
network = self._plugin.\
|
network = self._plugin.create_network(tenant_id,
|
||||||
create_network(tenant_id,
|
body['network']['name'],
|
||||||
body['network']['name'],
|
**body)
|
||||||
**body)
|
|
||||||
builder = networks_view.get_view_builder(request, self.version)
|
builder = networks_view.get_view_builder(request, self.version)
|
||||||
result = builder.build(network)['network']
|
result = builder.build(network)['network']
|
||||||
return dict(network=result)
|
return dict(network=result)
|
||||||
@ -153,13 +154,16 @@ class ControllerV10(Controller):
|
|||||||
"""Network resources controller for Quantum v1.0 API"""
|
"""Network resources controller for Quantum v1.0 API"""
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"network": ["id", "name"],
|
"network": ["id", "name"],
|
||||||
"port": ["id", "state"],
|
"port": ["id", "state"],
|
||||||
"attachment": ["id"]},
|
"attachment": ["id"],
|
||||||
"plurals": {"networks": "network",
|
},
|
||||||
"ports": "port"}
|
"plurals": {
|
||||||
}
|
"networks": "network",
|
||||||
|
"ports": "port",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self.version = "1.0"
|
self.version = "1.0"
|
||||||
@ -176,13 +180,16 @@ class ControllerV11(Controller):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"network": ["id", "name", "op-status"],
|
"network": ["id", "name", "op-status"],
|
||||||
"port": ["id", "state", "op-status"],
|
"port": ["id", "state", "op-status"],
|
||||||
"attachment": ["id"]},
|
"attachment": ["id"],
|
||||||
"plurals": {"networks": "network",
|
},
|
||||||
"ports": "port"}
|
"plurals": {
|
||||||
}
|
"networks": "network",
|
||||||
|
"ports": "port",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self.version = "1.1"
|
self.version = "1.1"
|
||||||
|
@ -26,22 +26,22 @@ LOG = logging.getLogger('quantum.api.ports')
|
|||||||
|
|
||||||
def create_resource(plugin, version):
|
def create_resource(plugin, version):
|
||||||
controller_dict = {
|
controller_dict = {
|
||||||
'1.0': [ControllerV10(plugin),
|
'1.0': [ControllerV10(plugin),
|
||||||
ControllerV10._serialization_metadata,
|
ControllerV10._serialization_metadata,
|
||||||
common.XML_NS_V10],
|
common.XML_NS_V10],
|
||||||
'1.1': [ControllerV11(plugin),
|
'1.1': [ControllerV11(plugin),
|
||||||
ControllerV11._serialization_metadata,
|
ControllerV11._serialization_metadata,
|
||||||
common.XML_NS_V11]}
|
common.XML_NS_V11],
|
||||||
|
}
|
||||||
return common.create_resource(version, controller_dict)
|
return common.create_resource(version, controller_dict)
|
||||||
|
|
||||||
|
|
||||||
class Controller(common.QuantumController):
|
class Controller(common.QuantumController):
|
||||||
""" Port API controller for Quantum API """
|
""" Port API controller for Quantum API """
|
||||||
|
|
||||||
_port_ops_param_list = [{
|
_port_ops_param_list = [
|
||||||
'param-name': 'state',
|
{'param-name': 'state', 'default-value': 'DOWN', 'required': False},
|
||||||
'default-value': 'DOWN',
|
]
|
||||||
'required': False}, ]
|
|
||||||
|
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self._resource_name = 'port'
|
self._resource_name = 'port'
|
||||||
@ -69,10 +69,10 @@ class Controller(common.QuantumController):
|
|||||||
# This can be inefficient.
|
# This can be inefficient.
|
||||||
# TODO(salvatore-orlando): the fix for bug #834012 should deal with it
|
# TODO(salvatore-orlando): the fix for bug #834012 should deal with it
|
||||||
if port_details:
|
if port_details:
|
||||||
port_list_detail = \
|
port_list_detail = [
|
||||||
[self._plugin.get_port_details(
|
self._plugin.get_port_details(tenant_id, network_id,
|
||||||
tenant_id, network_id, port['port-id'])
|
port['port-id'])
|
||||||
for port in port_list]
|
for port in port_list]
|
||||||
port_list = port_list_detail
|
port_list = port_list_detail
|
||||||
|
|
||||||
# Perform manual filtering if not supported by plugin
|
# Perform manual filtering if not supported by plugin
|
||||||
@ -92,8 +92,7 @@ class Controller(common.QuantumController):
|
|||||||
def _item(self, request, tenant_id, network_id, port_id,
|
def _item(self, request, tenant_id, network_id, port_id,
|
||||||
att_details=False):
|
att_details=False):
|
||||||
""" Returns a specific port. """
|
""" Returns a specific port. """
|
||||||
port = self._plugin.get_port_details(
|
port = self._plugin.get_port_details(tenant_id, network_id, port_id)
|
||||||
tenant_id, network_id, port_id)
|
|
||||||
builder = ports_view.get_view_builder(request, self.version)
|
builder = ports_view.get_view_builder(request, self.version)
|
||||||
result = builder.build(port, port_details=True,
|
result = builder.build(port, port_details=True,
|
||||||
att_details=att_details)['port']
|
att_details=att_details)['port']
|
||||||
@ -160,11 +159,14 @@ class ControllerV10(Controller):
|
|||||||
"""Port resources controller for Quantum v1.0 API"""
|
"""Port resources controller for Quantum v1.0 API"""
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"port": ["id", "state"],
|
"port": ["id", "state"],
|
||||||
"attachment": ["id"]},
|
"attachment": ["id"],
|
||||||
"plurals": {"ports": "port"}
|
},
|
||||||
}
|
"plurals": {
|
||||||
|
"ports": "port",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self.version = "1.0"
|
self.version = "1.0"
|
||||||
@ -175,11 +177,14 @@ class ControllerV11(Controller):
|
|||||||
"""Port resources controller for Quantum v1.1 API"""
|
"""Port resources controller for Quantum v1.1 API"""
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"port": ["id", "state", "op-status"],
|
"port": ["id", "state", "op-status"],
|
||||||
"attachment": ["id"]},
|
"attachment": ["id"],
|
||||||
"plurals": {"ports": "port"}
|
},
|
||||||
}
|
"plurals": {
|
||||||
|
"ports": "port",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self.version = "1.1"
|
self.version = "1.1"
|
||||||
|
@ -31,8 +31,9 @@ import socket
|
|||||||
|
|
||||||
from paste import deploy
|
from paste import deploy
|
||||||
|
|
||||||
from quantum.common import flags
|
|
||||||
from quantum.common import exceptions as exception
|
from quantum.common import exceptions as exception
|
||||||
|
from quantum.common import flags
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
|
DEFAULT_LOG_FORMAT = "%(asctime)s %(levelname)8s [%(name)s] %(message)s"
|
||||||
DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
DEFAULT_LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
|
||||||
@ -142,10 +143,10 @@ def setup_logging(options, conf):
|
|||||||
|
|
||||||
# If either the CLI option or the conf value
|
# If either the CLI option or the conf value
|
||||||
# is True, we set to True
|
# is True, we set to True
|
||||||
debug = options.get('debug') or \
|
debug = (options.get('debug') or
|
||||||
get_option(conf, 'debug', type='bool', default=False)
|
get_option(conf, 'debug', type='bool', default=False))
|
||||||
verbose = options.get('verbose') or \
|
verbose = (options.get('verbose') or
|
||||||
get_option(conf, 'verbose', type='bool', default=False)
|
get_option(conf, 'verbose', type='bool', default=False))
|
||||||
root_logger = logging.root
|
root_logger = logging.root
|
||||||
if debug:
|
if debug:
|
||||||
root_logger.setLevel(logging.DEBUG)
|
root_logger.setLevel(logging.DEBUG)
|
||||||
@ -227,7 +228,7 @@ def find_config_file(options, args, config_file='quantum.conf'):
|
|||||||
# Handle standard directory search for the config file
|
# Handle standard directory search for the config file
|
||||||
config_file_dirs = [fix_path(os.path.join(os.getcwd(), 'etc')),
|
config_file_dirs = [fix_path(os.path.join(os.getcwd(), 'etc')),
|
||||||
fix_path(os.path.join('~', '.quantum-venv', 'etc',
|
fix_path(os.path.join('~', '.quantum-venv', 'etc',
|
||||||
'quantum')),
|
'quantum')),
|
||||||
fix_path('~'),
|
fix_path('~'),
|
||||||
os.path.join(FLAGS.state_path, 'etc'),
|
os.path.join(FLAGS.state_path, 'etc'),
|
||||||
os.path.join(FLAGS.state_path, 'etc', 'quantum'),
|
os.path.join(FLAGS.state_path, 'etc', 'quantum'),
|
||||||
@ -239,13 +240,14 @@ def find_config_file(options, args, config_file='quantum.conf'):
|
|||||||
'/etc']
|
'/etc']
|
||||||
|
|
||||||
if 'plugin' in options:
|
if 'plugin' in options:
|
||||||
config_file_dirs = [os.path.join(x, 'quantum', 'plugins',
|
config_file_dirs = [
|
||||||
options['plugin'])
|
os.path.join(x, 'quantum', 'plugins', options['plugin'])
|
||||||
for x in config_file_dirs]
|
for x in config_file_dirs
|
||||||
|
]
|
||||||
|
|
||||||
if os.path.exists(os.path.join(root, 'plugins')):
|
if os.path.exists(os.path.join(root, 'plugins')):
|
||||||
plugins = [fix_path(os.path.join(root, 'plugins', p, 'etc'))
|
plugins = [fix_path(os.path.join(root, 'plugins', p, 'etc'))
|
||||||
for p in os.listdir(os.path.join(root, 'plugins'))]
|
for p in os.listdir(os.path.join(root, 'plugins'))]
|
||||||
plugins = [p for p in plugins if os.path.isdir(p)]
|
plugins = [p for p in plugins if os.path.isdir(p)]
|
||||||
config_file_dirs.extend(plugins)
|
config_file_dirs.extend(plugins)
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class NetworkNotFound(NotFound):
|
|||||||
|
|
||||||
|
|
||||||
class PortNotFound(NotFound):
|
class PortNotFound(NotFound):
|
||||||
message = _("Port %(port_id)s could not be found " \
|
message = _("Port %(port_id)s could not be found "
|
||||||
"on network %(net_id)s")
|
"on network %(net_id)s")
|
||||||
|
|
||||||
|
|
||||||
@ -65,19 +65,19 @@ class StateInvalid(QuantumException):
|
|||||||
|
|
||||||
|
|
||||||
class NetworkInUse(QuantumException):
|
class NetworkInUse(QuantumException):
|
||||||
message = _("Unable to complete operation on network %(net_id)s. " \
|
message = _("Unable to complete operation on network %(net_id)s. "
|
||||||
"There is one or more attachments plugged into its ports.")
|
"There is one or more attachments plugged into its ports.")
|
||||||
|
|
||||||
|
|
||||||
class PortInUse(QuantumException):
|
class PortInUse(QuantumException):
|
||||||
message = _("Unable to complete operation on port %(port_id)s " \
|
message = _("Unable to complete operation on port %(port_id)s "
|
||||||
"for network %(net_id)s. The attachment '%(att_id)s" \
|
"for network %(net_id)s. The attachment '%(att_id)s"
|
||||||
"is plugged into the logical port.")
|
"is plugged into the logical port.")
|
||||||
|
|
||||||
|
|
||||||
class AlreadyAttached(QuantumException):
|
class AlreadyAttached(QuantumException):
|
||||||
message = _("Unable to plug the attachment %(att_id)s into port " \
|
message = _("Unable to plug the attachment %(att_id)s into port "
|
||||||
"%(port_id)s for network %(net_id)s. The attachment is " \
|
"%(port_id)s for network %(net_id)s. The attachment is "
|
||||||
"already plugged into port %(att_port_id)s")
|
"already plugged into port %(att_port_id)s")
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ def DECLARE(name, module_string, flag_values=FLAGS):
|
|||||||
__import__(module_string, globals(), locals())
|
__import__(module_string, globals(), locals())
|
||||||
if name not in flag_values:
|
if name not in flag_values:
|
||||||
raise gflags.UnrecognizedFlag(
|
raise gflags.UnrecognizedFlag(
|
||||||
"%s not defined by %s" % (name, module_string))
|
"%s not defined by %s" % (name, module_string))
|
||||||
|
|
||||||
|
|
||||||
# __GLOBAL FLAGS ONLY__
|
# __GLOBAL FLAGS ONLY__
|
||||||
|
@ -37,15 +37,14 @@
|
|||||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
import gettext
|
|
||||||
import os
|
|
||||||
import unittest
|
|
||||||
import sys
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
from nose import result
|
|
||||||
from nose import core
|
|
||||||
from nose import config
|
from nose import config
|
||||||
|
from nose import core
|
||||||
|
from nose import result
|
||||||
|
|
||||||
|
|
||||||
class _AnsiColorizer(object):
|
class _AnsiColorizer(object):
|
||||||
|
@ -20,27 +20,28 @@
|
|||||||
|
|
||||||
"""Utilities and helper functions."""
|
"""Utilities and helper functions."""
|
||||||
|
|
||||||
|
|
||||||
|
import base64
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import datetime
|
import datetime
|
||||||
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import subprocess
|
|
||||||
import socket
|
|
||||||
import sys
|
|
||||||
import base64
|
|
||||||
import functools
|
|
||||||
import json
|
|
||||||
import re
|
import re
|
||||||
|
import socket
|
||||||
import string
|
import string
|
||||||
import struct
|
import struct
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
import types
|
import types
|
||||||
|
|
||||||
from quantum.common import flags
|
|
||||||
from quantum.common import exceptions as exception
|
from quantum.common import exceptions as exception
|
||||||
from quantum.common.exceptions import ProcessExecutionError
|
from quantum.common.exceptions import ProcessExecutionError
|
||||||
|
from quantum.common import flags
|
||||||
|
|
||||||
|
|
||||||
def import_class(import_str):
|
def import_class(import_str):
|
||||||
@ -96,6 +97,7 @@ def dumps(value):
|
|||||||
def loads(s):
|
def loads(s):
|
||||||
return json.loads(s)
|
return json.loads(s)
|
||||||
|
|
||||||
|
|
||||||
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
@ -173,7 +175,6 @@ def abspath(s):
|
|||||||
|
|
||||||
# TODO(sirp): when/if utils is extracted to common library, we should remove
|
# TODO(sirp): when/if utils is extracted to common library, we should remove
|
||||||
# the argument's default.
|
# the argument's default.
|
||||||
#def default_flagfile(filename='nova.conf'):
|
|
||||||
def default_flagfile(filename='quantum.conf'):
|
def default_flagfile(filename='quantum.conf'):
|
||||||
for arg in sys.argv:
|
for arg in sys.argv:
|
||||||
if arg.find('flagfile') != -1:
|
if arg.find('flagfile') != -1:
|
||||||
@ -184,8 +185,7 @@ def default_flagfile(filename='quantum.conf'):
|
|||||||
script_dir = os.path.dirname(inspect.stack()[-1][1])
|
script_dir = os.path.dirname(inspect.stack()[-1][1])
|
||||||
filename = os.path.abspath(os.path.join(script_dir, filename))
|
filename = os.path.abspath(os.path.join(script_dir, filename))
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
sys.argv = \
|
sys.argv.insert(1, '--flagfile=%s' % filename)
|
||||||
sys.argv[:1] + ['--flagfile=%s' % filename] + sys.argv[1:]
|
|
||||||
|
|
||||||
|
|
||||||
def debug(arg):
|
def debug(arg):
|
||||||
@ -231,9 +231,9 @@ def parse_isotime(timestr):
|
|||||||
|
|
||||||
|
|
||||||
def get_plugin_from_config(file="config.ini"):
|
def get_plugin_from_config(file="config.ini"):
|
||||||
Config = ConfigParser.ConfigParser()
|
Config = ConfigParser.ConfigParser()
|
||||||
Config.read(file)
|
Config.read(file)
|
||||||
return Config.get("PLUGIN", "provider")
|
return Config.get("PLUGIN", "provider")
|
||||||
|
|
||||||
|
|
||||||
class LazyPluggable(object):
|
class LazyPluggable(object):
|
||||||
@ -251,7 +251,7 @@ class LazyPluggable(object):
|
|||||||
raise exception.Error('Invalid backend: %s' % backend_name)
|
raise exception.Error('Invalid backend: %s' % backend_name)
|
||||||
|
|
||||||
backend = self.__backends[backend_name]
|
backend = self.__backends[backend_name]
|
||||||
if type(backend) == type(tuple()):
|
if isinstance(backend, tuple):
|
||||||
name = backend[0]
|
name = backend[0]
|
||||||
fromlist = backend[1]
|
fromlist = backend[1]
|
||||||
else:
|
else:
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
# @author: Dan Wendlandt, Nicira Networks, Inc.
|
# @author: Dan Wendlandt, Nicira Networks, Inc.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import sqlalchemy as sql
|
import sqlalchemy as sql
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.exc import DisconnectionError
|
from sqlalchemy.exc import DisconnectionError
|
||||||
@ -127,17 +128,17 @@ def network_all_tenant_list():
|
|||||||
|
|
||||||
def network_list(tenant_id):
|
def network_list(tenant_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
return session.query(models.Network).\
|
return (session.query(models.Network).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
all()
|
all())
|
||||||
|
|
||||||
|
|
||||||
def network_get(net_id):
|
def network_get(net_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
try:
|
try:
|
||||||
return session.query(models.Network).\
|
return (session.query(models.Network).
|
||||||
filter_by(uuid=net_id).\
|
filter_by(uuid=net_id).
|
||||||
one()
|
one())
|
||||||
except exc.NoResultFound, e:
|
except exc.NoResultFound, e:
|
||||||
raise q_exc.NetworkNotFound(net_id=net_id)
|
raise q_exc.NetworkNotFound(net_id=net_id)
|
||||||
|
|
||||||
@ -155,13 +156,13 @@ def network_update(net_id, tenant_id, **kwargs):
|
|||||||
def network_destroy(net_id):
|
def network_destroy(net_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
try:
|
try:
|
||||||
net = session.query(models.Network).\
|
net = (session.query(models.Network).
|
||||||
filter_by(uuid=net_id).\
|
filter_by(uuid=net_id).
|
||||||
one()
|
one())
|
||||||
|
|
||||||
ports = session.query(models.Port).\
|
ports = (session.query(models.Port).
|
||||||
filter_by(network_id=net_id).\
|
filter_by(network_id=net_id).
|
||||||
all()
|
all())
|
||||||
for p in ports:
|
for p in ports:
|
||||||
session.delete(p)
|
session.delete(p)
|
||||||
|
|
||||||
@ -175,10 +176,10 @@ def network_destroy(net_id):
|
|||||||
def validate_network_ownership(tenant_id, net_id):
|
def validate_network_ownership(tenant_id, net_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
try:
|
try:
|
||||||
return session.query(models.Network).\
|
return (session.query(models.Network).
|
||||||
filter_by(uuid=net_id).\
|
filter_by(uuid=net_id).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
one()
|
one())
|
||||||
except exc.NoResultFound, e:
|
except exc.NoResultFound, e:
|
||||||
raise q_exc.NetworkNotFound(net_id=net_id)
|
raise q_exc.NetworkNotFound(net_id=net_id)
|
||||||
|
|
||||||
@ -204,9 +205,9 @@ def port_list(net_id):
|
|||||||
# confirm network exists
|
# confirm network exists
|
||||||
network_get(net_id)
|
network_get(net_id)
|
||||||
session = get_session()
|
session = get_session()
|
||||||
return session.query(models.Port).\
|
return (session.query(models.Port).
|
||||||
filter_by(network_id=net_id).\
|
filter_by(network_id=net_id).
|
||||||
all()
|
all())
|
||||||
|
|
||||||
|
|
||||||
def port_get(port_id, net_id, session=None):
|
def port_get(port_id, net_id, session=None):
|
||||||
@ -215,10 +216,10 @@ def port_get(port_id, net_id, session=None):
|
|||||||
if not session:
|
if not session:
|
||||||
session = get_session()
|
session = get_session()
|
||||||
try:
|
try:
|
||||||
return session.query(models.Port).\
|
return (session.query(models.Port).
|
||||||
filter_by(uuid=port_id).\
|
filter_by(uuid=port_id).
|
||||||
filter_by(network_id=net_id).\
|
filter_by(network_id=net_id).
|
||||||
one()
|
one())
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise q_exc.PortNotFound(net_id=net_id, port_id=port_id)
|
raise q_exc.PortNotFound(net_id=net_id, port_id=port_id)
|
||||||
|
|
||||||
@ -228,7 +229,7 @@ def port_update(port_id, net_id, **kwargs):
|
|||||||
network_get(net_id)
|
network_get(net_id)
|
||||||
port = port_get(port_id, net_id)
|
port = port_get(port_id, net_id)
|
||||||
session = get_session()
|
session = get_session()
|
||||||
for key in kwargs.keys():
|
for key in kwargs:
|
||||||
if key == "state":
|
if key == "state":
|
||||||
if kwargs[key] not in ('ACTIVE', 'DOWN'):
|
if kwargs[key] not in ('ACTIVE', 'DOWN'):
|
||||||
raise q_exc.StateInvalid(port_state=kwargs[key])
|
raise q_exc.StateInvalid(port_state=kwargs[key])
|
||||||
@ -249,16 +250,16 @@ def port_set_attachment(port_id, net_id, new_interface_id):
|
|||||||
# We are setting, not clearing, the attachment-id
|
# We are setting, not clearing, the attachment-id
|
||||||
if port['interface_id']:
|
if port['interface_id']:
|
||||||
raise q_exc.PortInUse(net_id=net_id, port_id=port_id,
|
raise q_exc.PortInUse(net_id=net_id, port_id=port_id,
|
||||||
att_id=port['interface_id'])
|
att_id=port['interface_id'])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
port = session.query(models.Port).\
|
port = (session.query(models.Port).
|
||||||
filter_by(interface_id=new_interface_id).\
|
filter_by(interface_id=new_interface_id).
|
||||||
one()
|
one())
|
||||||
raise q_exc.AlreadyAttached(net_id=net_id,
|
raise q_exc.AlreadyAttached(net_id=net_id,
|
||||||
port_id=port_id,
|
port_id=port_id,
|
||||||
att_id=new_interface_id,
|
att_id=new_interface_id,
|
||||||
att_port_id=port['uuid'])
|
att_port_id=port['uuid'])
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
# this is what should happen
|
# this is what should happen
|
||||||
pass
|
pass
|
||||||
@ -285,13 +286,13 @@ def port_destroy(port_id, net_id):
|
|||||||
|
|
||||||
session = get_session()
|
session = get_session()
|
||||||
try:
|
try:
|
||||||
port = session.query(models.Port).\
|
port = (session.query(models.Port).
|
||||||
filter_by(uuid=port_id).\
|
filter_by(uuid=port_id).
|
||||||
filter_by(network_id=net_id).\
|
filter_by(network_id=net_id).
|
||||||
one()
|
one())
|
||||||
if port['interface_id']:
|
if port['interface_id']:
|
||||||
raise q_exc.PortInUse(net_id=net_id, port_id=port_id,
|
raise q_exc.PortInUse(net_id=net_id, port_id=port_id,
|
||||||
att_id=port['interface_id'])
|
att_id=port['interface_id'])
|
||||||
session.delete(port)
|
session.delete(port)
|
||||||
session.flush()
|
session.flush()
|
||||||
return port
|
return port
|
||||||
|
@ -26,6 +26,7 @@ from sqlalchemy.orm import relation, object_mapper
|
|||||||
|
|
||||||
from quantum.api import api_common as common
|
from quantum.api import api_common as common
|
||||||
|
|
||||||
|
|
||||||
BASE = declarative_base()
|
BASE = declarative_base()
|
||||||
|
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ class QuantumBase(object):
|
|||||||
Includes attributes from joins."""
|
Includes attributes from joins."""
|
||||||
local = dict(self)
|
local = dict(self)
|
||||||
joined = dict([(k, v) for k, v in self.__dict__.iteritems()
|
joined = dict([(k, v) for k, v in self.__dict__.iteritems()
|
||||||
if not k[0] == '_'])
|
if not k[0] == '_'])
|
||||||
local.update(joined)
|
local.update(joined)
|
||||||
return local.iteritems()
|
return local.iteritems()
|
||||||
|
|
||||||
@ -76,8 +77,7 @@ class Port(BASE, QuantumBase):
|
|||||||
state = Column(String(8))
|
state = Column(String(8))
|
||||||
op_status = Column(String(16))
|
op_status = Column(String(16))
|
||||||
|
|
||||||
def __init__(self, network_id,
|
def __init__(self, network_id, op_status=common.OperationalStatus.UNKNOWN):
|
||||||
op_status=common.OperationalStatus.UNKNOWN):
|
|
||||||
self.uuid = str(uuid.uuid4())
|
self.uuid = str(uuid.uuid4())
|
||||||
self.network_id = network_id
|
self.network_id = network_id
|
||||||
self.interface_id = None
|
self.interface_id = None
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,7 +16,6 @@
|
|||||||
#
|
#
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def get_view_builder(req):
|
def get_view_builder(req):
|
||||||
@ -52,5 +50,5 @@ class ViewBuilder(object):
|
|||||||
def _build_detail(self, credential_data):
|
def _build_detail(self, credential_data):
|
||||||
"""Return a detailed description of credential."""
|
"""Return a detailed description of credential."""
|
||||||
return dict(credential=dict(id=credential_data['credential_id'],
|
return dict(credential=dict(id=credential_data['credential_id'],
|
||||||
name=credential_data['user_name'],
|
name=credential_data['user_name'],
|
||||||
password=credential_data['password']))
|
password=credential_data['password']))
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,7 +16,7 @@
|
|||||||
#
|
#
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Nicira Networks, Inc. All rights reserved.
|
# Copyright 2011 Nicira Networks, Inc. All rights reserved.
|
||||||
@ -17,7 +16,6 @@
|
|||||||
#
|
#
|
||||||
# @author: Brad Hall, Nicira Networks, Inc
|
# @author: Brad Hall, Nicira Networks, Inc
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def get_view_builder(req):
|
def get_view_builder(req):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,8 +15,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def get_view_builder(req):
|
def get_view_builder(req):
|
||||||
@ -52,11 +49,15 @@ class ViewBuilder(object):
|
|||||||
def _build_detail(self, portprofile_data):
|
def _build_detail(self, portprofile_data):
|
||||||
"""Return a detailed info of a portprofile."""
|
"""Return a detailed info of a portprofile."""
|
||||||
if (portprofile_data['assignment'] is None):
|
if (portprofile_data['assignment'] is None):
|
||||||
return dict(portprofile=dict(id=portprofile_data['profile_id'],
|
return dict(portprofile=dict(
|
||||||
name=portprofile_data['profile_name'],
|
id=portprofile_data['profile_id'],
|
||||||
qos_name=portprofile_data['qos_name']))
|
name=portprofile_data['profile_name'],
|
||||||
|
qos_name=portprofile_data['qos_name'],
|
||||||
|
))
|
||||||
else:
|
else:
|
||||||
return dict(portprofile=dict(id=portprofile_data['profile_id'],
|
return dict(portprofile=dict(
|
||||||
name=portprofile_data['profile_name'],
|
id=portprofile_data['profile_id'],
|
||||||
qos_name=portprofile_data['qos_name'],
|
name=portprofile_data['profile_name'],
|
||||||
assignment=portprofile_data['assignment']))
|
qos_name=portprofile_data['qos_name'],
|
||||||
|
assignment=portprofile_data['assignment'],
|
||||||
|
))
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,7 +16,6 @@
|
|||||||
#
|
#
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def get_view_builder(req):
|
def get_view_builder(req):
|
||||||
@ -52,5 +50,5 @@ class ViewBuilder(object):
|
|||||||
def _build_detail(self, qos_data):
|
def _build_detail(self, qos_data):
|
||||||
"""Return a detailed description of qos."""
|
"""Return a detailed description of qos."""
|
||||||
return dict(qos=dict(id=qos_data['qos_id'],
|
return dict(qos=dict(id=qos_data['qos_id'],
|
||||||
name=qos_data['qos_name'],
|
name=qos_data['qos_name'],
|
||||||
description=qos_data['qos_desc']))
|
description=qos_data['qos_desc']))
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,18 +15,19 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from webob import exc
|
from webob import exc
|
||||||
from quantum import wsgi
|
|
||||||
from quantum.extensions import _credential_view as credential_view
|
|
||||||
from quantum.api import api_common as common
|
from quantum.api import api_common as common
|
||||||
|
from quantum.extensions import _credential_view as credential_view
|
||||||
from quantum.extensions import extensions
|
from quantum.extensions import extensions
|
||||||
from quantum.manager import QuantumManager
|
from quantum.manager import QuantumManager
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as exception
|
from quantum.plugins.cisco.common import cisco_exceptions as exception
|
||||||
from quantum.plugins.cisco.common import cisco_faults as faults
|
from quantum.plugins.cisco.common import cisco_faults as faults
|
||||||
|
from quantum import wsgi
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum.api.credentials')
|
LOG = logging.getLogger('quantum.api.credentials')
|
||||||
|
|
||||||
@ -76,13 +76,11 @@ class CredentialController(common.QuantumController, wsgi.Controller):
|
|||||||
""" credential API controller
|
""" credential API controller
|
||||||
based on QuantumController """
|
based on QuantumController """
|
||||||
|
|
||||||
_credential_ops_param_list = [{
|
_credential_ops_param_list = [
|
||||||
'param-name': 'credential_name',
|
{'param-name': 'credential_name', 'required': True},
|
||||||
'required': True}, {
|
{'param-name': 'user_name', 'required': True},
|
||||||
'param-name': 'user_name',
|
{'param-name': 'password', 'required': True},
|
||||||
'required': True}, {
|
]
|
||||||
'param-name': 'password',
|
|
||||||
'required': True}]
|
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
@ -112,8 +110,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
|
|||||||
def show(self, request, tenant_id, id):
|
def show(self, request, tenant_id, id):
|
||||||
""" Returns credential details for the given credential id """
|
""" Returns credential details for the given credential id """
|
||||||
try:
|
try:
|
||||||
credential = self._plugin.get_credential_details(
|
credential = self._plugin.get_credential_details(tenant_id, id)
|
||||||
tenant_id, id)
|
|
||||||
builder = credential_view.get_view_builder(request)
|
builder = credential_view.get_view_builder(request)
|
||||||
#build response with details
|
#build response with details
|
||||||
result = builder.build(credential, True)
|
result = builder.build(credential, True)
|
||||||
@ -125,18 +122,17 @@ class CredentialController(common.QuantumController, wsgi.Controller):
|
|||||||
""" Creates a new credential for a given tenant """
|
""" Creates a new credential for a given tenant """
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
req_body = \
|
req_body = self._prepare_request_body(
|
||||||
self._prepare_request_body(body,
|
body, self._credential_ops_param_list)
|
||||||
self._credential_ops_param_list)
|
|
||||||
req_params = req_body[self._resource_name]
|
req_params = req_body[self._resource_name]
|
||||||
|
|
||||||
except exc.HTTPError as exp:
|
except exc.HTTPError as exp:
|
||||||
return faults.Fault(exp)
|
return faults.Fault(exp)
|
||||||
credential = self._plugin.\
|
credential = self._plugin.create_credential(
|
||||||
create_credential(tenant_id,
|
tenant_id,
|
||||||
req_params['credential_name'],
|
req_params['credential_name'],
|
||||||
req_params['user_name'],
|
req_params['user_name'],
|
||||||
req_params['password'])
|
req_params['password'])
|
||||||
builder = credential_view.get_view_builder(request)
|
builder = credential_view.get_view_builder(request)
|
||||||
result = builder.build(credential)
|
result = builder.build(credential)
|
||||||
return dict(credentials=result)
|
return dict(credentials=result)
|
||||||
@ -145,16 +141,14 @@ class CredentialController(common.QuantumController, wsgi.Controller):
|
|||||||
""" Updates the name for the credential with the given id """
|
""" Updates the name for the credential with the given id """
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
req_body = \
|
req_body = self._prepare_request_body(
|
||||||
self._prepare_request_body(body,
|
body, self._credential_ops_param_list)
|
||||||
self._credential_ops_param_list)
|
|
||||||
req_params = req_body[self._resource_name]
|
req_params = req_body[self._resource_name]
|
||||||
except exc.HTTPError as exp:
|
except exc.HTTPError as exp:
|
||||||
return faults.Fault(exp)
|
return faults.Fault(exp)
|
||||||
try:
|
try:
|
||||||
credential = self._plugin.\
|
credential = self._plugin.rename_credential(
|
||||||
rename_credential(tenant_id,
|
tenant_id, id, req_params['credential_name'])
|
||||||
id, req_params['credential_name'])
|
|
||||||
|
|
||||||
builder = credential_view.get_view_builder(request)
|
builder = credential_view.get_view_builder(request)
|
||||||
result = builder.build(credential, True)
|
result = builder.build(credential, True)
|
||||||
|
@ -16,20 +16,22 @@
|
|||||||
# 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
|
||||||
import imp
|
import imp
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import routes
|
import routes
|
||||||
import webob.dec
|
import webob.dec
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
from gettext import gettext as _
|
|
||||||
from abc import ABCMeta
|
|
||||||
from quantum.common import exceptions
|
from quantum.common import exceptions
|
||||||
import quantum.extensions
|
import quantum.extensions
|
||||||
from quantum.manager import QuantumManager
|
from quantum.manager import QuantumManager
|
||||||
from quantum import wsgi
|
from quantum import wsgi
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum.extensions.extensions')
|
LOG = logging.getLogger('quantum.extensions.extensions')
|
||||||
|
|
||||||
|
|
||||||
@ -281,14 +283,14 @@ class ExtensionMiddleware(wsgi.Middleware):
|
|||||||
if not action.collection in action_controllers.keys():
|
if not action.collection in action_controllers.keys():
|
||||||
controller = ActionExtensionController(application)
|
controller = ActionExtensionController(application)
|
||||||
mapper.connect("/%s/:(id)/action.:(format)" %
|
mapper.connect("/%s/:(id)/action.:(format)" %
|
||||||
action.collection,
|
action.collection,
|
||||||
action='action',
|
action='action',
|
||||||
controller=controller,
|
controller=controller,
|
||||||
conditions=dict(method=['POST']))
|
conditions=dict(method=['POST']))
|
||||||
mapper.connect("/%s/:(id)/action" % action.collection,
|
mapper.connect("/%s/:(id)/action" % action.collection,
|
||||||
action='action',
|
action='action',
|
||||||
controller=controller,
|
controller=controller,
|
||||||
conditions=dict(method=['POST']))
|
conditions=dict(method=['POST']))
|
||||||
action_controllers[action.collection] = controller
|
action_controllers[action.collection] = controller
|
||||||
|
|
||||||
return action_controllers
|
return action_controllers
|
||||||
@ -300,14 +302,14 @@ class ExtensionMiddleware(wsgi.Middleware):
|
|||||||
if not req_ext.key in request_ext_controllers.keys():
|
if not req_ext.key in request_ext_controllers.keys():
|
||||||
controller = RequestExtensionController(application)
|
controller = RequestExtensionController(application)
|
||||||
mapper.connect(req_ext.url_route + '.:(format)',
|
mapper.connect(req_ext.url_route + '.:(format)',
|
||||||
action='process',
|
action='process',
|
||||||
controller=controller,
|
controller=controller,
|
||||||
conditions=req_ext.conditions)
|
conditions=req_ext.conditions)
|
||||||
|
|
||||||
mapper.connect(req_ext.url_route,
|
mapper.connect(req_ext.url_route,
|
||||||
action='process',
|
action='process',
|
||||||
controller=controller,
|
controller=controller,
|
||||||
conditions=req_ext.conditions)
|
conditions=req_ext.conditions)
|
||||||
request_ext_controllers[req_ext.key] = controller
|
request_ext_controllers[req_ext.key] = controller
|
||||||
|
|
||||||
return request_ext_controllers
|
return request_ext_controllers
|
||||||
@ -361,7 +363,7 @@ class ExtensionManager(object):
|
|||||||
"""Returns a list of ResourceExtension objects."""
|
"""Returns a list of ResourceExtension objects."""
|
||||||
resources = []
|
resources = []
|
||||||
resources.append(ResourceExtension('extensions',
|
resources.append(ResourceExtension('extensions',
|
||||||
ExtensionController(self)))
|
ExtensionController(self)))
|
||||||
for alias, ext in self.extensions.iteritems():
|
for alias, ext in self.extensions.iteritems():
|
||||||
try:
|
try:
|
||||||
resources.extend(ext.get_resources())
|
resources.extend(ext.get_resources())
|
||||||
@ -496,7 +498,7 @@ class PluginAwareExtensionManager(ExtensionManager):
|
|||||||
if not plugin_has_interface:
|
if not plugin_has_interface:
|
||||||
LOG.warn("plugin %s does not implement extension's"
|
LOG.warn("plugin %s does not implement extension's"
|
||||||
"plugin interface %s" % (self.plugin,
|
"plugin interface %s" % (self.plugin,
|
||||||
extension.get_alias()))
|
extension.get_alias()))
|
||||||
return plugin_has_interface
|
return plugin_has_interface
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,18 +15,19 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from webob import exc
|
from webob import exc
|
||||||
from quantum import wsgi
|
|
||||||
from quantum.api import api_common as common
|
from quantum.api import api_common as common
|
||||||
from quantum.api.views import ports as port_view
|
from quantum.api.views import ports as port_view
|
||||||
from quantum.extensions import extensions
|
from quantum.extensions import extensions
|
||||||
from quantum.manager import QuantumManager
|
from quantum.manager import QuantumManager
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as exception
|
from quantum.plugins.cisco.common import cisco_exceptions as exception
|
||||||
from quantum.plugins.cisco.common import cisco_faults as faults
|
from quantum.plugins.cisco.common import cisco_faults as faults
|
||||||
|
from quantum import wsgi
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum.api.multiports')
|
LOG = logging.getLogger('quantum.api.multiports')
|
||||||
|
|
||||||
@ -76,13 +76,11 @@ class MultiportController(common.QuantumController, wsgi.Controller):
|
|||||||
""" multiport API controller
|
""" multiport API controller
|
||||||
based on QuantumController """
|
based on QuantumController """
|
||||||
|
|
||||||
_multiport_ops_param_list = [{
|
_multiport_ops_param_list = [
|
||||||
'param-name': 'net_id_list',
|
{'param-name': 'net_id_list', 'required': True},
|
||||||
'required': True}, {
|
{'param-name': 'status', 'required': True},
|
||||||
'param-name': 'status',
|
{'param-name': 'ports_desc', 'required': True},
|
||||||
'required': True}, {
|
]
|
||||||
'param-name': 'ports_desc',
|
|
||||||
'required': True}]
|
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
@ -102,19 +100,16 @@ class MultiportController(common.QuantumController, wsgi.Controller):
|
|||||||
""" Creates a new multiport for a given tenant """
|
""" Creates a new multiport for a given tenant """
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
req_body = \
|
req_body = self._prepare_request_body(
|
||||||
self._prepare_request_body(body,
|
body, self._multiport_ops_param_list)
|
||||||
self._multiport_ops_param_list)
|
|
||||||
req_params = req_body[self._resource_name]
|
req_params = req_body[self._resource_name]
|
||||||
|
|
||||||
except exc.HTTPError as exp:
|
except exc.HTTPError as exp:
|
||||||
return faults.Fault(exp)
|
return faults.Fault(exp)
|
||||||
multiports = self._plugin.\
|
multiports = self._plugin.create_multiport(tenant_id,
|
||||||
create_multiport(tenant_id,
|
req_params['net_id_list'],
|
||||||
req_params['net_id_list'],
|
req_params['status'],
|
||||||
req_params['status'],
|
req_params['ports_desc'])
|
||||||
req_params['ports_desc'])
|
|
||||||
builder = port_view.get_view_builder(request, self.version)
|
builder = port_view.get_view_builder(request, self.version)
|
||||||
result = [builder.build(port)['port']
|
result = [builder.build(port)['port'] for port in multiports]
|
||||||
for port in multiports]
|
|
||||||
return dict(ports=result)
|
return dict(ports=result)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,16 +15,16 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
from webob import exc
|
from webob import exc
|
||||||
from quantum import wsgi
|
|
||||||
from quantum.extensions import _novatenant_view as novatenant_view
|
|
||||||
from quantum.api import api_common as common
|
from quantum.api import api_common as common
|
||||||
from quantum.common import exceptions as qexception
|
from quantum.common import exceptions as qexception
|
||||||
from quantum.extensions import extensions
|
from quantum.extensions import extensions
|
||||||
|
from quantum.extensions import _novatenant_view as novatenant_view
|
||||||
from quantum.manager import QuantumManager
|
from quantum.manager import QuantumManager
|
||||||
from quantum.plugins.cisco.common import cisco_faults as faults
|
from quantum.plugins.cisco.common import cisco_faults as faults
|
||||||
|
from quantum import wsgi
|
||||||
|
|
||||||
|
|
||||||
class Novatenant(object):
|
class Novatenant(object):
|
||||||
@ -76,15 +75,14 @@ class NovatenantsController(common.QuantumController, wsgi.Controller):
|
|||||||
""" Novatenant API controller
|
""" Novatenant API controller
|
||||||
based on QuantumController """
|
based on QuantumController """
|
||||||
|
|
||||||
_Novatenant_ops_param_list = [{
|
_Novatenant_ops_param_list = [
|
||||||
'param-name': 'novatenant_name',
|
{'param-name': 'novatenant_name', 'required': True},
|
||||||
'required': True}]
|
]
|
||||||
|
|
||||||
_schedule_host_ops_param_list = [{
|
_schedule_host_ops_param_list = [
|
||||||
'param-name': 'instance_id',
|
{'param-name': 'instance_id', 'required': True},
|
||||||
'required': True}, {
|
{'param-name': 'instance_desc', 'required': True},
|
||||||
'param-name': 'instance_desc',
|
]
|
||||||
'required': True}]
|
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
@ -122,9 +120,8 @@ class NovatenantsController(common.QuantumController, wsgi.Controller):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, content_type)
|
body = self._deserialize(request.body, content_type)
|
||||||
req_body = \
|
req_body = self._prepare_request_body(
|
||||||
self._prepare_request_body(body,
|
body, self._schedule_host_ops_param_list)
|
||||||
self._schedule_host_ops_param_list)
|
|
||||||
req_params = req_body[self._resource_name]
|
req_params = req_body[self._resource_name]
|
||||||
|
|
||||||
except exc.HTTPError as exp:
|
except exc.HTTPError as exp:
|
||||||
@ -132,8 +129,9 @@ class NovatenantsController(common.QuantumController, wsgi.Controller):
|
|||||||
instance_id = req_params['instance_id']
|
instance_id = req_params['instance_id']
|
||||||
instance_desc = req_params['instance_desc']
|
instance_desc = req_params['instance_desc']
|
||||||
try:
|
try:
|
||||||
host = self._plugin.\
|
host = self._plugin.schedule_host(tenant_id,
|
||||||
schedule_host(tenant_id, instance_id, instance_desc)
|
instance_id,
|
||||||
|
instance_desc)
|
||||||
builder = novatenant_view.get_view_builder(request)
|
builder = novatenant_view.get_view_builder(request)
|
||||||
result = builder.build_host(host)
|
result = builder.build_host(host)
|
||||||
return result
|
return result
|
||||||
@ -144,9 +142,8 @@ class NovatenantsController(common.QuantumController, wsgi.Controller):
|
|||||||
content_type = request.best_match_content_type()
|
content_type = request.best_match_content_type()
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, content_type)
|
body = self._deserialize(request.body, content_type)
|
||||||
req_body = \
|
req_body = self._prepare_request_body(
|
||||||
self._prepare_request_body(body,
|
body, self._schedule_host_ops_param_list)
|
||||||
self._schedule_host_ops_param_list)
|
|
||||||
req_params = req_body[self._resource_name]
|
req_params = req_body[self._resource_name]
|
||||||
|
|
||||||
except exc.HTTPError as exp:
|
except exc.HTTPError as exp:
|
||||||
@ -154,8 +151,9 @@ class NovatenantsController(common.QuantumController, wsgi.Controller):
|
|||||||
instance_id = req_params['instance_id']
|
instance_id = req_params['instance_id']
|
||||||
instance_desc = req_params['instance_desc']
|
instance_desc = req_params['instance_desc']
|
||||||
try:
|
try:
|
||||||
vif = self._plugin. \
|
vif = self._plugin.associate_port(tenant_id,
|
||||||
associate_port(tenant_id, instance_id, instance_desc)
|
instance_id,
|
||||||
|
instance_desc)
|
||||||
builder = novatenant_view.get_view_builder(request)
|
builder = novatenant_view.get_view_builder(request)
|
||||||
result = builder.build_vif(vif)
|
result = builder.build_vif(vif)
|
||||||
return result
|
return result
|
||||||
@ -166,9 +164,8 @@ class NovatenantsController(common.QuantumController, wsgi.Controller):
|
|||||||
content_type = request.best_match_content_type()
|
content_type = request.best_match_content_type()
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, content_type)
|
body = self._deserialize(request.body, content_type)
|
||||||
req_body = \
|
req_body = self._prepare_request_body(
|
||||||
self._prepare_request_body(body,
|
body, self._schedule_host_ops_param_list)
|
||||||
self._schedule_host_ops_param_list)
|
|
||||||
req_params = req_body[self._resource_name]
|
req_params = req_body[self._resource_name]
|
||||||
|
|
||||||
except exc.HTTPError as exp:
|
except exc.HTTPError as exp:
|
||||||
@ -178,8 +175,9 @@ class NovatenantsController(common.QuantumController, wsgi.Controller):
|
|||||||
instance_desc = req_params['instance_desc']
|
instance_desc = req_params['instance_desc']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
vif = self._plugin. \
|
vif = self._plugin.detach_port(tenant_id,
|
||||||
detach_port(tenant_id, instance_id, instance_desc)
|
instance_id,
|
||||||
|
instance_desc)
|
||||||
builder = novatenant_view.get_view_builder(request)
|
builder = novatenant_view.get_view_builder(request)
|
||||||
result = builder.build_result(True)
|
result = builder.build_result(True)
|
||||||
return result
|
return result
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,18 +15,17 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
from webob import exc
|
from webob import exc
|
||||||
from quantum import wsgi
|
|
||||||
from quantum.extensions import _pprofiles as pprofiles_view
|
|
||||||
from quantum.api import api_common as common
|
from quantum.api import api_common as common
|
||||||
from quantum.common import exceptions as qexception
|
from quantum.common import exceptions as qexception
|
||||||
|
from quantum.extensions import _pprofiles as pprofiles_view
|
||||||
from quantum.extensions import extensions
|
from quantum.extensions import extensions
|
||||||
from quantum.manager import QuantumManager
|
from quantum.manager import QuantumManager
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as exception
|
from quantum.plugins.cisco.common import cisco_exceptions as exception
|
||||||
from quantum.plugins.cisco.common import cisco_faults as faults
|
from quantum.plugins.cisco.common import cisco_faults as faults
|
||||||
|
from quantum import wsgi
|
||||||
|
|
||||||
|
|
||||||
class Portprofile(object):
|
class Portprofile(object):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Nicira Networks, Inc. All rights reserved.
|
# Copyright 2011 Nicira Networks, Inc. All rights reserved.
|
||||||
@ -16,17 +15,15 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Brad Hall, Nicira Networks, Inc
|
# @author: Brad Hall, Nicira Networks, Inc
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from quantum import wsgi
|
|
||||||
from quantum.extensions import _portstats_view as portstats_view
|
|
||||||
from quantum.api import faults
|
from quantum.api import faults
|
||||||
from quantum.common import exceptions as qexception
|
from quantum.common import exceptions as qexception
|
||||||
from quantum.common import extensions
|
from quantum.common import extensions
|
||||||
|
from quantum.extensions import _portstats_view as portstats_view
|
||||||
from quantum.manager import QuantumManager
|
from quantum.manager import QuantumManager
|
||||||
|
from quantum import wsgi
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger("quantum.api.portstats")
|
LOG = logging.getLogger("quantum.api.portstats")
|
||||||
@ -61,8 +58,8 @@ class Portstats(object):
|
|||||||
""" Returns all defined resources """
|
""" Returns all defined resources """
|
||||||
controller = StatsController(QuantumManager.get_plugin())
|
controller = StatsController(QuantumManager.get_plugin())
|
||||||
parent_resource = dict(member_name="port",
|
parent_resource = dict(member_name="port",
|
||||||
collection_name="extensions/ovs/tenants/" + \
|
collection_name="extensions/ovs/tenants/"
|
||||||
":(tenant_id)/networks/:(network_id)/ports")
|
":(tenant_id)/ networks/:(network_id)/ports")
|
||||||
return [extensions.ResourceExtension('stats', controller,
|
return [extensions.ResourceExtension('stats', controller,
|
||||||
parent=parent_resource)]
|
parent=parent_resource)]
|
||||||
|
|
||||||
@ -84,12 +81,10 @@ class StatsController(wsgi.Controller):
|
|||||||
def _show(self, request, tenant_id, network_id, port_id):
|
def _show(self, request, tenant_id, network_id, port_id):
|
||||||
"""Returns port statistics for a given port"""
|
"""Returns port statistics for a given port"""
|
||||||
if not hasattr(self._plugin, "get_port_stats"):
|
if not hasattr(self._plugin, "get_port_stats"):
|
||||||
return \
|
return faults.QuantumHTTPError(
|
||||||
faults.QuantumHTTPError(
|
qexception.NotImplementedError("get_port_stats"))
|
||||||
qexception.NotImplementedError("get_port_stats"))
|
|
||||||
|
|
||||||
stats = self._plugin.get_port_stats(tenant_id, network_id,
|
stats = self._plugin.get_port_stats(tenant_id, network_id, port_id)
|
||||||
port_id)
|
|
||||||
builder = portstats_view.get_view_builder(request)
|
builder = portstats_view.get_view_builder(request)
|
||||||
result = builder.build(stats, True)
|
result = builder.build(stats, True)
|
||||||
return dict(stats=result)
|
return dict(stats=result)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,18 +15,18 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from quantum import wsgi
|
|
||||||
from webob import exc
|
from webob import exc
|
||||||
from quantum.extensions import _qos_view as qos_view
|
|
||||||
from quantum.api import api_common as common
|
from quantum.api import api_common as common
|
||||||
|
from quantum.extensions import _qos_view as qos_view
|
||||||
from quantum.extensions import extensions
|
from quantum.extensions import extensions
|
||||||
from quantum.manager import QuantumManager
|
from quantum.manager import QuantumManager
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as exception
|
from quantum.plugins.cisco.common import cisco_exceptions as exception
|
||||||
from quantum.plugins.cisco.common import cisco_faults as faults
|
from quantum.plugins.cisco.common import cisco_faults as faults
|
||||||
|
from quantum import wsgi
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum.api.qoss')
|
LOG = logging.getLogger('quantum.api.qoss')
|
||||||
@ -78,11 +77,11 @@ class QosController(common.QuantumController, wsgi.Controller):
|
|||||||
""" qos API controller
|
""" qos API controller
|
||||||
based on QuantumController """
|
based on QuantumController """
|
||||||
|
|
||||||
_qos_ops_param_list = [{
|
_qos_ops_param_list = [
|
||||||
'param-name': 'qos_name',
|
{'param-name': 'qos_name', 'required': True},
|
||||||
'required': True}, {
|
{'param-name': 'qos_desc', 'required': True},
|
||||||
'param-name': 'qos_desc',
|
]
|
||||||
'required': True}]
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
@ -103,16 +102,14 @@ class QosController(common.QuantumController, wsgi.Controller):
|
|||||||
""" Returns a list of qoss. """
|
""" Returns a list of qoss. """
|
||||||
qoss = self._plugin.get_all_qoss(tenant_id)
|
qoss = self._plugin.get_all_qoss(tenant_id)
|
||||||
builder = qos_view.get_view_builder(request)
|
builder = qos_view.get_view_builder(request)
|
||||||
result = [builder.build(qos, is_detail)['qos']
|
result = [builder.build(qos, is_detail)['qos'] for qos in qoss]
|
||||||
for qos in qoss]
|
|
||||||
return dict(qoss=result)
|
return dict(qoss=result)
|
||||||
|
|
||||||
# pylint: disable-msg=E1101
|
# pylint: disable-msg=E1101
|
||||||
def show(self, request, tenant_id, id):
|
def show(self, request, tenant_id, id):
|
||||||
""" Returns qos details for the given qos id """
|
""" Returns qos details for the given qos id """
|
||||||
try:
|
try:
|
||||||
qos = self._plugin.get_qos_details(
|
qos = self._plugin.get_qos_details(tenant_id, id)
|
||||||
tenant_id, id)
|
|
||||||
builder = qos_view.get_view_builder(request)
|
builder = qos_view.get_view_builder(request)
|
||||||
#build response with details
|
#build response with details
|
||||||
result = builder.build(qos, True)
|
result = builder.build(qos, True)
|
||||||
@ -125,16 +122,14 @@ class QosController(common.QuantumController, wsgi.Controller):
|
|||||||
#look for qos name in request
|
#look for qos name in request
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
req_body = \
|
req_body = self._prepare_request_body(body,
|
||||||
self._prepare_request_body(body,
|
self._qos_ops_param_list)
|
||||||
self._qos_ops_param_list)
|
|
||||||
req_params = req_body[self._resource_name]
|
req_params = req_body[self._resource_name]
|
||||||
except exc.HTTPError as exp:
|
except exc.HTTPError as exp:
|
||||||
return faults.Fault(exp)
|
return faults.Fault(exp)
|
||||||
qos = self._plugin.\
|
qos = self._plugin.create_qos(tenant_id,
|
||||||
create_qos(tenant_id,
|
req_params['qos_name'],
|
||||||
req_params['qos_name'],
|
req_params['qos_desc'])
|
||||||
req_params['qos_desc'])
|
|
||||||
builder = qos_view.get_view_builder(request)
|
builder = qos_view.get_view_builder(request)
|
||||||
result = builder.build(qos)
|
result = builder.build(qos)
|
||||||
return dict(qoss=result)
|
return dict(qoss=result)
|
||||||
@ -143,16 +138,14 @@ class QosController(common.QuantumController, wsgi.Controller):
|
|||||||
""" Updates the name for the qos with the given id """
|
""" Updates the name for the qos with the given id """
|
||||||
try:
|
try:
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
req_body = \
|
req_body = self._prepare_request_body(body,
|
||||||
self._prepare_request_body(body,
|
self._qos_ops_param_list)
|
||||||
self._qos_ops_param_list)
|
|
||||||
req_params = req_body[self._resource_name]
|
req_params = req_body[self._resource_name]
|
||||||
except exc.HTTPError as exp:
|
except exc.HTTPError as exp:
|
||||||
return faults.Fault(exp)
|
return faults.Fault(exp)
|
||||||
try:
|
try:
|
||||||
qos = self._plugin.\
|
qos = self._plugin.rename_qos(tenant_id, id,
|
||||||
rename_qos(tenant_id,
|
req_params['qos_name'])
|
||||||
id, req_params['qos_name'])
|
|
||||||
|
|
||||||
builder = qos_view.get_view_builder(request)
|
builder = qos_view.get_view_builder(request)
|
||||||
result = builder.build(qos, True)
|
result = builder.build(qos, True)
|
||||||
|
@ -16,27 +16,26 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
# @author: Somik Behera, Nicira Networks, Inc.
|
# @author: Somik Behera, Nicira Networks, Inc.
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Quantum's Manager class is responsible for parsing a config file and
|
Quantum's Manager class is responsible for parsing a config file and
|
||||||
instantiating the correct plugin that concretely implement quantum_plugin_base
|
instantiating the correct plugin that concretely implement quantum_plugin_base
|
||||||
class.
|
class.
|
||||||
The caller should make sure that QuantumManager is a singleton.
|
The caller should make sure that QuantumManager is a singleton.
|
||||||
"""
|
"""
|
||||||
import gettext
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
gettext.install('quantum', unicode=1)
|
|
||||||
|
|
||||||
from quantum.common import utils
|
from quantum.common import utils
|
||||||
from quantum.common.config import find_config_file
|
from quantum.common.config import find_config_file
|
||||||
from quantum.common.exceptions import ClassNotFound
|
from quantum.common.exceptions import ClassNotFound
|
||||||
from quantum_plugin_base import QuantumPluginBase
|
from quantum.quantum_plugin_base import QuantumPluginBase
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum.manager')
|
LOG = logging.getLogger('quantum.manager')
|
||||||
|
|
||||||
|
|
||||||
CONFIG_FILE = "plugins.ini"
|
CONFIG_FILE = "plugins.ini"
|
||||||
LOG = logging.getLogger('quantum.manager')
|
|
||||||
|
|
||||||
|
|
||||||
def find_config(basepath):
|
def find_config(basepath):
|
||||||
@ -61,23 +60,23 @@ class QuantumManager(object):
|
|||||||
self.configuration_file = find_config_file(options, config_file,
|
self.configuration_file = find_config_file(options, config_file,
|
||||||
CONFIG_FILE)
|
CONFIG_FILE)
|
||||||
if not 'plugin_provider' in options:
|
if not 'plugin_provider' in options:
|
||||||
options['plugin_provider'] = \
|
options['plugin_provider'] = utils.get_plugin_from_config(
|
||||||
utils.get_plugin_from_config(self.configuration_file)
|
self.configuration_file)
|
||||||
LOG.debug("Plugin location:%s", options['plugin_provider'])
|
LOG.debug("Plugin location:%s", options['plugin_provider'])
|
||||||
|
|
||||||
# If the plugin can't be found let them know gracefully
|
# If the plugin can't be found let them know gracefully
|
||||||
try:
|
try:
|
||||||
plugin_klass = utils.import_class(options['plugin_provider'])
|
plugin_klass = utils.import_class(options['plugin_provider'])
|
||||||
except ClassNotFound:
|
except ClassNotFound:
|
||||||
raise Exception("Plugin not found. You can install a " \
|
raise Exception("Plugin not found. You can install a "
|
||||||
"plugin with: pip install <plugin-name>\n" \
|
"plugin with: pip install <plugin-name>\n"
|
||||||
"Example: pip install quantum-sample-plugin")
|
"Example: pip install quantum-sample-plugin")
|
||||||
|
|
||||||
if not issubclass(plugin_klass, QuantumPluginBase):
|
if not issubclass(plugin_klass, QuantumPluginBase):
|
||||||
raise Exception("Configured Quantum plug-in " \
|
raise Exception("Configured Quantum plug-in "
|
||||||
"didn't pass compatibility test")
|
"didn't pass compatibility test")
|
||||||
else:
|
else:
|
||||||
LOG.debug("Successfully imported Quantum plug-in." \
|
LOG.debug("Successfully imported Quantum plug-in."
|
||||||
"All compatibility tests passed")
|
"All compatibility tests passed")
|
||||||
self.plugin = plugin_klass()
|
self.plugin = plugin_klass()
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,4 +16,3 @@
|
|||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,5 +15,3 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -24,27 +23,22 @@
|
|||||||
# Cisco adaptation for extensions
|
# Cisco adaptation for extensions
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
import gettext
|
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from optparse import OptionParser
|
|
||||||
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantumclient import Client
|
from quantumclient import Client
|
||||||
import quantumclient.cli as qcli
|
import quantumclient.cli as qcli
|
||||||
|
|
||||||
|
|
||||||
gettext.install('quantum', unicode=1)
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum')
|
LOG = logging.getLogger('quantum')
|
||||||
|
|
||||||
|
|
||||||
FORMAT = 'json'
|
FORMAT = 'json'
|
||||||
ACTION_PREFIX_EXT = '/v1.0'
|
ACTION_PREFIX_EXT = '/v1.0'
|
||||||
ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \
|
ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \
|
||||||
@ -58,8 +52,8 @@ def help():
|
|||||||
"""Help for CLI"""
|
"""Help for CLI"""
|
||||||
print "\nCisco Extension Commands:"
|
print "\nCisco Extension Commands:"
|
||||||
for key in COMMANDS.keys():
|
for key in COMMANDS.keys():
|
||||||
print " %s %s" % (key,
|
print " %s %s" % (
|
||||||
" ".join(["<%s>" % y for y in COMMANDS[key]["args"]]))
|
key, " ".join(["<%s>" % y for y in COMMANDS[key]["args"]]))
|
||||||
|
|
||||||
|
|
||||||
def build_args(cmd, cmdargs, arglist):
|
def build_args(cmd, cmdargs, arglist):
|
||||||
@ -72,15 +66,15 @@ def build_args(cmd, cmdargs, arglist):
|
|||||||
del arglist[0]
|
del arglist[0]
|
||||||
except:
|
except:
|
||||||
LOG.error("Not enough arguments for \"%s\" (expected: %d, got: %d)" % (
|
LOG.error("Not enough arguments for \"%s\" (expected: %d, got: %d)" % (
|
||||||
cmd, len(cmdargs), len(orig_arglist)))
|
cmd, len(cmdargs), len(orig_arglist)))
|
||||||
print "Usage:\n %s %s" % (cmd,
|
print "Usage:\n %s %s" % (
|
||||||
" ".join(["<%s>" % y for y in COMMANDS[cmd]["args"]]))
|
cmd, " ".join(["<%s>" % y for y in COMMANDS[cmd]["args"]]))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if len(arglist) > 0:
|
if len(arglist) > 0:
|
||||||
LOG.error("Too many arguments for \"%s\" (expected: %d, got: %d)" % (
|
LOG.error("Too many arguments for \"%s\" (expected: %d, got: %d)" % (
|
||||||
cmd, len(cmdargs), len(orig_arglist)))
|
cmd, len(cmdargs), len(orig_arglist)))
|
||||||
print "Usage:\n %s %s" % (cmd,
|
print "Usage:\n %s %s" % (
|
||||||
" ".join(["<%s>" % y for y in COMMANDS[cmd]["args"]]))
|
cmd, " ".join(["<%s>" % y for y in COMMANDS[cmd]["args"]]))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
@ -98,12 +92,15 @@ def schedule_host(tenant_id, instance_id, user_id=None):
|
|||||||
"""Gets the host name from the Quantum service"""
|
"""Gets the host name from the Quantum service"""
|
||||||
project_id = tenant_id
|
project_id = tenant_id
|
||||||
|
|
||||||
instance_data_dict = \
|
instance_data_dict = {
|
||||||
{'novatenant': \
|
'novatenant': {
|
||||||
{'instance_id': instance_id,
|
'instance_id': instance_id,
|
||||||
'instance_desc': \
|
'instance_desc': {
|
||||||
{'user_id': user_id,
|
'user_id': user_id,
|
||||||
'project_id': project_id}}}
|
'project_id': project_id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
request_url = "/novatenants/" + project_id + "/schedule_host"
|
request_url = "/novatenants/" + project_id + "/schedule_host"
|
||||||
client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID,
|
client = Client(HOST, PORT, USE_SSL, format='json', tenant=TENANT_ID,
|
||||||
@ -112,8 +109,8 @@ def schedule_host(tenant_id, instance_id, user_id=None):
|
|||||||
|
|
||||||
hostname = data["host_list"]["host_1"]
|
hostname = data["host_list"]["host_1"]
|
||||||
if not hostname:
|
if not hostname:
|
||||||
print("Scheduler was unable to locate a host" + \
|
print("Scheduler was unable to locate a host"
|
||||||
" for this request. Is the appropriate" + \
|
" for this request. Is the appropriate"
|
||||||
" service running?")
|
" service running?")
|
||||||
|
|
||||||
print("Quantum service returned host: %s" % hostname)
|
print("Quantum service returned host: %s" % hostname)
|
||||||
@ -122,7 +119,7 @@ def schedule_host(tenant_id, instance_id, user_id=None):
|
|||||||
def create_multiport(tenant_id, net_id_list, *args):
|
def create_multiport(tenant_id, net_id_list, *args):
|
||||||
"""Creates ports on a single host"""
|
"""Creates ports on a single host"""
|
||||||
net_list = net_id_list.split(",")
|
net_list = net_id_list.split(",")
|
||||||
ports_info = {'multiport': \
|
ports_info = {'multiport':
|
||||||
{'status': 'ACTIVE',
|
{'status': 'ACTIVE',
|
||||||
'net_id_list': net_list,
|
'net_id_list': net_list,
|
||||||
'ports_desc': {'key': 'value'}}}
|
'ports_desc': {'key': 'value'}}}
|
||||||
@ -136,16 +133,20 @@ def create_multiport(tenant_id, net_id_list, *args):
|
|||||||
|
|
||||||
|
|
||||||
COMMANDS = {
|
COMMANDS = {
|
||||||
"create_multiport": {
|
"create_multiport": {
|
||||||
"func": create_multiport,
|
"func": create_multiport,
|
||||||
"args": ["tenant-id",
|
"args": ["tenant-id",
|
||||||
"net-id-list (comma separated list of netword IDs)"]},
|
"net-id-list (comma separated list of netword IDs)"],
|
||||||
"list_extensions": {
|
},
|
||||||
"func": list_extensions,
|
"list_extensions": {
|
||||||
"args": []},
|
"func": list_extensions,
|
||||||
"schedule_host": {
|
"args": [],
|
||||||
"func": schedule_host,
|
},
|
||||||
"args": ["tenant-id", "instance-id"]}, }
|
"schedule_host": {
|
||||||
|
"func": schedule_host,
|
||||||
|
"args": ["tenant-id", "instance-id"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -153,17 +154,20 @@ def main():
|
|||||||
usagestr = "Usage: %prog [OPTIONS] <command> [args]"
|
usagestr = "Usage: %prog [OPTIONS] <command> [args]"
|
||||||
PARSER = OptionParser(usage=usagestr)
|
PARSER = OptionParser(usage=usagestr)
|
||||||
PARSER.add_option("-H", "--host", dest="host",
|
PARSER.add_option("-H", "--host", dest="host",
|
||||||
type="string", default="127.0.0.1", help="ip address of api host")
|
type="string", default="127.0.0.1",
|
||||||
|
help="ip address of api host")
|
||||||
PARSER.add_option("-p", "--port", dest="port",
|
PARSER.add_option("-p", "--port", dest="port",
|
||||||
type="int", default=9696, help="api poort")
|
type="int", default=9696, help="api poort")
|
||||||
PARSER.add_option("-s", "--ssl", dest="ssl",
|
PARSER.add_option("-s", "--ssl", dest="ssl",
|
||||||
action="store_true", default=False, help="use ssl")
|
action="store_true", default=False, help="use ssl")
|
||||||
PARSER.add_option("-v", "--verbose", dest="verbose",
|
PARSER.add_option("-v", "--verbose", dest="verbose",
|
||||||
action="store_true", default=False, help="turn on verbose logging")
|
action="store_true", default=False,
|
||||||
|
help="turn on verbose logging")
|
||||||
PARSER.add_option("-f", "--logfile", dest="logfile",
|
PARSER.add_option("-f", "--logfile", dest="logfile",
|
||||||
type="string", default="syslog", help="log file path")
|
type="string", default="syslog", help="log file path")
|
||||||
PARSER.add_option('--version', default=DEFAULT_QUANTUM_VERSION,
|
PARSER.add_option(
|
||||||
help='Accepts 1.1 and 1.0, defaults to env[QUANTUM_VERSION].')
|
'--version', default=DEFAULT_QUANTUM_VERSION,
|
||||||
|
help='Accepts 1.1 and 1.0, defaults to env[QUANTUM_VERSION].')
|
||||||
options, args = PARSER.parse_args()
|
options, args = PARSER.parse_args()
|
||||||
|
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,5 +15,3 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,10 +15,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
from configobj import ConfigObj
|
from configobj import ConfigObj
|
||||||
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,8 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
PLUGINS = 'PLUGINS'
|
PLUGINS = 'PLUGINS'
|
||||||
INVENTORY = 'INVENTORY'
|
INVENTORY = 'INVENTORY'
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,8 +15,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import logging as LOG
|
import logging as LOG
|
||||||
@ -28,11 +25,12 @@ from quantum.plugins.cisco.common import cisco_constants as const
|
|||||||
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
|
|
||||||
|
|
||||||
LOG.basicConfig(level=LOG.WARN)
|
LOG.basicConfig(level=LOG.WARN)
|
||||||
LOG.getLogger(const.LOGGER_COMPONENT_NAME)
|
LOG.getLogger(const.LOGGER_COMPONENT_NAME)
|
||||||
|
|
||||||
CREDENTIALS_FILE = find_config_file({'plugin': 'cisco'}, None,
|
CREDENTIALS_FILE = find_config_file({'plugin': 'cisco'}, None,
|
||||||
"credentials.ini")
|
"credentials.ini")
|
||||||
TENANT = const.NETWORK_ADMIN
|
TENANT = const.NETWORK_ADMIN
|
||||||
|
|
||||||
cp = confp.CiscoConfigParser(CREDENTIALS_FILE)
|
cp = confp.CiscoConfigParser(CREDENTIALS_FILE)
|
||||||
|
@ -20,68 +20,69 @@
|
|||||||
"""
|
"""
|
||||||
Exceptions used by the Cisco plugin
|
Exceptions used by the Cisco plugin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from quantum.common import exceptions
|
from quantum.common import exceptions
|
||||||
|
|
||||||
|
|
||||||
class NoMoreNics(exceptions.QuantumException):
|
class NoMoreNics(exceptions.QuantumException):
|
||||||
"""No more dynamic nics are available in the system"""
|
"""No more dynamic nics are available in the system"""
|
||||||
message = _("Unable to complete operation. No more dynamic nics are " \
|
message = _("Unable to complete operation. No more dynamic nics are "
|
||||||
"available in the system.")
|
"available in the system.")
|
||||||
|
|
||||||
|
|
||||||
class PortProfileLimit(exceptions.QuantumException):
|
class PortProfileLimit(exceptions.QuantumException):
|
||||||
"""Port profile limit has been hit"""
|
"""Port profile limit has been hit"""
|
||||||
message = _("Unable to complete operation on port %(port_id)s " \
|
message = _("Unable to complete operation on port %(port_id)s "
|
||||||
"for network %(net_id)s. The system has reached the maximum" \
|
"for network %(net_id)s. The system has reached the maximum"
|
||||||
"limit of allowed port profiles.")
|
"limit of allowed port profiles.")
|
||||||
|
|
||||||
|
|
||||||
class UCSMPortProfileLimit(exceptions.QuantumException):
|
class UCSMPortProfileLimit(exceptions.QuantumException):
|
||||||
"""UCSM Port profile limit has been hit"""
|
"""UCSM Port profile limit has been hit"""
|
||||||
message = _("Unable to complete operation on port %(port_id)s " \
|
message = _("Unable to complete operation on port %(port_id)s "
|
||||||
"for network %(net_id)s. The system has reached the maximum" \
|
"for network %(net_id)s. The system has reached the maximum"
|
||||||
"limit of allowed UCSM port profiles.")
|
"limit of allowed UCSM port profiles.")
|
||||||
|
|
||||||
|
|
||||||
class NetworksLimit(exceptions.QuantumException):
|
class NetworksLimit(exceptions.QuantumException):
|
||||||
"""Total number of network objects limit has been hit"""
|
"""Total number of network objects limit has been hit"""
|
||||||
message = _("Unable to create new network. Number of networks" \
|
message = _("Unable to create new network. Number of networks"
|
||||||
"for the system has exceeded the limit")
|
"for the system has exceeded the limit")
|
||||||
|
|
||||||
|
|
||||||
class PortProfileNotFound(exceptions.QuantumException):
|
class PortProfileNotFound(exceptions.QuantumException):
|
||||||
"""Port profile cannot be found"""
|
"""Port profile cannot be found"""
|
||||||
message = _("Port profile %(portprofile_id)s could not be found " \
|
message = _("Port profile %(portprofile_id)s could not be found "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class MultiportNotFound(exceptions.QuantumException):
|
class MultiportNotFound(exceptions.QuantumException):
|
||||||
"""Multiport cannot be found"""
|
"""Multiport cannot be found"""
|
||||||
message = _("Multiports %(port_id)s could not be found " \
|
message = _("Multiports %(port_id)s could not be found "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class PortProfileInvalidDelete(exceptions.QuantumException):
|
class PortProfileInvalidDelete(exceptions.QuantumException):
|
||||||
"""Port profile cannot be deleted since its being used"""
|
"""Port profile cannot be deleted since its being used"""
|
||||||
message = _("Port profile %(profile_id)s could not be deleted " \
|
message = _("Port profile %(profile_id)s could not be deleted "
|
||||||
"for tenant %(tenant_id)s since port associations exist")
|
"for tenant %(tenant_id)s since port associations exist")
|
||||||
|
|
||||||
|
|
||||||
class NetworkVlanBindingAlreadyExists(exceptions.QuantumException):
|
class NetworkVlanBindingAlreadyExists(exceptions.QuantumException):
|
||||||
"""Binding cannot be created, since it already exists"""
|
"""Binding cannot be created, since it already exists"""
|
||||||
message = _("NetworkVlanBinding for %(vlan_id)s and network " \
|
message = _("NetworkVlanBinding for %(vlan_id)s and network "
|
||||||
"%(network_id)s already exists")
|
"%(network_id)s already exists")
|
||||||
|
|
||||||
|
|
||||||
class PortProfileAlreadyExists(exceptions.QuantumException):
|
class PortProfileAlreadyExists(exceptions.QuantumException):
|
||||||
"""Port profile cannot be created since it already exisits"""
|
"""Port profile cannot be created since it already exisits"""
|
||||||
message = _("PortProfile %(pp_name) for %(tenant_id)s " \
|
message = _("PortProfile %(pp_name) for %(tenant_id)s "
|
||||||
"already exists")
|
"already exists")
|
||||||
|
|
||||||
|
|
||||||
class PortProfileBindingAlreadyExists(exceptions.QuantumException):
|
class PortProfileBindingAlreadyExists(exceptions.QuantumException):
|
||||||
"""Binding cannot be created, since it already exists"""
|
"""Binding cannot be created, since it already exists"""
|
||||||
message = _("PortProfileBinding for port profile %(pp_id)s to " \
|
message = _("PortProfileBinding for port profile %(pp_id)s to "
|
||||||
"port %(port_id) already exists")
|
"port %(port_id) already exists")
|
||||||
|
|
||||||
|
|
||||||
@ -97,37 +98,37 @@ class VlanIDNotAvailable(exceptions.QuantumException):
|
|||||||
|
|
||||||
class QosNotFound(exceptions.QuantumException):
|
class QosNotFound(exceptions.QuantumException):
|
||||||
"""QoS level with this ID cannot be found"""
|
"""QoS level with this ID cannot be found"""
|
||||||
message = _("QoS level %(qos_id)s could not be found " \
|
message = _("QoS level %(qos_id)s could not be found "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class QoSLevelInvalidDelete(exceptions.QuantumException):
|
class QoSLevelInvalidDelete(exceptions.QuantumException):
|
||||||
"""QoS is associated with a port profile, hence cannot be deleted"""
|
"""QoS is associated with a port profile, hence cannot be deleted"""
|
||||||
message = _("QoS level %(qos_id)s could not be deleted " \
|
message = _("QoS level %(qos_id)s could not be deleted "
|
||||||
"for tenant %(tenant_id)s since association exists")
|
"for tenant %(tenant_id)s since association exists")
|
||||||
|
|
||||||
|
|
||||||
class QosNameAlreadyExists(exceptions.QuantumException):
|
class QosNameAlreadyExists(exceptions.QuantumException):
|
||||||
"""QoS Name already exists"""
|
"""QoS Name already exists"""
|
||||||
message = _("QoS level with name %(qos_name)s already exists " \
|
message = _("QoS level with name %(qos_name)s already exists "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class CredentialNotFound(exceptions.QuantumException):
|
class CredentialNotFound(exceptions.QuantumException):
|
||||||
"""Credential with this ID cannot be found"""
|
"""Credential with this ID cannot be found"""
|
||||||
message = _("Credential %(credential_id)s could not be found " \
|
message = _("Credential %(credential_id)s could not be found "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class CredentialNameNotFound(exceptions.QuantumException):
|
class CredentialNameNotFound(exceptions.QuantumException):
|
||||||
"""Credential Name could not be found"""
|
"""Credential Name could not be found"""
|
||||||
message = _("Credential %(credential_name)s could not be found " \
|
message = _("Credential %(credential_name)s could not be found "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
class CredentialAlreadyExists(exceptions.QuantumException):
|
class CredentialAlreadyExists(exceptions.QuantumException):
|
||||||
"""Credential ID already exists"""
|
"""Credential ID already exists"""
|
||||||
message = _("Credential %(credential_id)s already exists " \
|
message = _("Credential %(credential_id)s already exists "
|
||||||
"for tenant %(tenant_id)s")
|
"for tenant %(tenant_id)s")
|
||||||
|
|
||||||
|
|
||||||
@ -177,23 +178,8 @@ class PortVnicNotFound(exceptions.QuantumException):
|
|||||||
|
|
||||||
|
|
||||||
class InvalidAttach(exceptions.QuantumException):
|
class InvalidAttach(exceptions.QuantumException):
|
||||||
message = _("Unable to plug the attachment %(att_id)s into port " \
|
message = _("Unable to plug the attachment %(att_id)s into port "
|
||||||
"%(port_id)s for network %(net_id)s. Association of " \
|
"%(port_id)s for network %(net_id)s. Association of "
|
||||||
"attachment ID with port ID happens implicitly when " \
|
"attachment ID with port ID happens implicitly when "
|
||||||
"VM is instantiated; attach operation can be " \
|
"VM is instantiated; attach operation can be "
|
||||||
"performed subsequently.")
|
"performed subsequently.")
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
_("test")
|
|
||||||
except NameError:
|
|
||||||
|
|
||||||
def _(a_string):
|
|
||||||
"""
|
|
||||||
Default implementation of the gettext string
|
|
||||||
translation function: no translation
|
|
||||||
"""
|
|
||||||
return a_string
|
|
||||||
except TypeError:
|
|
||||||
# during doctesting, _ might mean something else
|
|
||||||
pass
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,8 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Ying Liu, Cisco Systems, Inc.
|
# @author: Ying Liu, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
import webob.dec
|
import webob.dec
|
||||||
|
|
||||||
from quantum import wsgi
|
from quantum import wsgi
|
||||||
@ -73,7 +71,7 @@ class PortprofileNotFound(webob.exc.HTTPClientError):
|
|||||||
code = 450
|
code = 450
|
||||||
title = 'Portprofile Not Found'
|
title = 'Portprofile Not Found'
|
||||||
explanation = ('Unable to find a Portprofile with'
|
explanation = ('Unable to find a Portprofile with'
|
||||||
+ ' the specified identifier.')
|
' the specified identifier.')
|
||||||
|
|
||||||
|
|
||||||
class PortNotFound(webob.exc.HTTPClientError):
|
class PortNotFound(webob.exc.HTTPClientError):
|
||||||
@ -102,7 +100,7 @@ class CredentialNotFound(webob.exc.HTTPClientError):
|
|||||||
code = 451
|
code = 451
|
||||||
title = 'Credential Not Found'
|
title = 'Credential Not Found'
|
||||||
explanation = ('Unable to find a Credential with'
|
explanation = ('Unable to find a Credential with'
|
||||||
+ ' the specified identifier.')
|
' the specified identifier.')
|
||||||
|
|
||||||
|
|
||||||
class QosNotFound(webob.exc.HTTPClientError):
|
class QosNotFound(webob.exc.HTTPClientError):
|
||||||
@ -117,7 +115,7 @@ class QosNotFound(webob.exc.HTTPClientError):
|
|||||||
code = 452
|
code = 452
|
||||||
title = 'QoS Not Found'
|
title = 'QoS Not Found'
|
||||||
explanation = ('Unable to find a QoS with'
|
explanation = ('Unable to find a QoS with'
|
||||||
+ ' the specified identifier.')
|
' the specified identifier.')
|
||||||
|
|
||||||
|
|
||||||
class NovatenantNotFound(webob.exc.HTTPClientError):
|
class NovatenantNotFound(webob.exc.HTTPClientError):
|
||||||
@ -132,7 +130,7 @@ class NovatenantNotFound(webob.exc.HTTPClientError):
|
|||||||
code = 453
|
code = 453
|
||||||
title = 'Nova tenant Not Found'
|
title = 'Nova tenant Not Found'
|
||||||
explanation = ('Unable to find a Novatenant with'
|
explanation = ('Unable to find a Novatenant with'
|
||||||
+ ' the specified identifier.')
|
' the specified identifier.')
|
||||||
|
|
||||||
|
|
||||||
class MultiportNotFound(webob.exc.HTTPClientError):
|
class MultiportNotFound(webob.exc.HTTPClientError):
|
||||||
@ -147,7 +145,7 @@ class MultiportNotFound(webob.exc.HTTPClientError):
|
|||||||
code = 454
|
code = 454
|
||||||
title = 'Multiport Not Found'
|
title = 'Multiport Not Found'
|
||||||
explanation = ('Unable to find Multiport with'
|
explanation = ('Unable to find Multiport with'
|
||||||
+ ' the specified identifier.')
|
' the specified identifier.')
|
||||||
|
|
||||||
|
|
||||||
class RequestedStateInvalid(webob.exc.HTTPClientError):
|
class RequestedStateInvalid(webob.exc.HTTPClientError):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,18 +15,18 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import MySQLdb
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
import MySQLdb
|
||||||
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,11 +15,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
import inspect
|
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
|
||||||
class L2NetworkDeviceInventoryBase(object):
|
class L2NetworkDeviceInventoryBase(object):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,11 +15,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
import inspect
|
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
|
||||||
class L2DevicePluginBase(object):
|
class L2DevicePluginBase(object):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,11 +15,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
import inspect
|
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
|
||||||
class L2NetworkModelBase(object):
|
class L2NetworkModelBase(object):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,8 +15,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
@ -26,7 +23,6 @@ import re
|
|||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
from quantum.common import utils
|
from quantum.common import utils
|
||||||
from quantum.quantum_plugin_base import QuantumPluginBase
|
from quantum.quantum_plugin_base import QuantumPluginBase
|
||||||
|
|
||||||
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.common import cisco_credentials as cred
|
from quantum.plugins.cisco.common import cisco_credentials as cred
|
||||||
@ -35,6 +31,7 @@ from quantum.plugins.cisco.common import cisco_utils as cutil
|
|||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -83,8 +80,8 @@ class L2Network(QuantumPluginBase):
|
|||||||
vlan_id = self._get_vlan_for_tenant(tenant_id, net_name)
|
vlan_id = self._get_vlan_for_tenant(tenant_id, net_name)
|
||||||
vlan_name = self._get_vlan_name(new_net_id, str(vlan_id))
|
vlan_name = self._get_vlan_name(new_net_id, str(vlan_id))
|
||||||
self._invoke_device_plugins(self._func_name(), [tenant_id, net_name,
|
self._invoke_device_plugins(self._func_name(), [tenant_id, net_name,
|
||||||
new_net_id, vlan_name,
|
new_net_id, vlan_name,
|
||||||
vlan_id])
|
vlan_id])
|
||||||
cdb.add_vlan_binding(vlan_id, vlan_name, new_net_id)
|
cdb.add_vlan_binding(vlan_id, vlan_name, new_net_id)
|
||||||
new_net_dict = {const.NET_ID: new_net_id,
|
new_net_dict = {const.NET_ID: new_net_id,
|
||||||
const.NET_NAME: net_name,
|
const.NET_NAME: net_name,
|
||||||
@ -137,8 +134,8 @@ class L2Network(QuantumPluginBase):
|
|||||||
ports_on_net.append(new_port)
|
ports_on_net.append(new_port)
|
||||||
|
|
||||||
new_network = cutil.make_net_dict(network[const.UUID],
|
new_network = cutil.make_net_dict(network[const.UUID],
|
||||||
network[const.NETWORKNAME],
|
network[const.NETWORKNAME],
|
||||||
ports_on_net)
|
ports_on_net)
|
||||||
|
|
||||||
return new_network
|
return new_network
|
||||||
|
|
||||||
@ -151,7 +148,7 @@ class L2Network(QuantumPluginBase):
|
|||||||
db.validate_network_ownership(tenant_id, net_id)
|
db.validate_network_ownership(tenant_id, net_id)
|
||||||
network = db.network_update(net_id, tenant_id, **kwargs)
|
network = db.network_update(net_id, tenant_id, **kwargs)
|
||||||
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
|
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
|
||||||
kwargs])
|
kwargs])
|
||||||
net_dict = cutil.make_net_dict(network[const.UUID],
|
net_dict = cutil.make_net_dict(network[const.UUID],
|
||||||
network[const.NETWORKNAME],
|
network[const.NETWORKNAME],
|
||||||
[])
|
[])
|
||||||
@ -187,8 +184,8 @@ class L2Network(QuantumPluginBase):
|
|||||||
port = db.port_create(net_id, port_state)
|
port = db.port_create(net_id, port_state)
|
||||||
unique_port_id_string = port[const.UUID]
|
unique_port_id_string = port[const.UUID]
|
||||||
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
|
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
|
||||||
port_state,
|
port_state,
|
||||||
unique_port_id_string])
|
unique_port_id_string])
|
||||||
new_port_dict = cutil.make_port_dict(port[const.UUID],
|
new_port_dict = cutil.make_port_dict(port[const.UUID],
|
||||||
port[const.PORTSTATE],
|
port[const.PORTSTATE],
|
||||||
port[const.NETWORKID],
|
port[const.NETWORKID],
|
||||||
@ -226,7 +223,7 @@ class L2Network(QuantumPluginBase):
|
|||||||
db.validate_port_ownership(tenant_id, net_id, port_id)
|
db.validate_port_ownership(tenant_id, net_id, port_id)
|
||||||
network = db.network_get(net_id)
|
network = db.network_get(net_id)
|
||||||
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
|
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
|
||||||
port_id, kwargs])
|
port_id, kwargs])
|
||||||
self._validate_port_state(kwargs["state"])
|
self._validate_port_state(kwargs["state"])
|
||||||
db.port_update(port_id, net_id, **kwargs)
|
db.port_update(port_id, net_id, **kwargs)
|
||||||
|
|
||||||
@ -243,7 +240,7 @@ class L2Network(QuantumPluginBase):
|
|||||||
db.validate_port_ownership(tenant_id, net_id, port_id)
|
db.validate_port_ownership(tenant_id, net_id, port_id)
|
||||||
network = db.network_get(net_id)
|
network = db.network_get(net_id)
|
||||||
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
|
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
|
||||||
port_id])
|
port_id])
|
||||||
port = db.port_get(net_id, port_id)
|
port = db.port_get(net_id, port_id)
|
||||||
new_port_dict = cutil.make_port_dict(port[const.UUID],
|
new_port_dict = cutil.make_port_dict(port[const.UUID],
|
||||||
port[const.PORTSTATE],
|
port[const.PORTSTATE],
|
||||||
@ -264,7 +261,7 @@ class L2Network(QuantumPluginBase):
|
|||||||
attachment_id = port[const.INTERFACEID]
|
attachment_id = port[const.INTERFACEID]
|
||||||
if attachment_id is None:
|
if attachment_id is None:
|
||||||
raise cexc.InvalidAttach(port_id=port_id, net_id=net_id,
|
raise cexc.InvalidAttach(port_id=port_id, net_id=net_id,
|
||||||
att_id=remote_interface_id)
|
att_id=remote_interface_id)
|
||||||
attachment_id = attachment_id[:const.UUID_LENGTH]
|
attachment_id = attachment_id[:const.UUID_LENGTH]
|
||||||
remote_interface_id = remote_interface_id[:const.UUID_LENGTH]
|
remote_interface_id = remote_interface_id[:const.UUID_LENGTH]
|
||||||
if remote_interface_id != attachment_id:
|
if remote_interface_id != attachment_id:
|
||||||
@ -295,7 +292,7 @@ class L2Network(QuantumPluginBase):
|
|||||||
raise exc.InvalidDetach(port_id=port_id, net_id=net_id,
|
raise exc.InvalidDetach(port_id=port_id, net_id=net_id,
|
||||||
att_id=remote_interface_id)
|
att_id=remote_interface_id)
|
||||||
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
|
self._invoke_device_plugins(self._func_name(), [tenant_id, net_id,
|
||||||
port_id])
|
port_id])
|
||||||
attachment_id = attachment_id[:const.UUID_LENGTH]
|
attachment_id = attachment_id[:const.UUID_LENGTH]
|
||||||
attachment_id = attachment_id + const.UNPLUGGED
|
attachment_id = attachment_id + const.UNPLUGGED
|
||||||
db.port_unset_attachment(net_id, port_id)
|
db.port_unset_attachment(net_id, port_id)
|
||||||
@ -337,7 +334,7 @@ class L2Network(QuantumPluginBase):
|
|||||||
"""Create port profile"""
|
"""Create port profile"""
|
||||||
LOG.debug("create_portprofile() called\n")
|
LOG.debug("create_portprofile() called\n")
|
||||||
portprofile = cdb.add_portprofile(tenant_id, profile_name,
|
portprofile = cdb.add_portprofile(tenant_id, profile_name,
|
||||||
const.NO_VLAN_ID, qos)
|
const.NO_VLAN_ID, qos)
|
||||||
new_pp = cutil.make_portprofile_dict(tenant_id,
|
new_pp = cutil.make_portprofile_dict(tenant_id,
|
||||||
portprofile[const.UUID],
|
portprofile[const.UUID],
|
||||||
portprofile[const.PPNAME],
|
portprofile[const.PPNAME],
|
||||||
@ -491,9 +488,10 @@ class L2Network(QuantumPluginBase):
|
|||||||
def schedule_host(self, tenant_id, instance_id, instance_desc):
|
def schedule_host(self, tenant_id, instance_id, instance_desc):
|
||||||
"""Provides the hostname on which a dynamic vnic is reserved"""
|
"""Provides the hostname on which a dynamic vnic is reserved"""
|
||||||
LOG.debug("schedule_host() called\n")
|
LOG.debug("schedule_host() called\n")
|
||||||
host_list = self._invoke_device_plugins(self._func_name(), [tenant_id,
|
host_list = self._invoke_device_plugins(self._func_name(),
|
||||||
instance_id,
|
[tenant_id,
|
||||||
instance_desc])
|
instance_id,
|
||||||
|
instance_desc])
|
||||||
return host_list
|
return host_list
|
||||||
|
|
||||||
def associate_port(self, tenant_id, instance_id, instance_desc):
|
def associate_port(self, tenant_id, instance_id, instance_desc):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,18 +16,18 @@
|
|||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
# @author: Rohit Agarwalla, Cisco Systems, Inc.
|
# @author: Rohit Agarwalla, Cisco Systems, Inc.
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from quantum.common.config import find_config_file
|
from quantum.common.config import find_config_file
|
||||||
from quantum.plugins.cisco.common import cisco_configparser as confp
|
from quantum.plugins.cisco.common import cisco_configparser as confp
|
||||||
|
|
||||||
|
|
||||||
CONF_FILE = find_config_file({'plugin': 'cisco'}, None, "l2network_plugin.ini")
|
CONF_FILE = find_config_file({'plugin': 'cisco'}, None, "l2network_plugin.ini")
|
||||||
CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)
|
CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)
|
||||||
|
|
||||||
"""
|
|
||||||
Reading the conf for the l2network_plugin
|
# Read the conf for the l2network_plugin
|
||||||
"""
|
|
||||||
SECTION_CONF = CONF_PARSER_OBJ['VLANS']
|
SECTION_CONF = CONF_PARSER_OBJ['VLANS']
|
||||||
VLAN_NAME_PREFIX = SECTION_CONF['vlan_name_prefix']
|
VLAN_NAME_PREFIX = SECTION_CONF['vlan_name_prefix']
|
||||||
VLAN_START = SECTION_CONF['vlan_start']
|
VLAN_START = SECTION_CONF['vlan_start']
|
||||||
@ -54,18 +53,16 @@ MANAGER_CLASS = SECTION_CONF['manager_class']
|
|||||||
|
|
||||||
CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)
|
CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)
|
||||||
|
|
||||||
"""
|
|
||||||
Reading the config for the device plugins
|
# Read the config for the device plugins
|
||||||
"""
|
|
||||||
PLUGINS = CONF_PARSER_OBJ.walk(CONF_PARSER_OBJ.dummy)
|
PLUGINS = CONF_PARSER_OBJ.walk(CONF_PARSER_OBJ.dummy)
|
||||||
|
|
||||||
CONF_FILE = find_config_file({'plugin': 'cisco'}, None, "db_conn.ini")
|
CONF_FILE = find_config_file({'plugin': 'cisco'}, None, "db_conn.ini")
|
||||||
|
|
||||||
CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)
|
CONF_PARSER_OBJ = confp.CiscoConfigParser(CONF_FILE)
|
||||||
|
|
||||||
"""
|
|
||||||
Reading DB config for the Quantum DB
|
# Read DB config for the Quantum DB
|
||||||
"""
|
|
||||||
SECTION_CONF = CONF_PARSER_OBJ['DATABASE']
|
SECTION_CONF = CONF_PARSER_OBJ['DATABASE']
|
||||||
DB_NAME = SECTION_CONF['name']
|
DB_NAME = SECTION_CONF['name']
|
||||||
DB_USER = SECTION_CONF['user']
|
DB_USER = SECTION_CONF['user']
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,11 +15,9 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
import inspect
|
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
|
||||||
class L2NetworkSegmentationMgrBase(object):
|
class L2NetworkSegmentationMgrBase(object):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,5 +15,3 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,8 +15,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import inspect
|
import inspect
|
||||||
@ -31,6 +28,7 @@ from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
|||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -49,13 +47,13 @@ class L2NetworkMultiBlade(L2NetworkModelBase):
|
|||||||
for key in conf.PLUGINS[const.PLUGINS].keys():
|
for key in conf.PLUGINS[const.PLUGINS].keys():
|
||||||
self._plugins[key] = utils.import_object(
|
self._plugins[key] = utils.import_object(
|
||||||
conf.PLUGINS[const.PLUGINS][key])
|
conf.PLUGINS[const.PLUGINS][key])
|
||||||
LOG.debug("Loaded device plugin %s\n" % \
|
LOG.debug("Loaded device plugin %s\n" %
|
||||||
conf.PLUGINS[const.PLUGINS][key])
|
conf.PLUGINS[const.PLUGINS][key])
|
||||||
if key in conf.PLUGINS[const.INVENTORY].keys():
|
if key in conf.PLUGINS[const.INVENTORY].keys():
|
||||||
self._inventory[key] = utils.import_object(
|
self._inventory[key] = utils.import_object(
|
||||||
conf.PLUGINS[const.INVENTORY][key])
|
conf.PLUGINS[const.INVENTORY][key])
|
||||||
LOG.debug("Loaded device inventory %s\n" % \
|
LOG.debug("Loaded device inventory %s\n" %
|
||||||
conf.PLUGINS[const.INVENTORY][key])
|
conf.PLUGINS[const.INVENTORY][key])
|
||||||
|
|
||||||
def _func_name(self, offset=0):
|
def _func_name(self, offset=0):
|
||||||
"""Get the name of the calling function"""
|
"""Get the name of the calling function"""
|
||||||
@ -65,8 +63,8 @@ class L2NetworkMultiBlade(L2NetworkModelBase):
|
|||||||
"""Invoke only device plugin for all the devices in the system"""
|
"""Invoke only device plugin for all the devices in the system"""
|
||||||
if not plugin_key in self._plugins.keys():
|
if not plugin_key in self._plugins.keys():
|
||||||
LOG.info("No %s Plugin loaded" % plugin_key)
|
LOG.info("No %s Plugin loaded" % plugin_key)
|
||||||
LOG.info("%s: %s with args %s ignored" \
|
LOG.info("%s: %s with args %s ignored" %
|
||||||
% (plugin_key, function_name, args))
|
(plugin_key, function_name, args))
|
||||||
return
|
return
|
||||||
device_params = self._invoke_inventory(plugin_key, function_name,
|
device_params = self._invoke_inventory(plugin_key, function_name,
|
||||||
args)
|
args)
|
||||||
@ -74,7 +72,7 @@ class L2NetworkMultiBlade(L2NetworkModelBase):
|
|||||||
if not device_ips:
|
if not device_ips:
|
||||||
# Return in a list
|
# Return in a list
|
||||||
return [self._invoke_plugin(plugin_key, function_name, args,
|
return [self._invoke_plugin(plugin_key, function_name, args,
|
||||||
device_params)]
|
device_params)]
|
||||||
else:
|
else:
|
||||||
# Return a list of return values from each device
|
# Return a list of return values from each device
|
||||||
output = []
|
output = []
|
||||||
@ -82,15 +80,15 @@ class L2NetworkMultiBlade(L2NetworkModelBase):
|
|||||||
new_device_params = deepcopy(device_params)
|
new_device_params = deepcopy(device_params)
|
||||||
new_device_params[const.DEVICE_IP] = device_ip
|
new_device_params[const.DEVICE_IP] = device_ip
|
||||||
output.append(self._invoke_plugin(plugin_key, function_name,
|
output.append(self._invoke_plugin(plugin_key, function_name,
|
||||||
args, new_device_params))
|
args, new_device_params))
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def _invoke_inventory(self, plugin_key, function_name, args):
|
def _invoke_inventory(self, plugin_key, function_name, args):
|
||||||
"""Invoke only the inventory implementation"""
|
"""Invoke only the inventory implementation"""
|
||||||
if not plugin_key in self._inventory.keys():
|
if not plugin_key in self._inventory.keys():
|
||||||
LOG.warn("No %s inventory loaded" % plugin_key)
|
LOG.warn("No %s inventory loaded" % plugin_key)
|
||||||
LOG.warn("%s: %s with args %s ignored" \
|
LOG.warn("%s: %s with args %s ignored" %
|
||||||
% (plugin_key, function_name, args))
|
(plugin_key, function_name, args))
|
||||||
return {const.DEVICE_IP: []}
|
return {const.DEVICE_IP: []}
|
||||||
else:
|
else:
|
||||||
return getattr(self._inventory[plugin_key], function_name)(args)
|
return getattr(self._inventory[plugin_key], function_name)(args)
|
||||||
@ -101,8 +99,7 @@ class L2NetworkMultiBlade(L2NetworkModelBase):
|
|||||||
|
|
||||||
# If there are more args than needed, add them to kwargs
|
# If there are more args than needed, add them to kwargs
|
||||||
args_copy = deepcopy(args)
|
args_copy = deepcopy(args)
|
||||||
if args.__len__() + 1 > \
|
if (args.__len__() + 1) > inspect.getargspec(func).args.__len__():
|
||||||
inspect.getargspec(func).args.__len__():
|
|
||||||
kwargs.update(args_copy.pop())
|
kwargs.update(args_copy.pop())
|
||||||
|
|
||||||
return func(*args_copy, **kwargs)
|
return func(*args_copy, **kwargs)
|
||||||
@ -115,9 +112,9 @@ class L2NetworkMultiBlade(L2NetworkModelBase):
|
|||||||
"""Support for the Quantum core API call"""
|
"""Support for the Quantum core API call"""
|
||||||
output = []
|
output = []
|
||||||
ucs_output = self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
ucs_output = self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
nexus_output = self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
|
nexus_output = self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
output.extend(ucs_output or [])
|
output.extend(ucs_output or [])
|
||||||
output.extend(nexus_output or [])
|
output.extend(nexus_output or [])
|
||||||
return output
|
return output
|
||||||
@ -126,9 +123,9 @@ class L2NetworkMultiBlade(L2NetworkModelBase):
|
|||||||
"""Support for the Quantum core API call"""
|
"""Support for the Quantum core API call"""
|
||||||
output = []
|
output = []
|
||||||
ucs_output = self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
ucs_output = self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
nexus_output = self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
|
nexus_output = self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
output.extend(ucs_output or [])
|
output.extend(ucs_output or [])
|
||||||
output.extend(nexus_output or [])
|
output.extend(nexus_output or [])
|
||||||
return output
|
return output
|
||||||
@ -141,9 +138,9 @@ class L2NetworkMultiBlade(L2NetworkModelBase):
|
|||||||
"""Support for the Quantum core API call"""
|
"""Support for the Quantum core API call"""
|
||||||
output = []
|
output = []
|
||||||
ucs_output = self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
ucs_output = self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
nexus_output = self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
|
nexus_output = self._invoke_plugin_per_device(const.NEXUS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
output.extend(ucs_output or [])
|
output.extend(ucs_output or [])
|
||||||
output.extend(nexus_output or [])
|
output.extend(nexus_output or [])
|
||||||
return output
|
return output
|
||||||
@ -155,12 +152,12 @@ class L2NetworkMultiBlade(L2NetworkModelBase):
|
|||||||
def create_port(self, args):
|
def create_port(self, args):
|
||||||
"""Support for the Quantum core API call"""
|
"""Support for the Quantum core API call"""
|
||||||
return self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
return self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
|
|
||||||
def delete_port(self, args):
|
def delete_port(self, args):
|
||||||
"""Support for the Quantum core API call"""
|
"""Support for the Quantum core API call"""
|
||||||
return self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
return self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
|
|
||||||
def update_port(self, args):
|
def update_port(self, args):
|
||||||
"""Not implemented for this model"""
|
"""Not implemented for this model"""
|
||||||
@ -173,12 +170,12 @@ class L2NetworkMultiBlade(L2NetworkModelBase):
|
|||||||
def plug_interface(self, args):
|
def plug_interface(self, args):
|
||||||
"""Support for the Quantum core API call"""
|
"""Support for the Quantum core API call"""
|
||||||
return self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
return self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
|
|
||||||
def unplug_interface(self, args):
|
def unplug_interface(self, args):
|
||||||
"""Support for the Quantum core API call"""
|
"""Support for the Quantum core API call"""
|
||||||
return self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
return self._invoke_plugin_per_device(const.UCS_PLUGIN,
|
||||||
self._func_name(), args)
|
self._func_name(), args)
|
||||||
|
|
||||||
def schedule_host(self, args):
|
def schedule_host(self, args):
|
||||||
"""Provides the hostname on which a dynamic vnic is reserved"""
|
"""Provides the hostname on which a dynamic vnic is reserved"""
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,8 +15,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import inspect
|
import inspect
|
||||||
@ -31,6 +28,7 @@ from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
|||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -46,13 +44,13 @@ class L2NetworkSingleBlade(L2NetworkModelBase):
|
|||||||
for key in conf.PLUGINS[const.PLUGINS].keys():
|
for key in conf.PLUGINS[const.PLUGINS].keys():
|
||||||
self._plugins[key] = utils.import_object(
|
self._plugins[key] = utils.import_object(
|
||||||
conf.PLUGINS[const.PLUGINS][key])
|
conf.PLUGINS[const.PLUGINS][key])
|
||||||
LOG.debug("Loaded device plugin %s\n" % \
|
LOG.debug("Loaded device plugin %s\n" %
|
||||||
conf.PLUGINS[const.PLUGINS][key])
|
conf.PLUGINS[const.PLUGINS][key])
|
||||||
if key in conf.PLUGINS[const.INVENTORY].keys():
|
if key in conf.PLUGINS[const.INVENTORY].keys():
|
||||||
self._inventory[key] = utils.import_object(
|
self._inventory[key] = utils.import_object(
|
||||||
conf.PLUGINS[const.INVENTORY][key])
|
conf.PLUGINS[const.INVENTORY][key])
|
||||||
LOG.debug("Loaded device inventory %s\n" % \
|
LOG.debug("Loaded device inventory %s\n" %
|
||||||
conf.PLUGINS[const.INVENTORY][key])
|
conf.PLUGINS[const.INVENTORY][key])
|
||||||
|
|
||||||
def _func_name(self, offset=0):
|
def _func_name(self, offset=0):
|
||||||
"""Get the name of the calling function"""
|
"""Get the name of the calling function"""
|
||||||
@ -62,8 +60,8 @@ class L2NetworkSingleBlade(L2NetworkModelBase):
|
|||||||
"""Invoke only device plugin for all the devices in the system"""
|
"""Invoke only device plugin for all the devices in the system"""
|
||||||
if not plugin_key in self._plugins.keys():
|
if not plugin_key in self._plugins.keys():
|
||||||
LOG.info("No %s Plugin loaded" % plugin_key)
|
LOG.info("No %s Plugin loaded" % plugin_key)
|
||||||
LOG.info("%s: %s with args %s ignored" \
|
LOG.info("%s: %s with args %s ignored" %
|
||||||
% (plugin_key, function_name, args))
|
(plugin_key, function_name, args))
|
||||||
return
|
return
|
||||||
device_params = self._invoke_inventory(plugin_key, function_name,
|
device_params = self._invoke_inventory(plugin_key, function_name,
|
||||||
args)
|
args)
|
||||||
@ -82,8 +80,8 @@ class L2NetworkSingleBlade(L2NetworkModelBase):
|
|||||||
"""Invoke only the inventory implementation"""
|
"""Invoke only the inventory implementation"""
|
||||||
if not plugin_key in self._inventory.keys():
|
if not plugin_key in self._inventory.keys():
|
||||||
LOG.warn("No %s inventory loaded" % plugin_key)
|
LOG.warn("No %s inventory loaded" % plugin_key)
|
||||||
LOG.warn("%s: %s with args %s ignored" \
|
LOG.warn("%s: %s with args %s ignored" %
|
||||||
% (plugin_key, function_name, args))
|
(plugin_key, function_name, args))
|
||||||
return {const.DEVICE_IP: []}
|
return {const.DEVICE_IP: []}
|
||||||
else:
|
else:
|
||||||
return getattr(self._inventory[plugin_key], function_name)(args)
|
return getattr(self._inventory[plugin_key], function_name)(args)
|
||||||
|
@ -27,6 +27,7 @@ import os
|
|||||||
from quantum.common.config import find_config_file
|
from quantum.common.config import find_config_file
|
||||||
from quantum.plugins.cisco.common import cisco_configparser as confp
|
from quantum.plugins.cisco.common import cisco_configparser as confp
|
||||||
|
|
||||||
|
|
||||||
CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, None,
|
CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, None,
|
||||||
"nexus.ini"))
|
"nexus.ini"))
|
||||||
|
|
||||||
|
@ -23,11 +23,12 @@ Implements a Nexus-OS NETCONF over SSHv2 API Client
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from ncclient import manager
|
||||||
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
from quantum.plugins.cisco.nexus import cisco_nexus_snippets as snipp
|
from quantum.plugins.cisco.nexus import cisco_nexus_snippets as snipp
|
||||||
|
|
||||||
from ncclient import manager
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ class CiscoNEXUSDriver():
|
|||||||
Makes the SSH connection to the Nexus Switch
|
Makes the SSH connection to the Nexus Switch
|
||||||
"""
|
"""
|
||||||
man = manager.connect(host=nexus_host, port=nexus_ssh_port,
|
man = manager.connect(host=nexus_host, port=nexus_ssh_port,
|
||||||
username=nexus_user, password=nexus_password)
|
username=nexus_user, password=nexus_password)
|
||||||
return man
|
return man
|
||||||
|
|
||||||
def create_xml_snippet(self, cutomized_config):
|
def create_xml_snippet(self, cutomized_config):
|
||||||
|
@ -32,6 +32,7 @@ from quantum.plugins.cisco.db import nexus_db as nxos_db
|
|||||||
from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase
|
from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase
|
||||||
from quantum.plugins.cisco.nexus import cisco_nexus_configuration as conf
|
from quantum.plugins.cisco.nexus import cisco_nexus_configuration as conf
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -70,10 +71,11 @@ class NexusPlugin(L2DevicePluginBase):
|
|||||||
for this VLAN
|
for this VLAN
|
||||||
"""
|
"""
|
||||||
LOG.debug("NexusPlugin:create_network() called\n")
|
LOG.debug("NexusPlugin:create_network() called\n")
|
||||||
self._client.create_vlan(vlan_name, str(vlan_id), self._nexus_ip,
|
self._client.create_vlan(
|
||||||
self._nexus_username, self._nexus_password,
|
vlan_name, str(vlan_id), self._nexus_ip,
|
||||||
self._nexus_first_port, self._nexus_second_port,
|
self._nexus_username, self._nexus_password,
|
||||||
self._nexus_ssh_port)
|
self._nexus_first_port, self._nexus_second_port,
|
||||||
|
self._nexus_ssh_port)
|
||||||
nxos_db.add_nexusport_binding(self._nexus_first_port, str(vlan_id))
|
nxos_db.add_nexusport_binding(self._nexus_first_port, str(vlan_id))
|
||||||
nxos_db.add_nexusport_binding(self._nexus_second_port, str(vlan_id))
|
nxos_db.add_nexusport_binding(self._nexus_second_port, str(vlan_id))
|
||||||
|
|
||||||
@ -97,7 +99,8 @@ class NexusPlugin(L2DevicePluginBase):
|
|||||||
nxos_db.remove_nexusport_binding(vlan_id)
|
nxos_db.remove_nexusport_binding(vlan_id)
|
||||||
net = self._get_network(tenant_id, net_id)
|
net = self._get_network(tenant_id, net_id)
|
||||||
if net:
|
if net:
|
||||||
self._client.delete_vlan(str(vlan_id), self._nexus_ip,
|
self._client.delete_vlan(
|
||||||
|
str(vlan_id), self._nexus_ip,
|
||||||
self._nexus_username, self._nexus_password,
|
self._nexus_username, self._nexus_password,
|
||||||
self._nexus_first_port, self._nexus_second_port,
|
self._nexus_first_port, self._nexus_second_port,
|
||||||
self._nexus_ssh_port)
|
self._nexus_ssh_port)
|
||||||
|
@ -24,6 +24,7 @@ import logging
|
|||||||
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,13 +26,14 @@ from nova import exception as excp
|
|||||||
from nova import flags
|
from nova import flags
|
||||||
from nova import log as logging
|
from nova import log as logging
|
||||||
from nova.openstack.common import cfg
|
from nova.openstack.common import cfg
|
||||||
from nova.scheduler import driver
|
|
||||||
from nova.scheduler import chance
|
from nova.scheduler import chance
|
||||||
from quantum.client import Client
|
from nova.scheduler import driver
|
||||||
|
from quantumclient import Client
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
quantum_opts = [
|
quantum_opts = [
|
||||||
cfg.StrOpt('quantum_connection_host',
|
cfg.StrOpt('quantum_connection_host',
|
||||||
default='127.0.0.1',
|
default='127.0.0.1',
|
||||||
@ -45,6 +46,7 @@ quantum_opts = [
|
|||||||
help='Default tenant id when creating quantum networks'),
|
help='Default tenant id when creating quantum networks'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
FLAGS.register_opts(quantum_opts)
|
FLAGS.register_opts(quantum_opts)
|
||||||
|
|
||||||
@ -88,17 +90,14 @@ class QuantumPortAwareScheduler(chance.ChanceScheduler):
|
|||||||
"""Gets the host name from the Quantum service"""
|
"""Gets the host name from the Quantum service"""
|
||||||
LOG.debug("Cisco Quantum Port-aware Scheduler is scheduling...")
|
LOG.debug("Cisco Quantum Port-aware Scheduler is scheduling...")
|
||||||
instance_id = request_spec['instance_properties']['uuid']
|
instance_id = request_spec['instance_properties']['uuid']
|
||||||
user_id = \
|
user_id = request_spec['instance_properties']['user_id']
|
||||||
request_spec['instance_properties']['user_id']
|
project_id = request_spec['instance_properties']['project_id']
|
||||||
project_id = \
|
|
||||||
request_spec['instance_properties']['project_id']
|
|
||||||
|
|
||||||
instance_data_dict = \
|
instance_data_dict = {'novatenant':
|
||||||
{'novatenant': \
|
{'instance_id': instance_id,
|
||||||
{'instance_id': instance_id,
|
'instance_desc':
|
||||||
'instance_desc': \
|
{'user_id': user_id,
|
||||||
{'user_id': user_id,
|
'project_id': project_id}}}
|
||||||
'project_id': project_id}}}
|
|
||||||
|
|
||||||
client = Client(HOST, PORT, USE_SSL, format='json', version=VERSION,
|
client = Client(HOST, PORT, USE_SSL, format='json', version=VERSION,
|
||||||
uri_prefix=URI_PREFIX_CSCO, tenant=TENANT_ID,
|
uri_prefix=URI_PREFIX_CSCO, tenant=TENANT_ID,
|
||||||
@ -109,8 +108,8 @@ class QuantumPortAwareScheduler(chance.ChanceScheduler):
|
|||||||
hostname = data["host_list"]["host_1"]
|
hostname = data["host_list"]["host_1"]
|
||||||
if not hostname:
|
if not hostname:
|
||||||
raise excp.NoValidHost(_("Scheduler was unable to locate a host"
|
raise excp.NoValidHost(_("Scheduler was unable to locate a host"
|
||||||
" for this request. Is the appropriate"
|
" for this request. Is the appropriate"
|
||||||
" service running?"))
|
" service running?"))
|
||||||
|
|
||||||
LOG.debug(_("Quantum service returned host: %s") % hostname)
|
LOG.debug(_("Quantum service returned host: %s") % hostname)
|
||||||
return hostname
|
return hostname
|
||||||
|
@ -24,7 +24,7 @@ from nova import flags
|
|||||||
from nova import log as logging
|
from nova import log as logging
|
||||||
from nova.openstack.common import cfg
|
from nova.openstack.common import cfg
|
||||||
from nova.virt.vif import VIFDriver
|
from nova.virt.vif import VIFDriver
|
||||||
from quantum.client import Client
|
from quantumclient import Client
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -26,9 +26,12 @@ export PLUGIN_DIR=quantum/plugins/cisco
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from nose import config
|
from nose import config
|
||||||
|
|
||||||
sys.path.append(os.getcwd())
|
sys.path.append(os.getcwd())
|
||||||
sys.path.append(os.path.dirname(__file__))
|
sys.path.append(os.path.dirname(__file__))
|
||||||
|
|
||||||
from quantum.common.test_lib import run_tests, test_config
|
from quantum.common.test_lib import run_tests, test_config
|
||||||
import quantum.tests.unit
|
import quantum.tests.unit
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,4 +16,3 @@
|
|||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,14 +16,15 @@
|
|||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
from quantum.plugins.cisco.l2network_segmentation_base \
|
from quantum.plugins.cisco.l2network_segmentation_base import (
|
||||||
import L2NetworkSegmentationMgrBase
|
L2NetworkSegmentationMgrBase,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -26,30 +26,29 @@ Currently has four functionalities:
|
|||||||
4. disconnect_vm <vm_instance_id>
|
4. disconnect_vm <vm_instance_id>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import re
|
import re
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from optparse import OptionParser
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.client import Client
|
|
||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.db import l2network_db as l2db
|
from quantum.plugins.cisco.db import l2network_db as l2db
|
||||||
from quantum.plugins.cisco.db import services_db as sdb
|
from quantum.plugins.cisco.db import services_db as sdb
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
|
||||||
from quantum.plugins.cisco.services import services_constants as servconts
|
from quantum.plugins.cisco.services import services_constants as servconts
|
||||||
from quantum.plugins.cisco.services import services_logistics as servlogcs
|
from quantum.plugins.cisco.services import services_logistics as servlogcs
|
||||||
|
from quantumclient import Client
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def insert_inpath_service(tenant_id, service_image_id,
|
def insert_inpath_service(tenant_id, service_image_id,
|
||||||
management_net_name, northbound_net_name,
|
management_net_name, northbound_net_name,
|
||||||
southbound_net_name, *args):
|
southbound_net_name, *args):
|
||||||
"""Inserting a network service between two networks"""
|
"""Inserting a network service between two networks"""
|
||||||
print ("Creating Network for Services and Servers")
|
print ("Creating Network for Services and Servers")
|
||||||
service_logic = servlogcs.ServicesLogistics()
|
service_logic = servlogcs.ServicesLogistics()
|
||||||
@ -62,8 +61,8 @@ def insert_inpath_service(tenant_id, service_image_id,
|
|||||||
data = {servconts.NETWORK: {servconts.NAME: net}}
|
data = {servconts.NETWORK: {servconts.NAME: net}}
|
||||||
net_list[net] = client.create_network(data)
|
net_list[net] = client.create_network(data)
|
||||||
net_list[net][servconts.PORTS] = []
|
net_list[net][servconts.PORTS] = []
|
||||||
LOG.debug("Network %s Created with ID: %s " % (net, \
|
LOG.debug("Network %s Created with ID: %s " % (
|
||||||
net_list[net][servconts.NETWORK][servconts.ID]))
|
net, net_list[net][servconts.NETWORK][servconts.ID]))
|
||||||
print "Completed"
|
print "Completed"
|
||||||
print ("Creating Ports on Services and Server Networks")
|
print ("Creating Ports on Services and Server Networks")
|
||||||
LOG.debug("Operation 'create_port' executed.")
|
LOG.debug("Operation 'create_port' executed.")
|
||||||
@ -82,8 +81,8 @@ def insert_inpath_service(tenant_id, service_image_id,
|
|||||||
for net in networks_name_list:
|
for net in networks_name_list:
|
||||||
port_id = data[servconts.PORTS][net_idx][servconts.ID]
|
port_id = data[servconts.PORTS][net_idx][servconts.ID]
|
||||||
net_list[net][servconts.PORTS].append(port_id)
|
net_list[net][servconts.PORTS].append(port_id)
|
||||||
LOG.debug("Port UUID: %s on network: %s" % \
|
LOG.debug("Port UUID: %s on network: %s" %
|
||||||
(data[servconts.PORTS][net_idx][servconts.ID], net))
|
(data[servconts.PORTS][net_idx][servconts.ID], net))
|
||||||
net_idx = net_idx + 1
|
net_idx = net_idx + 1
|
||||||
print "Completed"
|
print "Completed"
|
||||||
try:
|
try:
|
||||||
@ -110,9 +109,9 @@ def insert_inpath_service(tenant_id, service_image_id,
|
|||||||
port_id = net_list[net][servconts.PORTS][idx]
|
port_id = net_list[net][servconts.PORTS][idx]
|
||||||
attachment = client.show_port_attachment(network_id, port_id)
|
attachment = client.show_port_attachment(network_id, port_id)
|
||||||
attachment = attachment[servconts.ATTACHMENT][servconts.ID][:36]
|
attachment = attachment[servconts.ATTACHMENT][servconts.ID][:36]
|
||||||
LOG.debug("Plugging virtual interface: %s of VM %s \
|
LOG.debug(("Plugging virtual interface: %s of VM %s"
|
||||||
into port: %s on network: %s" %
|
"into port: %s on network: %s") %
|
||||||
(attachment, service_vm_name, port_id, net))
|
(attachment, service_vm_name, port_id, net))
|
||||||
attach_data = {servconts.ATTACHMENT: {servconts.ID: '%s' %
|
attach_data = {servconts.ATTACHMENT: {servconts.ID: '%s' %
|
||||||
attachment}}
|
attachment}}
|
||||||
client.attach_resource(network_id, port_id, attach_data)
|
client.attach_resource(network_id, port_id, attach_data)
|
||||||
@ -222,9 +221,9 @@ def connect_vm(tenant_id, vm_image_id, service_instance_id, *args):
|
|||||||
south_net = service_nets.sbnet_id
|
south_net = service_nets.sbnet_id
|
||||||
attachment = client.show_port_attachment(south_net, new_port_id)
|
attachment = client.show_port_attachment(south_net, new_port_id)
|
||||||
attachment = attachment[servconts.ATTACHMENT][servconts.ID][:36]
|
attachment = attachment[servconts.ATTACHMENT][servconts.ID][:36]
|
||||||
LOG.debug("Plugging virtual interface: %s of VM %s \
|
LOG.debug(("Plugging virtual interface: %s of VM %s "
|
||||||
into port: %s on network: %s" %
|
"into port: %s on network: %s") %
|
||||||
(attachment, vm_name, new_port_id, service_nets.sbnet_id))
|
(attachment, vm_name, new_port_id, service_nets.sbnet_id))
|
||||||
attach_data = {servconts.ATTACHMENT: {servconts.ID: '%s' % attachment}}
|
attach_data = {servconts.ATTACHMENT: {servconts.ID: '%s' % attachment}}
|
||||||
client.attach_resource(service_nets.sbnet_id, new_port_id, attach_data)
|
client.attach_resource(service_nets.sbnet_id, new_port_id, attach_data)
|
||||||
print ("Connect VM Ended")
|
print ("Connect VM Ended")
|
||||||
@ -232,13 +231,13 @@ def connect_vm(tenant_id, vm_image_id, service_instance_id, *args):
|
|||||||
|
|
||||||
def create_multiport(tenant_id, networks_list, *args):
|
def create_multiport(tenant_id, networks_list, *args):
|
||||||
"""Creates ports on a single host"""
|
"""Creates ports on a single host"""
|
||||||
ports_info = {'multiport': \
|
ports_info = {'multiport':
|
||||||
{'status': 'ACTIVE',
|
{'status': 'ACTIVE',
|
||||||
'net_id_list': networks_list,
|
'net_id_list': networks_list,
|
||||||
'ports_desc': {'key': 'value'}}}
|
'ports_desc': {'key': 'value'}}}
|
||||||
request_url = "/multiport"
|
request_url = "/multiport"
|
||||||
client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id,
|
client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id,
|
||||||
action_prefix=servconts.ACTION_PREFIX_CSCO)
|
action_prefix=servconts.ACTION_PREFIX_CSCO)
|
||||||
data = client.do_request('POST', request_url, body=ports_info)
|
data = client.do_request('POST', request_url, body=ports_info)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -252,36 +251,39 @@ def build_args(cmd, cmdargs, arglist):
|
|||||||
args.append(arglist[0])
|
args.append(arglist[0])
|
||||||
del arglist[0]
|
del arglist[0]
|
||||||
except:
|
except:
|
||||||
LOG.debug("Not enough arguments for \"%s\" (expected: %d, got: %d)"
|
LOG.debug("Not enough arguments for \"%s\" (expected: %d, got: %d)" %
|
||||||
% (cmd, len(cmdargs), len(orig_arglist)))
|
(cmd, len(cmdargs), len(orig_arglist)))
|
||||||
print "Service Insertion Usage:\n %s %s" % (cmd,
|
print "Service Insertion Usage:\n %s %s" % (
|
||||||
" ".join(["<%s>" % y for y in SERVICE_COMMANDS[cmd]["args"]]))
|
cmd, " ".join(["<%s>" % y for y in SERVICE_COMMANDS[cmd]["args"]]))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if len(arglist) > 0:
|
if len(arglist) > 0:
|
||||||
LOG.debug("Too many arguments for \"%s\" (expected: %d, got: %d)" \
|
LOG.debug("Too many arguments for \"%s\" (expected: %d, got: %d)" \
|
||||||
% (cmd, len(cmdargs), len(orig_arglist)))
|
% (cmd, len(cmdargs), len(orig_arglist)))
|
||||||
print "Service Insertion Usage:\n %s %s" % (cmd,
|
print "Service Insertion Usage:\n %s %s" % (
|
||||||
" ".join(["<%s>" % y for y in SERVICE_COMMANDS[cmd]["args"]]))
|
cmd, " ".join(["<%s>" % y for y in SERVICE_COMMANDS[cmd]["args"]]))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
SERVICE_COMMANDS = {
|
SERVICE_COMMANDS = {
|
||||||
"insert_inpath_service": {
|
"insert_inpath_service": {
|
||||||
"func": insert_inpath_service,
|
"func": insert_inpath_service,
|
||||||
"args": ["tenant_id", "service_image_id",
|
"args": ["tenant_id", "service_image_id", "management_net_name",
|
||||||
"management_net_name", "northbound_net_name",
|
"northbound_net_name", "southbound_net_name"],
|
||||||
"southbound_net_name"]},
|
},
|
||||||
"delete_service": {
|
"delete_service": {
|
||||||
"func": delete_service,
|
"func": delete_service,
|
||||||
"args": ["tenant_id", "service_instance_id"]},
|
"args": ["tenant_id", "service_instance_id"],
|
||||||
"connect_vm": {
|
},
|
||||||
"func": connect_vm,
|
"connect_vm": {
|
||||||
"args": ["tenant_id", "vm_image_id",
|
"func": connect_vm,
|
||||||
"service_instance_id"]},
|
"args": ["tenant_id", "vm_image_id", "service_instance_id"],
|
||||||
"disconnect_vm": {
|
},
|
||||||
"func": disconnect_vm,
|
"disconnect_vm": {
|
||||||
"args": ["vm_instance_id"]}}
|
"func": disconnect_vm,
|
||||||
|
"args": ["vm_instance_id"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -289,15 +291,17 @@ if __name__ == "__main__":
|
|||||||
usagestr = "Usage: %prog [OPTIONS] <command> [args]"
|
usagestr = "Usage: %prog [OPTIONS] <command> [args]"
|
||||||
PARSER = OptionParser(usage=usagestr)
|
PARSER = OptionParser(usage=usagestr)
|
||||||
PARSER.add_option("-H", "--host", dest="host",
|
PARSER.add_option("-H", "--host", dest="host",
|
||||||
type="string", default="127.0.0.1", help="ip address of api host")
|
type="string", default="127.0.0.1",
|
||||||
|
help="ip address of api host")
|
||||||
PARSER.add_option("-p", "--port", dest="port",
|
PARSER.add_option("-p", "--port", dest="port",
|
||||||
type="int", default=9696, help="api port")
|
type="int", default=9696, help="api port")
|
||||||
PARSER.add_option("-s", "--ssl", dest="ssl",
|
PARSER.add_option("-s", "--ssl", dest="ssl",
|
||||||
action="store_true", default=False, help="use ssl")
|
action="store_true", default=False, help="use ssl")
|
||||||
PARSER.add_option("-v", "--verbose", dest="verbose",
|
PARSER.add_option("-v", "--verbose", dest="verbose",
|
||||||
action="store_true", default=False, help="turn on verbose logging")
|
action="store_true", default=False,
|
||||||
|
help="turn on verbose logging")
|
||||||
PARSER.add_option("-f", "--logfile", dest="logfile",
|
PARSER.add_option("-f", "--logfile", dest="logfile",
|
||||||
type="string", default="syslog", help="log file path")
|
type="string", default="syslog", help="log file path")
|
||||||
options, args = PARSER.parse_args()
|
options, args = PARSER.parse_args()
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
LOG.setLevel(logging.DEBUG)
|
LOG.setLevel(logging.DEBUG)
|
||||||
|
@ -22,8 +22,7 @@ Services Constants for the Services insertion Library
|
|||||||
|
|
||||||
FORMAT = 'json'
|
FORMAT = 'json'
|
||||||
ACTION_PREFIX_EXT = '/v1.0'
|
ACTION_PREFIX_EXT = '/v1.0'
|
||||||
ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \
|
ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + '/extensions/csco/tenants/{tenant_id}'
|
||||||
'/extensions/csco/tenants/{tenant_id}'
|
|
||||||
NETWORK = 'network'
|
NETWORK = 'network'
|
||||||
ID = 'id'
|
ID = 'id'
|
||||||
PORTS = 'ports'
|
PORTS = 'ports'
|
||||||
|
@ -26,10 +26,11 @@ import time
|
|||||||
|
|
||||||
from quantum.common import utils
|
from quantum.common import utils
|
||||||
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
||||||
from quantum.plugins.cisco.db import services_db as sdb
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
|
from quantum.plugins.cisco.db import services_db as sdb
|
||||||
from quantum.plugins.cisco.services import services_constants as servconts
|
from quantum.plugins.cisco.services import services_constants as servconts
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ class ServicesLogistics():
|
|||||||
while not flag and counter <= 5:
|
while not flag and counter <= 5:
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
time.sleep(2.5)
|
time.sleep(2.5)
|
||||||
process = subprocess.Popen(service_args, \
|
process = subprocess.Popen(service_args,
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
result = process.stdout.readlines()
|
result = process.stdout.readlines()
|
||||||
if not result:
|
if not result:
|
||||||
@ -74,8 +75,8 @@ class ServicesLogistics():
|
|||||||
while not flag and counter <= 10:
|
while not flag and counter <= 10:
|
||||||
counter = counter + 1
|
counter = counter + 1
|
||||||
time.sleep(2.5)
|
time.sleep(2.5)
|
||||||
process = subprocess.Popen(service_args, \
|
process = subprocess.Popen(service_args,
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
result = process.stdout.readlines()
|
result = process.stdout.readlines()
|
||||||
if result:
|
if result:
|
||||||
tokens = re.search("running", str(result[1]))
|
tokens = re.search("running", str(result[1]))
|
||||||
@ -105,8 +106,8 @@ class ServicesLogistics():
|
|||||||
"""
|
"""
|
||||||
_plugins = {}
|
_plugins = {}
|
||||||
for key in conf.PLUGINS[const.PLUGINS].keys():
|
for key in conf.PLUGINS[const.PLUGINS].keys():
|
||||||
_plugins[key] = \
|
_plugins[key] = (
|
||||||
utils.import_object(conf.PLUGINS[const.PLUGINS][key])
|
utils.import_object(conf.PLUGINS[const.PLUGINS][key]))
|
||||||
if not plugin_key in _plugins.keys():
|
if not plugin_key in _plugins.keys():
|
||||||
LOG.debug("No %s Plugin loaded" % plugin_key)
|
LOG.debug("No %s Plugin loaded" % plugin_key)
|
||||||
return False
|
return False
|
||||||
|
@ -17,37 +17,46 @@
|
|||||||
# @authors: Shweta Padubidri, Cisco Systems, Inc.
|
# @authors: Shweta Padubidri, Cisco Systems, Inc.
|
||||||
# Peter Strunk , Cisco Systems, Inc.
|
# Peter Strunk , Cisco Systems, Inc.
|
||||||
# Shubhangi Satras , Cisco Systems, Inc.
|
# Shubhangi Satras , Cisco Systems, Inc.
|
||||||
import unittest
|
|
||||||
import logging
|
|
||||||
import webob
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
|
import unittest
|
||||||
|
|
||||||
import routes
|
import routes
|
||||||
|
import webob
|
||||||
from webtest import TestApp
|
from webtest import TestApp
|
||||||
from quantum.extensions import credential
|
|
||||||
from quantum.extensions import portprofile
|
|
||||||
from quantum.extensions import novatenant
|
|
||||||
from quantum.extensions import qos
|
|
||||||
from quantum.extensions import multiport
|
|
||||||
from quantum.plugins.cisco.db import api as db
|
|
||||||
from quantum import wsgi
|
|
||||||
from quantum.common import config
|
|
||||||
from quantum.extensions import extensions
|
|
||||||
from quantum import api as server
|
from quantum import api as server
|
||||||
|
from quantum.common import config
|
||||||
|
from quantum.extensions import (
|
||||||
|
credential,
|
||||||
|
extensions,
|
||||||
|
multiport,
|
||||||
|
novatenant,
|
||||||
|
portprofile,
|
||||||
|
qos,
|
||||||
|
)
|
||||||
|
from quantum.extensions.extensions import (
|
||||||
|
ExtensionMiddleware,
|
||||||
|
PluginAwareExtensionManager,
|
||||||
|
)
|
||||||
|
from quantum.manager import QuantumManager
|
||||||
|
from quantum.plugins.cisco.db import api as db
|
||||||
|
from quantum.plugins.cisco import l2network_plugin
|
||||||
from quantum.plugins.cisco.l2network_plugin import L2Network
|
from quantum.plugins.cisco.l2network_plugin import L2Network
|
||||||
from quantum.tests.unit.extension_stubs import StubBaseAppController
|
from quantum.tests.unit.extension_stubs import StubBaseAppController
|
||||||
from quantum.extensions.extensions import (PluginAwareExtensionManager,
|
from quantum import wsgi
|
||||||
ExtensionMiddleware)
|
|
||||||
from quantum.manager import QuantumManager
|
|
||||||
from quantum.plugins.cisco import l2network_plugin
|
LOG = logging.getLogger('quantum.plugins.cisco.tests.test_cisco_extensions')
|
||||||
|
|
||||||
|
|
||||||
TEST_CONF_FILE = config.find_config_file({'plugin': 'cisco'}, None,
|
TEST_CONF_FILE = config.find_config_file({'plugin': 'cisco'}, None,
|
||||||
'quantum.conf.ciscoext')
|
'quantum.conf.ciscoext')
|
||||||
EXTENSIONS_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
EXTENSIONS_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
|
||||||
os.pardir, os.pardir, "extensions")
|
os.pardir, os.pardir, "extensions")
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum.plugins.cisco.tests.test_cisco_extensions')
|
|
||||||
|
|
||||||
|
|
||||||
class ExtensionsTestApp(wsgi.Router):
|
class ExtensionsTestApp(wsgi.Router):
|
||||||
|
|
||||||
@ -71,23 +80,26 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
member_actions = {'associate_portprofile': "PUT",
|
member_actions = {'associate_portprofile': "PUT",
|
||||||
'disassociate_portprofile': "PUT"}
|
'disassociate_portprofile': "PUT"}
|
||||||
controller = portprofile.PortprofilesController(
|
controller = portprofile.PortprofilesController(
|
||||||
QuantumManager.get_plugin())
|
QuantumManager.get_plugin())
|
||||||
res_ext = extensions.ResourceExtension('portprofiles', controller,
|
res_ext = extensions.ResourceExtension('portprofiles', controller,
|
||||||
parent=parent_resource,
|
parent=parent_resource,
|
||||||
member_actions=member_actions)
|
member_actions=member_actions)
|
||||||
self.test_app = setup_extensions_test_app(
|
self.test_app = setup_extensions_test_app(
|
||||||
SimpleExtensionManager(res_ext))
|
SimpleExtensionManager(res_ext))
|
||||||
self.contenttype = 'application/json'
|
self.contenttype = 'application/json'
|
||||||
self.profile_path = '/extensions/csco/tenants/tt/portprofiles'
|
self.profile_path = '/extensions/csco/tenants/tt/portprofiles'
|
||||||
self.portprofile_path = '/extensions/csco/tenants/tt/portprofiles/'
|
self.portprofile_path = '/extensions/csco/tenants/tt/portprofiles/'
|
||||||
self.test_port_profile = {'portprofile':
|
self.test_port_profile = {
|
||||||
{'portprofile_name': 'cisco_test_portprofile',
|
'portprofile': {
|
||||||
'qos_name': 'test-qos1'}}
|
'portprofile_name': 'cisco_test_portprofile',
|
||||||
|
'qos_name': 'test-qos1',
|
||||||
|
},
|
||||||
|
}
|
||||||
self.tenant_id = "test_tenant"
|
self.tenant_id = "test_tenant"
|
||||||
self.network_name = "test_network"
|
self.network_name = "test_network"
|
||||||
options = {}
|
options = {}
|
||||||
options['plugin_provider'] = 'quantum.plugins.cisco.l2network_plugin'\
|
options['plugin_provider'] = ('quantum.plugins.cisco.l2network_plugin'
|
||||||
'.L2Network'
|
'.L2Network')
|
||||||
self.api = server.APIRouterV10(options)
|
self.api = server.APIRouterV10(options)
|
||||||
self._l2network_plugin = l2network_plugin.L2Network()
|
self._l2network_plugin = l2network_plugin.L2Network()
|
||||||
|
|
||||||
@ -98,14 +110,17 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_list_portprofile - START")
|
LOG.debug("test_list_portprofile - START")
|
||||||
req_body1 = json.dumps(self.test_port_profile)
|
req_body1 = json.dumps(self.test_port_profile)
|
||||||
create_response1 = self.test_app.post(
|
create_response1 = self.test_app.post(
|
||||||
self.profile_path, req_body1,
|
self.profile_path, req_body1,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
req_body2 = json.dumps({'portprofile':
|
req_body2 = json.dumps({
|
||||||
{'portprofile_name': 'cisco_test_portprofile2',
|
'portprofile': {
|
||||||
'qos_name': 'test-qos2'}})
|
'portprofile_name': 'cisco_test_portprofile2',
|
||||||
|
'qos_name': 'test-qos2',
|
||||||
|
},
|
||||||
|
})
|
||||||
create_response2 = self.test_app.post(
|
create_response2 = self.test_app.post(
|
||||||
self.profile_path, req_body2,
|
self.profile_path, req_body2,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
|
|
||||||
index_response = self.test_app.get(self.profile_path)
|
index_response = self.test_app.get(self.profile_path)
|
||||||
index_resp_body = wsgi.Serializer().deserialize(index_response.body,
|
index_resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
@ -114,19 +129,21 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
|
|
||||||
resp_body1 = wsgi.Serializer().deserialize(create_response1.body,
|
resp_body1 = wsgi.Serializer().deserialize(create_response1.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
portprofile_path1_temp = self.portprofile_path +\
|
portprofile_path1_temp = (
|
||||||
resp_body1['portprofiles']['portprofile']['id']
|
self.portprofile_path +
|
||||||
|
resp_body1['portprofiles']['portprofile']['id'])
|
||||||
portprofile_path1 = str(portprofile_path1_temp)
|
portprofile_path1 = str(portprofile_path1_temp)
|
||||||
resp_body2 = wsgi.Serializer().deserialize(create_response2.body,
|
resp_body2 = wsgi.Serializer().deserialize(create_response2.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
list_all_portprofiles = [resp_body1['portprofiles']['portprofile'],
|
list_all_portprofiles = [resp_body1['portprofiles']['portprofile'],
|
||||||
resp_body2['portprofiles']['portprofile']]
|
resp_body2['portprofiles']['portprofile']]
|
||||||
self.assertTrue(index_resp_body['portprofiles'][0] in
|
self.assertTrue(index_resp_body['portprofiles'][0] in
|
||||||
list_all_portprofiles)
|
list_all_portprofiles)
|
||||||
self.assertTrue(index_resp_body['portprofiles'][1] in
|
self.assertTrue(index_resp_body['portprofiles'][1] in
|
||||||
list_all_portprofiles)
|
list_all_portprofiles)
|
||||||
portprofile_path2_temp = self.portprofile_path +\
|
portprofile_path2_temp = (
|
||||||
resp_body2['portprofiles']['portprofile']['id']
|
self.portprofile_path +
|
||||||
|
resp_body2['portprofiles']['portprofile']['id'])
|
||||||
portprofile_path2 = str(portprofile_path2_temp)
|
portprofile_path2 = str(portprofile_path2_temp)
|
||||||
|
|
||||||
# Clean Up - Delete the Port Profiles
|
# Clean Up - Delete the Port Profiles
|
||||||
@ -147,8 +164,9 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
# Clean Up - Delete the Port Profile
|
# Clean Up - Delete the Port Profile
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
portprofile_path_temp = self.portprofile_path +\
|
portprofile_path_temp = (
|
||||||
resp_body['portprofiles']['portprofile']['id']
|
self.portprofile_path +
|
||||||
|
resp_body['portprofiles']['portprofile']['id'])
|
||||||
portprofile_path = str(portprofile_path_temp)
|
portprofile_path = str(portprofile_path_temp)
|
||||||
self.tear_down_profile(portprofile_path)
|
self.tear_down_profile(portprofile_path)
|
||||||
LOG.debug("test_create_portprofile - END")
|
LOG.debug("test_create_portprofile - END")
|
||||||
@ -174,18 +192,18 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
show_path_temp = self.portprofile_path +\
|
show_path_temp = (self.portprofile_path +
|
||||||
resp_body['portprofiles']['portprofile']['id']
|
resp_body['portprofiles']['portprofile']['id'])
|
||||||
show_port_path = str(show_path_temp)
|
show_port_path = str(show_path_temp)
|
||||||
show_response = self.test_app.get(show_port_path)
|
show_response = self.test_app.get(show_port_path)
|
||||||
show_resp_dict = wsgi.Serializer().deserialize(show_response.body,
|
show_resp_dict = wsgi.Serializer().deserialize(show_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
show_resp_dict['portprofiles']['portprofile']['qos_name'],
|
show_resp_dict['portprofiles']['portprofile']['qos_name'],
|
||||||
self.test_port_profile['portprofile']['qos_name'])
|
self.test_port_profile['portprofile']['qos_name'])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
show_resp_dict['portprofiles']['portprofile']['name'],
|
show_resp_dict['portprofiles']['portprofile']['name'],
|
||||||
self.test_port_profile['portprofile']['portprofile_name'])
|
self.test_port_profile['portprofile']['portprofile_name'])
|
||||||
self.assertEqual(200, show_response.status_int)
|
self.assertEqual(200, show_response.status_int)
|
||||||
|
|
||||||
# Clean Up - Delete the Port Profile
|
# Clean Up - Delete the Port Profile
|
||||||
@ -210,27 +228,30 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_update_portprofile - START")
|
LOG.debug("test_update_portprofile - START")
|
||||||
req_body = json.dumps(self.test_port_profile)
|
req_body = json.dumps(self.test_port_profile)
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.profile_path, req_body,
|
self.profile_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
rename_port_profile = {'portprofile':
|
rename_port_profile = {
|
||||||
{'portprofile_name': 'cisco_rename_portprofile',
|
'portprofile': {
|
||||||
'qos_name': 'test-qos1'}}
|
'portprofile_name': 'cisco_rename_portprofile',
|
||||||
|
'qos_name': 'test-qos1',
|
||||||
|
},
|
||||||
|
}
|
||||||
rename_req_body = json.dumps(rename_port_profile)
|
rename_req_body = json.dumps(rename_port_profile)
|
||||||
rename_path_temp = self.portprofile_path +\
|
rename_path_temp = (self.portprofile_path +
|
||||||
resp_body['portprofiles']['portprofile']['id']
|
resp_body['portprofiles']['portprofile']['id'])
|
||||||
rename_path = str(rename_path_temp)
|
rename_path = str(rename_path_temp)
|
||||||
rename_response = self.test_app.put(rename_path, rename_req_body,
|
rename_response = self.test_app.put(rename_path, rename_req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
rename_resp_dict = wsgi.Serializer().deserialize(rename_response.body,
|
rename_resp_dict = wsgi.Serializer().deserialize(rename_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
rename_resp_dict['portprofiles']['portprofile']['qos_name'],
|
rename_resp_dict['portprofiles']['portprofile']['qos_name'],
|
||||||
self.test_port_profile['portprofile']['qos_name'])
|
self.test_port_profile['portprofile']['qos_name'])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
rename_resp_dict['portprofiles']['portprofile']['name'],
|
rename_resp_dict['portprofiles']['portprofile']['name'],
|
||||||
rename_port_profile['portprofile']['portprofile_name'])
|
rename_port_profile['portprofile']['portprofile_name'])
|
||||||
self.assertEqual(200, rename_response.status_int)
|
self.assertEqual(200, rename_response.status_int)
|
||||||
|
|
||||||
# Clean Up - Delete the Port Profile
|
# Clean Up - Delete the Port Profile
|
||||||
@ -244,12 +265,12 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_update_portprofileBADRequest - START")
|
LOG.debug("test_update_portprofileBADRequest - START")
|
||||||
req_body = json.dumps(self.test_port_profile)
|
req_body = json.dumps(self.test_port_profile)
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.profile_path, req_body,
|
self.profile_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
rename_path_temp = self.portprofile_path +\
|
rename_path_temp = (self.portprofile_path +
|
||||||
resp_body['portprofiles']['portprofile']['id']
|
resp_body['portprofiles']['portprofile']['id'])
|
||||||
rename_path = str(rename_path_temp)
|
rename_path = str(rename_path_temp)
|
||||||
rename_response = self.test_app.put(rename_path, 'BAD_REQUEST',
|
rename_response = self.test_app.put(rename_path, 'BAD_REQUEST',
|
||||||
status='*')
|
status='*')
|
||||||
@ -264,9 +285,12 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
""" Test update Portprofile does not exist"""
|
""" Test update Portprofile does not exist"""
|
||||||
|
|
||||||
LOG.debug("test_update_portprofileiDNE - START")
|
LOG.debug("test_update_portprofileiDNE - START")
|
||||||
rename_port_profile = {'portprofile':
|
rename_port_profile = {
|
||||||
{'portprofile_name': 'cisco_rename_portprofile',
|
'portprofile': {
|
||||||
'qos_name': 'test-qos1'}}
|
'portprofile_name': 'cisco_rename_portprofile',
|
||||||
|
'qos_name': 'test-qos1',
|
||||||
|
},
|
||||||
|
}
|
||||||
rename_req_body = json.dumps(rename_port_profile)
|
rename_req_body = json.dumps(rename_port_profile)
|
||||||
update_path_temp = self.portprofile_path + portprofile_id
|
update_path_temp = self.portprofile_path + portprofile_id
|
||||||
update_path = str(update_path_temp)
|
update_path = str(update_path_temp)
|
||||||
@ -283,12 +307,12 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_delete_portprofile - START")
|
LOG.debug("test_delete_portprofile - START")
|
||||||
req_body = json.dumps(self.test_port_profile)
|
req_body = json.dumps(self.test_port_profile)
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.profile_path, req_body,
|
self.profile_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
delete_path_temp = self.portprofile_path +\
|
delete_path_temp = (self.portprofile_path +
|
||||||
resp_body['portprofiles']['portprofile']['id']
|
resp_body['portprofiles']['portprofile']['id'])
|
||||||
delete_path = str(delete_path_temp)
|
delete_path = str(delete_path_temp)
|
||||||
delete_response = self.test_app.delete(delete_path)
|
delete_response = self.test_app.delete(delete_path)
|
||||||
|
|
||||||
@ -359,8 +383,8 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
def _delete_port(self, network_id, port_id):
|
def _delete_port(self, network_id, port_id):
|
||||||
""" Delete port """
|
""" Delete port """
|
||||||
LOG.debug("Deleting port for network %s - START", network_id)
|
LOG.debug("Deleting port for network %s - START", network_id)
|
||||||
port_path = "/tenants/tt/networks/%(network_id)s/ports/"\
|
port_path = ("/tenants/tt/networks/%(network_id)s/ports/%(port_id)s" %
|
||||||
"%(port_id)s" % locals()
|
locals())
|
||||||
port_req = self.create_request(port_path, None,
|
port_req = self.create_request(port_path, None,
|
||||||
self.contenttype, 'DELETE')
|
self.contenttype, 'DELETE')
|
||||||
port_req.get_response(self.api)
|
port_req.get_response(self.api)
|
||||||
@ -371,7 +395,7 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("Deleting network %s - START", network_id)
|
LOG.debug("Deleting network %s - START", network_id)
|
||||||
network_path = "/tenants/tt/networks/%s" % network_id
|
network_path = "/tenants/tt/networks/%s" % network_id
|
||||||
network_req = self.create_request(network_path, None,
|
network_req = self.create_request(network_path, None,
|
||||||
self.contenttype, 'DELETE')
|
self.contenttype, 'DELETE')
|
||||||
network_req.get_response(self.api)
|
network_req.get_response(self.api)
|
||||||
LOG.debug("Deleting network - END")
|
LOG.debug("Deleting network - END")
|
||||||
|
|
||||||
@ -384,32 +408,38 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
port_id = self._create_port(net_id, "ACTIVE")
|
port_id = self._create_port(net_id, "ACTIVE")
|
||||||
req_body = json.dumps(self.test_port_profile)
|
req_body = json.dumps(self.test_port_profile)
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.profile_path, req_body,
|
self.profile_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
test_port_assign_data = {'portprofile': {'network-id': net_id,
|
test_port_assign_data = {
|
||||||
'port-id': port_id}}
|
'portprofile': {
|
||||||
|
'network-id': net_id,
|
||||||
|
'port-id': port_id,
|
||||||
|
},
|
||||||
|
}
|
||||||
req_assign_body = json.dumps(test_port_assign_data)
|
req_assign_body = json.dumps(test_port_assign_data)
|
||||||
associate_path_temp = self.portprofile_path +\
|
associate_path_temp = (
|
||||||
resp_body['portprofiles']['portprofile']['id'] +\
|
self.portprofile_path +
|
||||||
"/associate_portprofile"
|
resp_body['portprofiles']['portprofile']['id'] +
|
||||||
|
"/associate_portprofile")
|
||||||
associate_path = str(associate_path_temp)
|
associate_path = str(associate_path_temp)
|
||||||
associate_response = self.test_app.put(
|
associate_response = self.test_app.put(
|
||||||
associate_path, req_assign_body,
|
associate_path, req_assign_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
self.assertEqual(200, associate_response.status_int)
|
self.assertEqual(200, associate_response.status_int)
|
||||||
|
|
||||||
# Clean Up - Disassociate and Delete the Port Profile
|
# Clean Up - Disassociate and Delete the Port Profile
|
||||||
disassociate_path_temp = self.portprofile_path +\
|
disassociate_path_temp = (
|
||||||
resp_body['portprofiles']['portprofile']['id'] +\
|
self.portprofile_path +
|
||||||
"/disassociate_portprofile"
|
resp_body['portprofiles']['portprofile']['id'] +
|
||||||
|
"/disassociate_portprofile")
|
||||||
disassociate_path = str(disassociate_path_temp)
|
disassociate_path = str(disassociate_path_temp)
|
||||||
delete_path_temp = self.portprofile_path +\
|
delete_path_temp = (self.portprofile_path +
|
||||||
resp_body['portprofiles']['portprofile']['id']
|
resp_body['portprofiles']['portprofile']['id'])
|
||||||
delete_path = str(delete_path_temp)
|
delete_path = str(delete_path_temp)
|
||||||
self.tear_down_associate_profile(delete_path, disassociate_path,
|
self.tear_down_associate_profile(delete_path, disassociate_path,
|
||||||
req_assign_body)
|
req_assign_body)
|
||||||
self.tear_down_port_network(net_id, port_id)
|
self.tear_down_port_network(net_id, port_id)
|
||||||
LOG.debug("test_associate_portprofile - END")
|
LOG.debug("test_associate_portprofile - END")
|
||||||
|
|
||||||
@ -418,14 +448,19 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
""" Test associate portprofile does not exist"""
|
""" Test associate portprofile does not exist"""
|
||||||
|
|
||||||
LOG.debug("test_associate_portprofileDNE - START")
|
LOG.debug("test_associate_portprofileDNE - START")
|
||||||
test_port_assign_data = {'portprofile': {'network-id': '001',
|
test_port_assign_data = {
|
||||||
'port-id': '1'}}
|
'portprofile': {
|
||||||
|
'network-id': '001',
|
||||||
|
'port-id': '1',
|
||||||
|
},
|
||||||
|
}
|
||||||
req_assign_body = json.dumps(test_port_assign_data)
|
req_assign_body = json.dumps(test_port_assign_data)
|
||||||
associate_path = self.portprofile_path + portprofile_id +\
|
associate_path = (self.portprofile_path +
|
||||||
"/associate_portprofile"
|
portprofile_id +
|
||||||
|
"/associate_portprofile")
|
||||||
associate_response = self.test_app.put(
|
associate_response = self.test_app.put(
|
||||||
associate_path, req_assign_body,
|
associate_path, req_assign_body,
|
||||||
content_type=self.contenttype, status='*')
|
content_type=self.contenttype, status='*')
|
||||||
self.assertEqual(450, associate_response.status_int)
|
self.assertEqual(450, associate_response.status_int)
|
||||||
LOG.debug("test_associate_portprofileDNE - END")
|
LOG.debug("test_associate_portprofileDNE - END")
|
||||||
|
|
||||||
@ -439,33 +474,38 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
|
|
||||||
req_body = json.dumps(self.test_port_profile)
|
req_body = json.dumps(self.test_port_profile)
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.profile_path, req_body,
|
self.profile_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
|
|
||||||
test_port_assign_data = {'portprofile': {'network-id': net_id,
|
test_port_assign_data = {
|
||||||
'port-id': port_id}}
|
'portprofile': {
|
||||||
|
'network-id': net_id,
|
||||||
|
'port-id': port_id,
|
||||||
|
},
|
||||||
|
}
|
||||||
req_assign_body = json.dumps(test_port_assign_data)
|
req_assign_body = json.dumps(test_port_assign_data)
|
||||||
associate_path_temp = self.portprofile_path +\
|
associate_path_temp = (self.portprofile_path +
|
||||||
resp_body['portprofiles']['portprofile']['id'] +\
|
resp_body['portprofiles']['portprofile']['id'] +
|
||||||
"/associate_portprofile"
|
"/associate_portprofile")
|
||||||
associate_path = str(associate_path_temp)
|
associate_path = str(associate_path_temp)
|
||||||
self.test_app.put(associate_path, req_assign_body,
|
self.test_app.put(associate_path, req_assign_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
disassociate_path_temp = self.portprofile_path +\
|
disassociate_path_temp = (
|
||||||
resp_body['portprofiles']['portprofile']['id'] +\
|
self.portprofile_path +
|
||||||
"/disassociate_portprofile"
|
resp_body['portprofiles']['portprofile']['id'] +
|
||||||
|
"/disassociate_portprofile")
|
||||||
|
|
||||||
disassociate_path = str(disassociate_path_temp)
|
disassociate_path = str(disassociate_path_temp)
|
||||||
disassociate_response = self.test_app.put(
|
disassociate_response = self.test_app.put(
|
||||||
disassociate_path, req_assign_body,
|
disassociate_path, req_assign_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
self.assertEqual(200, disassociate_response.status_int)
|
self.assertEqual(200, disassociate_response.status_int)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
delete_path_temp = self.portprofile_path +\
|
delete_path_temp = (self.portprofile_path +
|
||||||
resp_body['portprofiles']['portprofile']['id']
|
resp_body['portprofiles']['portprofile']['id'])
|
||||||
delete_path = str(delete_path_temp)
|
delete_path = str(delete_path_temp)
|
||||||
self.tear_down_profile(delete_path)
|
self.tear_down_profile(delete_path)
|
||||||
self.tear_down_port_network(net_id, port_id)
|
self.tear_down_port_network(net_id, port_id)
|
||||||
@ -484,12 +524,12 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
self.test_app.delete(delete_profile_path)
|
self.test_app.delete(delete_profile_path)
|
||||||
|
|
||||||
def tear_down_associate_profile(self, delete_profile_path,
|
def tear_down_associate_profile(self, delete_profile_path,
|
||||||
dissociate_profile_path, req_body):
|
dissociate_profile_path, req_body):
|
||||||
|
|
||||||
""" Tear down associate profile"""
|
""" Tear down associate profile"""
|
||||||
|
|
||||||
self.test_app.put(dissociate_profile_path, req_body,
|
self.test_app.put(dissociate_profile_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
self.tear_down_profile(delete_profile_path)
|
self.tear_down_profile(delete_profile_path)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@ -510,20 +550,33 @@ class NovatenantExtensionTest(unittest.TestCase):
|
|||||||
member_actions = {'schedule_host': "PUT",
|
member_actions = {'schedule_host': "PUT",
|
||||||
'associate_port': "PUT"}
|
'associate_port': "PUT"}
|
||||||
controller = novatenant.NovatenantsController(
|
controller = novatenant.NovatenantsController(
|
||||||
QuantumManager.get_plugin())
|
QuantumManager.get_plugin())
|
||||||
res_ext = extensions.ResourceExtension('novatenants', controller,
|
res_ext = extensions.ResourceExtension('novatenants', controller,
|
||||||
parent=parent_resource,
|
parent=parent_resource,
|
||||||
member_actions=member_actions)
|
member_actions=member_actions)
|
||||||
self.test_app = setup_extensions_test_app(
|
self.test_app = setup_extensions_test_app(
|
||||||
SimpleExtensionManager(res_ext))
|
SimpleExtensionManager(res_ext))
|
||||||
self.contenttype = 'application/json'
|
self.contenttype = 'application/json'
|
||||||
self.novatenants_path = '/extensions/csco/tenants/tt/novatenants/'
|
self.novatenants_path = '/extensions/csco/tenants/tt/novatenants/'
|
||||||
self.test_associate_port_data = {'novatenant': {'instance_id': 1,
|
self.test_associate_port_data = {
|
||||||
'instance_desc': {'project_id': 'demo',
|
'novatenant': {
|
||||||
'user_id': 'root', 'vif_id': '23432423'}}}
|
'instance_id': 1,
|
||||||
self.test_associate_data = {'novatenant': {'instance_id': 1,
|
'instance_desc': {
|
||||||
'instance_desc': {'project_id': 'demo',
|
'project_id': 'demo',
|
||||||
'user_id': 'root'}}}
|
'user_id': 'root',
|
||||||
|
'vif_id': '23432423',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
self.test_associate_data = {
|
||||||
|
'novatenant': {
|
||||||
|
'instance_id': 1,
|
||||||
|
'instance_desc': {
|
||||||
|
'project_id': 'demo',
|
||||||
|
'user_id': 'root',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
self._l2network_plugin = l2network_plugin.L2Network()
|
self._l2network_plugin = l2network_plugin.L2Network()
|
||||||
|
|
||||||
def test_schedule_host(self):
|
def test_schedule_host(self):
|
||||||
@ -532,8 +585,8 @@ class NovatenantExtensionTest(unittest.TestCase):
|
|||||||
req_body = json.dumps(self.test_associate_data)
|
req_body = json.dumps(self.test_associate_data)
|
||||||
host_path = self.novatenants_path + "001/schedule_host"
|
host_path = self.novatenants_path + "001/schedule_host"
|
||||||
host_response = self.test_app.put(
|
host_response = self.test_app.put(
|
||||||
host_path, req_body,
|
host_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
self.assertEqual(200, host_response.status_int)
|
self.assertEqual(200, host_response.status_int)
|
||||||
LOG.debug("test_schedule_host - END")
|
LOG.debug("test_schedule_host - END")
|
||||||
|
|
||||||
@ -542,8 +595,8 @@ class NovatenantExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_schedule_hostBADRequest - START")
|
LOG.debug("test_schedule_hostBADRequest - START")
|
||||||
host_path = self.novatenants_path + "001/schedule_host"
|
host_path = self.novatenants_path + "001/schedule_host"
|
||||||
host_response = self.test_app.put(
|
host_response = self.test_app.put(
|
||||||
host_path, 'BAD_REQUEST',
|
host_path, 'BAD_REQUEST',
|
||||||
content_type=self.contenttype, status='*')
|
content_type=self.contenttype, status='*')
|
||||||
self.assertEqual(400, host_response.status_int)
|
self.assertEqual(400, host_response.status_int)
|
||||||
LOG.debug("test_schedule_hostBADRequest - END")
|
LOG.debug("test_schedule_hostBADRequest - END")
|
||||||
|
|
||||||
@ -553,8 +606,8 @@ class NovatenantExtensionTest(unittest.TestCase):
|
|||||||
req_body = json.dumps(self.test_associate_port_data)
|
req_body = json.dumps(self.test_associate_port_data)
|
||||||
associate_port_path = self.novatenants_path + "001/associate_port"
|
associate_port_path = self.novatenants_path + "001/associate_port"
|
||||||
associate_port_response = self.test_app.put(
|
associate_port_response = self.test_app.put(
|
||||||
associate_port_path, req_body,
|
associate_port_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
self.assertEqual(200, associate_port_response.status_int)
|
self.assertEqual(200, associate_port_response.status_int)
|
||||||
LOG.debug("test_associate_port - END")
|
LOG.debug("test_associate_port - END")
|
||||||
|
|
||||||
@ -574,15 +627,22 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
collection_name="extensions/csco/tenants")
|
collection_name="extensions/csco/tenants")
|
||||||
controller = qos.QosController(QuantumManager.get_plugin())
|
controller = qos.QosController(QuantumManager.get_plugin())
|
||||||
res_ext = extensions.ResourceExtension('qos', controller,
|
res_ext = extensions.ResourceExtension('qos', controller,
|
||||||
parent=parent_resource)
|
parent=parent_resource)
|
||||||
|
|
||||||
self.test_app = setup_extensions_test_app(
|
self.test_app = setup_extensions_test_app(
|
||||||
SimpleExtensionManager(res_ext))
|
SimpleExtensionManager(res_ext))
|
||||||
self.contenttype = 'application/json'
|
self.contenttype = 'application/json'
|
||||||
self.qos_path = '/extensions/csco/tenants/tt/qos'
|
self.qos_path = '/extensions/csco/tenants/tt/qos'
|
||||||
self.qos_second_path = '/extensions/csco/tenants/tt/qos/'
|
self.qos_second_path = '/extensions/csco/tenants/tt/qos/'
|
||||||
self.test_qos_data = {'qos': {'qos_name': 'cisco_test_qos',
|
self.test_qos_data = {
|
||||||
'qos_desc': {'PPS': 50, 'TTL': 5}}}
|
'qos': {
|
||||||
|
'qos_name': 'cisco_test_qos',
|
||||||
|
'qos_desc': {
|
||||||
|
'PPS': 50,
|
||||||
|
'TTL': 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
self._l2network_plugin = l2network_plugin.L2Network()
|
self._l2network_plugin = l2network_plugin.L2Network()
|
||||||
|
|
||||||
def test_create_qos(self):
|
def test_create_qos(self):
|
||||||
@ -592,15 +652,14 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_create_qos - START")
|
LOG.debug("test_create_qos - START")
|
||||||
req_body = json.dumps(self.test_qos_data)
|
req_body = json.dumps(self.test_qos_data)
|
||||||
index_response = self.test_app.post(self.qos_path,
|
index_response = self.test_app.post(self.qos_path,
|
||||||
req_body,
|
req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
self.assertEqual(200, index_response.status_int)
|
self.assertEqual(200, index_response.status_int)
|
||||||
|
|
||||||
# Clean Up - Delete the qos
|
# Clean Up - Delete the qos
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
qos_path_temp = self.qos_second_path +\
|
qos_path_temp = self.qos_second_path + resp_body['qoss']['qos']['id']
|
||||||
resp_body['qoss']['qos']['id']
|
|
||||||
qos_path = str(qos_path_temp)
|
qos_path = str(qos_path_temp)
|
||||||
self.tearDownQos(qos_path)
|
self.tearDownQos(qos_path)
|
||||||
LOG.debug("test_create_qos - END")
|
LOG.debug("test_create_qos - END")
|
||||||
@ -625,8 +684,15 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
req_body1 = json.dumps(self.test_qos_data)
|
req_body1 = json.dumps(self.test_qos_data)
|
||||||
create_resp1 = self.test_app.post(self.qos_path, req_body1,
|
create_resp1 = self.test_app.post(self.qos_path, req_body1,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
req_body2 = json.dumps({'qos': {'qos_name': 'cisco_test_qos2',
|
req_body2 = json.dumps({
|
||||||
'qos_desc': {'PPS': 50, 'TTL': 5}}})
|
'qos': {
|
||||||
|
'qos_name': 'cisco_test_qos2',
|
||||||
|
'qos_desc': {
|
||||||
|
'PPS': 50,
|
||||||
|
'TTL': 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
create_resp2 = self.test_app.post(self.qos_path, req_body2,
|
create_resp2 = self.test_app.post(self.qos_path, req_body2,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
index_response = self.test_app.get(self.qos_path)
|
index_response = self.test_app.get(self.qos_path)
|
||||||
@ -637,16 +703,14 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
# Clean Up - Delete the qos's
|
# Clean Up - Delete the qos's
|
||||||
resp_body1 = wsgi.Serializer().deserialize(create_resp1.body,
|
resp_body1 = wsgi.Serializer().deserialize(create_resp1.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
qos_path1_temp = self.qos_second_path +\
|
qos_path1_temp = self.qos_second_path + resp_body1['qoss']['qos']['id']
|
||||||
resp_body1['qoss']['qos']['id']
|
|
||||||
qos_path1 = str(qos_path1_temp)
|
qos_path1 = str(qos_path1_temp)
|
||||||
resp_body2 = wsgi.Serializer().deserialize(create_resp2.body,
|
resp_body2 = wsgi.Serializer().deserialize(create_resp2.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
list_all_qos = [resp_body1['qoss']['qos'], resp_body2['qoss']['qos']]
|
list_all_qos = [resp_body1['qoss']['qos'], resp_body2['qoss']['qos']]
|
||||||
self.assertTrue(index_resp_body['qoss'][0] in list_all_qos)
|
self.assertTrue(index_resp_body['qoss'][0] in list_all_qos)
|
||||||
self.assertTrue(index_resp_body['qoss'][1] in list_all_qos)
|
self.assertTrue(index_resp_body['qoss'][1] in list_all_qos)
|
||||||
qos_path2_temp = self.qos_second_path +\
|
qos_path2_temp = self.qos_second_path + resp_body2['qoss']['qos']['id']
|
||||||
resp_body2['qoss']['qos']['id']
|
|
||||||
qos_path2 = str(qos_path2_temp)
|
qos_path2 = str(qos_path2_temp)
|
||||||
self.tearDownQos(qos_path1)
|
self.tearDownQos(qos_path1)
|
||||||
self.tearDownQos(qos_path2)
|
self.tearDownQos(qos_path2)
|
||||||
@ -662,15 +726,13 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
show_path_temp = self.qos_second_path +\
|
show_path_temp = self.qos_second_path + resp_body['qoss']['qos']['id']
|
||||||
resp_body['qoss']['qos']['id']
|
|
||||||
show_qos_path = str(show_path_temp)
|
show_qos_path = str(show_path_temp)
|
||||||
show_response = self.test_app.get(show_qos_path)
|
show_response = self.test_app.get(show_qos_path)
|
||||||
show_resp_dict = wsgi.Serializer().deserialize(show_response.body,
|
show_resp_dict = wsgi.Serializer().deserialize(show_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
self.assertEqual(
|
self.assertEqual(show_resp_dict['qoss']['qos']['name'],
|
||||||
show_resp_dict['qoss']['qos']['name'],
|
self.test_qos_data['qos']['qos_name'])
|
||||||
self.test_qos_data['qos']['qos_name'])
|
|
||||||
|
|
||||||
self.assertEqual(200, show_response.status_int)
|
self.assertEqual(200, show_response.status_int)
|
||||||
|
|
||||||
@ -699,16 +761,23 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
rename_req_body = json.dumps({'qos': {'qos_name': 'cisco_rename_qos',
|
rename_req_body = json.dumps({
|
||||||
'qos_desc': {'PPS': 50, 'TTL': 5}}})
|
'qos': {
|
||||||
rename_path_temp = self.qos_second_path +\
|
'qos_name': 'cisco_rename_qos',
|
||||||
resp_body['qoss']['qos']['id']
|
'qos_desc': {
|
||||||
|
'PPS': 50,
|
||||||
|
'TTL': 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
rename_path_temp = (self.qos_second_path +
|
||||||
|
resp_body['qoss']['qos']['id'])
|
||||||
rename_path = str(rename_path_temp)
|
rename_path = str(rename_path_temp)
|
||||||
rename_response = self.test_app.put(rename_path, rename_req_body,
|
rename_response = self.test_app.put(rename_path, rename_req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
self.assertEqual(200, rename_response.status_int)
|
self.assertEqual(200, rename_response.status_int)
|
||||||
rename_resp_dict = wsgi.Serializer().deserialize(rename_response.body,
|
rename_resp_dict = wsgi.Serializer().deserialize(rename_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
rename_resp_dict['qoss']['qos']['name'],
|
rename_resp_dict['qoss']['qos']['name'],
|
||||||
'cisco_rename_qos')
|
'cisco_rename_qos')
|
||||||
@ -720,8 +789,15 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
""" Test update qos does not exist """
|
""" Test update qos does not exist """
|
||||||
|
|
||||||
LOG.debug("test_update_qosDNE - START")
|
LOG.debug("test_update_qosDNE - START")
|
||||||
rename_req_body = json.dumps({'qos': {'qos_name': 'cisco_rename_qos',
|
rename_req_body = json.dumps({
|
||||||
'qos_desc': {'PPS': 50, 'TTL': 5}}})
|
'qos': {
|
||||||
|
'qos_name': 'cisco_rename_qos',
|
||||||
|
'qos_desc': {
|
||||||
|
'PPS': 50,
|
||||||
|
'TTL': 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
rename_path_temp = self.qos_second_path + qos_id
|
rename_path_temp = self.qos_second_path + qos_id
|
||||||
rename_path = str(rename_path_temp)
|
rename_path = str(rename_path_temp)
|
||||||
rename_response = self.test_app.put(rename_path, rename_req_body,
|
rename_response = self.test_app.put(rename_path, rename_req_body,
|
||||||
@ -740,8 +816,8 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
rename_path_temp = self.qos_second_path +\
|
rename_path_temp = (self.qos_second_path +
|
||||||
resp_body['qoss']['qos']['id']
|
resp_body['qoss']['qos']['id'])
|
||||||
rename_path = str(rename_path_temp)
|
rename_path = str(rename_path_temp)
|
||||||
rename_response = self.test_app.put(rename_path, 'BAD_REQUEST',
|
rename_response = self.test_app.put(rename_path, 'BAD_REQUEST',
|
||||||
status="*")
|
status="*")
|
||||||
@ -756,14 +832,21 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
""" Test delte qos """
|
""" Test delte qos """
|
||||||
|
|
||||||
LOG.debug("test_delete_qos - START")
|
LOG.debug("test_delete_qos - START")
|
||||||
req_body = json.dumps({'qos': {'qos_name': 'cisco_test_qos',
|
req_body = json.dumps({
|
||||||
'qos_desc': {'PPS': 50, 'TTL': 5}}})
|
'qos': {
|
||||||
|
'qos_name': 'cisco_test_qos',
|
||||||
|
'qos_desc': {
|
||||||
|
'PPS': 50,
|
||||||
|
'TTL': 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
index_response = self.test_app.post(self.qos_path, req_body,
|
index_response = self.test_app.post(self.qos_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
delete_path_temp = self.qos_second_path +\
|
delete_path_temp = (self.qos_second_path +
|
||||||
resp_body['qoss']['qos']['id']
|
resp_body['qoss']['qos']['id'])
|
||||||
delete_path = str(delete_path_temp)
|
delete_path = str(delete_path_temp)
|
||||||
delete_response = self.test_app.delete(delete_path)
|
delete_response = self.test_app.delete(delete_path)
|
||||||
self.assertEqual(200, delete_response.status_int)
|
self.assertEqual(200, delete_response.status_int)
|
||||||
@ -801,16 +884,19 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
controller = credential.CredentialController(
|
controller = credential.CredentialController(
|
||||||
QuantumManager.get_plugin())
|
QuantumManager.get_plugin())
|
||||||
res_ext = extensions.ResourceExtension('credentials', controller,
|
res_ext = extensions.ResourceExtension('credentials', controller,
|
||||||
parent=parent_resource)
|
parent=parent_resource)
|
||||||
self.test_app = setup_extensions_test_app(
|
self.test_app = setup_extensions_test_app(
|
||||||
SimpleExtensionManager(res_ext))
|
SimpleExtensionManager(res_ext))
|
||||||
self.contenttype = 'application/json'
|
self.contenttype = 'application/json'
|
||||||
self.credential_path = '/extensions/csco/tenants/tt/credentials'
|
self.credential_path = '/extensions/csco/tenants/tt/credentials'
|
||||||
self.cred_second_path = '/extensions/csco/tenants/tt/credentials/'
|
self.cred_second_path = '/extensions/csco/tenants/tt/credentials/'
|
||||||
self.test_credential_data = {'credential':
|
self.test_credential_data = {
|
||||||
{'credential_name': 'cred8',
|
'credential': {
|
||||||
'user_name': 'newUser2',
|
'credential_name': 'cred8',
|
||||||
'password': 'newPasswd1'}}
|
'user_name': 'newUser2',
|
||||||
|
'password': 'newPasswd1',
|
||||||
|
},
|
||||||
|
}
|
||||||
self._l2network_plugin = l2network_plugin.L2Network()
|
self._l2network_plugin = l2network_plugin.L2Network()
|
||||||
|
|
||||||
def test_list_credentials(self):
|
def test_list_credentials(self):
|
||||||
@ -821,36 +907,38 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_list_credentials - START")
|
LOG.debug("test_list_credentials - START")
|
||||||
req_body1 = json.dumps(self.test_credential_data)
|
req_body1 = json.dumps(self.test_credential_data)
|
||||||
create_response1 = self.test_app.post(
|
create_response1 = self.test_app.post(
|
||||||
self.credential_path, req_body1,
|
self.credential_path, req_body1,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
req_body2 = json.dumps({'credential':
|
req_body2 = json.dumps({
|
||||||
{'credential_name': 'cred9',
|
'credential': {
|
||||||
'user_name': 'newUser2',
|
'credential_name': 'cred9',
|
||||||
'password': 'newPasswd2'}})
|
'user_name': 'newUser2',
|
||||||
|
'password': 'newPasswd2',
|
||||||
|
},
|
||||||
|
})
|
||||||
create_response2 = self.test_app.post(
|
create_response2 = self.test_app.post(
|
||||||
self.credential_path, req_body2,
|
self.credential_path, req_body2,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
index_response = self.test_app.get(
|
index_response = self.test_app.get(self.credential_path)
|
||||||
self.credential_path)
|
|
||||||
index_resp_body = wsgi.Serializer().deserialize(index_response.body,
|
index_resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
self.assertEqual(200, index_response.status_int)
|
self.assertEqual(200, index_response.status_int)
|
||||||
#CLean Up - Deletion of the Credentials
|
#CLean Up - Deletion of the Credentials
|
||||||
resp_body1 = wsgi.Serializer().deserialize(
|
resp_body1 = wsgi.Serializer().deserialize(create_response1.body,
|
||||||
create_response1.body, self.contenttype)
|
self.contenttype)
|
||||||
delete_path1_temp = self.cred_second_path +\
|
delete_path1_temp = (self.cred_second_path +
|
||||||
resp_body1['credentials']['credential']['id']
|
resp_body1['credentials']['credential']['id'])
|
||||||
delete_path1 = str(delete_path1_temp)
|
delete_path1 = str(delete_path1_temp)
|
||||||
resp_body2 = wsgi.Serializer().deserialize(
|
resp_body2 = wsgi.Serializer().deserialize(create_response2.body,
|
||||||
create_response2.body, self.contenttype)
|
self.contenttype)
|
||||||
list_all_credential = [resp_body1['credentials']['credential'],
|
list_all_credential = [resp_body1['credentials']['credential'],
|
||||||
resp_body2['credentials']['credential']]
|
resp_body2['credentials']['credential']]
|
||||||
self.assertTrue(index_resp_body['credentials'][0] in
|
self.assertTrue(
|
||||||
list_all_credential)
|
index_resp_body['credentials'][0] in list_all_credential)
|
||||||
self.assertTrue(index_resp_body['credentials'][1] in
|
self.assertTrue(
|
||||||
list_all_credential)
|
index_resp_body['credentials'][1] in list_all_credential)
|
||||||
delete_path2_temp = self.cred_second_path +\
|
delete_path2_temp = (self.cred_second_path +
|
||||||
resp_body2['credentials']['credential']['id']
|
resp_body2['credentials']['credential']['id'])
|
||||||
delete_path2 = str(delete_path2_temp)
|
delete_path2 = str(delete_path2_temp)
|
||||||
self.tearDownCredential(delete_path1)
|
self.tearDownCredential(delete_path1)
|
||||||
self.tearDownCredential(delete_path2)
|
self.tearDownCredential(delete_path2)
|
||||||
@ -863,14 +951,14 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_create_credential - START")
|
LOG.debug("test_create_credential - START")
|
||||||
req_body = json.dumps(self.test_credential_data)
|
req_body = json.dumps(self.test_credential_data)
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.credential_path, req_body,
|
self.credential_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
self.assertEqual(200, index_response.status_int)
|
self.assertEqual(200, index_response.status_int)
|
||||||
#CLean Up - Deletion of the Credentials
|
#CLean Up - Deletion of the Credentials
|
||||||
resp_body = wsgi.Serializer().deserialize(
|
resp_body = wsgi.Serializer().deserialize(
|
||||||
index_response.body, self.contenttype)
|
index_response.body, self.contenttype)
|
||||||
delete_path_temp = self.cred_second_path +\
|
delete_path_temp = (self.cred_second_path +
|
||||||
resp_body['credentials']['credential']['id']
|
resp_body['credentials']['credential']['id'])
|
||||||
delete_path = str(delete_path_temp)
|
delete_path = str(delete_path_temp)
|
||||||
self.tearDownCredential(delete_path)
|
self.tearDownCredential(delete_path)
|
||||||
LOG.debug("test_create_credential - END")
|
LOG.debug("test_create_credential - END")
|
||||||
@ -881,8 +969,8 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_create_credentialBADRequest - START")
|
LOG.debug("test_create_credentialBADRequest - START")
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.credential_path, 'BAD_REQUEST',
|
self.credential_path, 'BAD_REQUEST',
|
||||||
content_type=self.contenttype, status='*')
|
content_type=self.contenttype, status='*')
|
||||||
self.assertEqual(400, index_response.status_int)
|
self.assertEqual(400, index_response.status_int)
|
||||||
LOG.debug("test_create_credentialBADRequest - END")
|
LOG.debug("test_create_credentialBADRequest - END")
|
||||||
|
|
||||||
@ -893,22 +981,21 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_show_credential - START")
|
LOG.debug("test_show_credential - START")
|
||||||
req_body = json.dumps(self.test_credential_data)
|
req_body = json.dumps(self.test_credential_data)
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.credential_path, req_body,
|
self.credential_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(
|
resp_body = wsgi.Serializer().deserialize(index_response.body,
|
||||||
index_response.body, self.contenttype)
|
self.contenttype)
|
||||||
show_path_temp = self.cred_second_path +\
|
show_path_temp = (self.cred_second_path +
|
||||||
resp_body['credentials']['credential']['id']
|
resp_body['credentials']['credential']['id'])
|
||||||
show_cred_path = str(show_path_temp)
|
show_cred_path = str(show_path_temp)
|
||||||
show_response = self.test_app.get(show_cred_path)
|
show_response = self.test_app.get(show_cred_path)
|
||||||
show_resp_dict = wsgi.Serializer().deserialize(show_response.body,
|
show_resp_dict = wsgi.Serializer().deserialize(show_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
|
self.assertEqual(show_resp_dict['credentials']['credential']['name'],
|
||||||
|
self.test_credential_data['credential']['user_name'])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
show_resp_dict['credentials']['credential']['name'],
|
show_resp_dict['credentials']['credential']['password'],
|
||||||
self.test_credential_data['credential']['user_name'])
|
self.test_credential_data['credential']['password'])
|
||||||
self.assertEqual(
|
|
||||||
show_resp_dict['credentials']['credential']['password'],
|
|
||||||
self.test_credential_data['credential']['password'])
|
|
||||||
self.assertEqual(200, show_response.status_int)
|
self.assertEqual(200, show_response.status_int)
|
||||||
LOG.debug("test_show_credential - END")
|
LOG.debug("test_show_credential - END")
|
||||||
|
|
||||||
@ -931,27 +1018,29 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
req_body = json.dumps(self.test_credential_data)
|
req_body = json.dumps(self.test_credential_data)
|
||||||
|
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.credential_path, req_body,
|
self.credential_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(
|
resp_body = wsgi.Serializer().deserialize(
|
||||||
index_response.body, self.contenttype)
|
index_response.body, self.contenttype)
|
||||||
rename_req_body = json.dumps({'credential':
|
rename_req_body = json.dumps({
|
||||||
{'credential_name': 'cred3',
|
'credential': {
|
||||||
'user_name': 'RenamedUser',
|
'credential_name': 'cred3',
|
||||||
'password': 'Renamedpassword'}})
|
'user_name': 'RenamedUser',
|
||||||
rename_path_temp = self.cred_second_path +\
|
'password': 'Renamedpassword',
|
||||||
resp_body['credentials']['credential']['id']
|
},
|
||||||
|
})
|
||||||
|
rename_path_temp = (self.cred_second_path +
|
||||||
|
resp_body['credentials']['credential']['id'])
|
||||||
rename_path = str(rename_path_temp)
|
rename_path = str(rename_path_temp)
|
||||||
rename_response = self.test_app.put(rename_path, rename_req_body,
|
rename_response = self.test_app.put(rename_path, rename_req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
rename_resp_dict = wsgi.Serializer().deserialize(rename_response.body,
|
rename_resp_dict = wsgi.Serializer().deserialize(rename_response.body,
|
||||||
self.contenttype)
|
self.contenttype)
|
||||||
|
self.assertEqual(rename_resp_dict['credentials']['credential']['name'],
|
||||||
|
'cred3')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
rename_resp_dict['credentials']['credential']['name'],
|
rename_resp_dict['credentials']['credential']['password'],
|
||||||
'cred3')
|
self.test_credential_data['credential']['password'])
|
||||||
self.assertEqual(
|
|
||||||
rename_resp_dict['credentials']['credential']['password'],
|
|
||||||
self.test_credential_data['credential']['password'])
|
|
||||||
self.assertEqual(200, rename_response.status_int)
|
self.assertEqual(200, rename_response.status_int)
|
||||||
# Clean Up - Delete the Credentials
|
# Clean Up - Delete the Credentials
|
||||||
self.tearDownCredential(rename_path)
|
self.tearDownCredential(rename_path)
|
||||||
@ -964,12 +1053,12 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_update_credBADReq - START")
|
LOG.debug("test_update_credBADReq - START")
|
||||||
req_body = json.dumps(self.test_credential_data)
|
req_body = json.dumps(self.test_credential_data)
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.credential_path, req_body,
|
self.credential_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(
|
resp_body = wsgi.Serializer().deserialize(
|
||||||
index_response.body, self.contenttype)
|
index_response.body, self.contenttype)
|
||||||
rename_path_temp = self.cred_second_path +\
|
rename_path_temp = (self.cred_second_path +
|
||||||
resp_body['credentials']['credential']['id']
|
resp_body['credentials']['credential']['id'])
|
||||||
rename_path = str(rename_path_temp)
|
rename_path = str(rename_path_temp)
|
||||||
rename_response = self.test_app.put(rename_path, 'BAD_REQUEST',
|
rename_response = self.test_app.put(rename_path, 'BAD_REQUEST',
|
||||||
status='*')
|
status='*')
|
||||||
@ -981,10 +1070,13 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
""" Test update credential does not exist"""
|
""" Test update credential does not exist"""
|
||||||
|
|
||||||
LOG.debug("test_update_credentialDNE - START")
|
LOG.debug("test_update_credentialDNE - START")
|
||||||
rename_req_body = json.dumps({'credential':
|
rename_req_body = json.dumps({
|
||||||
{'credential_name': 'cred3',
|
'credential': {
|
||||||
'user_name': 'RenamedUser',
|
'credential_name': 'cred3',
|
||||||
'password': 'Renamedpassword'}})
|
'user_name': 'RenamedUser',
|
||||||
|
'password': 'Renamedpassword',
|
||||||
|
},
|
||||||
|
})
|
||||||
rename_path_temp = self.cred_second_path + credential_id
|
rename_path_temp = self.cred_second_path + credential_id
|
||||||
rename_path = str(rename_path_temp)
|
rename_path = str(rename_path_temp)
|
||||||
rename_response = self.test_app.put(rename_path, rename_req_body,
|
rename_response = self.test_app.put(rename_path, rename_req_body,
|
||||||
@ -1000,12 +1092,12 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("test_delete_credential - START")
|
LOG.debug("test_delete_credential - START")
|
||||||
req_body = json.dumps(self.test_credential_data)
|
req_body = json.dumps(self.test_credential_data)
|
||||||
index_response = self.test_app.post(
|
index_response = self.test_app.post(
|
||||||
self.credential_path, req_body,
|
self.credential_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
resp_body = wsgi.Serializer().deserialize(
|
resp_body = wsgi.Serializer().deserialize(
|
||||||
index_response.body, self.contenttype)
|
index_response.body, self.contenttype)
|
||||||
delete_path_temp = self.cred_second_path +\
|
delete_path_temp = (self.cred_second_path +
|
||||||
resp_body['credentials']['credential']['id']
|
resp_body['credentials']['credential']['id'])
|
||||||
delete_path = str(delete_path_temp)
|
delete_path = str(delete_path_temp)
|
||||||
delete_response = self.test_app.delete(delete_path)
|
delete_response = self.test_app.delete(delete_path)
|
||||||
self.assertEqual(200, delete_response.status_int)
|
self.assertEqual(200, delete_response.status_int)
|
||||||
@ -1038,23 +1130,26 @@ class MultiPortExtensionTest(unittest.TestCase):
|
|||||||
parent_resource = dict(member_name="tenant",
|
parent_resource = dict(member_name="tenant",
|
||||||
collection_name="extensions/csco/tenants")
|
collection_name="extensions/csco/tenants")
|
||||||
controller = multiport.MultiportController(
|
controller = multiport.MultiportController(
|
||||||
QuantumManager.get_plugin())
|
QuantumManager.get_plugin())
|
||||||
res_ext = extensions.ResourceExtension('multiport', controller,
|
res_ext = extensions.ResourceExtension('multiport', controller,
|
||||||
parent=parent_resource)
|
parent=parent_resource)
|
||||||
self.test_app = setup_extensions_test_app(
|
self.test_app = setup_extensions_test_app(
|
||||||
SimpleExtensionManager(res_ext))
|
SimpleExtensionManager(res_ext))
|
||||||
self.contenttype = 'application/json'
|
self.contenttype = 'application/json'
|
||||||
self.multiport_path = '/extensions/csco/tenants/tt/multiport'
|
self.multiport_path = '/extensions/csco/tenants/tt/multiport'
|
||||||
self.multiport_path2 = '/extensions/csco/tenants/tt/multiport/'
|
self.multiport_path2 = '/extensions/csco/tenants/tt/multiport/'
|
||||||
self.test_multi_port = {'multiport':
|
self.test_multi_port = {
|
||||||
{'net_id_list': '1',
|
'multiport': {
|
||||||
'status': 'test-qos1',
|
'net_id_list': '1',
|
||||||
'ports_desc': 'Port Descr'}}
|
'status': 'test-qos1',
|
||||||
|
'ports_desc': 'Port Descr',
|
||||||
|
},
|
||||||
|
}
|
||||||
self.tenant_id = "test_tenant"
|
self.tenant_id = "test_tenant"
|
||||||
self.network_name = "test_network"
|
self.network_name = "test_network"
|
||||||
options = {}
|
options = {}
|
||||||
options['plugin_provider'] = 'quantum.plugins.cisco.l2network_plugin'\
|
options['plugin_provider'] = (
|
||||||
'.L2Network'
|
'quantum.plugins.cisco.l2network_plugin.L2Network')
|
||||||
self.api = server.APIRouterV10(options)
|
self.api = server.APIRouterV10(options)
|
||||||
self._l2network_plugin = l2network_plugin.L2Network()
|
self._l2network_plugin = l2network_plugin.L2Network()
|
||||||
|
|
||||||
@ -1096,7 +1191,7 @@ class MultiPortExtensionTest(unittest.TestCase):
|
|||||||
LOG.debug("Deleting network %s - START", network_id)
|
LOG.debug("Deleting network %s - START", network_id)
|
||||||
network_path = "/tenants/tt/networks/%s" % network_id
|
network_path = "/tenants/tt/networks/%s" % network_id
|
||||||
network_req = self.create_request(network_path, None,
|
network_req = self.create_request(network_path, None,
|
||||||
self.contenttype, 'DELETE')
|
self.contenttype, 'DELETE')
|
||||||
network_req.get_response(self.api)
|
network_req.get_response(self.api)
|
||||||
LOG.debug("Deleting network - END")
|
LOG.debug("Deleting network - END")
|
||||||
|
|
||||||
@ -1108,10 +1203,15 @@ class MultiPortExtensionTest(unittest.TestCase):
|
|||||||
|
|
||||||
net_id = self._create_network('net1')
|
net_id = self._create_network('net1')
|
||||||
net_id2 = self._create_network('net2')
|
net_id2 = self._create_network('net2')
|
||||||
test_multi_port = {'multiport':
|
test_multi_port = {
|
||||||
{'net_id_list': [net_id, net_id2],
|
'multiport': {
|
||||||
'status': 'ACTIVE',
|
'net_id_list': [net_id, net_id2],
|
||||||
'ports_desc': {'key': 'value'}}}
|
'status': 'ACTIVE',
|
||||||
|
'ports_desc': {
|
||||||
|
'key': 'value',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
req_body = json.dumps(test_multi_port)
|
req_body = json.dumps(test_multi_port)
|
||||||
index_response = self.test_app.post(self.multiport_path, req_body,
|
index_response = self.test_app.post(self.multiport_path, req_body,
|
||||||
content_type=self.contenttype)
|
content_type=self.contenttype)
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
test_database.py is an independent test suite
|
test_database.py is an independent test suite
|
||||||
that tests the database api method calls
|
that tests the database api method calls
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging as LOG
|
import logging as LOG
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
|
|
||||||
import quantum.plugins.cisco.db.api as db
|
import quantum.plugins.cisco.db.api as db
|
||||||
import quantum.plugins.cisco.db.l2network_db as l2network_db
|
import quantum.plugins.cisco.db.l2network_db as l2network_db
|
||||||
import quantum.plugins.cisco.db.nexus_db as nexus_db
|
import quantum.plugins.cisco.db.nexus_db as nexus_db
|
||||||
@ -72,13 +72,14 @@ class UcsDB(object):
|
|||||||
LOG.error("Failed to get port binding: %s" % str(exc))
|
LOG.error("Failed to get port binding: %s" % str(exc))
|
||||||
return port_binding
|
return port_binding
|
||||||
|
|
||||||
def create_port_binding(self, port_id, blade_intf_dn, portprofile_name, \
|
def create_port_binding(self, port_id, blade_intf_dn, portprofile_name,
|
||||||
vlan_name, vlan_id, qos):
|
vlan_name, vlan_id, qos):
|
||||||
"""create port binding"""
|
"""create port binding"""
|
||||||
port_bind_dict = {}
|
port_bind_dict = {}
|
||||||
try:
|
try:
|
||||||
res = ucs_db.add_portbinding(port_id, blade_intf_dn, \
|
res = ucs_db.add_portbinding(port_id, blade_intf_dn,
|
||||||
portprofile_name, vlan_name, vlan_id, qos)
|
portprofile_name, vlan_name,
|
||||||
|
vlan_id, qos)
|
||||||
LOG.debug("Created port binding: %s" % res.port_id)
|
LOG.debug("Created port binding: %s" % res.port_id)
|
||||||
port_bind_dict["port-id"] = res.port_id
|
port_bind_dict["port-id"] = res.port_id
|
||||||
port_bind_dict["blade-intf-dn"] = str(res.blade_intf_dn)
|
port_bind_dict["blade-intf-dn"] = str(res.blade_intf_dn)
|
||||||
@ -101,12 +102,13 @@ class UcsDB(object):
|
|||||||
except Exception, exc:
|
except Exception, exc:
|
||||||
raise Exception("Failed to delete port profile: %s" % str(exc))
|
raise Exception("Failed to delete port profile: %s" % str(exc))
|
||||||
|
|
||||||
def update_port_binding(self, port_id, blade_intf_dn, \
|
def update_port_binding(self, port_id, blade_intf_dn,
|
||||||
portprofile_name, vlan_name, vlan_id, qos):
|
portprofile_name, vlan_name, vlan_id, qos):
|
||||||
"""update port binding"""
|
"""update port binding"""
|
||||||
try:
|
try:
|
||||||
res = ucs_db.update_portbinding(port_id, blade_intf_dn, \
|
res = ucs_db.update_portbinding(port_id, blade_intf_dn,
|
||||||
portprofile_name, vlan_name, vlan_id, qos)
|
portprofile_name, vlan_name,
|
||||||
|
vlan_id, qos)
|
||||||
LOG.debug("Updating port binding: %s" % res.port_id)
|
LOG.debug("Updating port binding: %s" % res.port_id)
|
||||||
port_bind_dict = {}
|
port_bind_dict = {}
|
||||||
port_bind_dict["port-id"] = res.port_id
|
port_bind_dict["port-id"] = res.port_id
|
||||||
@ -223,7 +225,7 @@ class ServicesDB(object):
|
|||||||
"""create service binding"""
|
"""create service binding"""
|
||||||
bind_dict = {}
|
bind_dict = {}
|
||||||
try:
|
try:
|
||||||
res = services_db.add_services_binding(service_id, mngnet_id, \
|
res = services_db.add_services_binding(service_id, mngnet_id,
|
||||||
nbnet_id, sbnet_id)
|
nbnet_id, sbnet_id)
|
||||||
LOG.debug("Created service binding : %s" % res.service_id)
|
LOG.debug("Created service binding : %s" % res.service_id)
|
||||||
bind_dict["service_id"] = str(res.service_id)
|
bind_dict["service_id"] = str(res.service_id)
|
||||||
@ -253,7 +255,7 @@ class L2networkDB(object):
|
|||||||
try:
|
try:
|
||||||
for vlan_bind in l2network_db.get_all_vlan_bindings():
|
for vlan_bind in l2network_db.get_all_vlan_bindings():
|
||||||
LOG.debug("Getting vlan bindings for vlan: %s" %
|
LOG.debug("Getting vlan bindings for vlan: %s" %
|
||||||
vlan_bind.vlan_id)
|
vlan_bind.vlan_id)
|
||||||
vlan_dict = {}
|
vlan_dict = {}
|
||||||
vlan_dict["vlan-id"] = str(vlan_bind.vlan_id)
|
vlan_dict["vlan-id"] = str(vlan_bind.vlan_id)
|
||||||
vlan_dict["vlan-name"] = vlan_bind.vlan_name
|
vlan_dict["vlan-name"] = vlan_bind.vlan_name
|
||||||
@ -268,8 +270,8 @@ class L2networkDB(object):
|
|||||||
vlan = []
|
vlan = []
|
||||||
try:
|
try:
|
||||||
for vlan_bind in l2network_db.get_vlan_binding(network_id):
|
for vlan_bind in l2network_db.get_vlan_binding(network_id):
|
||||||
LOG.debug("Getting vlan binding for vlan: %s"
|
LOG.debug("Getting vlan binding for vlan: %s" %
|
||||||
% vlan_bind.vlan_id)
|
vlan_bind.vlan_id)
|
||||||
vlan_dict = {}
|
vlan_dict = {}
|
||||||
vlan_dict["vlan-id"] = str(vlan_bind.vlan_id)
|
vlan_dict["vlan-id"] = str(vlan_bind.vlan_id)
|
||||||
vlan_dict["vlan-name"] = vlan_bind.vlan_name
|
vlan_dict["vlan-name"] = vlan_bind.vlan_name
|
||||||
@ -395,7 +397,7 @@ class L2networkDB(object):
|
|||||||
try:
|
try:
|
||||||
for pp_bind in l2network_db.get_all_pp_bindings():
|
for pp_bind in l2network_db.get_all_pp_bindings():
|
||||||
LOG.debug("Getting port profile binding: %s" %
|
LOG.debug("Getting port profile binding: %s" %
|
||||||
pp_bind.portprofile_id)
|
pp_bind.portprofile_id)
|
||||||
ppbinding_dict = {}
|
ppbinding_dict = {}
|
||||||
ppbinding_dict["portprofile-id"] = str(pp_bind.portprofile_id)
|
ppbinding_dict["portprofile-id"] = str(pp_bind.portprofile_id)
|
||||||
ppbinding_dict["port-id"] = str(pp_bind.port_id)
|
ppbinding_dict["port-id"] = str(pp_bind.port_id)
|
||||||
@ -412,7 +414,7 @@ class L2networkDB(object):
|
|||||||
try:
|
try:
|
||||||
for pp_bind in l2network_db.get_pp_binding(tenant_id, pp_id):
|
for pp_bind in l2network_db.get_pp_binding(tenant_id, pp_id):
|
||||||
LOG.debug("Getting port profile binding: %s" %
|
LOG.debug("Getting port profile binding: %s" %
|
||||||
pp_bind.portprofile_id)
|
pp_bind.portprofile_id)
|
||||||
ppbinding_dict = {}
|
ppbinding_dict = {}
|
||||||
ppbinding_dict["portprofile-id"] = str(pp_bind.portprofile_id)
|
ppbinding_dict["portprofile-id"] = str(pp_bind.portprofile_id)
|
||||||
ppbinding_dict["port-id"] = str(pp_bind.port_id)
|
ppbinding_dict["port-id"] = str(pp_bind.port_id)
|
||||||
@ -428,7 +430,7 @@ class L2networkDB(object):
|
|||||||
ppbinding_dict = {}
|
ppbinding_dict = {}
|
||||||
try:
|
try:
|
||||||
res = l2network_db.add_pp_binding(tenant_id, port_id, pp_id,
|
res = l2network_db.add_pp_binding(tenant_id, port_id, pp_id,
|
||||||
default)
|
default)
|
||||||
LOG.debug("Created port profile binding: %s" % res.portprofile_id)
|
LOG.debug("Created port profile binding: %s" % res.portprofile_id)
|
||||||
ppbinding_dict["portprofile-id"] = str(res.portprofile_id)
|
ppbinding_dict["portprofile-id"] = str(res.portprofile_id)
|
||||||
ppbinding_dict["port-id"] = str(res.port_id)
|
ppbinding_dict["port-id"] = str(res.port_id)
|
||||||
@ -453,8 +455,8 @@ class L2networkDB(object):
|
|||||||
port_id, default):
|
port_id, default):
|
||||||
"""Update portprofile binding"""
|
"""Update portprofile binding"""
|
||||||
try:
|
try:
|
||||||
res = l2network_db.update_pp_binding(tenant_id, pp_id,
|
res = l2network_db.update_pp_binding(
|
||||||
newtenant_id, port_id, default)
|
tenant_id, pp_id, newtenant_id, port_id, default)
|
||||||
LOG.debug("Updating port profile binding: %s" % res.portprofile_id)
|
LOG.debug("Updating port profile binding: %s" % res.portprofile_id)
|
||||||
ppbinding_dict = {}
|
ppbinding_dict = {}
|
||||||
ppbinding_dict["portprofile-id"] = str(res.portprofile_id)
|
ppbinding_dict["portprofile-id"] = str(res.portprofile_id)
|
||||||
@ -653,8 +655,8 @@ class UcsDBTest(unittest.TestCase):
|
|||||||
"""create port binding"""
|
"""create port binding"""
|
||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
port1 = self.quantum.create_port(net1["net-id"])
|
port1 = self.quantum.create_port(net1["net-id"])
|
||||||
port_bind1 = self.dbtest.create_port_binding(port1["port-id"],
|
port_bind1 = self.dbtest.create_port_binding(
|
||||||
"vnic1", "pp1", "vlan1", 10, "qos1")
|
port1["port-id"], "vnic1", "pp1", "vlan1", 10, "qos1")
|
||||||
self.assertTrue(port_bind1["port-id"] == port1["port-id"])
|
self.assertTrue(port_bind1["port-id"] == port1["port-id"])
|
||||||
self.teardown_portbinding()
|
self.teardown_portbinding()
|
||||||
self.teardown_network_port()
|
self.teardown_network_port()
|
||||||
@ -664,10 +666,10 @@ class UcsDBTest(unittest.TestCase):
|
|||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
port1 = self.quantum.create_port(net1["net-id"])
|
port1 = self.quantum.create_port(net1["net-id"])
|
||||||
port2 = self.quantum.create_port(net1["net-id"])
|
port2 = self.quantum.create_port(net1["net-id"])
|
||||||
port_bind1 = self.dbtest.create_port_binding(port1["port-id"],
|
port_bind1 = self.dbtest.create_port_binding(
|
||||||
"vnic1", "pp1", "vlan1", 10, "qos1")
|
port1["port-id"], "vnic1", "pp1", "vlan1", 10, "qos1")
|
||||||
port_bind2 = self.dbtest.create_port_binding(port2["port-id"],
|
port_bind2 = self.dbtest.create_port_binding(
|
||||||
"vnic2", "pp2", "vlan2", 20, "qos2")
|
port2["port-id"], "vnic2", "pp2", "vlan2", 20, "qos2")
|
||||||
port_bindings = self.dbtest.get_all_port_bindings()
|
port_bindings = self.dbtest.get_all_port_bindings()
|
||||||
count = 0
|
count = 0
|
||||||
for pbind in port_bindings:
|
for pbind in port_bindings:
|
||||||
@ -681,8 +683,8 @@ class UcsDBTest(unittest.TestCase):
|
|||||||
"""delete port binding"""
|
"""delete port binding"""
|
||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
port1 = self.quantum.create_port(net1["net-id"])
|
port1 = self.quantum.create_port(net1["net-id"])
|
||||||
port_bind1 = self.dbtest.create_port_binding(port1["port-id"],
|
port_bind1 = self.dbtest.create_port_binding(
|
||||||
"vnic1", "pp1", "vlan1", 10, "qos1")
|
port1["port-id"], "vnic1", "pp1", "vlan1", 10, "qos1")
|
||||||
self.dbtest.delete_port_binding(port1["port-id"])
|
self.dbtest.delete_port_binding(port1["port-id"])
|
||||||
port_bindings = self.dbtest.get_all_port_bindings()
|
port_bindings = self.dbtest.get_all_port_bindings()
|
||||||
count = 0
|
count = 0
|
||||||
@ -697,10 +699,10 @@ class UcsDBTest(unittest.TestCase):
|
|||||||
"""update port binding"""
|
"""update port binding"""
|
||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
port1 = self.quantum.create_port(net1["net-id"])
|
port1 = self.quantum.create_port(net1["net-id"])
|
||||||
port_bind1 = self.dbtest.create_port_binding(port1["port-id"],
|
port_bind1 = self.dbtest.create_port_binding(
|
||||||
"vnic1", "pp1", "vlan1", 10, "qos1")
|
port1["port-id"], "vnic1", "pp1", "vlan1", 10, "qos1")
|
||||||
port_bind1 = self.dbtest.update_port_binding(port1["port-id"],
|
port_bind1 = self.dbtest.update_port_binding(
|
||||||
"vnic1", "newpp1", "newvlan1", 11, "newqos1")
|
port1["port-id"], "vnic1", "newpp1", "newvlan1", 11, "newqos1")
|
||||||
port_bindings = self.dbtest.get_all_port_bindings()
|
port_bindings = self.dbtest.get_all_port_bindings()
|
||||||
count = 0
|
count = 0
|
||||||
for pbind in port_bindings:
|
for pbind in port_bindings:
|
||||||
@ -776,8 +778,8 @@ class NexusDBTest(unittest.TestCase):
|
|||||||
def testd_update_nexusportbinding(self):
|
def testd_update_nexusportbinding(self):
|
||||||
"""update nexus port binding"""
|
"""update nexus port binding"""
|
||||||
binding1 = self.dbtest.create_nexusportbinding("port1", 10)
|
binding1 = self.dbtest.create_nexusportbinding("port1", 10)
|
||||||
binding1 = self.dbtest.update_nexusport_binding(binding1["port-id"], \
|
binding1 = self.dbtest.update_nexusport_binding(binding1["port-id"],
|
||||||
20)
|
20)
|
||||||
bindings = self.dbtest.get_all_nexusportbindings()
|
bindings = self.dbtest.get_all_nexusportbindings()
|
||||||
count = 0
|
count = 0
|
||||||
for bind in bindings:
|
for bind in bindings:
|
||||||
@ -809,15 +811,15 @@ class ServicesDBTest(unittest.TestCase):
|
|||||||
|
|
||||||
def testa_create_servicebinding(self):
|
def testa_create_servicebinding(self):
|
||||||
"""create service binding"""
|
"""create service binding"""
|
||||||
service_id = self.dbtest.create_servicebinding("i-00001", \
|
service_id = self.dbtest.create_servicebinding(
|
||||||
"mng_net", "northb_net", "northb_net")
|
"i-00001", "mng_net", "northb_net", "northb_net")
|
||||||
self.assertTrue(service_id["service_id"] == "i-00001")
|
self.assertTrue(service_id["service_id"] == "i-00001")
|
||||||
self.tearDown_servicebinding()
|
self.tearDown_servicebinding()
|
||||||
|
|
||||||
def testb_get_servicesbindings(self):
|
def testb_get_servicesbindings(self):
|
||||||
"""get all services binding"""
|
"""get all services binding"""
|
||||||
service_id = self.dbtest.create_servicebinding("i-00001", \
|
service_id = self.dbtest.create_servicebinding(
|
||||||
"mng_net", "northb_net", "northb_net")
|
"i-00001", "mng_net", "northb_net", "northb_net")
|
||||||
bindings = self.dbtest.get_servicebindings("i-00001")
|
bindings = self.dbtest.get_servicebindings("i-00001")
|
||||||
count = 0
|
count = 0
|
||||||
if bindings:
|
if bindings:
|
||||||
@ -827,10 +829,10 @@ class ServicesDBTest(unittest.TestCase):
|
|||||||
|
|
||||||
def testb_getall_servicesbindings(self):
|
def testb_getall_servicesbindings(self):
|
||||||
"""get all services binding"""
|
"""get all services binding"""
|
||||||
service_id = self.dbtest.create_servicebinding("i-00001", \
|
service_id = self.dbtest.create_servicebinding(
|
||||||
"mng_net", "northb_net", "northb_net")
|
"i-00001", "mng_net", "northb_net", "northb_net")
|
||||||
service_id = self.dbtest.create_servicebinding("i-00002", \
|
service_id = self.dbtest.create_servicebinding(
|
||||||
"mng_net", "northb_net", "northb_net")
|
"i-00002", "mng_net", "northb_net", "northb_net")
|
||||||
bindings = self.dbtest.get_all_servicesbindings()
|
bindings = self.dbtest.get_all_servicesbindings()
|
||||||
count = 0
|
count = 0
|
||||||
for bind in bindings:
|
for bind in bindings:
|
||||||
@ -841,8 +843,8 @@ class ServicesDBTest(unittest.TestCase):
|
|||||||
|
|
||||||
def testc_delete_servicesbinding(self):
|
def testc_delete_servicesbinding(self):
|
||||||
"""delete services binding"""
|
"""delete services binding"""
|
||||||
binding_serv = self.dbtest.create_servicebinding("i-00001", \
|
binding_serv = self.dbtest.create_servicebinding(
|
||||||
"mng_net", "northb_net", "northb_net")
|
"i-00001", "mng_net", "northb_net", "northb_net")
|
||||||
self.dbtest.delete_servicebinding("i-00001")
|
self.dbtest.delete_servicebinding("i-00001")
|
||||||
bindings = self.dbtest.get_all_servicesbindings()
|
bindings = self.dbtest.get_all_servicesbindings()
|
||||||
count = 0
|
count = 0
|
||||||
@ -967,8 +969,8 @@ class L2networkDBTest(unittest.TestCase):
|
|||||||
"""test update portprofile"""
|
"""test update portprofile"""
|
||||||
pp1 = self.dbtest.create_portprofile("t1", "portprofile1", 10, "qos1")
|
pp1 = self.dbtest.create_portprofile("t1", "portprofile1", 10, "qos1")
|
||||||
self.assertTrue(pp1["portprofile-name"] == "portprofile1")
|
self.assertTrue(pp1["portprofile-name"] == "portprofile1")
|
||||||
pp1 = self.dbtest.update_portprofile("t1", pp1["portprofile-id"], \
|
pp1 = self.dbtest.update_portprofile("t1", pp1["portprofile-id"],
|
||||||
"newportprofile1", 20, "qos2")
|
"newportprofile1", 20, "qos2")
|
||||||
pps = self.dbtest.get_all_portprofiles()
|
pps = self.dbtest.get_all_portprofiles()
|
||||||
count = 0
|
count = 0
|
||||||
for pprofile in pps:
|
for pprofile in pps:
|
||||||
@ -982,8 +984,8 @@ class L2networkDBTest(unittest.TestCase):
|
|||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
port1 = self.quantum.create_port(net1["net-id"])
|
port1 = self.quantum.create_port(net1["net-id"])
|
||||||
pp1 = self.dbtest.create_portprofile("t1", "portprofile1", 10, "qos1")
|
pp1 = self.dbtest.create_portprofile("t1", "portprofile1", 10, "qos1")
|
||||||
pp_binding1 = self.dbtest.create_pp_binding("t1", port1["port-id"], \
|
pp_binding1 = self.dbtest.create_pp_binding("t1", port1["port-id"],
|
||||||
pp1["portprofile-id"], "0")
|
pp1["portprofile-id"], "0")
|
||||||
self.assertTrue(pp_binding1["tenant-id"] == "t1")
|
self.assertTrue(pp_binding1["tenant-id"] == "t1")
|
||||||
self.teardown_portprofilebinding()
|
self.teardown_portprofilebinding()
|
||||||
self.teardown_port()
|
self.teardown_port()
|
||||||
@ -997,11 +999,11 @@ class L2networkDBTest(unittest.TestCase):
|
|||||||
port2 = self.quantum.create_port(net1["net-id"])
|
port2 = self.quantum.create_port(net1["net-id"])
|
||||||
pp1 = self.dbtest.create_portprofile("t1", "portprofile1", 10, "qos1")
|
pp1 = self.dbtest.create_portprofile("t1", "portprofile1", 10, "qos1")
|
||||||
pp2 = self.dbtest.create_portprofile("t1", "portprofile2", 20, "qos2")
|
pp2 = self.dbtest.create_portprofile("t1", "portprofile2", 20, "qos2")
|
||||||
pp_binding1 = self.dbtest.create_pp_binding("t1", port1["port-id"], \
|
pp_binding1 = self.dbtest.create_pp_binding("t1", port1["port-id"],
|
||||||
pp1["portprofile-id"], "0")
|
pp1["portprofile-id"], "0")
|
||||||
self.assertTrue(pp_binding1["tenant-id"] == "t1")
|
self.assertTrue(pp_binding1["tenant-id"] == "t1")
|
||||||
pp_binding2 = self.dbtest.create_pp_binding("t1", port2["port-id"], \
|
pp_binding2 = self.dbtest.create_pp_binding("t1", port2["port-id"],
|
||||||
pp2["portprofile-id"], "0")
|
pp2["portprofile-id"], "0")
|
||||||
self.assertTrue(pp_binding2["tenant-id"] == "t1")
|
self.assertTrue(pp_binding2["tenant-id"] == "t1")
|
||||||
pp_bindings = self.dbtest.get_all_pp_bindings()
|
pp_bindings = self.dbtest.get_all_pp_bindings()
|
||||||
count = 0
|
count = 0
|
||||||
@ -1019,10 +1021,10 @@ class L2networkDBTest(unittest.TestCase):
|
|||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
port1 = self.quantum.create_port(net1["net-id"])
|
port1 = self.quantum.create_port(net1["net-id"])
|
||||||
pp1 = self.dbtest.create_portprofile("t1", "portprofile1", 10, "qos1")
|
pp1 = self.dbtest.create_portprofile("t1", "portprofile1", 10, "qos1")
|
||||||
pp_binding1 = self.dbtest.create_pp_binding("t1", port1["port-id"], \
|
pp_binding1 = self.dbtest.create_pp_binding("t1", port1["port-id"],
|
||||||
pp1["portprofile-id"], "0")
|
pp1["portprofile-id"], "0")
|
||||||
self.assertTrue(pp_binding1["tenant-id"] == "t1")
|
self.assertTrue(pp_binding1["tenant-id"] == "t1")
|
||||||
self.dbtest.delete_pp_binding("t1", port1["port-id"], \
|
self.dbtest.delete_pp_binding("t1", port1["port-id"],
|
||||||
pp_binding1["portprofile-id"])
|
pp_binding1["portprofile-id"])
|
||||||
pp_bindings = self.dbtest.get_all_pp_bindings()
|
pp_bindings = self.dbtest.get_all_pp_bindings()
|
||||||
count = 0
|
count = 0
|
||||||
@ -1040,11 +1042,11 @@ class L2networkDBTest(unittest.TestCase):
|
|||||||
net1 = self.quantum.create_network("t1", "netid1")
|
net1 = self.quantum.create_network("t1", "netid1")
|
||||||
port1 = self.quantum.create_port(net1["net-id"])
|
port1 = self.quantum.create_port(net1["net-id"])
|
||||||
pp1 = self.dbtest.create_portprofile("t1", "portprofile1", 10, "qos1")
|
pp1 = self.dbtest.create_portprofile("t1", "portprofile1", 10, "qos1")
|
||||||
pp_binding1 = self.dbtest.create_pp_binding("t1", port1["port-id"], \
|
pp_binding1 = self.dbtest.create_pp_binding("t1", port1["port-id"],
|
||||||
pp1["portprofile-id"], "0")
|
pp1["portprofile-id"], "0")
|
||||||
self.assertTrue(pp_binding1["tenant-id"] == "t1")
|
self.assertTrue(pp_binding1["tenant-id"] == "t1")
|
||||||
pp_binding1 = self.dbtest.update_pp_binding("t1", \
|
pp_binding1 = self.dbtest.update_pp_binding(
|
||||||
pp1["portprofile-id"], "newt1", port1["port-id"], "1")
|
"t1", pp1["portprofile-id"], "newt1", port1["port-id"], "1")
|
||||||
pp_bindings = self.dbtest.get_all_pp_bindings()
|
pp_bindings = self.dbtest.get_all_pp_bindings()
|
||||||
count = 0
|
count = 0
|
||||||
for pp_bind in pp_bindings:
|
for pp_bind in pp_bindings:
|
||||||
@ -1246,26 +1248,3 @@ class QuantumDBTest(unittest.TestCase):
|
|||||||
for port in ports:
|
for port in ports:
|
||||||
self.dbtest.delete_port(port["net-id"], port["port-id"])
|
self.dbtest.delete_port(port["net-id"], port["port-id"])
|
||||||
self.dbtest.delete_network(netid)
|
self.dbtest.delete_network(netid)
|
||||||
|
|
||||||
"""
|
|
||||||
if __name__ == "__main__":
|
|
||||||
usagestr = "Usage: %prog [OPTIONS] <command> [args]"
|
|
||||||
parser = OptionParser(usage=usagestr)
|
|
||||||
parser.add_option("-v", "--verbose", dest="verbose",
|
|
||||||
action="store_true", default=False, help="turn on verbose logging")
|
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
|
||||||
|
|
||||||
if options.verbose:
|
|
||||||
LOG.basicConfig(level=LOG.DEBUG)
|
|
||||||
else:
|
|
||||||
LOG.basicConfig(level=LOG.WARN)
|
|
||||||
|
|
||||||
l2network_db.initialize()
|
|
||||||
|
|
||||||
# Run the tests
|
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(QuantumDBTest)
|
|
||||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(L2networkDBTest)
|
|
||||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
|
||||||
"""
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
||||||
@ -27,6 +28,7 @@ from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
|||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum.tests.test_core_api_func')
|
LOG = logging.getLogger('quantum.tests.test_core_api_func')
|
||||||
|
|
||||||
|
|
||||||
@ -48,7 +50,7 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
network_name = self.network_name
|
network_name = self.network_name
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, network_name)
|
tenant_id, network_name)
|
||||||
net = db.network_get(new_net_dict[const.NET_ID])
|
net = db.network_get(new_net_dict[const.NET_ID])
|
||||||
self.assertEqual(net[const.NETWORKNAME], network_name)
|
self.assertEqual(net[const.NETWORKNAME], network_name)
|
||||||
self.assertEqual(new_net_dict[const.NET_NAME], network_name)
|
self.assertEqual(new_net_dict[const.NET_NAME], network_name)
|
||||||
@ -65,13 +67,13 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
tenant_id = self.tenant_id
|
tenant_id = self.tenant_id
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
delete_net_dict = self._l2network_plugin.delete_network(
|
delete_net_dict = self._l2network_plugin.delete_network(
|
||||||
tenant_id, new_net_dict[const.NET_ID])
|
tenant_id, new_net_dict[const.NET_ID])
|
||||||
self.assertRaises(exc.NetworkNotFound, db.network_get,
|
self.assertRaises(exc.NetworkNotFound, db.network_get,
|
||||||
new_net_dict[const.NET_ID])
|
new_net_dict[const.NET_ID])
|
||||||
self.assertEqual(
|
self.assertEqual(new_net_dict[const.NET_ID],
|
||||||
new_net_dict[const.NET_ID], delete_net_dict[const.NET_ID])
|
delete_net_dict[const.NET_ID])
|
||||||
LOG.debug("test_delete_network - END")
|
LOG.debug("test_delete_network - END")
|
||||||
|
|
||||||
def test_delete_networkDNE(self, net_tenant_id=None, net_id='0005'):
|
def test_delete_networkDNE(self, net_tenant_id=None, net_id='0005'):
|
||||||
@ -99,9 +101,9 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
LOG.debug("test_delete_networkInUse - START")
|
LOG.debug("test_delete_networkInUse - START")
|
||||||
|
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID], self.state)
|
tenant_id, new_net_dict[const.NET_ID], self.state)
|
||||||
instance_desc = {'project_id': tenant_id,
|
instance_desc = {'project_id': tenant_id,
|
||||||
'user_id': nova_user_id}
|
'user_id': nova_user_id}
|
||||||
host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
|
host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
|
||||||
@ -111,15 +113,15 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
'user_id': nova_user_id,
|
'user_id': nova_user_id,
|
||||||
'vif_id': vif_id}
|
'vif_id': vif_id}
|
||||||
vif_description = self._l2network_plugin.associate_port(
|
vif_description = self._l2network_plugin.associate_port(
|
||||||
instance_tenant_id, instance_id,
|
instance_tenant_id, instance_id,
|
||||||
instance_vif_desc)
|
instance_vif_desc)
|
||||||
|
|
||||||
self.assertRaises(exc.NetworkInUse,
|
self.assertRaises(exc.NetworkInUse,
|
||||||
self._l2network_plugin.delete_network, tenant_id,
|
self._l2network_plugin.delete_network, tenant_id,
|
||||||
new_net_dict[const.NET_ID])
|
new_net_dict[const.NET_ID])
|
||||||
self.tearDownNetworkPortInterface(
|
self.tearDownNetworkPortInterface(
|
||||||
tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
|
tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
|
||||||
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
||||||
LOG.debug("test_delete_networkInUse - END")
|
LOG.debug("test_delete_networkInUse - END")
|
||||||
|
|
||||||
def test_show_network(self, net_tenant_id=None):
|
def test_show_network(self, net_tenant_id=None):
|
||||||
@ -133,13 +135,13 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
tenant_id = self.tenant_id
|
tenant_id = self.tenant_id
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
result_net_dict = self._l2network_plugin.get_network_details(
|
result_net_dict = self._l2network_plugin.get_network_details(
|
||||||
tenant_id, new_net_dict[const.NET_ID])
|
tenant_id, new_net_dict[const.NET_ID])
|
||||||
net = db.network_get(new_net_dict[const.NET_ID])
|
net = db.network_get(new_net_dict[const.NET_ID])
|
||||||
self.assertEqual(net[const.UUID], new_net_dict[const.NET_ID])
|
self.assertEqual(net[const.UUID], new_net_dict[const.NET_ID])
|
||||||
self.assertEqual(
|
self.assertEqual(new_net_dict[const.NET_ID],
|
||||||
new_net_dict[const.NET_ID], result_net_dict[const.NET_ID])
|
result_net_dict[const.NET_ID])
|
||||||
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
||||||
LOG.debug("test_show_network - END")
|
LOG.debug("test_show_network - END")
|
||||||
|
|
||||||
@ -170,10 +172,10 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
tenant_id = self.tenant_id
|
tenant_id = self.tenant_id
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
rename_net_dict = self._l2network_plugin.update_network(
|
rename_net_dict = self._l2network_plugin.update_network(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
name=new_name)
|
name=new_name)
|
||||||
net = db.network_get(new_net_dict[const.NET_ID])
|
net = db.network_get(new_net_dict[const.NET_ID])
|
||||||
self.assertEqual(net[const.NETWORKNAME], new_name)
|
self.assertEqual(net[const.NETWORKNAME], new_name)
|
||||||
self.assertEqual(new_name, rename_net_dict[const.NET_NAME])
|
self.assertEqual(new_name, rename_net_dict[const.NET_NAME])
|
||||||
@ -203,9 +205,9 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_list_networks - START")
|
LOG.debug("test_list_networks - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
new_net_dict2 = self._l2network_plugin.create_network(
|
new_net_dict2 = self._l2network_plugin.create_network(
|
||||||
tenant_id, 'test_net2')
|
tenant_id, 'test_net2')
|
||||||
net_list = self._l2network_plugin.get_all_networks(tenant_id)
|
net_list = self._l2network_plugin.get_all_networks(tenant_id)
|
||||||
net_temp_list = [new_net_dict, new_net_dict2]
|
net_temp_list = [new_net_dict, new_net_dict2]
|
||||||
networks_list = db.network_list(tenant_id)
|
networks_list = db.network_list(tenant_id)
|
||||||
@ -231,15 +233,15 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_list_ports - START")
|
LOG.debug("test_list_ports - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
self.state)
|
self.state)
|
||||||
port_dict2 = self._l2network_plugin.create_port(
|
port_dict2 = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
self.state)
|
self.state)
|
||||||
port_list = self._l2network_plugin.get_all_ports(
|
port_list = self._l2network_plugin.get_all_ports(
|
||||||
tenant_id, new_net_dict[const.NET_ID])
|
tenant_id, new_net_dict[const.NET_ID])
|
||||||
port_temp_list = [port_dict, port_dict2]
|
port_temp_list = [port_dict, port_dict2]
|
||||||
network = db.network_get(new_net_dict[const.NET_ID])
|
network = db.network_get(new_net_dict[const.NET_ID])
|
||||||
ports_list = network[const.NETWORKPORTS]
|
ports_list = network[const.NETWORKPORTS]
|
||||||
@ -270,9 +272,9 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_create_port - START")
|
LOG.debug("test_create_port - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID], state)
|
tenant_id, new_net_dict[const.NET_ID], state)
|
||||||
port = db.port_get(new_net_dict[const.NET_ID],
|
port = db.port_get(new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
self.assertEqual(port_dict[const.PORT_STATE], state)
|
self.assertEqual(port_dict[const.PORT_STATE], state)
|
||||||
@ -308,13 +310,13 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_delete_port - START")
|
LOG.debug("test_delete_port - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
state)
|
state)
|
||||||
delete_port_dict = self._l2network_plugin.delete_port(
|
delete_port_dict = self._l2network_plugin.delete_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
self.assertRaises(exc.PortNotFound, db.port_get,
|
self.assertRaises(exc.PortNotFound, db.port_get,
|
||||||
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
||||||
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
||||||
@ -330,7 +332,7 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_delete_port_networkDNE - START")
|
LOG.debug("test_delete_port_networkDNE - START")
|
||||||
self.assertRaises(exc.NetworkNotFound,
|
self.assertRaises(exc.NetworkNotFound,
|
||||||
self._l2network_plugin.delete_port, tenant_id,
|
self._l2network_plugin.delete_port, tenant_id,
|
||||||
net_id, port_id)
|
net_id, port_id)
|
||||||
LOG.debug("test_delete_port_networkDNE - END")
|
LOG.debug("test_delete_port_networkDNE - END")
|
||||||
|
|
||||||
@ -341,26 +343,28 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_delete_portDNE - START")
|
LOG.debug("test_delete_portDNE - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
self.assertRaises(exc.PortNotFound, self._l2network_plugin.delete_port,
|
self.assertRaises(exc.PortNotFound, self._l2network_plugin.delete_port,
|
||||||
tenant_id, new_net_dict[const.NET_ID], port_id)
|
tenant_id, new_net_dict[const.NET_ID], port_id)
|
||||||
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
||||||
LOG.debug("test_delete_portDNE - END")
|
LOG.debug("test_delete_portDNE - END")
|
||||||
|
|
||||||
def test_delete_portInUse(
|
def test_delete_portInUse(self,
|
||||||
self, tenant_id='test_tenant', instance_tenant_id='nova',
|
tenant_id='test_tenant',
|
||||||
nova_user_id='novaadmin', instance_id=10,
|
instance_tenant_id='nova',
|
||||||
vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
nova_user_id='novaadmin',
|
||||||
|
instance_id=10,
|
||||||
|
vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
||||||
"""
|
"""
|
||||||
Tests deletion of Ports when port is in Use.
|
Tests deletion of Ports when port is in Use.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
LOG.debug("test_delete_portInUse - START")
|
LOG.debug("test_delete_portInUse - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
self.state)
|
self.state)
|
||||||
instance_desc = {'project_id': tenant_id,
|
instance_desc = {'project_id': tenant_id,
|
||||||
'user_id': nova_user_id}
|
'user_id': nova_user_id}
|
||||||
host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
|
host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
|
||||||
@ -370,14 +374,14 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
'user_id': nova_user_id,
|
'user_id': nova_user_id,
|
||||||
'vif_id': vif_id}
|
'vif_id': vif_id}
|
||||||
vif_description = self._l2network_plugin.associate_port(
|
vif_description = self._l2network_plugin.associate_port(
|
||||||
instance_tenant_id, instance_id,
|
instance_tenant_id, instance_id,
|
||||||
instance_vif_desc)
|
instance_vif_desc)
|
||||||
self.assertRaises(exc.PortInUse,
|
self.assertRaises(exc.PortInUse,
|
||||||
self._l2network_plugin.delete_port, tenant_id,
|
self._l2network_plugin.delete_port, tenant_id,
|
||||||
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
||||||
self.tearDownNetworkPortInterface(
|
self.tearDownNetworkPortInterface(
|
||||||
tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
|
tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
|
||||||
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
||||||
LOG.debug("test_delete_portInUse - END")
|
LOG.debug("test_delete_portInUse - END")
|
||||||
|
|
||||||
def test_update_port(self, tenant_id='test_tenant',
|
def test_update_port(self, tenant_id='test_tenant',
|
||||||
@ -388,13 +392,13 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_update_port - START")
|
LOG.debug("test_update_port - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
self.state)
|
self.state)
|
||||||
update_port_dict = self._l2network_plugin.update_port(
|
update_port_dict = self._l2network_plugin.update_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID], state=state)
|
port_dict[const.PORT_ID], state=state)
|
||||||
new_port = db.port_get(new_net_dict[const.NET_ID],
|
new_port = db.port_get(new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
self.assertEqual(new_port[const.PORTSTATE], state)
|
self.assertEqual(new_port[const.PORTSTATE], state)
|
||||||
@ -422,7 +426,7 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_update_portDNE - START")
|
LOG.debug("test_update_portDNE - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.PortNotFound, self._l2network_plugin.update_port, tenant_id,
|
exc.PortNotFound, self._l2network_plugin.update_port, tenant_id,
|
||||||
new_net_dict[const.NET_ID], port_id, state=const.PORT_UP)
|
new_net_dict[const.NET_ID], port_id, state=const.PORT_UP)
|
||||||
@ -436,13 +440,13 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_show_port - START")
|
LOG.debug("test_show_port - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
self.state)
|
self.state)
|
||||||
get_port_dict = self._l2network_plugin.get_port_details(
|
get_port_dict = self._l2network_plugin.get_port_details(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
port = db.port_get(new_net_dict[const.NET_ID],
|
port = db.port_get(new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
self.assertEqual(port[const.PORTSTATE], self.state)
|
self.assertEqual(port[const.PORTSTATE], self.state)
|
||||||
@ -470,17 +474,19 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_show_portDNE - START")
|
LOG.debug("test_show_portDNE - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
self.assertRaises(exc.PortNotFound,
|
self.assertRaises(exc.PortNotFound,
|
||||||
self._l2network_plugin.get_port_details, tenant_id,
|
self._l2network_plugin.get_port_details, tenant_id,
|
||||||
new_net_dict[const.NET_ID], port_id)
|
new_net_dict[const.NET_ID], port_id)
|
||||||
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
||||||
LOG.debug("test_show_portDNE - END")
|
LOG.debug("test_show_portDNE - END")
|
||||||
|
|
||||||
def test_plug_interface(
|
def test_plug_interface(self,
|
||||||
self, tenant_id='test_tenant', instance_tenant_id='nova',
|
tenant_id='test_tenant',
|
||||||
nova_user_id='novaadmin', instance_id=10,
|
instance_tenant_id='nova',
|
||||||
vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
nova_user_id='novaadmin',
|
||||||
|
instance_id=10,
|
||||||
|
vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
||||||
"""
|
"""
|
||||||
Tests attachment of interface to the port
|
Tests attachment of interface to the port
|
||||||
"""
|
"""
|
||||||
@ -499,24 +505,26 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
'user_id': nova_user_id,
|
'user_id': nova_user_id,
|
||||||
'vif_id': vif_id}
|
'vif_id': vif_id}
|
||||||
vif_description = self._l2network_plugin.associate_port(
|
vif_description = self._l2network_plugin.associate_port(
|
||||||
instance_tenant_id, instance_id,
|
instance_tenant_id, instance_id,
|
||||||
instance_vif_desc)
|
instance_vif_desc)
|
||||||
|
|
||||||
self._l2network_plugin.plug_interface(
|
self._l2network_plugin.plug_interface(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID], vif_id)
|
port_dict[const.PORT_ID], vif_id)
|
||||||
port = db.port_get(new_net_dict[const.NET_ID],
|
port = db.port_get(new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
self.assertEqual(port[const.INTERFACEID], vif_id)
|
self.assertEqual(port[const.INTERFACEID], vif_id)
|
||||||
self.tearDownNetworkPortInterface(
|
self.tearDownNetworkPortInterface(
|
||||||
tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
|
tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
|
||||||
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
||||||
|
|
||||||
LOG.debug("test_plug_interface - END")
|
LOG.debug("test_plug_interface - END")
|
||||||
|
|
||||||
def test_plug_interface_networkDNE(
|
def test_plug_interface_networkDNE(self,
|
||||||
self, tenant_id='test_tenant', net_id='0005',
|
tenant_id='test_tenant',
|
||||||
port_id='p0005', remote_interface='new_interface'):
|
net_id='0005',
|
||||||
|
port_id='p0005',
|
||||||
|
remote_interface='new_interface'):
|
||||||
"""
|
"""
|
||||||
Tests attachment of interface network does not exist
|
Tests attachment of interface network does not exist
|
||||||
"""
|
"""
|
||||||
@ -535,8 +543,8 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
LOG.debug("test_plug_interface_portDNE - START")
|
LOG.debug("test_plug_interface_portDNE - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(tenant_id,
|
||||||
tenant_id, self.network_name)
|
self.network_name)
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exc.PortNotFound, self._l2network_plugin.plug_interface, tenant_id,
|
exc.PortNotFound, self._l2network_plugin.plug_interface, tenant_id,
|
||||||
new_net_dict[const.NET_ID], port_id, remote_interface)
|
new_net_dict[const.NET_ID], port_id, remote_interface)
|
||||||
@ -544,11 +552,10 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
LOG.debug("test_plug_interface_portDNE - END")
|
LOG.debug("test_plug_interface_portDNE - END")
|
||||||
|
|
||||||
def test_plug_interface_portInUse(
|
def test_plug_interface_portInUse(
|
||||||
self, tenant_id='test_tenant', instance_tenant_id='nova',
|
self, tenant_id='test_tenant', instance_tenant_id='nova',
|
||||||
nova_user_id='novaadmin', instance_id=10,
|
nova_user_id='novaadmin', instance_id=10,
|
||||||
vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
||||||
remote_interface='new_interface'):
|
remote_interface='new_interface'):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Tests attachment of new interface to the port when there is an
|
Tests attachment of new interface to the port when there is an
|
||||||
existing attachment
|
existing attachment
|
||||||
@ -556,9 +563,9 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_plug_interface_portInUse - START")
|
LOG.debug("test_plug_interface_portInUse - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID], self.state)
|
tenant_id, new_net_dict[const.NET_ID], self.state)
|
||||||
instance_desc = {'project_id': tenant_id,
|
instance_desc = {'project_id': tenant_id,
|
||||||
'user_id': nova_user_id}
|
'user_id': nova_user_id}
|
||||||
host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
|
host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
|
||||||
@ -568,34 +575,33 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
'user_id': nova_user_id,
|
'user_id': nova_user_id,
|
||||||
'vif_id': vif_id}
|
'vif_id': vif_id}
|
||||||
vif_description = self._l2network_plugin.associate_port(
|
vif_description = self._l2network_plugin.associate_port(
|
||||||
instance_tenant_id, instance_id,
|
instance_tenant_id, instance_id,
|
||||||
instance_vif_desc)
|
instance_vif_desc)
|
||||||
|
|
||||||
self.assertRaises(exc.PortInUse,
|
self.assertRaises(exc.PortInUse,
|
||||||
self._l2network_plugin.plug_interface, tenant_id,
|
self._l2network_plugin.plug_interface, tenant_id,
|
||||||
new_net_dict[const.NET_ID],
|
new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID], remote_interface)
|
port_dict[const.PORT_ID], remote_interface)
|
||||||
self.tearDownNetworkPortInterface(
|
self.tearDownNetworkPortInterface(
|
||||||
tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
|
tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
|
||||||
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
||||||
|
|
||||||
LOG.debug("test_plug_interface_portInUse - END")
|
LOG.debug("test_plug_interface_portInUse - END")
|
||||||
|
|
||||||
def test_unplug_interface(
|
def test_unplug_interface(
|
||||||
self, tenant_id='test_tenant', instance_tenant_id='nova',
|
self, tenant_id='test_tenant', instance_tenant_id='nova',
|
||||||
nova_user_id='novaadmin', instance_id=10,
|
nova_user_id='novaadmin', instance_id=10,
|
||||||
vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Tests detaachment of an interface to a port
|
Tests detaachment of an interface to a port
|
||||||
"""
|
"""
|
||||||
|
|
||||||
LOG.debug("test_unplug_interface - START")
|
LOG.debug("test_unplug_interface - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
self.state)
|
self.state)
|
||||||
instance_desc = {'project_id': tenant_id,
|
instance_desc = {'project_id': tenant_id,
|
||||||
'user_id': nova_user_id}
|
'user_id': nova_user_id}
|
||||||
host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
|
host_list = self._l2network_plugin.schedule_host(instance_tenant_id,
|
||||||
@ -605,22 +611,22 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
'user_id': nova_user_id,
|
'user_id': nova_user_id,
|
||||||
'vif_id': vif_id}
|
'vif_id': vif_id}
|
||||||
vif_description = self._l2network_plugin.associate_port(
|
vif_description = self._l2network_plugin.associate_port(
|
||||||
instance_tenant_id, instance_id,
|
instance_tenant_id, instance_id,
|
||||||
instance_vif_desc)
|
instance_vif_desc)
|
||||||
|
|
||||||
self._l2network_plugin.plug_interface(
|
self._l2network_plugin.plug_interface(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID], vif_id)
|
port_dict[const.PORT_ID], vif_id)
|
||||||
self._l2network_plugin.unplug_interface(
|
self._l2network_plugin.unplug_interface(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
port = db.port_get(new_net_dict[const.NET_ID],
|
port = db.port_get(new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
vif_id_unplugged = vif_id + '(detached)'
|
vif_id_unplugged = vif_id + '(detached)'
|
||||||
self.assertEqual(port[const.INTERFACEID], vif_id_unplugged)
|
self.assertEqual(port[const.INTERFACEID], vif_id_unplugged)
|
||||||
self.tearDownNetworkPortInterface(
|
self.tearDownNetworkPortInterface(
|
||||||
tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
|
tenant_id, instance_tenant_id, instance_id, instance_vif_desc,
|
||||||
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
new_net_dict[const.NET_ID], port_dict[const.PORT_ID])
|
||||||
|
|
||||||
LOG.debug("test_unplug_interface - END")
|
LOG.debug("test_unplug_interface - END")
|
||||||
|
|
||||||
@ -633,7 +639,7 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_unplug_interface_networkDNE - START")
|
LOG.debug("test_unplug_interface_networkDNE - START")
|
||||||
self.assertRaises(exc.NetworkNotFound,
|
self.assertRaises(exc.NetworkNotFound,
|
||||||
self._l2network_plugin.unplug_interface,
|
self._l2network_plugin.unplug_interface,
|
||||||
tenant_id, net_id, port_id)
|
tenant_id, net_id, port_id)
|
||||||
LOG.debug("test_unplug_interface_networkDNE - END")
|
LOG.debug("test_unplug_interface_networkDNE - END")
|
||||||
|
|
||||||
@ -646,10 +652,10 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_unplug_interface_portDNE - START")
|
LOG.debug("test_unplug_interface_portDNE - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(tenant_id,
|
new_net_dict = self._l2network_plugin.create_network(tenant_id,
|
||||||
self.network_name)
|
self.network_name)
|
||||||
self.assertRaises(exc.PortNotFound,
|
self.assertRaises(exc.PortNotFound,
|
||||||
self._l2network_plugin.unplug_interface, tenant_id,
|
self._l2network_plugin.unplug_interface, tenant_id,
|
||||||
new_net_dict[const.NET_ID], port_id)
|
new_net_dict[const.NET_ID], port_id)
|
||||||
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
||||||
LOG.debug("test_unplug_interface_portDNE - END")
|
LOG.debug("test_unplug_interface_portDNE - END")
|
||||||
|
|
||||||
@ -660,7 +666,7 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
LOG.debug("test_create_portprofile - tenant id: %s - START",
|
LOG.debug("test_create_portprofile - tenant id: %s - START",
|
||||||
net_tenant_id)
|
net_tenant_id)
|
||||||
if net_tenant_id:
|
if net_tenant_id:
|
||||||
tenant_id = net_tenant_id
|
tenant_id = net_tenant_id
|
||||||
else:
|
else:
|
||||||
@ -674,14 +680,14 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
qos = self.qos
|
qos = self.qos
|
||||||
port_profile_dict = self._l2network_plugin.create_portprofile(
|
port_profile_dict = self._l2network_plugin.create_portprofile(
|
||||||
tenant_id, profile_name, qos)
|
tenant_id, profile_name, qos)
|
||||||
port_profile_id = port_profile_dict['profile_id']
|
port_profile_id = port_profile_dict['profile_id']
|
||||||
port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
|
port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
|
||||||
self.assertEqual(port_profile[const.PPNAME], profile_name)
|
self.assertEqual(port_profile[const.PPNAME], profile_name)
|
||||||
self.assertEqual(port_profile[const.PPQOS], qos)
|
self.assertEqual(port_profile[const.PPQOS], qos)
|
||||||
self.tearDownPortProfile(tenant_id, port_profile_id)
|
self.tearDownPortProfile(tenant_id, port_profile_id)
|
||||||
LOG.debug("test_create_portprofile - tenant id: %s - END",
|
LOG.debug("test_create_portprofile - tenant id: %s - END",
|
||||||
net_tenant_id)
|
net_tenant_id)
|
||||||
|
|
||||||
def test_delete_portprofile(self, net_tenant_id=None):
|
def test_delete_portprofile(self, net_tenant_id=None):
|
||||||
"""
|
"""
|
||||||
@ -689,18 +695,18 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
LOG.debug("test_delete_portprofile - tenant id: %s - START",
|
LOG.debug("test_delete_portprofile - tenant id: %s - START",
|
||||||
net_tenant_id)
|
net_tenant_id)
|
||||||
if net_tenant_id:
|
if net_tenant_id:
|
||||||
tenant_id = net_tenant_id
|
tenant_id = net_tenant_id
|
||||||
else:
|
else:
|
||||||
tenant_id = self.tenant_id
|
tenant_id = self.tenant_id
|
||||||
port_profile_dict = self._l2network_plugin.create_portprofile(
|
port_profile_dict = self._l2network_plugin.create_portprofile(
|
||||||
tenant_id, self.profile_name, self.qos)
|
tenant_id, self.profile_name, self.qos)
|
||||||
port_profile_id = port_profile_dict['profile_id']
|
port_profile_id = port_profile_dict['profile_id']
|
||||||
self._l2network_plugin.delete_portprofile(tenant_id, port_profile_id)
|
self._l2network_plugin.delete_portprofile(tenant_id, port_profile_id)
|
||||||
self.assertRaises(Exception, cdb.get_portprofile, port_profile_id)
|
self.assertRaises(Exception, cdb.get_portprofile, port_profile_id)
|
||||||
LOG.debug("test_delete_portprofile - tenant id: %s - END",
|
LOG.debug("test_delete_portprofile - tenant id: %s - END",
|
||||||
net_tenant_id)
|
net_tenant_id)
|
||||||
|
|
||||||
def test_delete_portprofileDNE(self, tenant_id='test_tenant',
|
def test_delete_portprofileDNE(self, tenant_id='test_tenant',
|
||||||
profile_id='pr0005'):
|
profile_id='pr0005'):
|
||||||
@ -722,22 +728,22 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_delete_portprofileAssociated - START")
|
LOG.debug("test_delete_portprofileAssociated - START")
|
||||||
port_profile_dict = self._l2network_plugin.create_portprofile(
|
port_profile_dict = self._l2network_plugin.create_portprofile(
|
||||||
tenant_id, self.profile_name, self.qos)
|
tenant_id, self.profile_name, self.qos)
|
||||||
port_profile_id = port_profile_dict['profile_id']
|
port_profile_id = port_profile_dict['profile_id']
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, 'test_network')
|
tenant_id, 'test_network')
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
const.PORT_UP)
|
const.PORT_UP)
|
||||||
self._l2network_plugin.associate_portprofile(
|
self._l2network_plugin.associate_portprofile(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID], port_profile_id)
|
port_dict[const.PORT_ID], port_profile_id)
|
||||||
self.assertRaises(cexc.PortProfileInvalidDelete,
|
self.assertRaises(cexc.PortProfileInvalidDelete,
|
||||||
self._l2network_plugin.delete_portprofile,
|
self._l2network_plugin.delete_portprofile,
|
||||||
tenant_id, port_profile_id)
|
tenant_id, port_profile_id)
|
||||||
self.tearDownAssociatePortProfile(
|
self.tearDownAssociatePortProfile(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID], port_profile_id)
|
port_dict[const.PORT_ID], port_profile_id)
|
||||||
self.tearDownNetworkPort(tenant_id, new_net_dict[const.NET_ID],
|
self.tearDownNetworkPort(tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
LOG.debug("test_delete_portprofileAssociated - END")
|
LOG.debug("test_delete_portprofileAssociated - END")
|
||||||
@ -751,13 +757,13 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
profile_name2 = tenant_id + '_port_profile2'
|
profile_name2 = tenant_id + '_port_profile2'
|
||||||
qos2 = tenant_id + 'qos2'
|
qos2 = tenant_id + 'qos2'
|
||||||
port_profile_dict1 = self._l2network_plugin.create_portprofile(
|
port_profile_dict1 = self._l2network_plugin.create_portprofile(
|
||||||
tenant_id, self.profile_name, self.qos)
|
tenant_id, self.profile_name, self.qos)
|
||||||
port_profile_dict2 = self._l2network_plugin.create_portprofile(
|
port_profile_dict2 = self._l2network_plugin.create_portprofile(
|
||||||
tenant_id, profile_name2, qos2)
|
tenant_id, profile_name2, qos2)
|
||||||
port_profile_id1 = port_profile_dict1['profile_id']
|
port_profile_id1 = port_profile_dict1['profile_id']
|
||||||
port_profile_id2 = port_profile_dict2['profile_id']
|
port_profile_id2 = port_profile_dict2['profile_id']
|
||||||
list_all_portprofiles = self._l2network_plugin.get_all_portprofiles(
|
list_all_portprofiles = self._l2network_plugin.get_all_portprofiles(
|
||||||
tenant_id)
|
tenant_id)
|
||||||
port_profile_list = [port_profile_dict1, port_profile_dict2]
|
port_profile_list = [port_profile_dict1, port_profile_dict2]
|
||||||
pplist = cdb.get_all_portprofiles()
|
pplist = cdb.get_all_portprofiles()
|
||||||
new_pplist = []
|
new_pplist = []
|
||||||
@ -785,17 +791,17 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
tenant_id = self.tenant_id
|
tenant_id = self.tenant_id
|
||||||
port_profile_dict = self._l2network_plugin.create_portprofile(
|
port_profile_dict = self._l2network_plugin.create_portprofile(
|
||||||
tenant_id, self.profile_name, self.qos)
|
tenant_id, self.profile_name, self.qos)
|
||||||
port_profile_id = port_profile_dict['profile_id']
|
port_profile_id = port_profile_dict['profile_id']
|
||||||
result_port_profile = self._l2network_plugin.get_portprofile_details(
|
result_port_profile = self._l2network_plugin.get_portprofile_details(
|
||||||
tenant_id, port_profile_id)
|
tenant_id, port_profile_id)
|
||||||
port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
|
port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
|
||||||
self.assertEqual(port_profile[const.PPQOS], self.qos)
|
self.assertEqual(port_profile[const.PPQOS], self.qos)
|
||||||
self.assertEqual(port_profile[const.PPNAME], self.profile_name)
|
self.assertEqual(port_profile[const.PPNAME], self.profile_name)
|
||||||
self.assertEqual(result_port_profile[const.PROFILE_QOS],
|
self.assertEqual(result_port_profile[const.PROFILE_QOS],
|
||||||
self.qos)
|
self.qos)
|
||||||
self.assertEqual(result_port_profile[const.PROFILE_NAME],
|
self.assertEqual(result_port_profile[const.PROFILE_NAME],
|
||||||
self.profile_name)
|
self.profile_name)
|
||||||
self.tearDownPortProfile(tenant_id, port_profile_id)
|
self.tearDownPortProfile(tenant_id, port_profile_id)
|
||||||
LOG.debug("test_show_portprofile - tenant id: %s - END", net_tenant_id)
|
LOG.debug("test_show_portprofile - tenant id: %s - END", net_tenant_id)
|
||||||
|
|
||||||
@ -808,7 +814,7 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
LOG.debug("test_show_portprofileDNE - START")
|
LOG.debug("test_show_portprofileDNE - START")
|
||||||
self.assertRaises(Exception,
|
self.assertRaises(Exception,
|
||||||
self._l2network_plugin.get_portprofile_details,
|
self._l2network_plugin.get_portprofile_details,
|
||||||
tenant_id, profile_id)
|
tenant_id, profile_id)
|
||||||
LOG.debug("test_show_portprofileDNE - END")
|
LOG.debug("test_show_portprofileDNE - END")
|
||||||
|
|
||||||
def test_rename_portprofile(self, tenant_id='test_tenant',
|
def test_rename_portprofile(self, tenant_id='test_tenant',
|
||||||
@ -819,14 +825,14 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_rename_portprofile - START")
|
LOG.debug("test_rename_portprofile - START")
|
||||||
port_profile_dict = self._l2network_plugin.create_portprofile(
|
port_profile_dict = self._l2network_plugin.create_portprofile(
|
||||||
tenant_id, self.profile_name, self.qos)
|
tenant_id, self.profile_name, self.qos)
|
||||||
port_profile_id = port_profile_dict['profile_id']
|
port_profile_id = port_profile_dict['profile_id']
|
||||||
result_port_profile_dict = self._l2network_plugin.rename_portprofile(
|
result_port_profile_dict = self._l2network_plugin.rename_portprofile(
|
||||||
tenant_id, port_profile_id, new_profile_name)
|
tenant_id, port_profile_id, new_profile_name)
|
||||||
port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
|
port_profile = cdb.get_portprofile(tenant_id, port_profile_id)
|
||||||
self.assertEqual(port_profile[const.PPNAME], new_profile_name)
|
self.assertEqual(port_profile[const.PPNAME], new_profile_name)
|
||||||
self.assertEqual(result_port_profile_dict[const.PROFILE_NAME],
|
self.assertEqual(result_port_profile_dict[const.PROFILE_NAME],
|
||||||
new_profile_name)
|
new_profile_name)
|
||||||
self.tearDownPortProfile(tenant_id, port_profile_id)
|
self.tearDownPortProfile(tenant_id, port_profile_id)
|
||||||
LOG.debug("test_show_portprofile - tenant id: %s - END")
|
LOG.debug("test_show_portprofile - tenant id: %s - END")
|
||||||
|
|
||||||
@ -850,25 +856,24 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_associate_portprofile - START")
|
LOG.debug("test_associate_portprofile - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
self.state)
|
self.state)
|
||||||
port_profile_dict = self._l2network_plugin.create_portprofile(
|
port_profile_dict = self._l2network_plugin.create_portprofile(
|
||||||
tenant_id, self.profile_name, self.qos)
|
tenant_id, self.profile_name, self.qos)
|
||||||
port_profile_id = port_profile_dict['profile_id']
|
port_profile_id = port_profile_dict['profile_id']
|
||||||
self._l2network_plugin.associate_portprofile(
|
self._l2network_plugin.associate_portprofile(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID], port_profile_id)
|
port_dict[const.PORT_ID], port_profile_id)
|
||||||
port_profile_associate = cdb.get_pp_binding(tenant_id, port_profile_id)
|
port_profile_associate = cdb.get_pp_binding(tenant_id, port_profile_id)
|
||||||
self.assertEqual(port_profile_associate[const.PORTID],
|
self.assertEqual(port_profile_associate[const.PORTID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
self.tearDownAssociatePortProfile(
|
self.tearDownAssociatePortProfile(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID], port_profile_id)
|
port_dict[const.PORT_ID], port_profile_id)
|
||||||
self.tearDownNetworkPort(
|
self.tearDownNetworkPort(tenant_id, new_net_dict[const.NET_ID],
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
port_dict[const.PORT_ID])
|
||||||
port_dict[const.PORT_ID])
|
|
||||||
LOG.debug("test_associate_portprofile - END")
|
LOG.debug("test_associate_portprofile - END")
|
||||||
|
|
||||||
def test_associate_portprofileDNE(self, tenant_id='test_tenant',
|
def test_associate_portprofileDNE(self, tenant_id='test_tenant',
|
||||||
@ -892,25 +897,25 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_disassociate_portprofile - START")
|
LOG.debug("test_disassociate_portprofile - START")
|
||||||
new_net_dict = self._l2network_plugin.create_network(
|
new_net_dict = self._l2network_plugin.create_network(
|
||||||
tenant_id, self.network_name)
|
tenant_id, self.network_name)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
self.state)
|
self.state)
|
||||||
port_profile_dict = self._l2network_plugin.create_portprofile(
|
port_profile_dict = self._l2network_plugin.create_portprofile(
|
||||||
tenant_id, self.profile_name, self.qos)
|
tenant_id, self.profile_name, self.qos)
|
||||||
port_profile_id = port_profile_dict['profile_id']
|
port_profile_id = port_profile_dict['profile_id']
|
||||||
self._l2network_plugin.associate_portprofile(
|
self._l2network_plugin.associate_portprofile(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID], port_profile_id)
|
port_dict[const.PORT_ID], port_profile_id)
|
||||||
self._l2network_plugin.disassociate_portprofile(
|
self._l2network_plugin.disassociate_portprofile(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID], port_profile_id)
|
port_dict[const.PORT_ID], port_profile_id)
|
||||||
port_profile_associate = cdb.get_pp_binding(tenant_id, port_profile_id)
|
port_profile_associate = cdb.get_pp_binding(tenant_id, port_profile_id)
|
||||||
self.assertEqual(port_profile_associate, [])
|
self.assertEqual(port_profile_associate, [])
|
||||||
self.tearDownPortProfile(tenant_id, port_profile_id)
|
self.tearDownPortProfile(tenant_id, port_profile_id)
|
||||||
self.tearDownNetworkPort(
|
self.tearDownNetworkPort(
|
||||||
tenant_id, new_net_dict[const.NET_ID],
|
tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORT_ID])
|
port_dict[const.PORT_ID])
|
||||||
LOG.debug("test_disassociate_portprofile - END")
|
LOG.debug("test_disassociate_portprofile - END")
|
||||||
|
|
||||||
def test_disassociate_portprofileDNE(self, tenant_id='test_tenant',
|
def test_disassociate_portprofileDNE(self, tenant_id='test_tenant',
|
||||||
@ -1032,7 +1037,7 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
Tear down associate port profile
|
Tear down associate port profile
|
||||||
"""
|
"""
|
||||||
self._l2network_plugin.disassociate_portprofile(
|
self._l2network_plugin.disassociate_portprofile(
|
||||||
tenant_id, net_id, port_id, port_profile_id)
|
tenant_id, net_id, port_id, port_profile_id)
|
||||||
self.tearDownPortProfile(tenant_id, port_profile_id)
|
self.tearDownPortProfile(tenant_id, port_profile_id)
|
||||||
|
|
||||||
def _make_net_dict(self, net_id, net_name, ports):
|
def _make_net_dict(self, net_id, net_name, ports):
|
||||||
@ -1049,12 +1054,14 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
def _make_portprofile_dict(self, tenant_id, profile_id, profile_name,
|
def _make_portprofile_dict(self, tenant_id, profile_id, profile_name,
|
||||||
qos):
|
qos):
|
||||||
profile_associations = self._make_portprofile_assc_list(
|
profile_associations = self._make_portprofile_assc_list(
|
||||||
tenant_id, profile_id)
|
tenant_id, profile_id)
|
||||||
res = {const.PROFILE_ID: str(profile_id),
|
res = {
|
||||||
const.PROFILE_NAME: profile_name,
|
const.PROFILE_ID: str(profile_id),
|
||||||
const.PROFILE_ASSOCIATIONS: profile_associations,
|
const.PROFILE_NAME: profile_name,
|
||||||
const.PROFILE_VLAN_ID: None,
|
const.PROFILE_ASSOCIATIONS: profile_associations,
|
||||||
const.PROFILE_QOS: qos}
|
const.PROFILE_VLAN_ID: None,
|
||||||
|
const.PROFILE_QOS: qos,
|
||||||
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _make_portprofile_assc_list(self, tenant_id, profile_id):
|
def _make_portprofile_assc_list(self, tenant_id, profile_id):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -19,23 +18,22 @@
|
|||||||
# @author: Peter Strunk, Cisco Systems, Inc.
|
# @author: Peter Strunk, Cisco Systems, Inc.
|
||||||
# @author: Atul Gaikad, Cisco Systems, Inc.
|
# @author: Atul Gaikad, Cisco Systems, Inc.
|
||||||
# @author: Tyler Smith, Cisco Systems, Inc.
|
# @author: Tyler Smith, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
import logging
|
||||||
import unittest
|
import unittest
|
||||||
import logging as LOG
|
|
||||||
|
|
||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
from quantum.common import utils
|
from quantum.common import utils
|
||||||
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.common import cisco_credentials as creds
|
from quantum.plugins.cisco.common import cisco_credentials as creds
|
||||||
from quantum.plugins.cisco.models import l2network_multi_blade
|
|
||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
|
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
||||||
|
from quantum.plugins.cisco.models import l2network_multi_blade
|
||||||
|
|
||||||
LOG.basicConfig(level=LOG.WARN)
|
|
||||||
LOG.getLogger(__name__)
|
logging.basicConfig(level=logging.WARN)
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# Set some data to use in tests
|
# Set some data to use in tests
|
||||||
@ -72,10 +70,10 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
self.port_id = 0
|
self.port_id = 0
|
||||||
|
|
||||||
# Create the multiblade object
|
# Create the multiblade object
|
||||||
self._l2network_multiblade = l2network_multi_blade. \
|
self._l2network_multiblade = (
|
||||||
L2NetworkMultiBlade()
|
l2network_multi_blade.L2NetworkMultiBlade())
|
||||||
self.plugin_key = "quantum.plugins.cisco.ucs.cisco_ucs_plugin" + \
|
self.plugin_key = (
|
||||||
".UCSVICPlugin"
|
"quantum.plugins.cisco.ucs.cisco_ucs_plugin.UCSVICPlugin")
|
||||||
|
|
||||||
# Get UCS inventory to make sure all UCSs are affected by tests
|
# Get UCS inventory to make sure all UCSs are affected by tests
|
||||||
for key in conf.PLUGINS[const.PLUGINS].keys():
|
for key in conf.PLUGINS[const.PLUGINS].keys():
|
||||||
@ -83,15 +81,14 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
self._inventory[key] = utils.import_object(
|
self._inventory[key] = utils.import_object(
|
||||||
conf.PLUGINS[const.INVENTORY][key])
|
conf.PLUGINS[const.INVENTORY][key])
|
||||||
|
|
||||||
self.ucs_count = self._inventory['ucs_plugin'].\
|
self.ucs_count = self._inventory['ucs_plugin']._inventory.__len__()
|
||||||
_inventory.__len__()
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""Tear down our tests"""
|
"""Tear down our tests"""
|
||||||
try:
|
try:
|
||||||
port = db.port_get(self.net_id, self.port_id)
|
port = db.port_get(self.net_id, self.port_id)
|
||||||
self._l2network_multiblade.delete_port([tenant_id, self.net_id,
|
self._l2network_multiblade.delete_port([tenant_id, self.net_id,
|
||||||
self.port_id])
|
self.port_id])
|
||||||
except exc.NetworkNotFound:
|
except exc.NetworkNotFound:
|
||||||
# We won't always have a port to remove
|
# We won't always have a port to remove
|
||||||
pass
|
pass
|
||||||
@ -113,11 +110,13 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
|
|
||||||
# Create the network in the test DB, then with the model
|
# Create the network in the test DB, then with the model
|
||||||
self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
|
self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
|
||||||
networks = self._l2network_multiblade.create_network([tenant_id,
|
networks = self._l2network_multiblade.create_network([
|
||||||
net_name,
|
tenant_id,
|
||||||
self.net_id,
|
net_name,
|
||||||
vlan_name(self.net_id),
|
self.net_id,
|
||||||
vlan_id])
|
vlan_name(self.net_id),
|
||||||
|
vlan_id,
|
||||||
|
])
|
||||||
cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)
|
cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)
|
||||||
|
|
||||||
for network in networks:
|
for network in networks:
|
||||||
@ -140,7 +139,7 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)
|
cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)
|
||||||
|
|
||||||
networks = self._l2network_multiblade.delete_network([tenant_id,
|
networks = self._l2network_multiblade.delete_network([tenant_id,
|
||||||
self.net_id])
|
self.net_id])
|
||||||
cdb.remove_vlan_binding(self.net_id)
|
cdb.remove_vlan_binding(self.net_id)
|
||||||
db.network_destroy(self.net_id)
|
db.network_destroy(self.net_id)
|
||||||
for network in networks:
|
for network in networks:
|
||||||
@ -174,9 +173,11 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
|
|
||||||
net_details = db.network_update(self.net_id, tenant_id,
|
net_details = db.network_update(self.net_id, tenant_id,
|
||||||
name=new_net_name)
|
name=new_net_name)
|
||||||
networks = self._l2network_multiblade.update_network([tenant_id,
|
networks = self._l2network_multiblade.update_network([
|
||||||
self.net_id,
|
tenant_id,
|
||||||
{'name': new_net_name}])
|
self.net_id,
|
||||||
|
{'name': new_net_name},
|
||||||
|
])
|
||||||
|
|
||||||
for network in networks:
|
for network in networks:
|
||||||
self.assertEqual(network[const.NET_ID], self.net_id)
|
self.assertEqual(network[const.NET_ID], self.net_id)
|
||||||
@ -212,9 +213,9 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
|
|
||||||
self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
|
self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
|
||||||
port = self._l2network_multiblade.create_port([tenant_id,
|
port = self._l2network_multiblade.create_port([tenant_id,
|
||||||
self.net_id,
|
self.net_id,
|
||||||
port_state,
|
port_state,
|
||||||
self.port_id])
|
self.port_id])
|
||||||
|
|
||||||
self.assertEqual(self.port_id, port[0][const.PORTID])
|
self.assertEqual(self.port_id, port[0][const.PORTID])
|
||||||
LOG.debug("test_create_port - END")
|
LOG.debug("test_create_port - END")
|
||||||
@ -236,8 +237,8 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
port_state, self.port_id])
|
port_state, self.port_id])
|
||||||
|
|
||||||
port = self._l2network_multiblade.delete_port([tenant_id,
|
port = self._l2network_multiblade.delete_port([tenant_id,
|
||||||
self.net_id,
|
self.net_id,
|
||||||
self.port_id])
|
self.port_id])
|
||||||
|
|
||||||
self.assertEqual(self.port_id, port[0][const.PORTID])
|
self.assertEqual(self.port_id, port[0][const.PORTID])
|
||||||
|
|
||||||
@ -285,8 +286,8 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
self.net_id,
|
self.net_id,
|
||||||
port_state, self.port_id])
|
port_state, self.port_id])
|
||||||
|
|
||||||
interface = self._l2network_multiblade.plug_interface([tenant_id,
|
interface = self._l2network_multiblade.plug_interface(
|
||||||
self.net_id, self.port_id, interface_id])
|
[tenant_id, self.net_id, self.port_id, interface_id])
|
||||||
port = db.port_set_attachment(self.net_id, self.port_id, interface_id)
|
port = db.port_set_attachment(self.net_id, self.port_id, interface_id)
|
||||||
|
|
||||||
self.assertEqual(self.port_id, interface[0][const.PORTID])
|
self.assertEqual(self.port_id, interface[0][const.PORTID])
|
||||||
@ -349,10 +350,11 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
port_state, self.port_id])
|
port_state, self.port_id])
|
||||||
|
|
||||||
self._l2network_multiblade.plug_interface([tenant_id, self.net_id,
|
self._l2network_multiblade.plug_interface([tenant_id, self.net_id,
|
||||||
self.port_id, interface_id])
|
self.port_id, interface_id])
|
||||||
db.port_set_attachment(self.net_id, self.port_id, interface_id)
|
db.port_set_attachment(self.net_id, self.port_id, interface_id)
|
||||||
interface = self._l2network_multiblade.unplug_interface([tenant_id,
|
interface = self._l2network_multiblade.unplug_interface([tenant_id,
|
||||||
self.net_id, self.port_id])
|
self.net_id,
|
||||||
|
self.port_id])
|
||||||
|
|
||||||
self.assertEqual(self.port_id, interface[0][const.PORTID])
|
self.assertEqual(self.port_id, interface[0][const.PORTID])
|
||||||
LOG.debug("test_unplug_interface - END")
|
LOG.debug("test_unplug_interface - END")
|
||||||
|
@ -13,17 +13,18 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Shweta Padubidri, Peter Strunk, Cisco Systems, Inc.
|
# @author: Shweta Padubidri, Peter Strunk, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
import logging
|
import logging
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.common import cisco_credentials as creds
|
from quantum.plugins.cisco.common import cisco_credentials as creds
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
|
||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.common import cisco_credentials as cred
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
from quantum.plugins.cisco.nexus import cisco_nexus_plugin
|
from quantum.plugins.cisco.nexus import cisco_nexus_plugin
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum.tests.test_nexus')
|
LOG = logging.getLogger('quantum.tests.test_nexus')
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ class TestNexusPlugin(unittest.TestCase):
|
|||||||
self.port_id = "9"
|
self.port_id = "9"
|
||||||
db.configure_db({'sql_connection': 'sqlite:///:memory:'})
|
db.configure_db({'sql_connection': 'sqlite:///:memory:'})
|
||||||
cdb.initialize()
|
cdb.initialize()
|
||||||
cred.Store.initialize()
|
creds.Store.initialize()
|
||||||
self._cisco_nexus_plugin = cisco_nexus_plugin.NexusPlugin()
|
self._cisco_nexus_plugin = cisco_nexus_plugin.NexusPlugin()
|
||||||
|
|
||||||
def test_create_network(self, net_tenant_id=None, network_name=None,
|
def test_create_network(self, net_tenant_id=None, network_name=None,
|
||||||
@ -72,8 +73,8 @@ class TestNexusPlugin(unittest.TestCase):
|
|||||||
network_created = self.create_network(tenant_id, net_name)
|
network_created = self.create_network(tenant_id, net_name)
|
||||||
cdb.add_vlan_binding(vlan_id, vlan_name, network_created["net-id"])
|
cdb.add_vlan_binding(vlan_id, vlan_name, network_created["net-id"])
|
||||||
new_net_dict = self._cisco_nexus_plugin.create_network(
|
new_net_dict = self._cisco_nexus_plugin.create_network(
|
||||||
tenant_id, net_name, network_created["net-id"],
|
tenant_id, net_name, network_created["net-id"],
|
||||||
vlan_name, vlan_id)
|
vlan_name, vlan_id)
|
||||||
self.assertEqual(new_net_dict[const.NET_ID],
|
self.assertEqual(new_net_dict[const.NET_ID],
|
||||||
network_created["net-id"])
|
network_created["net-id"])
|
||||||
self.assertEqual(new_net_dict[const.NET_NAME], self.net_name)
|
self.assertEqual(new_net_dict[const.NET_NAME], self.net_name)
|
||||||
@ -102,10 +103,10 @@ class TestNexusPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
|
cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
|
||||||
network_created["net-id"])
|
network_created["net-id"])
|
||||||
new_net_dict = self._cisco_nexus_plugin.create_network(
|
new_net_dict = self._cisco_nexus_plugin.create_network(
|
||||||
tenant_id, self.net_name, network_created["net-id"],
|
tenant_id, self.net_name, network_created["net-id"],
|
||||||
self.vlan_name, self.vlan_id)
|
self.vlan_name, self.vlan_id)
|
||||||
deleted_net_dict = self._cisco_nexus_plugin.delete_network(
|
deleted_net_dict = self._cisco_nexus_plugin.delete_network(
|
||||||
tenant_id, new_net_dict[const.NET_ID])
|
tenant_id, new_net_dict[const.NET_ID])
|
||||||
self.assertEqual(deleted_net_dict[const.NET_ID],
|
self.assertEqual(deleted_net_dict[const.NET_ID],
|
||||||
network_created["net-id"])
|
network_created["net-id"])
|
||||||
LOG.debug("test_delete_network - END")
|
LOG.debug("test_delete_network - END")
|
||||||
@ -148,10 +149,10 @@ class TestNexusPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
|
cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
|
||||||
network_created["net-id"])
|
network_created["net-id"])
|
||||||
new_net_dict = self._cisco_nexus_plugin.create_network(
|
new_net_dict = self._cisco_nexus_plugin.create_network(
|
||||||
tenant_id, self.net_name, network_created["net-id"],
|
tenant_id, self.net_name, network_created["net-id"],
|
||||||
self.vlan_name, self.vlan_id)
|
self.vlan_name, self.vlan_id)
|
||||||
check_net_dict = self._cisco_nexus_plugin.get_network_details(
|
check_net_dict = self._cisco_nexus_plugin.get_network_details(
|
||||||
tenant_id, network_created["net-id"])
|
tenant_id, network_created["net-id"])
|
||||||
self.assertEqual(check_net_dict[const.NET_ID],
|
self.assertEqual(check_net_dict[const.NET_ID],
|
||||||
network_created["net-id"])
|
network_created["net-id"])
|
||||||
self.assertEqual(check_net_dict[const.NET_NAME], self.net_name)
|
self.assertEqual(check_net_dict[const.NET_NAME], self.net_name)
|
||||||
@ -199,10 +200,10 @@ class TestNexusPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
|
cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
|
||||||
network_created["net-id"])
|
network_created["net-id"])
|
||||||
new_net_dict = self._cisco_nexus_plugin.create_network(
|
new_net_dict = self._cisco_nexus_plugin.create_network(
|
||||||
tenant_id, self.net_name, network_created["net-id"],
|
tenant_id, self.net_name, network_created["net-id"],
|
||||||
self.vlan_name, self.vlan_id)
|
self.vlan_name, self.vlan_id)
|
||||||
rename_net_dict = self._cisco_nexus_plugin.update_network(
|
rename_net_dict = self._cisco_nexus_plugin.update_network(
|
||||||
tenant_id, new_net_dict[const.NET_ID], name=new_name)
|
tenant_id, new_net_dict[const.NET_ID], name=new_name)
|
||||||
self.assertEqual(rename_net_dict[const.NET_NAME], new_name)
|
self.assertEqual(rename_net_dict[const.NET_NAME], new_name)
|
||||||
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
||||||
LOG.debug("test_update_network - END")
|
LOG.debug("test_update_network - END")
|
||||||
@ -245,14 +246,14 @@ class TestNexusPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
|
cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
|
||||||
network_created["net-id"])
|
network_created["net-id"])
|
||||||
new_net_dict1 = self._cisco_nexus_plugin.create_network(
|
new_net_dict1 = self._cisco_nexus_plugin.create_network(
|
||||||
tenant_id, self.net_name, network_created["net-id"],
|
tenant_id, self.net_name, network_created["net-id"],
|
||||||
self.vlan_name, self.vlan_id)
|
self.vlan_name, self.vlan_id)
|
||||||
network_created2 = self.create_network(tenant_id, 'test_network2')
|
network_created2 = self.create_network(tenant_id, 'test_network2')
|
||||||
cdb.add_vlan_binding(self.second_vlan_id, 'second_vlan',
|
cdb.add_vlan_binding(self.second_vlan_id, 'second_vlan',
|
||||||
network_created2["net-id"])
|
network_created2["net-id"])
|
||||||
new_net_dict2 = self._cisco_nexus_plugin.create_network(
|
new_net_dict2 = self._cisco_nexus_plugin.create_network(
|
||||||
tenant_id, "New_Network2", network_created2["net-id"],
|
tenant_id, "New_Network2", network_created2["net-id"],
|
||||||
"second_vlan", self.second_vlan_id)
|
"second_vlan", self.second_vlan_id)
|
||||||
list_net_dict = self._cisco_nexus_plugin.get_all_networks(tenant_id)
|
list_net_dict = self._cisco_nexus_plugin.get_all_networks(tenant_id)
|
||||||
net_temp_list = [new_net_dict1, new_net_dict2]
|
net_temp_list = [new_net_dict1, new_net_dict2]
|
||||||
self.assertTrue(net_temp_list[0] in list_net_dict)
|
self.assertTrue(net_temp_list[0] in list_net_dict)
|
||||||
@ -281,10 +282,10 @@ class TestNexusPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
|
cdb.add_vlan_binding(self.vlan_id, self.vlan_name,
|
||||||
network_created["net-id"])
|
network_created["net-id"])
|
||||||
new_net_dict = self._cisco_nexus_plugin.create_network(
|
new_net_dict = self._cisco_nexus_plugin.create_network(
|
||||||
tenant_id, self.net_name, network_created["net-id"],
|
tenant_id, self.net_name, network_created["net-id"],
|
||||||
self.vlan_name, self.vlan_id)
|
self.vlan_name, self.vlan_id)
|
||||||
result_vlan_id = self._cisco_nexus_plugin._get_vlan_id_for_network(
|
result_vlan_id = self._cisco_nexus_plugin._get_vlan_id_for_network(
|
||||||
tenant_id, network_created["net-id"])
|
tenant_id, network_created["net-id"])
|
||||||
self.assertEqual(result_vlan_id, self.vlan_id)
|
self.assertEqual(result_vlan_id, self.vlan_id)
|
||||||
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
||||||
LOG.debug("test_get_vlan_id_for_network - END")
|
LOG.debug("test_get_vlan_id_for_network - END")
|
||||||
|
@ -22,52 +22,54 @@ import unittest
|
|||||||
|
|
||||||
from quantum.plugins.cisco.ucs import cisco_ucs_network_driver
|
from quantum.plugins.cisco.ucs import cisco_ucs_network_driver
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger('quantum.tests.test_ucs_driver')
|
LOG = logging.getLogger('quantum.tests.test_ucs_driver')
|
||||||
|
|
||||||
CREATE_VLAN_OUTPUT = "<configConfMos cookie=\"cookie_placeholder\" "\
|
|
||||||
"inHierarchical=\"true\"> <inConfigs><pair key=\"fabric/lan/net-New Vlan\"> "\
|
|
||||||
"<fabricVlan defaultNet=\"no\" dn=\"fabric/lan/net-New Vlan\" id=\"200\" "\
|
|
||||||
"name=\"New Vlan\" status=\"created\"></fabricVlan> </pair> </inConfigs> "\
|
|
||||||
"</configConfMos>"
|
|
||||||
|
|
||||||
CREATE_PROFILE_OUTPUT = "<configConfMos cookie=\"cookie_placeholder\" "\
|
CREATE_VLAN_OUTPUT = ("<configConfMos cookie=\"cookie_placeholder\" "
|
||||||
"inHierarchical=\"true\"> <inConfigs><pair key=\"fabric/lan/profiles/vnic-"\
|
"inHierarchical=\"true\"> <inConfigs><pair key=\"fabric/lan/net-New Vlan\"> "
|
||||||
"New Profile\"> <vnicProfile descr=\"Profile created by Cisco OpenStack "\
|
"<fabricVlan defaultNet=\"no\" dn=\"fabric/lan/net-New Vlan\" id=\"200\" "
|
||||||
"Quantum Plugin\" dn=\"fabric/lan/profiles/vnic-New Profile\" maxPorts="\
|
"name=\"New Vlan\" status=\"created\"></fabricVlan> </pair> </inConfigs> "
|
||||||
"\"64\" name=\"New Profile\" nwCtrlPolicyName=\"\" pinToGroupName=\"\" "\
|
"</configConfMos>")
|
||||||
"qosPolicyName=\"\" status=\"created\"> <vnicEtherIf defaultNet=\"yes\" "\
|
|
||||||
"name=\"New Vlan\" rn=\"if-New Vlan\" > </vnicEtherIf> </vnicProfile> "\
|
|
||||||
"</pair> </inConfigs> </configConfMos>"
|
|
||||||
|
|
||||||
CHANGE_VLAN_OUTPUT = "<configConfMos cookie=\"cookie_placeholder\" "\
|
CREATE_PROFILE_OUTPUT = ("<configConfMos cookie=\"cookie_placeholder\" "
|
||||||
"inHierarchical=\"true\"> <inConfigs><pair key=\""\
|
"inHierarchical=\"true\"> <inConfigs><pair key=\"fabric/lan/profiles/vnic-"
|
||||||
"fabric/lan/profiles/vnic-New Profile\"> <vnicProfile descr=\"Profile "\
|
"New Profile\"> <vnicProfile descr=\"Profile created by Cisco OpenStack "
|
||||||
"created by Cisco OpenStack Quantum Plugin\" "\
|
"Quantum Plugin\" dn=\"fabric/lan/profiles/vnic-New Profile\" maxPorts="
|
||||||
"dn=\"fabric/lan/profiles/vnic-New Profile\" maxPorts=\"64\" "\
|
"\"64\" name=\"New Profile\" nwCtrlPolicyName=\"\" pinToGroupName=\"\" "
|
||||||
"name=\"New Profile\" nwCtrlPolicyName=\"\" pinToGroupName=\"\" "\
|
"qosPolicyName=\"\" status=\"created\"> <vnicEtherIf defaultNet=\"yes\" "
|
||||||
"qosPolicyName=\"\" status=\"created,modified\"><vnicEtherIf "\
|
"name=\"New Vlan\" rn=\"if-New Vlan\" > </vnicEtherIf> </vnicProfile> "
|
||||||
"rn=\"if-Old Vlan\" status=\"deleted\"> </vnicEtherIf> "\
|
"</pair> </inConfigs> </configConfMos>")
|
||||||
"<vnicEtherIf defaultNet=\"yes\" name=\"New Vlan\" rn=\"if-New Vlan\" > "\
|
|
||||||
"</vnicEtherIf> </vnicProfile> </pair></inConfigs> </configConfMos>"
|
|
||||||
|
|
||||||
DELETE_VLAN_OUTPUT = "<configConfMos cookie=\"cookie_placeholder\" "\
|
CHANGE_VLAN_OUTPUT = ("<configConfMos cookie=\"cookie_placeholder\" "
|
||||||
"inHierarchical=\"true\"> <inConfigs><pair key=\"fabric/lan/net-New Vlan\"> "\
|
"inHierarchical=\"true\"> <inConfigs><pair key=\""
|
||||||
"<fabricVlan dn=\"fabric/lan/net-New Vlan\" status=\"deleted\"> "\
|
"fabric/lan/profiles/vnic-New Profile\"> <vnicProfile descr=\"Profile "
|
||||||
"</fabricVlan> </pair> </inConfigs></configConfMos>"
|
"created by Cisco OpenStack Quantum Plugin\" "
|
||||||
|
"dn=\"fabric/lan/profiles/vnic-New Profile\" maxPorts=\"64\" "
|
||||||
|
"name=\"New Profile\" nwCtrlPolicyName=\"\" pinToGroupName=\"\" "
|
||||||
|
"qosPolicyName=\"\" status=\"created,modified\"><vnicEtherIf "
|
||||||
|
"rn=\"if-Old Vlan\" status=\"deleted\"> </vnicEtherIf> "
|
||||||
|
"<vnicEtherIf defaultNet=\"yes\" name=\"New Vlan\" rn=\"if-New Vlan\" > "
|
||||||
|
"</vnicEtherIf> </vnicProfile> </pair></inConfigs> </configConfMos>")
|
||||||
|
|
||||||
DELETE_PROFILE_OUTPUT = "<configConfMos cookie=\"cookie_placeholder\" "\
|
DELETE_VLAN_OUTPUT = ("<configConfMos cookie=\"cookie_placeholder\" "
|
||||||
"inHierarchical=\"false\"> <inConfigs><pair key=\""\
|
"inHierarchical=\"true\"> <inConfigs><pair key=\"fabric/lan/net-New Vlan\"> "
|
||||||
"fabric/lan/profiles/vnic-New Profile\"> <vnicProfile "\
|
"<fabricVlan dn=\"fabric/lan/net-New Vlan\" status=\"deleted\"> "
|
||||||
"dn=\"fabric/lan/profiles/vnic-New Profile\" status=\"deleted\"> "\
|
"</fabricVlan> </pair> </inConfigs></configConfMos>")
|
||||||
"</vnicProfile></pair> </inConfigs> </configConfMos>"
|
|
||||||
|
|
||||||
ASSOCIATE_PROFILE_OUTPUT = "<configConfMos cookie=\"cookie_placeholder\" "\
|
DELETE_PROFILE_OUTPUT = ("<configConfMos cookie=\"cookie_placeholder\" "
|
||||||
"inHierarchical=\"true\"> <inConfigs> <pair key="\
|
"inHierarchical=\"false\"> <inConfigs><pair key=\""
|
||||||
"\"fabric/lan/profiles/vnic-New Profile/cl-New Profile Client\">"\
|
"fabric/lan/profiles/vnic-New Profile\"> <vnicProfile "
|
||||||
" <vmVnicProfCl dcName=\".*\" descr=\"\" dn=\"fabric/lan/profiles/vnic-"\
|
"dn=\"fabric/lan/profiles/vnic-New Profile\" status=\"deleted\"> "
|
||||||
"New Profile/cl-New Profile Client\"name=\"New Profile Client\" "\
|
"</vnicProfile></pair> </inConfigs> </configConfMos>")
|
||||||
"orgPath=\".*\" status=\"created\" swName=\"default$\"> </vmVnicProfCl>" \
|
|
||||||
"</pair> </inConfigs> </configConfMos>"
|
ASSOCIATE_PROFILE_OUTPUT = ("<configConfMos cookie=\"cookie_placeholder\" "
|
||||||
|
"inHierarchical=\"true\"> <inConfigs> <pair key="
|
||||||
|
"\"fabric/lan/profiles/vnic-New Profile/cl-New Profile Client\">"
|
||||||
|
" <vmVnicProfCl dcName=\".*\" descr=\"\" dn=\"fabric/lan/profiles/vnic-"
|
||||||
|
"New Profile/cl-New Profile Client\"name=\"New Profile Client\" "
|
||||||
|
"orgPath=\".*\" status=\"created\" swName=\"default$\"> </vmVnicProfCl>"
|
||||||
|
"</pair> </inConfigs> </configConfMos>")
|
||||||
|
|
||||||
|
|
||||||
class TestUCSDriver(unittest.TestCase):
|
class TestUCSDriver(unittest.TestCase):
|
||||||
@ -88,7 +90,7 @@ class TestUCSDriver(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_create_vlan")
|
LOG.debug("test_create_vlan")
|
||||||
vlan_details = self.ucsm_driver._create_vlan_post_data(
|
vlan_details = self.ucsm_driver._create_vlan_post_data(
|
||||||
self.vlan_name, self.vlan_id)
|
self.vlan_name, self.vlan_id)
|
||||||
self.assertEqual(vlan_details, expected_output)
|
self.assertEqual(vlan_details, expected_output)
|
||||||
LOG.debug("test_create_vlan - END")
|
LOG.debug("test_create_vlan - END")
|
||||||
|
|
||||||
@ -100,7 +102,7 @@ class TestUCSDriver(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_create_profile_post_data - START")
|
LOG.debug("test_create_profile_post_data - START")
|
||||||
profile_details = self.ucsm_driver._create_profile_post_data(
|
profile_details = self.ucsm_driver._create_profile_post_data(
|
||||||
self.profile_name, self.vlan_name)
|
self.profile_name, self.vlan_name)
|
||||||
self.assertEqual(profile_details, expected_output)
|
self.assertEqual(profile_details, expected_output)
|
||||||
LOG.debug("test_create_profile_post - END")
|
LOG.debug("test_create_profile_post - END")
|
||||||
|
|
||||||
@ -112,7 +114,7 @@ class TestUCSDriver(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_create_profile_post_data - START")
|
LOG.debug("test_create_profile_post_data - START")
|
||||||
profile_details = self.ucsm_driver._change_vlaninprof_post_data(
|
profile_details = self.ucsm_driver._change_vlaninprof_post_data(
|
||||||
self.profile_name, self.old_vlan_name, self.vlan_name)
|
self.profile_name, self.old_vlan_name, self.vlan_name)
|
||||||
self.assertEqual(profile_details, expected_output)
|
self.assertEqual(profile_details, expected_output)
|
||||||
LOG.debug("test_create_profile_post - END")
|
LOG.debug("test_create_profile_post - END")
|
||||||
|
|
||||||
@ -124,34 +126,34 @@ class TestUCSDriver(unittest.TestCase):
|
|||||||
LOG.debug("test_create_profile_post_data - START")
|
LOG.debug("test_create_profile_post_data - START")
|
||||||
|
|
||||||
self.ucsm_driver._create_vlan_post_data(
|
self.ucsm_driver._create_vlan_post_data(
|
||||||
self.vlan_name, self.vlan_id)
|
self.vlan_name, self.vlan_id)
|
||||||
vlan_delete_details = self.ucsm_driver._delete_vlan_post_data(
|
vlan_delete_details = self.ucsm_driver._delete_vlan_post_data(
|
||||||
self.vlan_name)
|
self.vlan_name)
|
||||||
self.assertEqual(vlan_delete_details, expected_output)
|
self.assertEqual(vlan_delete_details, expected_output)
|
||||||
LOG.debug("test_create_profile_post - END")
|
LOG.debug("test_create_profile_post - END")
|
||||||
|
|
||||||
def test_delete_profile_post_data(
|
def test_delete_profile_post_data(self,
|
||||||
self, expected_output=DELETE_PROFILE_OUTPUT):
|
expected_output=DELETE_PROFILE_OUTPUT):
|
||||||
"""
|
"""
|
||||||
Tests deletion of profile post Data
|
Tests deletion of profile post Data
|
||||||
"""
|
"""
|
||||||
|
|
||||||
LOG.debug("test_create_profile_post_data - START")
|
LOG.debug("test_create_profile_post_data - START")
|
||||||
self.ucsm_driver._create_profile_post_data(
|
self.ucsm_driver._create_profile_post_data(
|
||||||
self.profile_name, self.vlan_name)
|
self.profile_name, self.vlan_name)
|
||||||
profile_delete_details = self.ucsm_driver._delete_profile_post_data(
|
profile_delete_details = self.ucsm_driver._delete_profile_post_data(
|
||||||
self.profile_name)
|
self.profile_name)
|
||||||
self.assertEqual(profile_delete_details, expected_output)
|
self.assertEqual(profile_delete_details, expected_output)
|
||||||
LOG.debug("test_create_profile_post - END")
|
LOG.debug("test_create_profile_post - END")
|
||||||
|
|
||||||
def test_create_profile_client_data(
|
def test_create_profile_client_data(
|
||||||
self, expected_output=ASSOCIATE_PROFILE_OUTPUT):
|
self, expected_output=ASSOCIATE_PROFILE_OUTPUT):
|
||||||
"""
|
"""
|
||||||
Tests creation of profile client post Data
|
Tests creation of profile client post Data
|
||||||
"""
|
"""
|
||||||
|
|
||||||
LOG.debug("test_create_profile_client_data - START")
|
LOG.debug("test_create_profile_client_data - START")
|
||||||
profile_details = self.ucsm_driver._create_pclient_post_data(
|
profile_details = self.ucsm_driver._create_pclient_post_data(
|
||||||
self.profile_name, self.profile_client_name)
|
self.profile_name, self.profile_client_name)
|
||||||
self.assertEqual(profile_details, expected_output)
|
self.assertEqual(profile_details, expected_output)
|
||||||
LOG.debug("test_create_profile_post - END")
|
LOG.debug("test_create_profile_post - END")
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,22 +16,22 @@
|
|||||||
#
|
#
|
||||||
# @author: Shubhangi Satras, Cisco Systems, Inc.
|
# @author: Shubhangi Satras, Cisco Systems, Inc.
|
||||||
# @author: Tyler Smith, Cisco Systems, Inc.
|
# @author: Tyler Smith, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
import logging
|
||||||
import unittest
|
import unittest
|
||||||
import logging as LOG
|
|
||||||
|
|
||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
from quantum.plugins.cisco.l2network_plugin import L2Network
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.common import cisco_credentials as creds
|
from quantum.plugins.cisco.common import cisco_credentials as creds
|
||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
|
from quantum.plugins.cisco.l2network_plugin import L2Network
|
||||||
from quantum.plugins.cisco.ucs.cisco_ucs_inventory import UCSInventory
|
from quantum.plugins.cisco.ucs.cisco_ucs_inventory import UCSInventory
|
||||||
|
|
||||||
LOG.basicConfig(level=LOG.WARN)
|
|
||||||
LOG.getLogger(__name__)
|
logging.basicConfig(level=LOG.WARN)
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# Set some data to use in tests
|
# Set some data to use in tests
|
||||||
tenant = 'shubh'
|
tenant = 'shubh'
|
||||||
@ -97,12 +96,12 @@ class TestUCSInventory(unittest.TestCase):
|
|||||||
|
|
||||||
# Clean up created network and port
|
# Clean up created network and port
|
||||||
try:
|
try:
|
||||||
self._l2network.unplug_interface(tenant,
|
self._l2network.unplug_interface(
|
||||||
net[const.NET_ID], port[const.PORT_ID])
|
tenant, net[const.NET_ID], port[const.PORT_ID])
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self._l2network.delete_port(tenant,
|
self._l2network.delete_port(tenant,
|
||||||
net[const.NET_ID], port[const.PORT_ID])
|
net[const.NET_ID], port[const.PORT_ID])
|
||||||
self._l2network.delete_network(tenant, net[const.NET_ID])
|
self._l2network.delete_network(tenant, net[const.NET_ID])
|
||||||
db.clear_db()
|
db.clear_db()
|
||||||
|
|
||||||
|
@ -15,23 +15,23 @@
|
|||||||
#
|
#
|
||||||
# @author: Shubhangi Satras, Cisco Systems, Inc.
|
# @author: Shubhangi Satras, Cisco Systems, Inc.
|
||||||
# Shweta Padubidri, Cisco Systems, Inc.
|
# Shweta Padubidri, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
|
import logging
|
||||||
import unittest
|
import unittest
|
||||||
import logging as LOG
|
|
||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.ucs import cisco_ucs_plugin
|
|
||||||
from quantum.plugins.cisco.ucs import cisco_ucs_configuration as conf
|
|
||||||
from quantum.plugins.cisco.common import cisco_credentials as cred
|
from quantum.plugins.cisco.common import cisco_credentials as cred
|
||||||
|
from quantum.plugins.cisco.common import cisco_exceptions as c_exc
|
||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as c_exc
|
from quantum.plugins.cisco.ucs import cisco_ucs_configuration as conf
|
||||||
|
|
||||||
from quantum.plugins.cisco.ucs import cisco_ucs_inventory as ucsinv
|
from quantum.plugins.cisco.ucs import cisco_ucs_inventory as ucsinv
|
||||||
|
from quantum.plugins.cisco.ucs import cisco_ucs_plugin
|
||||||
|
|
||||||
LOG.basicConfig(level=LOG.WARN)
|
|
||||||
LOG.getLogger("cisco_ucs_plugin")
|
logging.basicConfig(level=LOG.WARN)
|
||||||
|
LOG = logging.getLogger("cisco_ucs_plugin")
|
||||||
|
|
||||||
|
|
||||||
class UCSVICTestPlugin(unittest.TestCase):
|
class UCSVICTestPlugin(unittest.TestCase):
|
||||||
@ -53,13 +53,13 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
self.device_ip = conf.UCSM_IP_ADDRESS
|
self.device_ip = conf.UCSM_IP_ADDRESS
|
||||||
self._ucs_inventory = ucsinv.UCSInventory()
|
self._ucs_inventory = ucsinv.UCSInventory()
|
||||||
self._ucs_inventory._load_inventory()
|
self._ucs_inventory._load_inventory()
|
||||||
self.chassis_id_list = self._ucs_inventory._inventory[\
|
self.chassis_id_list = (
|
||||||
self.device_ip].keys()
|
self._ucs_inventory._inventory[self.device_ip].keys())
|
||||||
self.chassis_id = self.chassis_id_list[0]
|
self.chassis_id = self.chassis_id_list[0]
|
||||||
self.blade_id_list = self._ucs_inventory._inventory[\
|
self.blade_id_list = (
|
||||||
self.device_ip][self.chassis_id]
|
self._ucs_inventory._inventory[self.device_ip][self.chassis_id])
|
||||||
self.blade_id = self._ucs_inventory._inventory[\
|
self.blade_id = (
|
||||||
self.device_ip][self.chassis_id][0]
|
self._ucs_inventory._inventory[self.device_ip][self.chassis_id][0])
|
||||||
|
|
||||||
def test_create_network(self):
|
def test_create_network(self):
|
||||||
"""
|
"""
|
||||||
@ -70,9 +70,9 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
new_net_dict = self._cisco_ucs_plugin.create_network(
|
new_net_dict = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network[const.NETWORKNAME],
|
self.tenant_id, new_network[const.NETWORKNAME],
|
||||||
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
|
self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
|
||||||
self.assertEqual(new_net_dict[const.NET_NAME],
|
self.assertEqual(new_net_dict[const.NET_NAME],
|
||||||
new_network[const.NETWORKNAME])
|
new_network[const.NETWORKNAME])
|
||||||
@ -88,11 +88,11 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
new_net_dict = self._cisco_ucs_plugin.create_network(
|
new_net_dict = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network[const.NETWORKNAME],
|
self.tenant_id, new_network[const.NETWORKNAME],
|
||||||
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
new_net_dict = self._cisco_ucs_plugin.delete_network(
|
new_net_dict = self._cisco_ucs_plugin.delete_network(
|
||||||
self.tenant_id, new_network[const.UUID], device_ip=self.device_ip)
|
self.tenant_id, new_network[const.UUID], device_ip=self.device_ip)
|
||||||
self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
|
self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
|
||||||
|
|
||||||
def test_get_network_details(self):
|
def test_get_network_details(self):
|
||||||
@ -105,12 +105,12 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
new_net_dict = self._cisco_ucs_plugin.create_network(
|
new_net_dict = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network[const.NETWORKNAME],
|
self.tenant_id, new_network[const.NETWORKNAME],
|
||||||
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
new_net_dict = self._cisco_ucs_plugin.get_network_details(
|
new_net_dict = self._cisco_ucs_plugin.get_network_details(
|
||||||
self.tenant_id, new_network[const.UUID],
|
self.tenant_id, new_network[const.UUID],
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
|
self.assertEqual(new_net_dict[const.NET_ID], new_network[const.UUID])
|
||||||
self.assertEqual(new_net_dict[const.NET_NAME],
|
self.assertEqual(new_net_dict[const.NET_NAME],
|
||||||
new_network[const.NETWORKNAME])
|
new_network[const.NETWORKNAME])
|
||||||
@ -127,18 +127,18 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network1[const.UUID])
|
new_network1[const.UUID])
|
||||||
new_net_dict1 = self._cisco_ucs_plugin.create_network(
|
new_net_dict1 = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network1[const.NETWORKNAME],
|
self.tenant_id, new_network1[const.NETWORKNAME],
|
||||||
new_network1[const.UUID], self.vlan_name, self.vlan_id,
|
new_network1[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
new_network2 = db.network_create(self.tenant_id, "test_network2")
|
new_network2 = db.network_create(self.tenant_id, "test_network2")
|
||||||
cdb.add_vlan_binding("6", "q-000006vlan", new_network2[const.UUID])
|
cdb.add_vlan_binding("6", "q-000006vlan", new_network2[const.UUID])
|
||||||
new_net_dict2 = self._cisco_ucs_plugin.create_network(
|
new_net_dict2 = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network2[const.NETWORKNAME],
|
self.tenant_id, new_network2[const.NETWORKNAME],
|
||||||
new_network2[const.UUID], "q-000006vlan", "6",
|
new_network2[const.UUID], "q-000006vlan", "6",
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
|
|
||||||
net_list = self._cisco_ucs_plugin.get_all_networks(
|
net_list = self._cisco_ucs_plugin.get_all_networks(
|
||||||
self.tenant_id, device_ip=self.device_ip)
|
self.tenant_id, device_ip=self.device_ip)
|
||||||
net_id_list = [new_net_dict1, new_net_dict2]
|
net_id_list = [new_net_dict1, new_net_dict2]
|
||||||
|
|
||||||
self.assertTrue(net_list[0] in net_id_list)
|
self.assertTrue(net_list[0] in net_id_list)
|
||||||
@ -156,29 +156,29 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
new_net_dict = self._cisco_ucs_plugin.create_network(
|
new_net_dict = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network[const.NETWORKNAME],
|
self.tenant_id, new_network[const.NETWORKNAME],
|
||||||
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
new_port1 = db.port_create(new_network[const.UUID], const.PORT_UP)
|
new_port1 = db.port_create(new_network[const.UUID], const.PORT_UP)
|
||||||
port_dict1 = self._cisco_ucs_plugin.create_port(
|
port_dict1 = self._cisco_ucs_plugin.create_port(
|
||||||
self.tenant_id, self.net_id, const.PORT_UP,
|
self.tenant_id, self.net_id, const.PORT_UP,
|
||||||
new_port1[const.UUID], device_ip=self.device_ip,
|
new_port1[const.UUID], device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
new_port2 = db.port_create(new_network[const.UUID], const.PORT_UP)
|
new_port2 = db.port_create(new_network[const.UUID], const.PORT_UP)
|
||||||
port_dict2 = self._cisco_ucs_plugin.create_port(
|
port_dict2 = self._cisco_ucs_plugin.create_port(
|
||||||
self.tenant_id, self.net_id, const.PORT_UP,
|
self.tenant_id, self.net_id, const.PORT_UP,
|
||||||
new_port2[const.UUID], device_ip=self.device_ip,
|
new_port2[const.UUID], device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
ports_on_net = self._cisco_ucs_plugin.get_all_ports(
|
ports_on_net = self._cisco_ucs_plugin.get_all_ports(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
device_ip=self.device_ip,
|
device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
port_list = [port_dict1, port_dict2]
|
port_list = [port_dict1, port_dict2]
|
||||||
self.assertTrue(str(ports_on_net[1]) == str(port_list[1]) or
|
self.assertTrue(str(ports_on_net[1]) == str(port_list[1]) or
|
||||||
str(ports_on_net[1]) == str(port_list[0]))
|
str(ports_on_net[1]) == str(port_list[0]))
|
||||||
@ -186,19 +186,19 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
str(ports_on_net[0]) == str(port_list[0]))
|
str(ports_on_net[0]) == str(port_list[0]))
|
||||||
|
|
||||||
blade_intf_details = self._ucs_inventory._get_rsvd_blade_intf_by_port(
|
blade_intf_details = self._ucs_inventory._get_rsvd_blade_intf_by_port(
|
||||||
self.tenant_id, port_dict1[const.PORTID])
|
self.tenant_id, port_dict1[const.PORTID])
|
||||||
self._cisco_ucs_plugin.delete_port(
|
self._cisco_ucs_plugin.delete_port(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict1[const.PORTID], device_ip=self.device_ip,
|
port_dict1[const.PORTID], device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
chassis_id=self.chassis_id, blade_id=self.blade_id,
|
chassis_id=self.chassis_id, blade_id=self.blade_id,
|
||||||
blade_intf_distinguished_name=blade_intf_details[\
|
blade_intf_distinguished_name=blade_intf_details[
|
||||||
const.BLADE_INTF_DN],
|
const.BLADE_INTF_DN],
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
self.tear_down_network_port(
|
self.tear_down_network_port(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict2[const.PORTID])
|
port_dict2[const.PORTID])
|
||||||
|
|
||||||
def test_create_port(self):
|
def test_create_port(self):
|
||||||
"""
|
"""
|
||||||
@ -210,23 +210,23 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
new_net_dict = self._cisco_ucs_plugin.create_network(
|
new_net_dict = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network[const.NETWORKNAME],
|
self.tenant_id, new_network[const.NETWORKNAME],
|
||||||
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
||||||
port_dict = self._cisco_ucs_plugin.create_port(
|
port_dict = self._cisco_ucs_plugin.create_port(
|
||||||
self.tenant_id, self.net_id, const.PORT_UP,
|
self.tenant_id, self.net_id, const.PORT_UP,
|
||||||
new_port[const.UUID], device_ip=self.device_ip,
|
new_port[const.UUID], device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
self.assertEqual(port_dict[const.PORTID], new_port[const.UUID])
|
self.assertEqual(port_dict[const.PORTID], new_port[const.UUID])
|
||||||
profile_name = self._cisco_ucs_plugin.\
|
profile_name = (
|
||||||
_get_profile_name(port_dict[const.PORTID])
|
self._cisco_ucs_plugin._get_profile_name(port_dict[const.PORTID]))
|
||||||
self.assertTrue(profile_name is not None)
|
self.assertTrue(profile_name is not None)
|
||||||
self.tear_down_network_port(
|
self.tear_down_network_port(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORTID])
|
port_dict[const.PORTID])
|
||||||
|
|
||||||
def test_delete_port(self):
|
def test_delete_port(self):
|
||||||
"""
|
"""
|
||||||
@ -240,28 +240,28 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
new_net_dict = self._cisco_ucs_plugin.create_network(
|
new_net_dict = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network[const.NETWORKNAME],
|
self.tenant_id, new_network[const.NETWORKNAME],
|
||||||
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
||||||
port_dict = self._cisco_ucs_plugin.create_port(
|
port_dict = self._cisco_ucs_plugin.create_port(
|
||||||
self.tenant_id, self.net_id, const.PORT_UP,
|
self.tenant_id, self.net_id, const.PORT_UP,
|
||||||
new_port[const.UUID], device_ip=self.device_ip,
|
new_port[const.UUID], device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
|
|
||||||
blade_intf_details = self._ucs_inventory._get_rsvd_blade_intf_by_port(
|
blade_intf_details = self._ucs_inventory._get_rsvd_blade_intf_by_port(
|
||||||
self.tenant_id, port_dict[const.PORTID])
|
self.tenant_id, port_dict[const.PORTID])
|
||||||
port_bind = self._cisco_ucs_plugin.delete_port(
|
port_bind = self._cisco_ucs_plugin.delete_port(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORTID], device_ip=self.device_ip,
|
port_dict[const.PORTID], device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
chassis_id=self.chassis_id, blade_id=self.blade_id,
|
chassis_id=self.chassis_id, blade_id=self.blade_id,
|
||||||
blade_intf_distinguished_name=blade_intf_details[\
|
blade_intf_distinguished_name=blade_intf_details[
|
||||||
const.BLADE_INTF_DN],
|
const.BLADE_INTF_DN],
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
|
|
||||||
self.assertEqual(port_bind[const.PORTID], new_port[const.UUID])
|
self.assertEqual(port_bind[const.PORTID], new_port[const.UUID])
|
||||||
self.tear_down_network(self.tenant_id, new_net_dict[const.NET_ID])
|
self.tear_down_network(self.tenant_id, new_net_dict[const.NET_ID])
|
||||||
@ -276,24 +276,24 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
new_net_dict = self._cisco_ucs_plugin.create_network(
|
new_net_dict = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network[const.NETWORKNAME],
|
self.tenant_id, new_network[const.NETWORKNAME],
|
||||||
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
new_port = db.port_create(new_network[const.UUID], port_state)
|
new_port = db.port_create(new_network[const.UUID], port_state)
|
||||||
port_dict = self._cisco_ucs_plugin.create_port(
|
port_dict = self._cisco_ucs_plugin.create_port(
|
||||||
self.tenant_id, self.net_id, port_state,
|
self.tenant_id, self.net_id, port_state,
|
||||||
new_port[const.UUID], device_ip=self.device_ip,
|
new_port[const.UUID], device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
|
|
||||||
port_detail = self._cisco_ucs_plugin.get_port_details(
|
port_detail = self._cisco_ucs_plugin.get_port_details(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORTID], device_ip=self.device_ip)
|
port_dict[const.PORTID], device_ip=self.device_ip)
|
||||||
self.assertEqual(str(port_dict), str(port_detail))
|
self.assertEqual(str(port_dict), str(port_detail))
|
||||||
self.tear_down_network_port(
|
self.tear_down_network_port(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORTID])
|
port_dict[const.PORTID])
|
||||||
|
|
||||||
def test_get_port_details_state_up(self):
|
def test_get_port_details_state_up(self):
|
||||||
"""
|
"""
|
||||||
@ -318,11 +318,11 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
||||||
self._cisco_ucs_plugin._set_ucsm(self.device_ip)
|
self._cisco_ucs_plugin._set_ucsm(self.device_ip)
|
||||||
new_port_profile = self._cisco_ucs_plugin._create_port_profile(
|
new_port_profile = self._cisco_ucs_plugin._create_port_profile(
|
||||||
self.tenant_id, new_network[const.UUID],
|
self.tenant_id, new_network[const.UUID],
|
||||||
new_port[const.UUID], self.vlan_name,
|
new_port[const.UUID], self.vlan_name,
|
||||||
self.vlan_id)
|
self.vlan_id)
|
||||||
profile_name = self._cisco_ucs_plugin.\
|
profile_name = (
|
||||||
_get_profile_name(new_port[const.UUID])
|
self._cisco_ucs_plugin._get_profile_name(new_port[const.UUID]))
|
||||||
self.assertEqual(new_port_profile[const.PROFILE_NAME], profile_name)
|
self.assertEqual(new_port_profile[const.PROFILE_NAME], profile_name)
|
||||||
self.assertEqual(new_port_profile[const.PROFILE_VLAN_NAME],
|
self.assertEqual(new_port_profile[const.PROFILE_VLAN_NAME],
|
||||||
self.vlan_name)
|
self.vlan_name)
|
||||||
@ -341,11 +341,11 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
||||||
self._cisco_ucs_plugin._set_ucsm(self.device_ip)
|
self._cisco_ucs_plugin._set_ucsm(self.device_ip)
|
||||||
self._cisco_ucs_plugin._create_port_profile(
|
self._cisco_ucs_plugin._create_port_profile(
|
||||||
self.tenant_id, new_network[const.UUID],
|
self.tenant_id, new_network[const.UUID],
|
||||||
new_port[const.UUID], self.vlan_name,
|
new_port[const.UUID], self.vlan_name,
|
||||||
self.vlan_id)
|
self.vlan_id)
|
||||||
profile_name = self._cisco_ucs_plugin.\
|
profile_name = (
|
||||||
_get_profile_name(new_port[const.UUID])
|
self._cisco_ucs_plugin._get_profile_name(new_port[const.UUID]))
|
||||||
|
|
||||||
counter1 = self._cisco_ucs_plugin._port_profile_counter
|
counter1 = self._cisco_ucs_plugin._port_profile_counter
|
||||||
self._cisco_ucs_plugin._delete_port_profile(new_port[const.UUID],
|
self._cisco_ucs_plugin._delete_port_profile(new_port[const.UUID],
|
||||||
@ -364,28 +364,28 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
new_net_dict = self._cisco_ucs_plugin.create_network(
|
new_net_dict = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network[const.NETWORKNAME],
|
self.tenant_id, new_network[const.NETWORKNAME],
|
||||||
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
||||||
port_dict = self._cisco_ucs_plugin.create_port(
|
port_dict = self._cisco_ucs_plugin.create_port(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
const.PORT_UP, new_port[const.UUID],
|
const.PORT_UP, new_port[const.UUID],
|
||||||
device_ip=self.device_ip,
|
device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
cdb.update_vlan_binding(new_network[const.UUID],
|
cdb.update_vlan_binding(new_network[const.UUID],
|
||||||
str(new_vlanid), new_vlan_name)
|
str(new_vlanid), new_vlan_name)
|
||||||
port_bind = self._cisco_ucs_plugin.plug_interface(
|
port_bind = self._cisco_ucs_plugin.plug_interface(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORTID], remote_interface_id,
|
port_dict[const.PORTID], remote_interface_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
self.assertEqual(port_bind[const.VLANNAME], new_vlan_name)
|
self.assertEqual(port_bind[const.VLANNAME], new_vlan_name)
|
||||||
self.assertEqual(port_bind[const.VLANID], new_vlanid)
|
self.assertEqual(port_bind[const.VLANID], new_vlanid)
|
||||||
self.tear_down_network_port_interface(
|
self.tear_down_network_port_interface(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
new_port[const.UUID])
|
new_port[const.UUID])
|
||||||
|
|
||||||
def test_unplug_interface(self, remote_interface_id=None,
|
def test_unplug_interface(self, remote_interface_id=None,
|
||||||
new_vlanid=10, new_vlan_name='new_vlan'):
|
new_vlanid=10, new_vlan_name='new_vlan'):
|
||||||
@ -398,32 +398,32 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
new_net_dict = self._cisco_ucs_plugin.create_network(
|
new_net_dict = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network[const.NETWORKNAME],
|
self.tenant_id, new_network[const.NETWORKNAME],
|
||||||
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
|
||||||
port_dict = self._cisco_ucs_plugin.create_port(
|
port_dict = self._cisco_ucs_plugin.create_port(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
const.PORT_UP, new_port[const.UUID],
|
const.PORT_UP, new_port[const.UUID],
|
||||||
device_ip=self.device_ip,
|
device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
cdb.update_vlan_binding(new_network[const.UUID],
|
cdb.update_vlan_binding(new_network[const.UUID],
|
||||||
str(new_vlanid), new_vlan_name)
|
str(new_vlanid), new_vlan_name)
|
||||||
self._cisco_ucs_plugin.plug_interface(
|
self._cisco_ucs_plugin.plug_interface(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORTID], remote_interface_id,
|
port_dict[const.PORTID], remote_interface_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
|
|
||||||
port_bind = self._cisco_ucs_plugin.unplug_interface(
|
port_bind = self._cisco_ucs_plugin.unplug_interface(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
port_dict[const.PORTID], device_ip=self.device_ip)
|
port_dict[const.PORTID], device_ip=self.device_ip)
|
||||||
self.assertEqual(port_bind[const.VLANNAME], self.vlan_name)
|
self.assertEqual(port_bind[const.VLANNAME], self.vlan_name)
|
||||||
self.assertEqual(port_bind[const.VLANID], self.vlan_id)
|
self.assertEqual(port_bind[const.VLANID], self.vlan_id)
|
||||||
self.tear_down_network_port_interface(
|
self.tear_down_network_port_interface(
|
||||||
self.tenant_id, new_net_dict[const.NET_ID],
|
self.tenant_id, new_net_dict[const.NET_ID],
|
||||||
new_port[const.UUID])
|
new_port[const.UUID])
|
||||||
|
|
||||||
def test_get_vlan_name_for_network(self):
|
def test_get_vlan_name_for_network(self):
|
||||||
"""
|
"""
|
||||||
@ -434,7 +434,7 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
vlan_bind_name = self._cisco_ucs_plugin._get_vlan_name_for_network(
|
vlan_bind_name = self._cisco_ucs_plugin._get_vlan_name_for_network(
|
||||||
self.tenant_id, new_network[const.UUID])
|
self.tenant_id, new_network[const.UUID])
|
||||||
|
|
||||||
self.assertEqual(vlan_bind_name, self.vlan_name)
|
self.assertEqual(vlan_bind_name, self.vlan_name)
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
vlan_bind_id = self._cisco_ucs_plugin._get_vlan_id_for_network(
|
vlan_bind_id = self._cisco_ucs_plugin._get_vlan_id_for_network(
|
||||||
self.tenant_id, new_network[const.UUID])
|
self.tenant_id, new_network[const.UUID])
|
||||||
self.assertEqual(str(vlan_bind_id), self.vlan_id)
|
self.assertEqual(str(vlan_bind_id), self.vlan_id)
|
||||||
|
|
||||||
def test_show_network_not_found(self):
|
def test_show_network_not_found(self):
|
||||||
@ -476,9 +476,9 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
|
||||||
new_network[const.UUID])
|
new_network[const.UUID])
|
||||||
new_net_dict = self._cisco_ucs_plugin.create_network(
|
new_net_dict = self._cisco_ucs_plugin.create_network(
|
||||||
self.tenant_id, new_network[const.NETWORKNAME],
|
self.tenant_id, new_network[const.NETWORKNAME],
|
||||||
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
new_network[const.UUID], self.vlan_name, self.vlan_id,
|
||||||
device_ip=self.device_ip)
|
device_ip=self.device_ip)
|
||||||
|
|
||||||
self.assertRaises(c_exc.PortVnicNotFound,
|
self.assertRaises(c_exc.PortVnicNotFound,
|
||||||
self._cisco_ucs_plugin.delete_port,
|
self._cisco_ucs_plugin.delete_port,
|
||||||
@ -487,8 +487,8 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
chassis_id=self.chassis_id, blade_id=self.blade_id,
|
chassis_id=self.chassis_id, blade_id=self.blade_id,
|
||||||
blade_intf_distinguished_name=None,
|
blade_intf_distinguished_name=None,
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
|
|
||||||
self.tear_down_network(self.tenant_id, new_net_dict[const.NET_ID])
|
self.tear_down_network(self.tenant_id, new_net_dict[const.NET_ID])
|
||||||
|
|
||||||
@ -503,19 +503,18 @@ class UCSVICTestPlugin(unittest.TestCase):
|
|||||||
|
|
||||||
def tear_down_network_port(self, tenant_id, net_id, port_id):
|
def tear_down_network_port(self, tenant_id, net_id, port_id):
|
||||||
blade_intf_details = self._ucs_inventory._get_rsvd_blade_intf_by_port(
|
blade_intf_details = self._ucs_inventory._get_rsvd_blade_intf_by_port(
|
||||||
tenant_id, port_id)
|
tenant_id, port_id)
|
||||||
self._cisco_ucs_plugin.delete_port(
|
self._cisco_ucs_plugin.delete_port(
|
||||||
tenant_id, net_id, port_id, device_ip=self.device_ip,
|
tenant_id, net_id, port_id, device_ip=self.device_ip,
|
||||||
ucs_inventory=self._ucs_inventory,
|
ucs_inventory=self._ucs_inventory,
|
||||||
chassis_id=self.chassis_id, blade_id=self.blade_id,
|
chassis_id=self.chassis_id, blade_id=self.blade_id,
|
||||||
blade_intf_distinguished_name=blade_intf_details[\
|
blade_intf_distinguished_name=blade_intf_details[
|
||||||
const.BLADE_INTF_DN],
|
const.BLADE_INTF_DN],
|
||||||
least_rsvd_blade_dict=self._ucs_inventory.\
|
least_rsvd_blade_dict=(
|
||||||
_get_least_reserved_blade())
|
self._ucs_inventory._get_least_reserved_blade()))
|
||||||
self.tear_down_network(tenant_id, net_id)
|
self.tear_down_network(tenant_id, net_id)
|
||||||
|
|
||||||
def tear_down_network_port_interface(self, tenant_id, net_id, port_id):
|
def tear_down_network_port_interface(self, tenant_id, net_id, port_id):
|
||||||
self._cisco_ucs_plugin.unplug_interface(
|
self._cisco_ucs_plugin.unplug_interface(tenant_id, net_id, port_id,
|
||||||
tenant_id, net_id, port_id,
|
device_ip=self.device_ip)
|
||||||
device_ip=self.device_ip)
|
|
||||||
self.tear_down_network_port(tenant_id, net_id, port_id)
|
self.tear_down_network_port(tenant_id, net_id, port_id)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,23 +15,23 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Peter Strunk, Cisco Systems, Inc.
|
# @author: Peter Strunk, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
import logging
|
||||||
import unittest
|
import unittest
|
||||||
import logging as LOG
|
|
||||||
|
|
||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as c_exc
|
from quantum.plugins.cisco.common import cisco_exceptions as c_exc
|
||||||
from quantum.plugins.cisco.common import cisco_credentials as creds
|
from quantum.plugins.cisco.common import cisco_credentials as creds
|
||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
from quantum.plugins.cisco.segmentation.l2network_vlan_mgr \
|
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
||||||
import L2NetworkVLANMgr
|
from quantum.plugins.cisco.segmentation.l2network_vlan_mgr import (
|
||||||
|
L2NetworkVLANMgr,
|
||||||
|
)
|
||||||
|
|
||||||
LOG.basicConfig(level=LOG.WARN)
|
|
||||||
LOG.getLogger(__name__)
|
logging.basicConfig(level=logging.WARN)
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Test_L2Network_Vlan_Mgr(unittest.TestCase):
|
class Test_L2Network_Vlan_Mgr(unittest.TestCase):
|
||||||
@ -50,8 +49,8 @@ class Test_L2Network_Vlan_Mgr(unittest.TestCase):
|
|||||||
self.vlan_id = 300
|
self.vlan_id = 300
|
||||||
self.net_id = 100
|
self.net_id = 100
|
||||||
self.vlan_mgr = L2NetworkVLANMgr()
|
self.vlan_mgr = L2NetworkVLANMgr()
|
||||||
self.plugin_key = "quantum.plugins.cisco.ucs.cisco_ucs_plugin" +\
|
self.plugin_key = (
|
||||||
".UCSVICPlugin"
|
"quantum.plugins.cisco.ucs.cisco_ucs_plugin.UCSVICPlugin")
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
db.clear_db()
|
db.clear_db()
|
||||||
@ -60,7 +59,7 @@ class Test_L2Network_Vlan_Mgr(unittest.TestCase):
|
|||||||
LOG.debug("test_reserve_segmentation_id - START")
|
LOG.debug("test_reserve_segmentation_id - START")
|
||||||
db.network_create(self.tenant_id, self.net_name)
|
db.network_create(self.tenant_id, self.net_name)
|
||||||
vlan_id = self.vlan_mgr.reserve_segmentation_id(self.tenant_id,
|
vlan_id = self.vlan_mgr.reserve_segmentation_id(self.tenant_id,
|
||||||
self.net_name)
|
self.net_name)
|
||||||
self.assertEqual(vlan_id, int(conf.VLAN_START))
|
self.assertEqual(vlan_id, int(conf.VLAN_START))
|
||||||
LOG.debug("test_reserve_segmentation_id - END")
|
LOG.debug("test_reserve_segmentation_id - END")
|
||||||
|
|
||||||
@ -77,10 +76,10 @@ class Test_L2Network_Vlan_Mgr(unittest.TestCase):
|
|||||||
LOG.debug("test_release_segmentation_id - START")
|
LOG.debug("test_release_segmentation_id - START")
|
||||||
db.network_create(self.tenant_id, self.net_name)
|
db.network_create(self.tenant_id, self.net_name)
|
||||||
vlan_id = self.vlan_mgr.reserve_segmentation_id(self.tenant_id,
|
vlan_id = self.vlan_mgr.reserve_segmentation_id(self.tenant_id,
|
||||||
self.net_name)
|
self.net_name)
|
||||||
cdb.add_vlan_binding(vlan_id, self.vlan_name, self.net_id)
|
cdb.add_vlan_binding(vlan_id, self.vlan_name, self.net_id)
|
||||||
release_return = self.vlan_mgr.release_segmentation_id(self.tenant_id,
|
release_return = self.vlan_mgr.release_segmentation_id(self.tenant_id,
|
||||||
self.net_id)
|
self.net_id)
|
||||||
self.assertEqual(release_return, False)
|
self.assertEqual(release_return, False)
|
||||||
LOG.debug("test_release_segmentation_id - END")
|
LOG.debug("test_release_segmentation_id - END")
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,4 +16,3 @@
|
|||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,7 +16,6 @@
|
|||||||
#
|
#
|
||||||
# @author: Rohit Agarwalla, Cisco Systems Inc.
|
# @author: Rohit Agarwalla, Cisco Systems Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@ -25,29 +23,29 @@ import subprocess
|
|||||||
def get_next_dynic(argv=[]):
|
def get_next_dynic(argv=[]):
|
||||||
"""Get the next available dynamic nic on this host"""
|
"""Get the next available dynamic nic on this host"""
|
||||||
cmd = ["ifconfig", "-a"]
|
cmd = ["ifconfig", "-a"]
|
||||||
f_cmd_output = subprocess.Popen(cmd, stdout=subprocess.PIPE).\
|
f_cmd_output = (
|
||||||
communicate()[0]
|
subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0])
|
||||||
eths = [lines.split(' ')[0] for lines in f_cmd_output.splitlines() \
|
eths = [lines.split(' ')[0] for lines in f_cmd_output.splitlines()
|
||||||
if "eth" in lines]
|
if "eth" in lines]
|
||||||
#print eths
|
#print eths
|
||||||
for eth in eths:
|
for eth in eths:
|
||||||
cmd = ["ethtool", "-i", eth]
|
cmd = ["ethtool", "-i", eth]
|
||||||
f_cmd_output = subprocess.Popen(cmd, stdout=subprocess.PIPE).\
|
f_cmd_output = (
|
||||||
communicate()[0]
|
subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0])
|
||||||
bdf = [lines.split(' ')[1] for lines in f_cmd_output.splitlines() \
|
bdf = [lines.split(' ')[1] for lines in f_cmd_output.splitlines()
|
||||||
if "bus-info" in lines]
|
if "bus-info" in lines]
|
||||||
#print bdf
|
#print bdf
|
||||||
cmd = ["lspci", "-n", "-s", bdf[0]]
|
cmd = ["lspci", "-n", "-s", bdf[0]]
|
||||||
f_cmd_output = subprocess.Popen(cmd, stdout=subprocess.PIPE).\
|
f_cmd_output = (subprocess.Popen(cmd, stdout=subprocess.PIPE).
|
||||||
communicate()[0]
|
communicate()[0])
|
||||||
deviceid = [(lines.split(':')[3]).split(' ')[0] \
|
deviceid = [(lines.split(':')[3]).split(' ')[0]
|
||||||
for lines in f_cmd_output.splitlines()]
|
for lines in f_cmd_output.splitlines()]
|
||||||
#print deviceid
|
#print deviceid
|
||||||
if deviceid[0] == "0044":
|
if deviceid[0] == "0044":
|
||||||
cmd = ["/sbin/ip", "link", "show", eth]
|
cmd = ["/sbin/ip", "link", "show", eth]
|
||||||
f_cmd_output = subprocess.Popen(cmd, stdout=subprocess.PIPE).\
|
f_cmd_output = (
|
||||||
communicate()[0]
|
subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0])
|
||||||
used = [lines for lines in f_cmd_output.splitlines() \
|
used = [lines for lines in f_cmd_output.splitlines()
|
||||||
if "UP" in lines]
|
if "UP" in lines]
|
||||||
if not used:
|
if not used:
|
||||||
break
|
break
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,14 +16,15 @@
|
|||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from quantum.common.config import find_config_file
|
from quantum.common.config import find_config_file
|
||||||
from quantum.plugins.cisco.common import cisco_configparser as confp
|
from quantum.plugins.cisco.common import cisco_configparser as confp
|
||||||
|
|
||||||
|
|
||||||
CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, [],
|
CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, [],
|
||||||
'ucs.ini'))
|
'ucs.ini'))
|
||||||
|
|
||||||
SECTION = CP['UCSM']
|
SECTION = CP['UCSM']
|
||||||
UCSM_IP_ADDRESS = SECTION['ip_address']
|
UCSM_IP_ADDRESS = SECTION['ip_address']
|
||||||
@ -37,6 +37,6 @@ SECTION = CP['DRIVER']
|
|||||||
UCSM_DRIVER = SECTION['name']
|
UCSM_DRIVER = SECTION['name']
|
||||||
|
|
||||||
CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, [],
|
CP = confp.CiscoConfigParser(find_config_file({'plugin': 'cisco'}, [],
|
||||||
'ucs_inventory.ini'))
|
'ucs_inventory.ini'))
|
||||||
|
|
||||||
INVENTORY = CP.walk(CP.dummy)
|
INVENTORY = CP.walk(CP.dummy)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,25 +15,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
from copy import deepcopy
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from quantum.common import exceptions as exc
|
|
||||||
from quantum.plugins.cisco.l2device_inventory_base \
|
|
||||||
import L2NetworkDeviceInventoryBase
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
|
||||||
from quantum.plugins.cisco.common import cisco_credentials as cred
|
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
|
||||||
from quantum.plugins.cisco.common import cisco_utils as cutil
|
|
||||||
from quantum.plugins.cisco.db import api as db
|
|
||||||
from quantum.plugins.cisco.db import ucs_db as udb
|
|
||||||
from quantum.plugins.cisco.ucs \
|
|
||||||
import cisco_ucs_inventory_configuration as conf
|
|
||||||
from quantum.plugins.cisco.ucs import cisco_ucs_network_driver
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
The _inventory data strcuture contains a nested disctioary:
|
The _inventory data strcuture contains a nested disctioary:
|
||||||
@ -80,6 +60,27 @@ const.INSTANCE_ID
|
|||||||
const.VIF_ID
|
const.VIF_ID
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from copy import deepcopy
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from quantum.common import exceptions as exc
|
||||||
|
from quantum.plugins.cisco.l2device_inventory_base import (
|
||||||
|
L2NetworkDeviceInventoryBase,
|
||||||
|
)
|
||||||
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
|
from quantum.plugins.cisco.common import cisco_credentials as cred
|
||||||
|
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
||||||
|
from quantum.plugins.cisco.common import cisco_utils as cutil
|
||||||
|
from quantum.plugins.cisco.db import api as db
|
||||||
|
from quantum.plugins.cisco.db import ucs_db as udb
|
||||||
|
from quantum.plugins.cisco.ucs import (
|
||||||
|
cisco_ucs_inventory_configuration as conf,
|
||||||
|
)
|
||||||
|
from quantum.plugins.cisco.ucs import cisco_ucs_network_driver
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class UCSInventory(L2NetworkDeviceInventoryBase):
|
class UCSInventory(L2NetworkDeviceInventoryBase):
|
||||||
"""
|
"""
|
||||||
@ -110,10 +111,10 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
inventory[ucsm][chassis].pop(const.CHASSIS_ID)
|
inventory[ucsm][chassis].pop(const.CHASSIS_ID)
|
||||||
blade_list = []
|
blade_list = []
|
||||||
for blade in inventory[ucsm][chassis].keys():
|
for blade in inventory[ucsm][chassis].keys():
|
||||||
blade_id = \
|
blade_id = (
|
||||||
inventory[ucsm][chassis][blade][const.BLADE_ID]
|
inventory[ucsm][chassis][blade][const.BLADE_ID])
|
||||||
host_name = \
|
host_name = (
|
||||||
inventory[ucsm][chassis][blade][const.HOST_NAME]
|
inventory[ucsm][chassis][blade][const.HOST_NAME])
|
||||||
host_key = ucsm_ip + "-" + chassis_id + "-" + blade_id
|
host_key = ucsm_ip + "-" + chassis_id + "-" + blade_id
|
||||||
self._host_names[host_key] = host_name
|
self._host_names[host_key] = host_name
|
||||||
blade_list.append(blade_id)
|
blade_list.append(blade_id)
|
||||||
@ -178,18 +179,18 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
if not const.VIF_ID in blade_intf_data[blade_intf].keys():
|
if not const.VIF_ID in blade_intf_data[blade_intf].keys():
|
||||||
blade_intf_data[blade_intf][const.VIF_ID] = None
|
blade_intf_data[blade_intf][const.VIF_ID] = None
|
||||||
|
|
||||||
if (blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] == \
|
if (blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] ==
|
||||||
const.BLADE_INTF_STATE_UNALLOCATED or \
|
const.BLADE_INTF_STATE_UNALLOCATED or
|
||||||
blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] == \
|
blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] ==
|
||||||
const.BLADE_INTF_STATE_UNKNOWN) and \
|
const.BLADE_INTF_STATE_UNKNOWN) and (
|
||||||
blade_intf_data[blade_intf][const.BLADE_INTF_OPER_STATE] == \
|
blade_intf_data[blade_intf][const.BLADE_INTF_OPER_STATE] ==
|
||||||
const.BLADE_INTF_STATE_UNKNOWN:
|
const.BLADE_INTF_STATE_UNKNOWN):
|
||||||
blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = \
|
blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = (
|
||||||
const.BLADE_INTF_UNRESERVED
|
const.BLADE_INTF_UNRESERVED)
|
||||||
unreserved_counter += 1
|
unreserved_counter += 1
|
||||||
else:
|
else:
|
||||||
blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = \
|
blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = (
|
||||||
const.BLADE_INTF_RESERVED
|
const.BLADE_INTF_RESERVED)
|
||||||
|
|
||||||
port_binding = udb.get_portbinding_dn(dist_name)
|
port_binding = udb.get_portbinding_dn(dist_name)
|
||||||
if port_binding:
|
if port_binding:
|
||||||
@ -198,21 +199,17 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
# need to change it, and also load the state from the DB for
|
# need to change it, and also load the state from the DB for
|
||||||
# other associations
|
# other associations
|
||||||
intf_data = blade_intf_data[blade_intf]
|
intf_data = blade_intf_data[blade_intf]
|
||||||
if intf_data[const.BLADE_INTF_RESERVATION] == \
|
if (intf_data[const.BLADE_INTF_RESERVATION] ==
|
||||||
const.BLADE_INTF_UNRESERVED:
|
const.BLADE_INTF_UNRESERVED):
|
||||||
unreserved_counter -= 1
|
unreserved_counter -= 1
|
||||||
intf_data[const.BLADE_INTF_RESERVATION] = \
|
intf_data[const.BLADE_INTF_RESERVATION] = (
|
||||||
const.BLADE_INTF_RESERVED
|
const.BLADE_INTF_RESERVED)
|
||||||
intf_data[const.TENANTID] = \
|
intf_data[const.TENANTID] = port_binding[const.TENANTID]
|
||||||
port_binding[const.TENANTID]
|
intf_data[const.PORTID] = port_binding[const.PORTID]
|
||||||
intf_data[const.PORTID] = \
|
intf_data[const.PROFILE_ID] = (
|
||||||
port_binding[const.PORTID]
|
port_binding[const.PORTPROFILENAME])
|
||||||
intf_data[const.PROFILE_ID] = \
|
intf_data[const.INSTANCE_ID] = port_binding[const.INSTANCE_ID]
|
||||||
port_binding[const.PORTPROFILENAME]
|
intf_data[const.VIF_ID] = port_binding[const.VIF_ID]
|
||||||
intf_data[const.INSTANCE_ID] = \
|
|
||||||
port_binding[const.INSTANCE_ID]
|
|
||||||
intf_data[const.VIF_ID] = \
|
|
||||||
port_binding[const.VIF_ID]
|
|
||||||
host_name = self._get_host_name(ucsm_ip, chassis_id, blade_id)
|
host_name = self._get_host_name(ucsm_ip, chassis_id, blade_id)
|
||||||
blade_data = {const.BLADE_INTF_DATA: blade_intf_data,
|
blade_data = {const.BLADE_INTF_DATA: blade_intf_data,
|
||||||
const.BLADE_UNRESERVED_INTF_COUNT: unreserved_counter,
|
const.BLADE_UNRESERVED_INTF_COUNT: unreserved_counter,
|
||||||
@ -220,7 +217,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
return blade_data
|
return blade_data
|
||||||
|
|
||||||
def _get_blade_state(self, chassis_id, blade_id, ucsm_ip,
|
def _get_blade_state(self, chassis_id, blade_id, ucsm_ip,
|
||||||
ucsm_username, ucsm_password):
|
ucsm_username, ucsm_password):
|
||||||
"""Get the blade state"""
|
"""Get the blade state"""
|
||||||
blade_intf_data = self._client.get_blade_data(chassis_id, blade_id,
|
blade_intf_data = self._client.get_blade_data(chassis_id, blade_id,
|
||||||
ucsm_ip, ucsm_username,
|
ucsm_ip, ucsm_username,
|
||||||
@ -228,21 +225,21 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
unreserved_counter = 0
|
unreserved_counter = 0
|
||||||
|
|
||||||
for blade_intf in blade_intf_data.keys():
|
for blade_intf in blade_intf_data.keys():
|
||||||
if (blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] == \
|
if (blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] ==
|
||||||
const.BLADE_INTF_STATE_UNALLOCATED or \
|
const.BLADE_INTF_STATE_UNALLOCATED or
|
||||||
blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] == \
|
blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] ==
|
||||||
const.BLADE_INTF_STATE_UNKNOWN) and \
|
const.BLADE_INTF_STATE_UNKNOWN) and (
|
||||||
blade_intf_data[blade_intf][const.BLADE_INTF_OPER_STATE] == \
|
blade_intf_data[blade_intf][const.BLADE_INTF_OPER_STATE] ==
|
||||||
const.BLADE_INTF_STATE_UNKNOWN:
|
const.BLADE_INTF_STATE_UNKNOWN):
|
||||||
blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = \
|
blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = (
|
||||||
const.BLADE_INTF_UNRESERVED
|
const.BLADE_INTF_UNRESERVED)
|
||||||
unreserved_counter += 1
|
unreserved_counter += 1
|
||||||
else:
|
else:
|
||||||
blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = \
|
blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = (
|
||||||
const.BLADE_INTF_RESERVED
|
const.BLADE_INTF_RESERVED)
|
||||||
|
|
||||||
blade_data = {const.BLADE_INTF_DATA: blade_intf_data,
|
blade_data = {const.BLADE_INTF_DATA: blade_intf_data,
|
||||||
const.BLADE_UNRESERVED_INTF_COUNT: unreserved_counter}
|
const.BLADE_UNRESERVED_INTF_COUNT: unreserved_counter}
|
||||||
return blade_data
|
return blade_data
|
||||||
|
|
||||||
def _get_all_ucsms(self):
|
def _get_all_ucsms(self):
|
||||||
@ -278,9 +275,9 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
tmp = deepcopy(blade_intf_data[blade_intf])
|
tmp = deepcopy(blade_intf_data[blade_intf])
|
||||||
intf_data = blade_intf_data[blade_intf]
|
intf_data = blade_intf_data[blade_intf]
|
||||||
if (intf_data[const.BLADE_INTF_RESERVATION] ==
|
if (intf_data[const.BLADE_INTF_RESERVATION] ==
|
||||||
const.BLADE_INTF_RESERVED and
|
const.BLADE_INTF_RESERVED and
|
||||||
intf_data[const.TENANTID] == tenant_id and
|
intf_data[const.TENANTID] == tenant_id and
|
||||||
intf_data[const.INSTANCE_ID] is None):
|
intf_data[const.INSTANCE_ID] is None):
|
||||||
intf_data[const.INSTANCE_ID] = instance_id
|
intf_data[const.INSTANCE_ID] = instance_id
|
||||||
host_name = self._get_host_name(ucsm_ip,
|
host_name = self._get_host_name(ucsm_ip,
|
||||||
chassis_id,
|
chassis_id,
|
||||||
@ -307,40 +304,40 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
blade_intf_data = blade_data[const.BLADE_INTF_DATA]
|
blade_intf_data = blade_data[const.BLADE_INTF_DATA]
|
||||||
for blade_intf in blade_intf_data.keys():
|
for blade_intf in blade_intf_data.keys():
|
||||||
intf_data = blade_intf_data[blade_intf]
|
intf_data = blade_intf_data[blade_intf]
|
||||||
if intf_data[const.BLADE_INTF_RESERVATION] == \
|
if (intf_data[const.BLADE_INTF_RESERVATION] ==
|
||||||
const.BLADE_INTF_RESERVED and \
|
const.BLADE_INTF_RESERVED and
|
||||||
intf_data[const.TENANTID] == tenant_id and \
|
intf_data[const.TENANTID] == tenant_id and
|
||||||
intf_data[const.INSTANCE_ID] == instance_id:
|
intf_data[const.INSTANCE_ID] == instance_id):
|
||||||
found_blade_intf_data = blade_intf_data
|
found_blade_intf_data = blade_intf_data
|
||||||
LOG.debug("Found blade %s associated with this" \
|
LOG.debug(("Found blade %s associated with this"
|
||||||
" instance: %s" % \
|
" instance: %s") % (blade_id,
|
||||||
(blade_id,
|
instance_id))
|
||||||
instance_id))
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if found_blade_intf_data:
|
if found_blade_intf_data:
|
||||||
blade_intf_data = found_blade_intf_data
|
blade_intf_data = found_blade_intf_data
|
||||||
for blade_intf in blade_intf_data.keys():
|
for blade_intf in blade_intf_data.keys():
|
||||||
intf_data = blade_intf_data[blade_intf]
|
intf_data = blade_intf_data[blade_intf]
|
||||||
if intf_data[const.BLADE_INTF_RESERVATION] == \
|
if (intf_data[const.BLADE_INTF_RESERVATION] ==
|
||||||
const.BLADE_INTF_RESERVED and \
|
const.BLADE_INTF_RESERVED and
|
||||||
intf_data[const.TENANTID] == tenant_id and \
|
intf_data[const.TENANTID] == tenant_id and
|
||||||
(not intf_data[const.VIF_ID]):
|
(not intf_data[const.VIF_ID])):
|
||||||
intf_data[const.VIF_ID] = vif_id
|
intf_data[const.VIF_ID] = vif_id
|
||||||
intf_data[const.INSTANCE_ID] = instance_id
|
intf_data[const.INSTANCE_ID] = instance_id
|
||||||
port_binding = udb.get_portbinding_dn(blade_intf)
|
port_binding = udb.get_portbinding_dn(blade_intf)
|
||||||
port_id = port_binding[const.PORTID]
|
port_id = port_binding[const.PORTID]
|
||||||
udb.update_portbinding(port_id, instance_id=instance_id,
|
udb.update_portbinding(port_id, instance_id=instance_id,
|
||||||
vif_id=vif_id)
|
vif_id=vif_id)
|
||||||
db.port_set_attachment_by_id(port_id, vif_id +
|
db.port_set_attachment_by_id(port_id,
|
||||||
const.UNPLUGGED)
|
vif_id + const.UNPLUGGED)
|
||||||
device_name = intf_data[const.BLADE_INTF_RHEL_DEVICE_NAME]
|
device_name = intf_data[const.BLADE_INTF_RHEL_DEVICE_NAME]
|
||||||
profile_name = port_binding[const.PORTPROFILENAME]
|
profile_name = port_binding[const.PORTPROFILENAME]
|
||||||
dynamicnic_details = \
|
dynamicnic_details = {
|
||||||
{const.DEVICENAME: device_name,
|
const.DEVICENAME: device_name,
|
||||||
const.UCSPROFILE: profile_name}
|
const.UCSPROFILE: profile_name,
|
||||||
LOG.debug("Found reserved dynamic nic: %s" \
|
}
|
||||||
"associated with port %s" %
|
LOG.debug(("Found reserved dynamic nic: %s"
|
||||||
|
"associated with port %s") %
|
||||||
(intf_data, port_id))
|
(intf_data, port_id))
|
||||||
LOG.debug("Returning dynamic nic details: %s" %
|
LOG.debug("Returning dynamic nic details: %s" %
|
||||||
dynamicnic_details)
|
dynamicnic_details)
|
||||||
@ -363,13 +360,13 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
blade_intf_data = blade_data[const.BLADE_INTF_DATA]
|
blade_intf_data = blade_data[const.BLADE_INTF_DATA]
|
||||||
for blade_intf in blade_intf_data.keys():
|
for blade_intf in blade_intf_data.keys():
|
||||||
intf_data = blade_intf_data[blade_intf]
|
intf_data = blade_intf_data[blade_intf]
|
||||||
if intf_data[const.BLADE_INTF_RESERVATION] == \
|
if (intf_data[const.BLADE_INTF_RESERVATION] ==
|
||||||
const.BLADE_INTF_RESERVED and \
|
const.BLADE_INTF_RESERVED and
|
||||||
intf_data[const.TENANTID] == tenant_id and \
|
intf_data[const.TENANTID] == tenant_id and
|
||||||
blade_intf_data[blade_intf][const.INSTANCE_ID] == \
|
blade_intf_data[blade_intf][const.INSTANCE_ID]
|
||||||
instance_id and \
|
== instance_id and
|
||||||
intf_data[const.VIF_ID][:const.UUID_LENGTH] == \
|
intf_data[const.VIF_ID][:const.UUID_LENGTH] ==
|
||||||
vif_id:
|
vif_id):
|
||||||
intf_data[const.VIF_ID] = None
|
intf_data[const.VIF_ID] = None
|
||||||
intf_data[const.INSTANCE_ID] = None
|
intf_data[const.INSTANCE_ID] = None
|
||||||
port_binding = udb.get_portbinding_dn(blade_intf)
|
port_binding = udb.get_portbinding_dn(blade_intf)
|
||||||
@ -377,15 +374,16 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
udb.update_portbinding(port_id, instance_id=None,
|
udb.update_portbinding(port_id, instance_id=None,
|
||||||
vif_id=None)
|
vif_id=None)
|
||||||
db.port_unset_attachment_by_id(port_id)
|
db.port_unset_attachment_by_id(port_id)
|
||||||
LOG.debug("Disassociated VIF-ID: %s " \
|
LOG.debug(
|
||||||
"from port: %s" \
|
("Disassociated VIF-ID: %s "
|
||||||
"in UCS inventory state for blade: %s" %
|
"from port: %s"
|
||||||
(vif_id, port_id, intf_data))
|
"in UCS inventory state for blade: %s") %
|
||||||
|
(vif_id, port_id, intf_data))
|
||||||
device_params = {const.DEVICE_IP: [ucsm_ip],
|
device_params = {const.DEVICE_IP: [ucsm_ip],
|
||||||
const.PORTID: port_id}
|
const.PORTID: port_id}
|
||||||
return device_params
|
return device_params
|
||||||
LOG.warn("Disassociating VIF-ID in UCS inventory failed. " \
|
LOG.warn(("Disassociating VIF-ID in UCS inventory failed. "
|
||||||
"Could not find a reserved dynamic nic for tenant: %s" %
|
"Could not find a reserved dynamic nic for tenant: %s") %
|
||||||
tenant_id)
|
tenant_id)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -401,14 +399,14 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
blade_data = ucsm[chassis_id][blade_id]
|
blade_data = ucsm[chassis_id][blade_id]
|
||||||
blade_intf_data = blade_data[const.BLADE_INTF_DATA]
|
blade_intf_data = blade_data[const.BLADE_INTF_DATA]
|
||||||
for blade_intf in blade_intf_data.keys():
|
for blade_intf in blade_intf_data.keys():
|
||||||
if not blade_intf_data[blade_intf][const.PORTID] or \
|
if (not blade_intf_data[blade_intf][const.PORTID] or
|
||||||
not blade_intf_data[blade_intf][const.TENANTID]:
|
not blade_intf_data[blade_intf][const.TENANTID]):
|
||||||
continue
|
continue
|
||||||
intf_data = blade_intf_data[blade_intf]
|
intf_data = blade_intf_data[blade_intf]
|
||||||
if intf_data[const.BLADE_INTF_RESERVATION] == \
|
if (intf_data[const.BLADE_INTF_RESERVATION] ==
|
||||||
const.BLADE_INTF_RESERVED and \
|
const.BLADE_INTF_RESERVED and
|
||||||
intf_data[const.TENANTID] == tenant_id and \
|
intf_data[const.TENANTID] == tenant_id and
|
||||||
intf_data[const.PORTID] == port_id:
|
intf_data[const.PORTID] == port_id):
|
||||||
interface_dn = intf_data[const.BLADE_INTF_DN]
|
interface_dn = intf_data[const.BLADE_INTF_DN]
|
||||||
blade_intf_info = {const.UCSM_IP: ucsm_ip,
|
blade_intf_info = {const.UCSM_IP: ucsm_ip,
|
||||||
const.CHASSIS_ID: chassis_id,
|
const.CHASSIS_ID: chassis_id,
|
||||||
@ -433,26 +431,27 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
for chassis_id in ucsm.keys():
|
for chassis_id in ucsm.keys():
|
||||||
for blade_id in ucsm[chassis_id]:
|
for blade_id in ucsm[chassis_id]:
|
||||||
blade_data = ucsm[chassis_id][blade_id]
|
blade_data = ucsm[chassis_id][blade_id]
|
||||||
if blade_data[const.BLADE_UNRESERVED_INTF_COUNT] > \
|
if (blade_data[const.BLADE_UNRESERVED_INTF_COUNT] >
|
||||||
unreserved_interface_count:
|
unreserved_interface_count):
|
||||||
unreserved_interface_count = \
|
unreserved_interface_count = (
|
||||||
blade_data[const.BLADE_UNRESERVED_INTF_COUNT]
|
blade_data[const.BLADE_UNRESERVED_INTF_COUNT])
|
||||||
least_reserved_blade_ucsm = ucsm_ip
|
least_reserved_blade_ucsm = ucsm_ip
|
||||||
least_reserved_blade_chassis = chassis_id
|
least_reserved_blade_chassis = chassis_id
|
||||||
least_reserved_blade_id = blade_id
|
least_reserved_blade_id = blade_id
|
||||||
least_reserved_blade_data = blade_data
|
least_reserved_blade_data = blade_data
|
||||||
|
|
||||||
if unreserved_interface_count < intf_count:
|
if unreserved_interface_count < intf_count:
|
||||||
LOG.warn("Not enough dynamic nics available on a single host." \
|
LOG.warn(("Not enough dynamic nics available on a single host."
|
||||||
" Requested: %s, Maximum available: %s" %
|
" Requested: %s, Maximum available: %s") %
|
||||||
(intf_count, unreserved_interface_count))
|
(intf_count, unreserved_interface_count))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
least_reserved_blade_dict = \
|
least_reserved_blade_dict = {
|
||||||
{const.LEAST_RSVD_BLADE_UCSM: least_reserved_blade_ucsm,
|
const.LEAST_RSVD_BLADE_UCSM: least_reserved_blade_ucsm,
|
||||||
const.LEAST_RSVD_BLADE_CHASSIS: least_reserved_blade_chassis,
|
const.LEAST_RSVD_BLADE_CHASSIS: least_reserved_blade_chassis,
|
||||||
const.LEAST_RSVD_BLADE_ID: least_reserved_blade_id,
|
const.LEAST_RSVD_BLADE_ID: least_reserved_blade_id,
|
||||||
const.LEAST_RSVD_BLADE_DATA: least_reserved_blade_data}
|
const.LEAST_RSVD_BLADE_DATA: least_reserved_blade_data,
|
||||||
|
}
|
||||||
LOG.debug("Found dynamic nic %s available for reservation",
|
LOG.debug("Found dynamic nic %s available for reservation",
|
||||||
least_reserved_blade_dict)
|
least_reserved_blade_dict)
|
||||||
return least_reserved_blade_dict
|
return least_reserved_blade_dict
|
||||||
@ -474,8 +473,6 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
blade_data = self._get_blade_state(chassis_id, blade_id, ucsm_ip,
|
blade_data = self._get_blade_state(chassis_id, blade_id, ucsm_ip,
|
||||||
ucsm_username, ucsm_password)
|
ucsm_username, ucsm_password)
|
||||||
blade_intf_data = blade_data[const.BLADE_INTF_DATA]
|
blade_intf_data = blade_data[const.BLADE_INTF_DATA]
|
||||||
#import sys
|
|
||||||
#sys.exit(ucsm_ip)
|
|
||||||
chassis_data = self._inventory_state[ucsm_ip][chassis_id]
|
chassis_data = self._inventory_state[ucsm_ip][chassis_id]
|
||||||
old_blade_intf_data = chassis_data[blade_id][const.BLADE_INTF_DATA]
|
old_blade_intf_data = chassis_data[blade_id][const.BLADE_INTF_DATA]
|
||||||
|
|
||||||
@ -485,34 +482,32 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
"""
|
"""
|
||||||
for blade_intf in blade_intf_data.keys():
|
for blade_intf in blade_intf_data.keys():
|
||||||
old_intf_data = old_blade_intf_data[blade_intf]
|
old_intf_data = old_blade_intf_data[blade_intf]
|
||||||
blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = \
|
blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = (
|
||||||
old_intf_data[const.BLADE_INTF_RESERVATION]
|
old_intf_data[const.BLADE_INTF_RESERVATION])
|
||||||
blade_intf_data[blade_intf][const.TENANTID] = \
|
blade_intf_data[blade_intf][const.TENANTID] = (
|
||||||
old_intf_data[const.TENANTID]
|
old_intf_data[const.TENANTID])
|
||||||
blade_intf_data[blade_intf][const.PORTID] = \
|
blade_intf_data[blade_intf][const.PORTID] = (
|
||||||
old_intf_data[const.PORTID]
|
old_intf_data[const.PORTID])
|
||||||
blade_intf_data[blade_intf][const.PROFILE_ID] = \
|
blade_intf_data[blade_intf][const.PROFILE_ID] = (
|
||||||
old_intf_data[const.PROFILE_ID]
|
old_intf_data[const.PROFILE_ID])
|
||||||
blade_intf_data[blade_intf][const.INSTANCE_ID] = \
|
blade_intf_data[blade_intf][const.INSTANCE_ID] = (
|
||||||
old_intf_data[const.INSTANCE_ID]
|
old_intf_data[const.INSTANCE_ID])
|
||||||
blade_intf_data[blade_intf][const.VIF_ID] = \
|
blade_intf_data[blade_intf][const.VIF_ID] = (
|
||||||
old_intf_data[const.VIF_ID]
|
old_intf_data[const.VIF_ID])
|
||||||
|
|
||||||
blade_data[const.BLADE_UNRESERVED_INTF_COUNT] = \
|
blade_data[const.BLADE_UNRESERVED_INTF_COUNT] = (
|
||||||
chassis_data[blade_id][const.BLADE_UNRESERVED_INTF_COUNT]
|
chassis_data[blade_id][const.BLADE_UNRESERVED_INTF_COUNT])
|
||||||
"""
|
"""
|
||||||
Now we will reserve an interface if its available
|
Now we will reserve an interface if its available
|
||||||
"""
|
"""
|
||||||
for blade_intf in blade_intf_data.keys():
|
for blade_intf in blade_intf_data.keys():
|
||||||
intf_data = blade_intf_data[blade_intf]
|
intf_data = blade_intf_data[blade_intf]
|
||||||
if intf_data[const.BLADE_INTF_RESERVATION] == \
|
if (intf_data[const.BLADE_INTF_RESERVATION] ==
|
||||||
const.BLADE_INTF_UNRESERVED:
|
const.BLADE_INTF_UNRESERVED):
|
||||||
intf_data[const.BLADE_INTF_RESERVATION] = \
|
intf_data[const.BLADE_INTF_RESERVATION] = (
|
||||||
const.BLADE_INTF_RESERVED
|
const.BLADE_INTF_RESERVED)
|
||||||
intf_data[const.TENANTID] = tenant_id
|
intf_data[const.TENANTID] = tenant_id
|
||||||
intf_data[const.PORTID] = port_id
|
intf_data[const.PORTID] = port_id
|
||||||
#intf_data[const.PROFILE_ID] = \
|
|
||||||
# portprofile_name
|
|
||||||
intf_data[const.INSTANCE_ID] = None
|
intf_data[const.INSTANCE_ID] = None
|
||||||
dev_eth_name = intf_data[const.BLADE_INTF_RHEL_DEVICE_NAME]
|
dev_eth_name = intf_data[const.BLADE_INTF_RHEL_DEVICE_NAME]
|
||||||
"""
|
"""
|
||||||
@ -520,11 +515,12 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
"""
|
"""
|
||||||
chassis_data[blade_id][const.BLADE_INTF_DATA] = blade_intf_data
|
chassis_data[blade_id][const.BLADE_INTF_DATA] = blade_intf_data
|
||||||
chassis_data[blade_id][const.BLADE_UNRESERVED_INTF_COUNT] -= 1
|
chassis_data[blade_id][const.BLADE_UNRESERVED_INTF_COUNT] -= 1
|
||||||
host_name = self._get_host_name(ucsm_ip, chassis_id,
|
host_name = self._get_host_name(ucsm_ip, chassis_id, blade_id)
|
||||||
blade_id)
|
reserved_nic_dict = {
|
||||||
reserved_nic_dict = {const.RESERVED_NIC_HOSTNAME: host_name,
|
const.RESERVED_NIC_HOSTNAME: host_name,
|
||||||
const.RESERVED_NIC_NAME: dev_eth_name,
|
const.RESERVED_NIC_NAME: dev_eth_name,
|
||||||
const.BLADE_INTF_DN: blade_intf}
|
const.BLADE_INTF_DN: blade_intf,
|
||||||
|
}
|
||||||
port_binding = udb.add_portbinding(port_id, blade_intf, None,
|
port_binding = udb.add_portbinding(port_id, blade_intf, None,
|
||||||
None, None, None)
|
None, None, None)
|
||||||
udb.update_portbinding(port_id,
|
udb.update_portbinding(port_id,
|
||||||
@ -598,10 +594,11 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
if not least_reserved_blade_dict:
|
if not least_reserved_blade_dict:
|
||||||
raise cexc.NoMoreNics()
|
raise cexc.NoMoreNics()
|
||||||
ucsm_ip = least_reserved_blade_dict[const.LEAST_RSVD_BLADE_UCSM]
|
ucsm_ip = least_reserved_blade_dict[const.LEAST_RSVD_BLADE_UCSM]
|
||||||
device_params = {const.DEVICE_IP: [ucsm_ip],
|
device_params = {
|
||||||
const.UCS_INVENTORY: self,
|
const.DEVICE_IP: [ucsm_ip],
|
||||||
const.LEAST_RSVD_BLADE_DICT:\
|
const.UCS_INVENTORY: self,
|
||||||
least_reserved_blade_dict}
|
const.LEAST_RSVD_BLADE_DICT: least_reserved_blade_dict,
|
||||||
|
}
|
||||||
return device_params
|
return device_params
|
||||||
|
|
||||||
def delete_port(self, args):
|
def delete_port(self, args):
|
||||||
@ -618,12 +615,13 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
LOG.warn("UCSInventory: Port not found: net_id: %s, port_id: %s" %
|
LOG.warn("UCSInventory: Port not found: net_id: %s, port_id: %s" %
|
||||||
(net_id, port_id))
|
(net_id, port_id))
|
||||||
return {const.DEVICE_IP: []}
|
return {const.DEVICE_IP: []}
|
||||||
device_params = \
|
device_params = {
|
||||||
{const.DEVICE_IP: [rsvd_info[const.UCSM_IP]],
|
const.DEVICE_IP: [rsvd_info[const.UCSM_IP]],
|
||||||
const.UCS_INVENTORY: self,
|
const.UCS_INVENTORY: self,
|
||||||
const.CHASSIS_ID: rsvd_info[const.CHASSIS_ID],
|
const.CHASSIS_ID: rsvd_info[const.CHASSIS_ID],
|
||||||
const.BLADE_ID: rsvd_info[const.BLADE_ID],
|
const.BLADE_ID: rsvd_info[const.BLADE_ID],
|
||||||
const.BLADE_INTF_DN: rsvd_info[const.BLADE_INTF_DN]}
|
const.BLADE_INTF_DN: rsvd_info[const.BLADE_INTF_DN],
|
||||||
|
}
|
||||||
return device_params
|
return device_params
|
||||||
|
|
||||||
def update_port(self, args):
|
def update_port(self, args):
|
||||||
@ -707,8 +705,10 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
if not least_reserved_blade_dict:
|
if not least_reserved_blade_dict:
|
||||||
raise cexc.NoMoreNics()
|
raise cexc.NoMoreNics()
|
||||||
ucsm_ip = least_reserved_blade_dict[const.LEAST_RSVD_BLADE_UCSM]
|
ucsm_ip = least_reserved_blade_dict[const.LEAST_RSVD_BLADE_UCSM]
|
||||||
device_params = {const.DEVICE_IP: [ucsm_ip],
|
device_params = {
|
||||||
const.UCS_INVENTORY: self,
|
const.DEVICE_IP: [ucsm_ip],
|
||||||
const.LEAST_RSVD_BLADE_DICT:\
|
const.UCS_INVENTORY: self,
|
||||||
least_reserved_blade_dict}
|
const.LEAST_RSVD_BLADE_DICT:
|
||||||
|
least_reserved_blade_dict,
|
||||||
|
}
|
||||||
return device_params
|
return device_params
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,12 +16,13 @@
|
|||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from quantum.common.config import find_config_file
|
from quantum.common.config import find_config_file
|
||||||
from quantum.plugins.cisco.common import cisco_configparser as confp
|
from quantum.plugins.cisco.common import cisco_configparser as confp
|
||||||
|
|
||||||
|
|
||||||
CONF_FILE = find_config_file({'plugin': 'cisco'}, None, "ucs_inventory.ini")
|
CONF_FILE = find_config_file({'plugin': 'cisco'}, None, "ucs_inventory.ini")
|
||||||
CP = confp.CiscoConfigParser(CONF_FILE)
|
CP = confp.CiscoConfigParser(CONF_FILE)
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,7 +16,6 @@
|
|||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems Inc.
|
# @author: Sumit Naiksatam, Cisco Systems Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Implements a UCSM XML API Client
|
Implements a UCSM XML API Client
|
||||||
@ -27,12 +25,14 @@ import httplib
|
|||||||
import logging
|
import logging
|
||||||
from xml.etree import ElementTree as et
|
from xml.etree import ElementTree as et
|
||||||
|
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
|
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
||||||
from quantum.plugins.cisco.ucs import cisco_getvif as gvif
|
from quantum.plugins.cisco.ucs import cisco_getvif as gvif
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
COOKIE_VALUE = "cookie_placeholder"
|
COOKIE_VALUE = "cookie_placeholder"
|
||||||
PROFILE_NAME = "profilename_placeholder"
|
PROFILE_NAME = "profilename_placeholder"
|
||||||
PROFILE_CLIENT = "profileclient_placeholder"
|
PROFILE_CLIENT = "profileclient_placeholder"
|
||||||
@ -144,35 +144,25 @@ class CiscoUCSMDriver():
|
|||||||
def _post_data(self, ucsm_ip, ucsm_username, ucsm_password, data):
|
def _post_data(self, ucsm_ip, ucsm_username, ucsm_password, data):
|
||||||
"""Send command to UCSM in http request"""
|
"""Send command to UCSM in http request"""
|
||||||
conn = httplib.HTTPSConnection(ucsm_ip)
|
conn = httplib.HTTPSConnection(ucsm_ip)
|
||||||
login_data = "<aaaLogin inName=\"" + ucsm_username + \
|
login_data = ("<aaaLogin inName=\"" + ucsm_username +
|
||||||
"\" inPassword=\"" + ucsm_password + "\" />"
|
"\" inPassword=\"" + ucsm_password + "\" />")
|
||||||
conn.request(METHOD, URL, login_data, HEADERS)
|
conn.request(METHOD, URL, login_data, HEADERS)
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
response_data = response.read()
|
response_data = response.read()
|
||||||
#LOG.debug(response.status)
|
|
||||||
#LOG.debug(response.reason)
|
|
||||||
#LOG.debug(response_data)
|
|
||||||
# TODO (Sumit): If login is not successful, throw exception
|
# TODO (Sumit): If login is not successful, throw exception
|
||||||
xml_tree = et.XML(response_data)
|
xml_tree = et.XML(response_data)
|
||||||
cookie = xml_tree.attrib["outCookie"]
|
cookie = xml_tree.attrib["outCookie"]
|
||||||
|
|
||||||
data = data.replace(COOKIE_VALUE, cookie)
|
data = data.replace(COOKIE_VALUE, cookie)
|
||||||
#LOG.debug("POST: %s" % data)
|
|
||||||
conn.request(METHOD, URL, data, HEADERS)
|
conn.request(METHOD, URL, data, HEADERS)
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
response_data = response.read()
|
response_data = response.read()
|
||||||
#LOG.debug(response.status)
|
|
||||||
#LOG.debug(response.reason)
|
|
||||||
#LOG.debug("UCSM Response: %s" % response_data)
|
|
||||||
post_data_response = response_data
|
post_data_response = response_data
|
||||||
|
|
||||||
logout_data = "<aaaLogout inCookie=\"" + cookie + "\" />"
|
logout_data = "<aaaLogout inCookie=\"" + cookie + "\" />"
|
||||||
conn.request(METHOD, URL, logout_data, HEADERS)
|
conn.request(METHOD, URL, logout_data, HEADERS)
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
response_data = response.read()
|
response_data = response.read()
|
||||||
#LOG.debug(response.status)
|
|
||||||
#LOG.debug(response.reason)
|
|
||||||
#LOG.debug(response_data)
|
|
||||||
return post_data_response
|
return post_data_response
|
||||||
|
|
||||||
def _create_vlan_post_data(self, vlan_name, vlan_id):
|
def _create_vlan_post_data(self, vlan_name, vlan_id):
|
||||||
@ -187,15 +177,14 @@ class CiscoUCSMDriver():
|
|||||||
data = data.replace(VLAN_NAME, vlan_name)
|
data = data.replace(VLAN_NAME, vlan_name)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _create_pclient_post_data(self, profile_name,
|
def _create_pclient_post_data(self, profile_name, profile_client_name):
|
||||||
profile_client_name):
|
|
||||||
"""Create command"""
|
"""Create command"""
|
||||||
data = ASSOCIATE_PROFILE.replace(PROFILE_NAME, profile_name)
|
data = ASSOCIATE_PROFILE.replace(PROFILE_NAME, profile_name)
|
||||||
data = data.replace(PROFILE_CLIENT, profile_client_name)
|
data = data.replace(PROFILE_CLIENT, profile_client_name)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _change_vlaninprof_post_data(self, profile_name, old_vlan_name,
|
def _change_vlaninprof_post_data(self, profile_name, old_vlan_name,
|
||||||
new_vlan_name):
|
new_vlan_name):
|
||||||
"""Create command"""
|
"""Create command"""
|
||||||
data = CHANGE_VLAN_IN_PROFILE.replace(PROFILE_NAME, profile_name)
|
data = CHANGE_VLAN_IN_PROFILE.replace(PROFILE_NAME, profile_name)
|
||||||
data = data.replace(OLD_VLAN_NAME, old_vlan_name)
|
data = data.replace(OLD_VLAN_NAME, old_vlan_name)
|
||||||
@ -229,20 +218,23 @@ class CiscoUCSMDriver():
|
|||||||
data = self._get_blade_interfaces_post_data(chassis_number,
|
data = self._get_blade_interfaces_post_data(chassis_number,
|
||||||
blade_number)
|
blade_number)
|
||||||
response = self._post_data(ucsm_ip, ucsm_username, ucsm_password, data)
|
response = self._post_data(ucsm_ip, ucsm_username, ucsm_password, data)
|
||||||
elements = \
|
elements = (
|
||||||
et.XML(response).find("outConfigs").findall("adaptorHostEthIf")
|
et.XML(response).find("outConfigs").findall("adaptorHostEthIf")
|
||||||
|
)
|
||||||
blade_interfaces = {}
|
blade_interfaces = {}
|
||||||
for element in elements:
|
for element in elements:
|
||||||
dist_name = element.get("dn", default=None)
|
dist_name = element.get("dn", default=None)
|
||||||
if dist_name:
|
if dist_name:
|
||||||
order = element.get("order", default=None)
|
order = element.get("order", default=None)
|
||||||
blade_interface = {const.BLADE_INTF_DN: dist_name,
|
blade_interface = {
|
||||||
const.BLADE_INTF_ORDER: order,
|
const.BLADE_INTF_DN: dist_name,
|
||||||
const.BLADE_INTF_LINK_STATE: None,
|
const.BLADE_INTF_ORDER: order,
|
||||||
const.BLADE_INTF_OPER_STATE: None,
|
const.BLADE_INTF_LINK_STATE: None,
|
||||||
const.BLADE_INTF_INST_TYPE: None,
|
const.BLADE_INTF_OPER_STATE: None,
|
||||||
const.BLADE_INTF_RHEL_DEVICE_NAME:
|
const.BLADE_INTF_INST_TYPE: None,
|
||||||
self._get_rhel_device_name(order)}
|
const.BLADE_INTF_RHEL_DEVICE_NAME:
|
||||||
|
self._get_rhel_device_name(order),
|
||||||
|
}
|
||||||
blade_interfaces[dist_name] = blade_interface
|
blade_interfaces[dist_name] = blade_interface
|
||||||
|
|
||||||
return blade_interfaces
|
return blade_interfaces
|
||||||
@ -250,18 +242,18 @@ class CiscoUCSMDriver():
|
|||||||
def _get_blade_interface_state(self, blade_intf, ucsm_ip,
|
def _get_blade_interface_state(self, blade_intf, ucsm_ip,
|
||||||
ucsm_username, ucsm_password):
|
ucsm_username, ucsm_password):
|
||||||
"""Create command"""
|
"""Create command"""
|
||||||
data = \
|
data = (
|
||||||
self._get_blade_intf_st_post_data(blade_intf[const.BLADE_INTF_DN])
|
self._get_blade_intf_st_post_data(blade_intf[const.BLADE_INTF_DN])
|
||||||
|
)
|
||||||
response = self._post_data(ucsm_ip, ucsm_username, ucsm_password, data)
|
response = self._post_data(ucsm_ip, ucsm_username, ucsm_password, data)
|
||||||
elements = \
|
elements = et.XML(response).find("outConfigs").findall("dcxVIf")
|
||||||
et.XML(response).find("outConfigs").findall("dcxVIf")
|
|
||||||
for element in elements:
|
for element in elements:
|
||||||
blade_intf[const.BLADE_INTF_LINK_STATE] = element.get("linkState",
|
blade_intf[const.BLADE_INTF_LINK_STATE] = element.get("linkState",
|
||||||
default=None)
|
default=None)
|
||||||
blade_intf[const.BLADE_INTF_OPER_STATE] = element.get("operState",
|
blade_intf[const.BLADE_INTF_OPER_STATE] = element.get("operState",
|
||||||
default=None)
|
default=None)
|
||||||
blade_intf[const.BLADE_INTF_INST_TYPE] = element.get("instType",
|
blade_intf[const.BLADE_INTF_INST_TYPE] = element.get("instType",
|
||||||
default=None)
|
default=None)
|
||||||
|
|
||||||
def _get_rhel_device_name(self, order):
|
def _get_rhel_device_name(self, order):
|
||||||
"""Get the device name as on the RHEL host"""
|
"""Get the device name as on the RHEL host"""
|
||||||
@ -279,8 +271,7 @@ class CiscoUCSMDriver():
|
|||||||
"""Create request for UCSM"""
|
"""Create request for UCSM"""
|
||||||
data = self._create_profile_post_data(profile_name, vlan_name)
|
data = self._create_profile_post_data(profile_name, vlan_name)
|
||||||
self._post_data(ucsm_ip, ucsm_username, ucsm_password, data)
|
self._post_data(ucsm_ip, ucsm_username, ucsm_password, data)
|
||||||
data = self._create_pclient_post_data(profile_name,
|
data = self._create_pclient_post_data(profile_name, profile_name[-16:])
|
||||||
profile_name[-16:])
|
|
||||||
self._post_data(ucsm_ip, ucsm_username, ucsm_password, data)
|
self._post_data(ucsm_ip, ucsm_username, ucsm_password, data)
|
||||||
|
|
||||||
def change_vlan_in_profile(self, profile_name, old_vlan_name,
|
def change_vlan_in_profile(self, profile_name, old_vlan_name,
|
||||||
@ -288,21 +279,20 @@ class CiscoUCSMDriver():
|
|||||||
ucsm_password):
|
ucsm_password):
|
||||||
"""Create request for UCSM"""
|
"""Create request for UCSM"""
|
||||||
data = self._change_vlaninprof_post_data(profile_name,
|
data = self._change_vlaninprof_post_data(profile_name,
|
||||||
old_vlan_name,
|
old_vlan_name,
|
||||||
new_vlan_name)
|
new_vlan_name)
|
||||||
self._post_data(ucsm_ip, ucsm_username, ucsm_password, data)
|
self._post_data(ucsm_ip, ucsm_username, ucsm_password, data)
|
||||||
|
|
||||||
def get_blade_data(self, chassis_number, blade_number,
|
def get_blade_data(self, chassis_number, blade_number, ucsm_ip,
|
||||||
ucsm_ip, ucsm_username,
|
ucsm_username, ucsm_password):
|
||||||
ucsm_password):
|
|
||||||
"""
|
"""
|
||||||
Returns only the dynamic interfaces on the blade
|
Returns only the dynamic interfaces on the blade
|
||||||
"""
|
"""
|
||||||
blade_interfaces = self._get_blade_interfaces(chassis_number,
|
blade_interfaces = self._get_blade_interfaces(chassis_number,
|
||||||
blade_number,
|
blade_number,
|
||||||
ucsm_ip,
|
ucsm_ip,
|
||||||
ucsm_username,
|
ucsm_username,
|
||||||
ucsm_password)
|
ucsm_password)
|
||||||
for blade_intf in blade_interfaces.keys():
|
for blade_intf in blade_interfaces.keys():
|
||||||
self._get_blade_interface_state(blade_interfaces[blade_intf],
|
self._get_blade_interface_state(blade_interfaces[blade_intf],
|
||||||
ucsm_ip, ucsm_username,
|
ucsm_ip, ucsm_username,
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2011 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,15 +16,14 @@
|
|||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
#
|
||||||
"""
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
from quantum.common import utils
|
from quantum.common import utils
|
||||||
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
|
||||||
from quantum.plugins.cisco.common import cisco_constants as const
|
from quantum.plugins.cisco.common import cisco_constants as const
|
||||||
from quantum.plugins.cisco.common import cisco_credentials as cred
|
from quantum.plugins.cisco.common import cisco_credentials as cred
|
||||||
|
from quantum.plugins.cisco.common import cisco_exceptions as cexc
|
||||||
from quantum.plugins.cisco.common import cisco_utils as cutil
|
from quantum.plugins.cisco.common import cisco_utils as cutil
|
||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
from quantum.plugins.cisco.db import l2network_db as cdb
|
from quantum.plugins.cisco.db import l2network_db as cdb
|
||||||
@ -33,6 +31,7 @@ from quantum.plugins.cisco.db import ucs_db as udb
|
|||||||
from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase
|
from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase
|
||||||
from quantum.plugins.cisco.ucs import cisco_ucs_configuration as conf
|
from quantum.plugins.cisco.ucs import cisco_ucs_configuration as conf
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -115,8 +114,8 @@ class UCSVICPlugin(L2DevicePluginBase):
|
|||||||
ports_on_net.append(new_port)
|
ports_on_net.append(new_port)
|
||||||
|
|
||||||
new_network = cutil.make_net_dict(network[const.UUID],
|
new_network = cutil.make_net_dict(network[const.UUID],
|
||||||
network[const.NETWORKNAME],
|
network[const.NETWORKNAME],
|
||||||
ports_on_net)
|
ports_on_net)
|
||||||
|
|
||||||
return new_network
|
return new_network
|
||||||
|
|
||||||
@ -166,16 +165,16 @@ class UCSVICPlugin(L2DevicePluginBase):
|
|||||||
conf.DEFAULT_VLAN_NAME,
|
conf.DEFAULT_VLAN_NAME,
|
||||||
conf.DEFAULT_VLAN_ID)
|
conf.DEFAULT_VLAN_ID)
|
||||||
profile_name = new_port_profile[const.PROFILE_NAME]
|
profile_name = new_port_profile[const.PROFILE_NAME]
|
||||||
rsvd_nic_dict = ucs_inventory.\
|
rsvd_nic_dict = ucs_inventory.reserve_blade_interface(
|
||||||
reserve_blade_interface(self._ucsm_ip, chassis_id,
|
self._ucsm_ip, chassis_id,
|
||||||
blade_id, blade_data_dict,
|
blade_id, blade_data_dict,
|
||||||
tenant_id, port_id,
|
tenant_id, port_id,
|
||||||
profile_name)
|
profile_name)
|
||||||
port_binding = udb.update_portbinding(port_id,
|
port_binding = udb.update_portbinding(port_id,
|
||||||
portprofile_name=profile_name,
|
portprofile_name=profile_name,
|
||||||
vlan_name=conf.DEFAULT_VLAN_NAME,
|
vlan_name=conf.DEFAULT_VLAN_NAME,
|
||||||
vlan_id=conf.DEFAULT_VLAN_ID,
|
vlan_id=conf.DEFAULT_VLAN_ID,
|
||||||
qos=qos)
|
qos=qos)
|
||||||
return port_binding
|
return port_binding
|
||||||
|
|
||||||
def delete_port(self, tenant_id, net_id, port_id, **kwargs):
|
def delete_port(self, tenant_id, net_id, port_id, **kwargs):
|
||||||
@ -269,21 +268,22 @@ class UCSVICPlugin(L2DevicePluginBase):
|
|||||||
blade_data_dict = least_rsvd_blade_dict[const.LEAST_RSVD_BLADE_DATA]
|
blade_data_dict = least_rsvd_blade_dict[const.LEAST_RSVD_BLADE_DATA]
|
||||||
port_binding_list = []
|
port_binding_list = []
|
||||||
for port_id, net_id in zip(port_id_list, net_id_list):
|
for port_id, net_id in zip(port_id_list, net_id_list):
|
||||||
new_port_profile = \
|
new_port_profile = self._create_port_profile(
|
||||||
self._create_port_profile(tenant_id, net_id, port_id,
|
tenant_id, net_id, port_id,
|
||||||
conf.DEFAULT_VLAN_NAME,
|
conf.DEFAULT_VLAN_NAME,
|
||||||
conf.DEFAULT_VLAN_ID)
|
conf.DEFAULT_VLAN_ID)
|
||||||
profile_name = new_port_profile[const.PROFILE_NAME]
|
profile_name = new_port_profile[const.PROFILE_NAME]
|
||||||
rsvd_nic_dict = ucs_inventory.\
|
rsvd_nic_dict = ucs_inventory.reserve_blade_interface(
|
||||||
reserve_blade_interface(self._ucsm_ip, chassis_id,
|
self._ucsm_ip, chassis_id,
|
||||||
blade_id, blade_data_dict,
|
blade_id, blade_data_dict,
|
||||||
tenant_id, port_id,
|
tenant_id, port_id,
|
||||||
profile_name)
|
profile_name)
|
||||||
port_binding = udb.update_portbinding(port_id,
|
port_binding = udb.update_portbinding(
|
||||||
portprofile_name=profile_name,
|
port_id,
|
||||||
vlan_name=conf.DEFAULT_VLAN_NAME,
|
portprofile_name=profile_name,
|
||||||
vlan_id=conf.DEFAULT_VLAN_ID,
|
vlan_name=conf.DEFAULT_VLAN_NAME,
|
||||||
qos=qos)
|
vlan_id=conf.DEFAULT_VLAN_ID,
|
||||||
|
qos=qos)
|
||||||
port_binding_list.append(port_binding)
|
port_binding_list.append(port_binding)
|
||||||
return port_binding_list
|
return port_binding_list
|
||||||
|
|
||||||
@ -298,8 +298,7 @@ class UCSVICPlugin(L2DevicePluginBase):
|
|||||||
|
|
||||||
def _get_profile_name(self, port_id):
|
def _get_profile_name(self, port_id):
|
||||||
"""Returns the port profile name based on the port UUID"""
|
"""Returns the port profile name based on the port UUID"""
|
||||||
profile_name = conf.PROFILE_NAME_PREFIX \
|
profile_name = conf.PROFILE_NAME_PREFIX + cutil.get16ByteUUID(port_id)
|
||||||
+ cutil.get16ByteUUID(port_id)
|
|
||||||
return profile_name
|
return profile_name
|
||||||
|
|
||||||
def _get_vlan_name_for_network(self, tenant_id, network_id):
|
def _get_vlan_name_for_network(self, tenant_id, network_id):
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2012, Cisco Systems, Inc.
|
# Copyright 2012, Cisco Systems, Inc.
|
||||||
@ -15,17 +14,16 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
"""
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from quantum.api.api_common import OperationalStatus
|
from quantum.api.api_common import OperationalStatus
|
||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
from quantum.db import api as db
|
from quantum.db import api as db
|
||||||
from quantum.plugins.linuxbridge import plugin_configuration as conf
|
|
||||||
from quantum.plugins.linuxbridge.common import constants as const
|
from quantum.plugins.linuxbridge.common import constants as const
|
||||||
from quantum.plugins.linuxbridge.common import utils as cutil
|
from quantum.plugins.linuxbridge.common import utils as cutil
|
||||||
from quantum.plugins.linuxbridge.db import l2network_db as cdb
|
from quantum.plugins.linuxbridge.db import l2network_db as cdb
|
||||||
|
from quantum.plugins.linuxbridge import plugin_configuration as conf
|
||||||
from quantum.quantum_plugin_base import QuantumPluginBase
|
from quantum.quantum_plugin_base import QuantumPluginBase
|
||||||
|
|
||||||
|
|
||||||
@ -111,10 +109,12 @@ class LinuxBridgePlugin(QuantumPluginBase):
|
|||||||
new_net_id = new_network[const.UUID]
|
new_net_id = new_network[const.UUID]
|
||||||
vlan_id = self._get_vlan_for_tenant(tenant_id)
|
vlan_id = self._get_vlan_for_tenant(tenant_id)
|
||||||
cdb.add_vlan_binding(vlan_id, new_net_id)
|
cdb.add_vlan_binding(vlan_id, new_net_id)
|
||||||
new_net_dict = {const.NET_ID: new_net_id,
|
new_net_dict = {
|
||||||
const.NET_NAME: net_name,
|
const.NET_ID: new_net_id,
|
||||||
const.NET_PORTS: [],
|
const.NET_NAME: net_name,
|
||||||
const.NET_OP_STATUS: new_network[const.OPSTATUS]}
|
const.NET_PORTS: [],
|
||||||
|
const.NET_OP_STATUS: new_network[const.OPSTATUS],
|
||||||
|
}
|
||||||
return new_net_dict
|
return new_net_dict
|
||||||
|
|
||||||
def delete_network(self, tenant_id, net_id):
|
def delete_network(self, tenant_id, net_id):
|
||||||
@ -197,7 +197,7 @@ class LinuxBridgePlugin(QuantumPluginBase):
|
|||||||
LOG.debug("LinuxBridgePlugin.create_port() called")
|
LOG.debug("LinuxBridgePlugin.create_port() called")
|
||||||
db.validate_network_ownership(tenant_id, net_id)
|
db.validate_network_ownership(tenant_id, net_id)
|
||||||
port = db.port_create(net_id, port_state,
|
port = db.port_create(net_id, port_state,
|
||||||
op_status=OperationalStatus.DOWN)
|
op_status=OperationalStatus.DOWN)
|
||||||
unique_port_id_string = port[const.UUID]
|
unique_port_id_string = port[const.UUID]
|
||||||
new_port_dict = cutil.make_port_dict(port)
|
new_port_dict = cutil.make_port_dict(port)
|
||||||
return new_port_dict
|
return new_port_dict
|
||||||
|
@ -21,21 +21,23 @@
|
|||||||
# Based on the structure of the OpenVSwitch agent in the
|
# Based on the structure of the OpenVSwitch agent in the
|
||||||
# Quantum OpenVSwitch Plugin.
|
# Quantum OpenVSwitch Plugin.
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
|
|
||||||
from optparse import OptionParser
|
|
||||||
from subprocess import *
|
|
||||||
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import logging as LOG
|
import logging
|
||||||
import MySQLdb
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import signal
|
import signal
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import MySQLdb
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
BRIDGE_NAME_PREFIX = "brq"
|
BRIDGE_NAME_PREFIX = "brq"
|
||||||
GATEWAY_INTERFACE_PREFIX = "gw-"
|
GATEWAY_INTERFACE_PREFIX = "gw-"
|
||||||
@ -62,7 +64,7 @@ class LinuxBridge:
|
|||||||
def run_cmd(self, args):
|
def run_cmd(self, args):
|
||||||
cmd = shlex.split(self.root_helper) + args
|
cmd = shlex.split(self.root_helper) + args
|
||||||
LOG.debug("Running command: " + " ".join(cmd))
|
LOG.debug("Running command: " + " ".join(cmd))
|
||||||
p = Popen(cmd, stdout=PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
retval = p.communicate()[0]
|
retval = p.communicate()[0]
|
||||||
if p.returncode == -(signal.SIGALRM):
|
if p.returncode == -(signal.SIGALRM):
|
||||||
LOG.debug("Timeout running command: " + " ".join(cmd))
|
LOG.debug("Timeout running command: " + " ".join(cmd))
|
||||||
@ -81,7 +83,7 @@ class LinuxBridge:
|
|||||||
def get_bridge_name(self, network_id):
|
def get_bridge_name(self, network_id):
|
||||||
if not network_id:
|
if not network_id:
|
||||||
LOG.warning("Invalid Network ID, will lead to incorrect bridge" \
|
LOG.warning("Invalid Network ID, will lead to incorrect bridge" \
|
||||||
"name")
|
"name")
|
||||||
bridge_name = self.br_name_prefix + network_id[0:11]
|
bridge_name = self.br_name_prefix + network_id[0:11]
|
||||||
return bridge_name
|
return bridge_name
|
||||||
|
|
||||||
@ -95,7 +97,7 @@ class LinuxBridge:
|
|||||||
def get_tap_device_name(self, interface_id):
|
def get_tap_device_name(self, interface_id):
|
||||||
if not interface_id:
|
if not interface_id:
|
||||||
LOG.warning("Invalid Interface ID, will lead to incorrect " \
|
LOG.warning("Invalid Interface ID, will lead to incorrect " \
|
||||||
"tap device name")
|
"tap device name")
|
||||||
tap_device_name = TAP_INTERFACE_PREFIX + interface_id[0:11]
|
tap_device_name = TAP_INTERFACE_PREFIX + interface_id[0:11]
|
||||||
return tap_device_name
|
return tap_device_name
|
||||||
|
|
||||||
@ -109,9 +111,8 @@ class LinuxBridge:
|
|||||||
|
|
||||||
def get_interfaces_on_bridge(self, bridge_name):
|
def get_interfaces_on_bridge(self, bridge_name):
|
||||||
if self.device_exists(bridge_name):
|
if self.device_exists(bridge_name):
|
||||||
bridge_interface_path = \
|
bridge_interface_path = BRIDGE_INTERFACES_FS.replace(
|
||||||
BRIDGE_INTERFACES_FS.replace(BRIDGE_NAME_PLACEHOLDER,
|
BRIDGE_NAME_PLACEHOLDER, bridge_name)
|
||||||
bridge_name)
|
|
||||||
return os.listdir(bridge_interface_path)
|
return os.listdir(bridge_interface_path)
|
||||||
|
|
||||||
def get_all_tap_devices(self):
|
def get_all_tap_devices(self):
|
||||||
@ -149,9 +150,8 @@ class LinuxBridge:
|
|||||||
if not device_name:
|
if not device_name:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
bridge_port_path = \
|
bridge_port_path = BRIDGE_PORT_FS_FOR_DEVICE.replace(
|
||||||
BRIDGE_PORT_FS_FOR_DEVICE.replace(DEVICE_NAME_PLACEHOLDER,
|
DEVICE_NAME_PLACEHOLDER, device_name)
|
||||||
device_name)
|
|
||||||
return os.path.exists(bridge_port_path)
|
return os.path.exists(bridge_port_path)
|
||||||
|
|
||||||
def ensure_vlan_bridge(self, network_id, vlan_id):
|
def ensure_vlan_bridge(self, network_id, vlan_id):
|
||||||
@ -183,7 +183,7 @@ class LinuxBridge:
|
|||||||
"""
|
"""
|
||||||
if not self.device_exists(bridge_name):
|
if not self.device_exists(bridge_name):
|
||||||
LOG.debug("Starting bridge %s for subinterface %s" % (bridge_name,
|
LOG.debug("Starting bridge %s for subinterface %s" % (bridge_name,
|
||||||
interface))
|
interface))
|
||||||
if self.run_cmd(['brctl', 'addbr', bridge_name]):
|
if self.run_cmd(['brctl', 'addbr', bridge_name]):
|
||||||
return
|
return
|
||||||
if self.run_cmd(['brctl', 'setfd', bridge_name, str(0)]):
|
if self.run_cmd(['brctl', 'setfd', bridge_name, str(0)]):
|
||||||
@ -210,8 +210,7 @@ class LinuxBridge:
|
|||||||
tap_device_name)
|
tap_device_name)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
current_bridge_name = \
|
current_bridge_name = self.get_bridge_for_tap_device(tap_device_name)
|
||||||
self.get_bridge_for_tap_device(tap_device_name)
|
|
||||||
bridge_name = self.get_bridge_name(network_id)
|
bridge_name = self.get_bridge_name(network_id)
|
||||||
if bridge_name == current_bridge_name:
|
if bridge_name == current_bridge_name:
|
||||||
return False
|
return False
|
||||||
@ -237,12 +236,10 @@ class LinuxBridge:
|
|||||||
"""
|
"""
|
||||||
return False
|
return False
|
||||||
if interface_id.startswith(GATEWAY_INTERFACE_PREFIX):
|
if interface_id.startswith(GATEWAY_INTERFACE_PREFIX):
|
||||||
return self.add_tap_interface(network_id, vlan_id,
|
return self.add_tap_interface(network_id, vlan_id, interface_id)
|
||||||
interface_id)
|
|
||||||
else:
|
else:
|
||||||
tap_device_name = self.get_tap_device_name(interface_id)
|
tap_device_name = self.get_tap_device_name(interface_id)
|
||||||
return self.add_tap_interface(network_id, vlan_id,
|
return self.add_tap_interface(network_id, vlan_id, tap_device_name)
|
||||||
tap_device_name)
|
|
||||||
|
|
||||||
def delete_vlan_bridge(self, bridge_name):
|
def delete_vlan_bridge(self, bridge_name):
|
||||||
if self.device_exists(bridge_name):
|
if self.device_exists(bridge_name):
|
||||||
@ -266,15 +263,15 @@ class LinuxBridge:
|
|||||||
if self.device_exists(bridge_name):
|
if self.device_exists(bridge_name):
|
||||||
if not self.is_device_on_bridge(interface_name):
|
if not self.is_device_on_bridge(interface_name):
|
||||||
return True
|
return True
|
||||||
LOG.debug("Removing device %s from bridge %s" % \
|
LOG.debug("Removing device %s from bridge %s" %
|
||||||
(interface_name, bridge_name))
|
(interface_name, bridge_name))
|
||||||
if self.run_cmd(['brctl', 'delif', bridge_name, interface_name]):
|
if self.run_cmd(['brctl', 'delif', bridge_name, interface_name]):
|
||||||
return False
|
return False
|
||||||
LOG.debug("Done removing device %s from bridge %s" % \
|
LOG.debug("Done removing device %s from bridge %s" %
|
||||||
(interface_name, bridge_name))
|
(interface_name, bridge_name))
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
LOG.debug("Cannot remove device %s, bridge %s does not exist" % \
|
LOG.debug("Cannot remove device %s, bridge %s does not exist" %
|
||||||
(interface_name, bridge_name))
|
(interface_name, bridge_name))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -327,16 +324,16 @@ class LinuxBridgeQuantumAgent:
|
|||||||
LOG.debug("plugged tap device names %s" % plugged_tap_device_names)
|
LOG.debug("plugged tap device names %s" % plugged_tap_device_names)
|
||||||
for tap_device in self.linux_br.get_all_tap_devices():
|
for tap_device in self.linux_br.get_all_tap_devices():
|
||||||
if tap_device not in plugged_tap_device_names:
|
if tap_device not in plugged_tap_device_names:
|
||||||
current_bridge_name = \
|
current_bridge_name = (
|
||||||
self.linux_br.get_bridge_for_tap_device(tap_device)
|
self.linux_br.get_bridge_for_tap_device(tap_device))
|
||||||
if current_bridge_name:
|
if current_bridge_name:
|
||||||
self.linux_br.remove_interface(current_bridge_name,
|
self.linux_br.remove_interface(current_bridge_name,
|
||||||
tap_device)
|
tap_device)
|
||||||
|
|
||||||
for gw_device in self.linux_br.get_all_gateway_devices():
|
for gw_device in self.linux_br.get_all_gateway_devices():
|
||||||
if gw_device not in plugged_gateway_device_names:
|
if gw_device not in plugged_gateway_device_names:
|
||||||
current_bridge_name = \
|
current_bridge_name = (
|
||||||
self.linux_br.get_bridge_for_tap_device(gw_device)
|
self.linux_br.get_bridge_for_tap_device(gw_device))
|
||||||
if current_bridge_name:
|
if current_bridge_name:
|
||||||
self.linux_br.remove_interface(current_bridge_name,
|
self.linux_br.remove_interface(current_bridge_name,
|
||||||
gw_device)
|
gw_device)
|
||||||
@ -378,15 +375,13 @@ class LinuxBridgeQuantumAgent:
|
|||||||
for pb in port_bindings:
|
for pb in port_bindings:
|
||||||
ports_string = "%s %s" % (ports_string, pb)
|
ports_string = "%s %s" % (ports_string, pb)
|
||||||
if pb['interface_id']:
|
if pb['interface_id']:
|
||||||
vlan_id = \
|
vlan_id = str(vlan_bindings[pb['network_id']]['vlan_id'])
|
||||||
str(vlan_bindings[pb['network_id']]['vlan_id'])
|
|
||||||
if self.process_port_binding(pb['uuid'],
|
if self.process_port_binding(pb['uuid'],
|
||||||
pb['network_id'],
|
pb['network_id'],
|
||||||
pb['interface_id'],
|
pb['interface_id'],
|
||||||
vlan_id):
|
vlan_id):
|
||||||
cursor = MySQLdb.cursors.DictCursor(conn)
|
cursor = MySQLdb.cursors.DictCursor(conn)
|
||||||
sql = PORT_OPSTATUS_UPDATESQL % (pb['uuid'],
|
sql = PORT_OPSTATUS_UPDATESQL % (pb['uuid'], OP_STATUS_UP)
|
||||||
OP_STATUS_UP)
|
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
cursor.close()
|
cursor.close()
|
||||||
plugged_interfaces.append(pb['interface_id'])
|
plugged_interfaces.append(pb['interface_id'])
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,5 +15,3 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,8 +15,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
from configobj import ConfigObj
|
from configobj import ConfigObj
|
||||||
|
|
||||||
@ -27,7 +24,7 @@ class ConfigParser(ConfigObj):
|
|||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
super(ConfigParser, self).__init__(filename, raise_errors=True,
|
super(ConfigParser, self).__init__(filename, raise_errors=True,
|
||||||
file_error=True)
|
file_error=True)
|
||||||
|
|
||||||
def dummy(self, section, key):
|
def dummy(self, section, key):
|
||||||
"""Dummy function to return the same key, used in walk"""
|
"""Dummy function to return the same key, used in walk"""
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,8 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
PORT_STATE = 'port-state'
|
PORT_STATE = 'port-state'
|
||||||
PORT_UP = "ACTIVE"
|
PORT_UP = "ACTIVE"
|
||||||
|
@ -20,24 +20,25 @@
|
|||||||
"""
|
"""
|
||||||
Exceptions used by the LinuxBridge plugin
|
Exceptions used by the LinuxBridge plugin
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from quantum.common import exceptions
|
from quantum.common import exceptions
|
||||||
|
|
||||||
|
|
||||||
class NetworksLimit(exceptions.QuantumException):
|
class NetworksLimit(exceptions.QuantumException):
|
||||||
"""Total number of network objects limit has been hit"""
|
"""Total number of network objects limit has been hit"""
|
||||||
message = _("Unable to create new network. Number of networks" \
|
message = _("Unable to create new network. Number of networks"
|
||||||
"for the system has exceeded the limit")
|
"for the system has exceeded the limit")
|
||||||
|
|
||||||
|
|
||||||
class NetworkVlanBindingAlreadyExists(exceptions.QuantumException):
|
class NetworkVlanBindingAlreadyExists(exceptions.QuantumException):
|
||||||
"""Binding cannot be created, since it already exists"""
|
"""Binding cannot be created, since it already exists"""
|
||||||
message = _("NetworkVlanBinding for %(vlan_id)s and network " \
|
message = _("NetworkVlanBinding for %(vlan_id)s and network "
|
||||||
"%(network_id)s already exists")
|
"%(network_id)s already exists")
|
||||||
|
|
||||||
|
|
||||||
class NetworkVlanBindingNotFound(exceptions.QuantumException):
|
class NetworkVlanBindingNotFound(exceptions.QuantumException):
|
||||||
"""Binding could not be found"""
|
"""Binding could not be found"""
|
||||||
message = _("NetworkVlanBinding for network " \
|
message = _("NetworkVlanBinding for network "
|
||||||
"%(network_id)s does not exist")
|
"%(network_id)s does not exist")
|
||||||
|
|
||||||
|
|
||||||
@ -53,20 +54,5 @@ class VlanIDNotAvailable(exceptions.QuantumException):
|
|||||||
|
|
||||||
class UnableToChangeVlanRange(exceptions.QuantumException):
|
class UnableToChangeVlanRange(exceptions.QuantumException):
|
||||||
"""No VLAN ID available"""
|
"""No VLAN ID available"""
|
||||||
message = _("Current VLAN ID range %(range_start)s to %(range_end)s " \
|
message = _("Current VLAN ID range %(range_start)s to %(range_end)s "
|
||||||
"cannot be changed. Please check plugin conf file.")
|
"cannot be changed. Please check plugin conf file.")
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
_("test")
|
|
||||||
except NameError:
|
|
||||||
|
|
||||||
def _(a_string):
|
|
||||||
"""
|
|
||||||
Default implementation of the gettext string
|
|
||||||
translation function: no translation
|
|
||||||
"""
|
|
||||||
return a_string
|
|
||||||
except TypeError:
|
|
||||||
# during doctesting, _ might mean something else
|
|
||||||
pass
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -16,21 +15,23 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
"""
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from quantum.api.api_common import OperationalStatus
|
from quantum.api.api_common import OperationalStatus
|
||||||
from quantum.plugins.linuxbridge.common import constants as const
|
from quantum.plugins.linuxbridge.common import constants as const
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def make_net_dict(net_id, net_name, ports, op_status):
|
def make_net_dict(net_id, net_name, ports, op_status):
|
||||||
"""Helper funciton"""
|
"""Helper funciton"""
|
||||||
res = {const.NET_ID: net_id, const.NET_NAME: net_name, const.NET_OP_STATUS:
|
res = {
|
||||||
op_status}
|
const.NET_ID: net_id,
|
||||||
|
const.NET_NAME: net_name,
|
||||||
|
const.NET_OP_STATUS: op_status,
|
||||||
|
}
|
||||||
if ports:
|
if ports:
|
||||||
res[const.NET_PORTS] = ports
|
res[const.NET_PORTS] = ports
|
||||||
return res
|
return res
|
||||||
@ -43,8 +44,10 @@ def make_port_dict(port):
|
|||||||
else:
|
else:
|
||||||
op_status = OperationalStatus.DOWN
|
op_status = OperationalStatus.DOWN
|
||||||
|
|
||||||
return {const.PORT_ID: str(port[const.UUID]),
|
return {
|
||||||
const.PORT_STATE: port[const.PORTSTATE],
|
const.PORT_ID: str(port[const.UUID]),
|
||||||
const.PORT_OP_STATUS: op_status,
|
const.PORT_STATE: port[const.PORTSTATE],
|
||||||
const.NET_ID: port[const.NETWORKID],
|
const.PORT_OP_STATUS: op_status,
|
||||||
const.ATTACHMENT: port[const.INTERFACEID]}
|
const.NET_ID: port[const.NETWORKID],
|
||||||
|
const.ATTACHMENT: port[const.INTERFACEID],
|
||||||
|
}
|
||||||
|
@ -15,17 +15,16 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
# @author: Rohit Agarwalla, Cisco Systems, Inc.
|
# @author: Rohit Agarwalla, Cisco Systems, Inc.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from sqlalchemy.orm import exc
|
from sqlalchemy.orm import exc
|
||||||
|
|
||||||
from quantum.common import exceptions as q_exc
|
from quantum.common import exceptions as q_exc
|
||||||
from quantum.plugins.linuxbridge import plugin_configuration as conf
|
import quantum.db.api as db
|
||||||
from quantum.plugins.linuxbridge.common import exceptions as c_exc
|
from quantum.plugins.linuxbridge.common import exceptions as c_exc
|
||||||
from quantum.plugins.linuxbridge.db import l2network_models
|
from quantum.plugins.linuxbridge.db import l2network_models
|
||||||
|
from quantum.plugins.linuxbridge import plugin_configuration as conf
|
||||||
import logging
|
|
||||||
|
|
||||||
import quantum.db.api as db
|
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -63,12 +62,12 @@ def create_vlanids():
|
|||||||
has to be supported.
|
has to be supported.
|
||||||
Per Dan's suggestion we just throw a server exception for now.
|
Per Dan's suggestion we just throw a server exception for now.
|
||||||
"""
|
"""
|
||||||
current_start = \
|
current_start = (
|
||||||
int(session.query(func.min(l2network_models.VlanID.vlan_id)).
|
int(session.query(func.min(l2network_models.VlanID.vlan_id)).
|
||||||
one()[0])
|
one()[0]))
|
||||||
current_end = \
|
current_end = (
|
||||||
int(session.query(func.max(l2network_models.VlanID.vlan_id)).
|
int(session.query(func.max(l2network_models.VlanID.vlan_id)).
|
||||||
one()[0])
|
one()[0]))
|
||||||
if current_start != start or current_end != end:
|
if current_start != start or current_end != end:
|
||||||
LOG.debug("Old VLAN range %s-%s" % (current_start, current_end))
|
LOG.debug("Old VLAN range %s-%s" % (current_start, current_end))
|
||||||
LOG.debug("New VLAN range %s-%s" % (start, end))
|
LOG.debug("New VLAN range %s-%s" % (start, end))
|
||||||
@ -89,8 +88,8 @@ def get_all_vlanids():
|
|||||||
LOG.debug("get_all_vlanids() called")
|
LOG.debug("get_all_vlanids() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
vlanids = session.query(l2network_models.VlanID).\
|
vlanids = (session.query(l2network_models.VlanID).
|
||||||
all()
|
all())
|
||||||
return vlanids
|
return vlanids
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -101,9 +100,9 @@ def is_vlanid_used(vlan_id):
|
|||||||
LOG.debug("is_vlanid_used() called")
|
LOG.debug("is_vlanid_used() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
vlanid = session.query(l2network_models.VlanID).\
|
vlanid = (session.query(l2network_models.VlanID).
|
||||||
filter_by(vlan_id=vlan_id).\
|
filter_by(vlan_id=vlan_id).
|
||||||
one()
|
one())
|
||||||
return vlanid["vlan_used"]
|
return vlanid["vlan_used"]
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.VlanIDNotFound(vlan_id=vlan_id)
|
raise c_exc.VlanIDNotFound(vlan_id=vlan_id)
|
||||||
@ -114,9 +113,9 @@ def release_vlanid(vlan_id):
|
|||||||
LOG.debug("release_vlanid() called")
|
LOG.debug("release_vlanid() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
vlanid = session.query(l2network_models.VlanID).\
|
vlanid = (session.query(l2network_models.VlanID).
|
||||||
filter_by(vlan_id=vlan_id).\
|
filter_by(vlan_id=vlan_id).
|
||||||
one()
|
one())
|
||||||
vlanid["vlan_used"] = False
|
vlanid["vlan_used"] = False
|
||||||
session.merge(vlanid)
|
session.merge(vlanid)
|
||||||
session.flush()
|
session.flush()
|
||||||
@ -131,9 +130,9 @@ def delete_vlanid(vlan_id):
|
|||||||
LOG.debug("delete_vlanid() called")
|
LOG.debug("delete_vlanid() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
vlanid = session.query(l2network_models.VlanID).\
|
vlanid = (session.query(l2network_models.VlanID).
|
||||||
filter_by(vlan_id=vlan_id).\
|
filter_by(vlan_id=vlan_id).
|
||||||
one()
|
one())
|
||||||
session.delete(vlanid)
|
session.delete(vlanid)
|
||||||
session.flush()
|
session.flush()
|
||||||
return vlanid
|
return vlanid
|
||||||
@ -146,20 +145,20 @@ def reserve_vlanid():
|
|||||||
LOG.debug("reserve_vlanid() called")
|
LOG.debug("reserve_vlanid() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
rvlan = session.query(l2network_models.VlanID).\
|
rvlan = (session.query(l2network_models.VlanID).
|
||||||
first()
|
first())
|
||||||
if not rvlan:
|
if not rvlan:
|
||||||
create_vlanids()
|
create_vlanids()
|
||||||
|
|
||||||
rvlan = session.query(l2network_models.VlanID).\
|
rvlan = (session.query(l2network_models.VlanID).
|
||||||
filter_by(vlan_used=False).\
|
filter_by(vlan_used=False).
|
||||||
first()
|
first())
|
||||||
if not rvlan:
|
if not rvlan:
|
||||||
raise c_exc.VlanIDNotAvailable()
|
raise c_exc.VlanIDNotAvailable()
|
||||||
|
|
||||||
rvlanid = session.query(l2network_models.VlanID).\
|
rvlanid = (session.query(l2network_models.VlanID).
|
||||||
filter_by(vlan_id=rvlan["vlan_id"]).\
|
filter_by(vlan_id=rvlan["vlan_id"]).
|
||||||
one()
|
one())
|
||||||
rvlanid["vlan_used"] = True
|
rvlanid["vlan_used"] = True
|
||||||
session.merge(rvlanid)
|
session.merge(rvlanid)
|
||||||
session.flush()
|
session.flush()
|
||||||
@ -173,9 +172,9 @@ def get_all_vlanids_used():
|
|||||||
LOG.debug("get_all_vlanids() called")
|
LOG.debug("get_all_vlanids() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
vlanids = session.query(l2network_models.VlanID).\
|
vlanids = (session.query(l2network_models.VlanID).
|
||||||
filter_by(vlan_used=True).\
|
filter_by(vlan_used=True).
|
||||||
all()
|
all())
|
||||||
return vlanids
|
return vlanids
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -186,8 +185,8 @@ def get_all_vlan_bindings():
|
|||||||
LOG.debug("get_all_vlan_bindings() called")
|
LOG.debug("get_all_vlan_bindings() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
bindings = session.query(l2network_models.VlanBinding).\
|
bindings = (session.query(l2network_models.VlanBinding).
|
||||||
all()
|
all())
|
||||||
return bindings
|
return bindings
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -198,9 +197,9 @@ def get_vlan_binding(netid):
|
|||||||
LOG.debug("get_vlan_binding() called")
|
LOG.debug("get_vlan_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(l2network_models.VlanBinding).\
|
binding = (session.query(l2network_models.VlanBinding).
|
||||||
filter_by(network_id=netid).\
|
filter_by(network_id=netid).
|
||||||
one()
|
one())
|
||||||
return binding
|
return binding
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.NetworkVlanBindingNotFound(network_id=netid)
|
raise c_exc.NetworkVlanBindingNotFound(network_id=netid)
|
||||||
@ -211,9 +210,9 @@ def add_vlan_binding(vlanid, netid):
|
|||||||
LOG.debug("add_vlan_binding() called")
|
LOG.debug("add_vlan_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(l2network_models.VlanBinding).\
|
binding = (session.query(l2network_models.VlanBinding).
|
||||||
filter_by(vlan_id=vlanid).\
|
filter_by(vlan_id=vlanid).
|
||||||
one()
|
one())
|
||||||
raise c_exc.NetworkVlanBindingAlreadyExists(vlan_id=vlanid,
|
raise c_exc.NetworkVlanBindingAlreadyExists(vlan_id=vlanid,
|
||||||
network_id=netid)
|
network_id=netid)
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
@ -228,9 +227,9 @@ def remove_vlan_binding(netid):
|
|||||||
LOG.debug("remove_vlan_binding() called")
|
LOG.debug("remove_vlan_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(l2network_models.VlanBinding).\
|
binding = (session.query(l2network_models.VlanBinding).
|
||||||
filter_by(network_id=netid).\
|
filter_by(network_id=netid).
|
||||||
one()
|
one())
|
||||||
session.delete(binding)
|
session.delete(binding)
|
||||||
session.flush()
|
session.flush()
|
||||||
return binding
|
return binding
|
||||||
@ -243,9 +242,9 @@ def update_vlan_binding(netid, newvlanid=None):
|
|||||||
LOG.debug("update_vlan_binding() called")
|
LOG.debug("update_vlan_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(l2network_models.VlanBinding).\
|
binding = (session.query(l2network_models.VlanBinding).
|
||||||
filter_by(network_id=netid).\
|
filter_by(network_id=netid).
|
||||||
one()
|
one())
|
||||||
if newvlanid:
|
if newvlanid:
|
||||||
binding["vlan_id"] = newvlanid
|
binding["vlan_id"] = newvlanid
|
||||||
session.merge(binding)
|
session.merge(binding)
|
||||||
|
@ -20,9 +20,9 @@ import uuid
|
|||||||
from sqlalchemy import Column, Integer, String, Boolean
|
from sqlalchemy import Column, Integer, String, Boolean
|
||||||
from sqlalchemy.orm import relation, object_mapper
|
from sqlalchemy.orm import relation, object_mapper
|
||||||
|
|
||||||
|
from quantum.db import models
|
||||||
from quantum.db.models import BASE
|
from quantum.db.models import BASE
|
||||||
from quantum.db.models import QuantumBase
|
from quantum.db.models import QuantumBase
|
||||||
from quantum.db import models
|
|
||||||
|
|
||||||
|
|
||||||
class VlanID(BASE, QuantumBase):
|
class VlanID(BASE, QuantumBase):
|
||||||
@ -37,8 +37,7 @@ class VlanID(BASE, QuantumBase):
|
|||||||
self.vlan_used = False
|
self.vlan_used = False
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<VlanID(%d,%s)>" % \
|
return "<VlanID(%d,%s)>" % (self.vlan_id, self.vlan_used)
|
||||||
(self.vlan_id, self.vlan_used)
|
|
||||||
|
|
||||||
|
|
||||||
class VlanBinding(BASE, QuantumBase):
|
class VlanBinding(BASE, QuantumBase):
|
||||||
@ -53,5 +52,4 @@ class VlanBinding(BASE, QuantumBase):
|
|||||||
self.network_id = network_id
|
self.network_id = network_id
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<VlanBinding(%d,%s,%s)>" % \
|
return "<VlanBinding(%d,%s,%s)>" % (self.vlan_id, self.network_id)
|
||||||
(self.vlan_id, self.network_id)
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
|
# Copyright 2012 Cisco Systems, Inc. All rights reserved.
|
||||||
@ -17,7 +16,6 @@
|
|||||||
#
|
#
|
||||||
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
# @author: Sumit Naiksatam, Cisco Systems, Inc.
|
||||||
# @author: Rohit Agarwalla, Cisco Systems, Inc.
|
# @author: Rohit Agarwalla, Cisco Systems, Inc.
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -25,11 +25,10 @@ To run all tests::
|
|||||||
PLUGIN_DIR=quantum/plugins/linuxbridge ./run_tests.sh
|
PLUGIN_DIR=quantum/plugins/linuxbridge ./run_tests.sh
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import gettext
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import unittest
|
|
||||||
import sys
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
from nose import config
|
from nose import config
|
||||||
from nose import core
|
from nose import core
|
||||||
|
@ -15,43 +15,43 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
# @author: Shweta Padubidri, Cisco Systems, Inc.
|
# @author: Shweta Padubidri, Cisco Systems, Inc.
|
||||||
#
|
|
||||||
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import logging as LOG
|
import logging
|
||||||
import unittest
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import signal
|
import signal
|
||||||
from subprocess import *
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
import quantum.plugins.linuxbridge.agent.linuxbridge_quantum_agent\
|
|
||||||
as linux_agent
|
|
||||||
from quantum.plugins.linuxbridge.common import constants as lconst
|
|
||||||
from quantum.plugins.linuxbridge import LinuxBridgePlugin
|
|
||||||
from quantum.plugins.linuxbridge.db import l2network_db as cdb
|
|
||||||
import quantum.db.api as db
|
import quantum.db.api as db
|
||||||
|
from quantum.plugins.linuxbridge import LinuxBridgePlugin
|
||||||
|
from quantum.plugins.linuxbridge.agent import (
|
||||||
|
linuxbridge_quantum_agent as linux_agent,
|
||||||
|
)
|
||||||
|
from quantum.plugins.linuxbridge.common import constants as lconst
|
||||||
|
from quantum.plugins.linuxbridge.db import l2network_db as cdb
|
||||||
|
|
||||||
|
|
||||||
LOG.getLogger(__name__)
|
LOG = logger.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class LinuxBridgeAgentTest(unittest.TestCase):
|
class LinuxBridgeAgentTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_add_gateway_interface(
|
def test_add_gateway_interface(
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
self, tenant_id="test_tenant", network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
||||||
mac_address='fe:16:3e:51:60:dd'):
|
mac_address='fe:16:3e:51:60:dd'):
|
||||||
|
|
||||||
LOG.debug("test_tap_gateway_interface - START")
|
LOG.debug("test_tap_gateway_interface - START")
|
||||||
new_network =\
|
new_network = (
|
||||||
self._linuxbridge_plugin.create_network(tenant_id, network_name)
|
self._linuxbridge_plugin.create_network(tenant_id, network_name))
|
||||||
new_port = self._linuxbridge_plugin.create_port(
|
new_port = self._linuxbridge_plugin.create_port(
|
||||||
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
||||||
self._linuxbridge_plugin.plug_interface(
|
self._linuxbridge_plugin.plug_interface(
|
||||||
tenant_id, new_network[lconst.NET_ID],
|
tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID], interface_id)
|
new_port[lconst.PORT_ID], interface_id)
|
||||||
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
||||||
self.create_bridge(bridge_name)
|
self.create_bridge(bridge_name)
|
||||||
device_name = self.gw_name_prefix + new_network[lconst.NET_ID][0:11]
|
device_name = self.gw_name_prefix + new_network[lconst.NET_ID][0:11]
|
||||||
@ -61,15 +61,15 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
vlan_id = vlan_bind[lconst.VLANID]
|
vlan_id = vlan_bind[lconst.VLANID]
|
||||||
|
|
||||||
self._linuxbridge_quantum_agent.process_port_binding(
|
self._linuxbridge_quantum_agent.process_port_binding(
|
||||||
new_port[lconst.PORT_ID], new_network[lconst.NET_ID],
|
new_port[lconst.PORT_ID], new_network[lconst.NET_ID],
|
||||||
device_name, str(vlan_id))
|
device_name, str(vlan_id))
|
||||||
list_interface = self._linuxbridge_quantum_agent.linux_br.\
|
list_interface = (self._linuxbridge_quantum_agent.linux_br.
|
||||||
get_interfaces_on_bridge(bridge_name)
|
get_interfaces_on_bridge(bridge_name))
|
||||||
|
|
||||||
self.assertTrue(device_name in list_interface)
|
self.assertTrue(device_name in list_interface)
|
||||||
for interface in list_interface:
|
for interface in list_interface:
|
||||||
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
||||||
bridge_name, interface)
|
bridge_name, interface)
|
||||||
self.delete_device(interface)
|
self.delete_device(interface)
|
||||||
self.delete_bridge(bridge_name)
|
self.delete_bridge(bridge_name)
|
||||||
self.tearDownUnplugInterface(tenant_id, new_network[lconst.NET_ID],
|
self.tearDownUnplugInterface(tenant_id, new_network[lconst.NET_ID],
|
||||||
@ -78,18 +78,18 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
LOG.debug("test_add_gateway_interface - END")
|
LOG.debug("test_add_gateway_interface - END")
|
||||||
|
|
||||||
def test_add_tap_interface(
|
def test_add_tap_interface(
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
self, tenant_id="test_tenant", network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
||||||
mac_address='fe:16:3e:51:60:dd'):
|
mac_address='fe:16:3e:51:60:dd'):
|
||||||
|
|
||||||
LOG.debug("test_add_tap_interface - START")
|
LOG.debug("test_add_tap_interface - START")
|
||||||
new_network =\
|
new_network = (
|
||||||
self._linuxbridge_plugin.create_network(tenant_id, network_name)
|
self._linuxbridge_plugin.create_network(tenant_id, network_name))
|
||||||
new_port = self._linuxbridge_plugin.create_port(
|
new_port = self._linuxbridge_plugin.create_port(
|
||||||
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
||||||
self._linuxbridge_plugin.plug_interface(
|
self._linuxbridge_plugin.plug_interface(
|
||||||
tenant_id, new_network[lconst.NET_ID],
|
tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID], interface_id)
|
new_port[lconst.PORT_ID], interface_id)
|
||||||
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
||||||
self.create_bridge(bridge_name)
|
self.create_bridge(bridge_name)
|
||||||
device_name = self.tap_name_prefix + interface_id[0:11]
|
device_name = self.tap_name_prefix + interface_id[0:11]
|
||||||
@ -99,15 +99,15 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
vlan_id = vlan_bind[lconst.VLANID]
|
vlan_id = vlan_bind[lconst.VLANID]
|
||||||
|
|
||||||
self._linuxbridge_quantum_agent.process_port_binding(
|
self._linuxbridge_quantum_agent.process_port_binding(
|
||||||
new_port[lconst.PORT_ID], new_network[lconst.NET_ID],
|
new_port[lconst.PORT_ID], new_network[lconst.NET_ID],
|
||||||
interface_id, str(vlan_id))
|
interface_id, str(vlan_id))
|
||||||
list_interface = self._linuxbridge_quantum_agent.linux_br.\
|
list_interface = (self._linuxbridge_quantum_agent.linux_br.
|
||||||
get_interfaces_on_bridge(bridge_name)
|
get_interfaces_on_bridge(bridge_name))
|
||||||
|
|
||||||
self.assertTrue(device_name in list_interface)
|
self.assertTrue(device_name in list_interface)
|
||||||
for interface in list_interface:
|
for interface in list_interface:
|
||||||
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
||||||
bridge_name, interface)
|
bridge_name, interface)
|
||||||
self.delete_device(interface)
|
self.delete_device(interface)
|
||||||
self.delete_bridge(bridge_name)
|
self.delete_bridge(bridge_name)
|
||||||
self.tearDownUnplugInterface(tenant_id, new_network[lconst.NET_ID],
|
self.tearDownUnplugInterface(tenant_id, new_network[lconst.NET_ID],
|
||||||
@ -121,13 +121,13 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
mac_address='fe:16:3e:51:60:dd'):
|
mac_address='fe:16:3e:51:60:dd'):
|
||||||
|
|
||||||
LOG.debug("test_remove_interface - START")
|
LOG.debug("test_remove_interface - START")
|
||||||
new_network =\
|
new_network = (
|
||||||
self._linuxbridge_plugin.create_network(tenant_id, network_name)
|
self._linuxbridge_plugin.create_network(tenant_id, network_name))
|
||||||
new_port = self._linuxbridge_plugin.create_port(
|
new_port = self._linuxbridge_plugin.create_port(
|
||||||
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
||||||
self._linuxbridge_plugin.plug_interface(
|
self._linuxbridge_plugin.plug_interface(
|
||||||
tenant_id, new_network[lconst.NET_ID],
|
tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID], interface_id)
|
new_port[lconst.PORT_ID], interface_id)
|
||||||
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
||||||
self.create_bridge(bridge_name)
|
self.create_bridge(bridge_name)
|
||||||
device_name = self.tap_name_prefix + interface_id[0:11]
|
device_name = self.tap_name_prefix + interface_id[0:11]
|
||||||
@ -137,19 +137,19 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
vlan_id = vlan_bind[lconst.VLANID]
|
vlan_id = vlan_bind[lconst.VLANID]
|
||||||
|
|
||||||
self._linuxbridge_quantum_agent.process_port_binding(
|
self._linuxbridge_quantum_agent.process_port_binding(
|
||||||
new_port[lconst.PORT_ID], new_network[lconst.NET_ID],
|
new_port[lconst.PORT_ID], new_network[lconst.NET_ID],
|
||||||
interface_id, str(vlan_id))
|
interface_id, str(vlan_id))
|
||||||
list_interface = self._linuxbridge_quantum_agent.linux_br.\
|
list_interface = (self._linuxbridge_quantum_agent.linux_br.
|
||||||
get_interfaces_on_bridge(bridge_name)
|
get_interfaces_on_bridge(bridge_name))
|
||||||
|
|
||||||
self._linuxbridge_quantum_agent.linux_br.remove_interface(bridge_name,
|
self._linuxbridge_quantum_agent.linux_br.remove_interface(bridge_name,
|
||||||
device_name)
|
device_name)
|
||||||
list_interface = self._linuxbridge_quantum_agent.linux_br.\
|
list_interface = (self._linuxbridge_quantum_agent.linux_br.
|
||||||
get_interfaces_on_bridge(bridge_name)
|
get_interfaces_on_bridge(bridge_name))
|
||||||
self.assertFalse(device_name in list_interface)
|
self.assertFalse(device_name in list_interface)
|
||||||
for interface in list_interface:
|
for interface in list_interface:
|
||||||
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
||||||
bridge_name, interface)
|
bridge_name, interface)
|
||||||
self.delete_device(interface)
|
self.delete_device(interface)
|
||||||
self.delete_device(device_name)
|
self.delete_device(device_name)
|
||||||
self.delete_bridge(bridge_name)
|
self.delete_bridge(bridge_name)
|
||||||
@ -159,34 +159,35 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
LOG.debug("test_remove_interface -END")
|
LOG.debug("test_remove_interface -END")
|
||||||
|
|
||||||
def test_ensure_vlan_bridge(
|
def test_ensure_vlan_bridge(
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
self, tenant_id="test_tenant",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
network_name="test_network",
|
||||||
|
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
||||||
|
|
||||||
LOG.debug("test_ensure_vlan_bridge - START")
|
LOG.debug("test_ensure_vlan_bridge - START")
|
||||||
new_network =\
|
new_network = (
|
||||||
self._linuxbridge_plugin.create_network(tenant_id, network_name)
|
self._linuxbridge_plugin.create_network(tenant_id, network_name))
|
||||||
new_port = self._linuxbridge_plugin.create_port(
|
new_port = self._linuxbridge_plugin.create_port(
|
||||||
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
||||||
self._linuxbridge_plugin.plug_interface(
|
self._linuxbridge_plugin.plug_interface(
|
||||||
tenant_id, new_network[lconst.NET_ID],
|
tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID], interface_id)
|
new_port[lconst.PORT_ID], interface_id)
|
||||||
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
||||||
vlan_bind = cdb.get_vlan_binding(new_network[lconst.NET_ID])
|
vlan_bind = cdb.get_vlan_binding(new_network[lconst.NET_ID])
|
||||||
vlan_id = vlan_bind[lconst.VLANID]
|
vlan_id = vlan_bind[lconst.VLANID]
|
||||||
vlan_subinterface = self.physical_interface + '.' + str(vlan_id)
|
vlan_subinterface = self.physical_interface + '.' + str(vlan_id)
|
||||||
|
|
||||||
self._linuxbridge_quantum_agent.linux_br.ensure_vlan_bridge(
|
self._linuxbridge_quantum_agent.linux_br.ensure_vlan_bridge(
|
||||||
new_network[lconst.NET_ID], str(vlan_id))
|
new_network[lconst.NET_ID], str(vlan_id))
|
||||||
list_quantum_bridges = self._linuxbridge_quantum_agent.linux_br.\
|
list_quantum_bridges = (self._linuxbridge_quantum_agent.linux_br.
|
||||||
get_all_quantum_bridges()
|
get_all_quantum_bridges())
|
||||||
self.assertTrue(bridge_name in list_quantum_bridges)
|
self.assertTrue(bridge_name in list_quantum_bridges)
|
||||||
list_interface = self._linuxbridge_quantum_agent.linux_br.\
|
list_interface = (self._linuxbridge_quantum_agent.linux_br.
|
||||||
get_interfaces_on_bridge(bridge_name)
|
get_interfaces_on_bridge(bridge_name))
|
||||||
self.assertTrue(vlan_subinterface in list_interface)
|
self.assertTrue(vlan_subinterface in list_interface)
|
||||||
|
|
||||||
for interface in list_interface:
|
for interface in list_interface:
|
||||||
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
||||||
bridge_name, interface)
|
bridge_name, interface)
|
||||||
self.delete_device(interface)
|
self.delete_device(interface)
|
||||||
self.delete_bridge(bridge_name)
|
self.delete_bridge(bridge_name)
|
||||||
self.tearDownUnplugInterface(tenant_id, new_network[lconst.NET_ID],
|
self.tearDownUnplugInterface(tenant_id, new_network[lconst.NET_ID],
|
||||||
@ -195,26 +196,26 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
LOG.debug("test_ensure_vlan_bridge -END")
|
LOG.debug("test_ensure_vlan_bridge -END")
|
||||||
|
|
||||||
def test_delete_vlan_bridge(
|
def test_delete_vlan_bridge(
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
self, tenant_id="test_tenant", network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
||||||
|
|
||||||
LOG.debug("test_delete_vlan_bridge - START")
|
LOG.debug("test_delete_vlan_bridge - START")
|
||||||
new_network =\
|
new_network = (
|
||||||
self._linuxbridge_plugin.create_network(tenant_id, network_name)
|
self._linuxbridge_plugin.create_network(tenant_id, network_name))
|
||||||
new_port = self._linuxbridge_plugin.create_port(
|
new_port = self._linuxbridge_plugin.create_port(
|
||||||
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
||||||
self._linuxbridge_plugin.plug_interface(
|
self._linuxbridge_plugin.plug_interface(
|
||||||
tenant_id, new_network[lconst.NET_ID],
|
tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID], interface_id)
|
new_port[lconst.PORT_ID], interface_id)
|
||||||
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
||||||
vlan_bind = cdb.get_vlan_binding(new_network[lconst.NET_ID])
|
vlan_bind = cdb.get_vlan_binding(new_network[lconst.NET_ID])
|
||||||
vlan_id = vlan_bind[lconst.VLANID]
|
vlan_id = vlan_bind[lconst.VLANID]
|
||||||
vlan_subinterface = self.physical_interface + '.' + str(vlan_id)
|
vlan_subinterface = self.physical_interface + '.' + str(vlan_id)
|
||||||
|
|
||||||
self._linuxbridge_quantum_agent.linux_br.ensure_vlan_bridge(
|
self._linuxbridge_quantum_agent.linux_br.ensure_vlan_bridge(
|
||||||
new_network[lconst.NET_ID], str(vlan_id))
|
new_network[lconst.NET_ID], str(vlan_id))
|
||||||
self._linuxbridge_quantum_agent.linux_br.delete_vlan_bridge(
|
self._linuxbridge_quantum_agent.linux_br.delete_vlan_bridge(
|
||||||
bridge_name)
|
bridge_name)
|
||||||
|
|
||||||
self.assertEquals(self.device_exists(vlan_subinterface), False)
|
self.assertEquals(self.device_exists(vlan_subinterface), False)
|
||||||
self.assertEquals(self.device_exists(bridge_name), False)
|
self.assertEquals(self.device_exists(bridge_name), False)
|
||||||
@ -224,26 +225,26 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
LOG.debug("test_delete_vlan_bridge - END")
|
LOG.debug("test_delete_vlan_bridge - END")
|
||||||
|
|
||||||
def test_process_deleted_networks(
|
def test_process_deleted_networks(
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
self, tenant_id="test_tenant", network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
||||||
|
|
||||||
LOG.debug("test_delete_vlan_bridge - START")
|
LOG.debug("test_delete_vlan_bridge - START")
|
||||||
new_network =\
|
new_network = (
|
||||||
self._linuxbridge_plugin.create_network(tenant_id, network_name)
|
self._linuxbridge_plugin.create_network(tenant_id, network_name))
|
||||||
new_port = self._linuxbridge_plugin.create_port(
|
new_port = self._linuxbridge_plugin.create_port(
|
||||||
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
||||||
self._linuxbridge_plugin.plug_interface(
|
self._linuxbridge_plugin.plug_interface(
|
||||||
tenant_id, new_network[lconst.NET_ID],
|
tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID], interface_id)
|
new_port[lconst.PORT_ID], interface_id)
|
||||||
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
||||||
vlan_bindings = {}
|
vlan_bindings = {}
|
||||||
vlan_bindings[new_network[lconst.NET_ID]] =\
|
vlan_bindings[new_network[lconst.NET_ID]] = (
|
||||||
cdb.get_vlan_binding(new_network[lconst.NET_ID])
|
cdb.get_vlan_binding(new_network[lconst.NET_ID]))
|
||||||
vlan_id = vlan_bindings[new_network[lconst.NET_ID]][lconst.VLANID]
|
vlan_id = vlan_bindings[new_network[lconst.NET_ID]][lconst.VLANID]
|
||||||
vlan_subinterface = self.physical_interface + '.' + str(vlan_id)
|
vlan_subinterface = self.physical_interface + '.' + str(vlan_id)
|
||||||
|
|
||||||
self._linuxbridge_quantum_agent.linux_br.ensure_vlan_bridge(
|
self._linuxbridge_quantum_agent.linux_br.ensure_vlan_bridge(
|
||||||
new_network[lconst.NET_ID], str(vlan_id))
|
new_network[lconst.NET_ID], str(vlan_id))
|
||||||
self.tearDownUnplugInterface(tenant_id, new_network[lconst.NET_ID],
|
self.tearDownUnplugInterface(tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID])
|
new_port[lconst.PORT_ID])
|
||||||
vlan_bindings = {}
|
vlan_bindings = {}
|
||||||
@ -254,18 +255,18 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
LOG.debug("test_delete_vlan_bridge - END")
|
LOG.debug("test_delete_vlan_bridge - END")
|
||||||
|
|
||||||
def test_process_unplugged_tap_interface(
|
def test_process_unplugged_tap_interface(
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
self, tenant_id="test_tenant", network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
||||||
mac_address='fe:16:3e:51:60:dd'):
|
mac_address='fe:16:3e:51:60:dd'):
|
||||||
|
|
||||||
LOG.debug("test_process_unplugged_tap_interface - START")
|
LOG.debug("test_process_unplugged_tap_interface - START")
|
||||||
new_network =\
|
new_network = (
|
||||||
self._linuxbridge_plugin.create_network(tenant_id, network_name)
|
self._linuxbridge_plugin.create_network(tenant_id, network_name))
|
||||||
new_port = self._linuxbridge_plugin.create_port(
|
new_port = self._linuxbridge_plugin.create_port(
|
||||||
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
||||||
self._linuxbridge_plugin.plug_interface(
|
self._linuxbridge_plugin.plug_interface(
|
||||||
tenant_id, new_network[lconst.NET_ID],
|
tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID], interface_id)
|
new_port[lconst.PORT_ID], interface_id)
|
||||||
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
||||||
self.create_bridge(bridge_name)
|
self.create_bridge(bridge_name)
|
||||||
device_name = self.tap_name_prefix + interface_id[0:11]
|
device_name = self.tap_name_prefix + interface_id[0:11]
|
||||||
@ -275,43 +276,43 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
vlan_id = vlan_bind[lconst.VLANID]
|
vlan_id = vlan_bind[lconst.VLANID]
|
||||||
|
|
||||||
self._linuxbridge_quantum_agent.process_port_binding(
|
self._linuxbridge_quantum_agent.process_port_binding(
|
||||||
new_port[lconst.PORT_ID], new_network[lconst.NET_ID],
|
new_port[lconst.PORT_ID], new_network[lconst.NET_ID],
|
||||||
interface_id, str(vlan_id))
|
interface_id, str(vlan_id))
|
||||||
list_interface = self._linuxbridge_quantum_agent.linux_br.\
|
list_interface = self._linuxbridge_quantum_agent.linux_br.\
|
||||||
get_interfaces_on_bridge(bridge_name)
|
get_interfaces_on_bridge(bridge_name)
|
||||||
self._linuxbridge_plugin.unplug_interface(tenant_id,
|
self._linuxbridge_plugin.unplug_interface(tenant_id,
|
||||||
new_network[lconst.NET_ID],
|
new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID])
|
new_port[lconst.PORT_ID])
|
||||||
plugged_interface = []
|
plugged_interface = []
|
||||||
self._linuxbridge_quantum_agent.process_unplugged_interfaces(
|
self._linuxbridge_quantum_agent.process_unplugged_interfaces(
|
||||||
plugged_interface)
|
plugged_interface)
|
||||||
list_interface = self._linuxbridge_quantum_agent.linux_br.\
|
list_interface = (self._linuxbridge_quantum_agent.linux_br.
|
||||||
get_interfaces_on_bridge(bridge_name)
|
get_interfaces_on_bridge(bridge_name))
|
||||||
self.assertFalse(device_name in list_interface)
|
self.assertFalse(device_name in list_interface)
|
||||||
for interface in list_interface:
|
for interface in list_interface:
|
||||||
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
||||||
bridge_name, interface)
|
bridge_name, interface)
|
||||||
self.delete_device(interface)
|
self.delete_device(interface)
|
||||||
self.delete_device(device_name)
|
self.delete_device(device_name)
|
||||||
self.delete_bridge(bridge_name)
|
self.delete_bridge(bridge_name)
|
||||||
self.tearDownNetworkPort(tenant_id, new_network[lconst.NET_ID],
|
self.tearDownNetworkPort(tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID])
|
new_port[lconst.PORT_ID])
|
||||||
|
|
||||||
LOG.debug("test_test_process_unplugged_tap_interface -END")
|
LOG.debug("test_test_process_unplugged_tap_interface -END")
|
||||||
|
|
||||||
def test_process_unplugged_gw_interface(
|
def test_process_unplugged_gw_interface(
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
self, tenant_id="test_tenant", network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
||||||
mac_address='fe:16:3e:51:60:dd'):
|
mac_address='fe:16:3e:51:60:dd'):
|
||||||
|
|
||||||
LOG.debug("test_process_unplugged_gw_interface - START")
|
LOG.debug("test_process_unplugged_gw_interface - START")
|
||||||
new_network =\
|
new_network = (
|
||||||
self._linuxbridge_plugin.create_network(tenant_id, network_name)
|
self._linuxbridge_plugin.create_network(tenant_id, network_name))
|
||||||
new_port = self._linuxbridge_plugin.create_port(
|
new_port = self._linuxbridge_plugin.create_port(
|
||||||
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
tenant_id, new_network[lconst.NET_ID], lconst.PORT_UP)
|
||||||
self._linuxbridge_plugin.plug_interface(
|
self._linuxbridge_plugin.plug_interface(
|
||||||
tenant_id, new_network[lconst.NET_ID],
|
tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID], interface_id)
|
new_port[lconst.PORT_ID], interface_id)
|
||||||
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
bridge_name = self.br_name_prefix + new_network[lconst.NET_ID][0:11]
|
||||||
self.create_bridge(bridge_name)
|
self.create_bridge(bridge_name)
|
||||||
device_name = self.gw_name_prefix + new_network[lconst.NET_ID][0:11]
|
device_name = self.gw_name_prefix + new_network[lconst.NET_ID][0:11]
|
||||||
@ -321,27 +322,27 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
vlan_id = vlan_bind[lconst.VLANID]
|
vlan_id = vlan_bind[lconst.VLANID]
|
||||||
|
|
||||||
self._linuxbridge_quantum_agent.process_port_binding(
|
self._linuxbridge_quantum_agent.process_port_binding(
|
||||||
new_port[lconst.PORT_ID], new_network[lconst.NET_ID],
|
new_port[lconst.PORT_ID], new_network[lconst.NET_ID],
|
||||||
interface_id, str(vlan_id))
|
interface_id, str(vlan_id))
|
||||||
list_interface = self._linuxbridge_quantum_agent.linux_br.\
|
list_interface = (self._linuxbridge_quantum_agent.linux_br.
|
||||||
get_interfaces_on_bridge(bridge_name)
|
get_interfaces_on_bridge(bridge_name))
|
||||||
self._linuxbridge_plugin.unplug_interface(tenant_id,
|
self._linuxbridge_plugin.unplug_interface(tenant_id,
|
||||||
new_network[lconst.NET_ID],
|
new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID])
|
new_port[lconst.PORT_ID])
|
||||||
plugged_interface = []
|
plugged_interface = []
|
||||||
self._linuxbridge_quantum_agent.process_unplugged_interfaces(
|
self._linuxbridge_quantum_agent.process_unplugged_interfaces(
|
||||||
plugged_interface)
|
plugged_interface)
|
||||||
list_interface = self._linuxbridge_quantum_agent.linux_br.\
|
list_interface = (self._linuxbridge_quantum_agent.linux_br.
|
||||||
get_interfaces_on_bridge(bridge_name)
|
get_interfaces_on_bridge(bridge_name))
|
||||||
self.assertFalse(device_name in list_interface)
|
self.assertFalse(device_name in list_interface)
|
||||||
for interface in list_interface:
|
for interface in list_interface:
|
||||||
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
self._linuxbridge_quantum_agent.linux_br.remove_interface(
|
||||||
bridge_name, interface)
|
bridge_name, interface)
|
||||||
self.delete_device(interface)
|
self.delete_device(interface)
|
||||||
self.delete_device(device_name)
|
self.delete_device(device_name)
|
||||||
self.delete_bridge(bridge_name)
|
self.delete_bridge(bridge_name)
|
||||||
self.tearDownNetworkPort(tenant_id, new_network[lconst.NET_ID],
|
self.tearDownNetworkPort(tenant_id, new_network[lconst.NET_ID],
|
||||||
new_port[lconst.PORT_ID])
|
new_port[lconst.PORT_ID])
|
||||||
|
|
||||||
LOG.debug("test_test_process_unplugged_gw_interface -END")
|
LOG.debug("test_test_process_unplugged_gw_interface -END")
|
||||||
|
|
||||||
@ -402,15 +403,15 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
self.physical_interface,
|
self.physical_interface,
|
||||||
self.root_helper)
|
self.root_helper)
|
||||||
self._linuxbridge_quantum_agent = linux_agent.LinuxBridgeQuantumAgent(
|
self._linuxbridge_quantum_agent = linux_agent.LinuxBridgeQuantumAgent(
|
||||||
self.br_name_prefix,
|
self.br_name_prefix,
|
||||||
self.physical_interface,
|
self.physical_interface,
|
||||||
self.polling_interval,
|
self.polling_interval,
|
||||||
self.root_helper)
|
self.root_helper)
|
||||||
|
|
||||||
def run_cmd(self, args):
|
def run_cmd(self, args):
|
||||||
cmd = shlex.split(self.root_helper) + args
|
cmd = shlex.split(self.root_helper) + args
|
||||||
LOG.debug("Running command: " + " ".join(cmd))
|
LOG.debug("Running command: " + " ".join(cmd))
|
||||||
p = Popen(cmd, stdout=PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
retval = p.communicate()[0]
|
retval = p.communicate()[0]
|
||||||
if p.returncode == -(signal.SIGALRM):
|
if p.returncode == -(signal.SIGALRM):
|
||||||
LOG.debug("Timeout running command: " + " ".join(args))
|
LOG.debug("Timeout running command: " + " ".join(args))
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
"""
|
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
#
|
#
|
||||||
# Copyright 2012, Cisco Systems, Inc.
|
# Copyright 2012, Cisco Systems, Inc.
|
||||||
@ -15,22 +14,21 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
# @author: Rohit Agarwalla, Cisco Systems, Inc.
|
# @author: Rohit Agarwalla, Cisco Systems, Inc.
|
||||||
"""
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
test_database.py is an independent test suite
|
test_database.py is an independent test suite
|
||||||
that tests the database api method calls
|
that tests the database api method calls
|
||||||
"""
|
"""
|
||||||
import logging as LOG
|
|
||||||
|
import logging
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from common import constants as const
|
|
||||||
|
|
||||||
import quantum.db.api as db
|
import quantum.db.api as db
|
||||||
import db.l2network_db as l2network_db
|
from quantum.plugins.linuxbridge.common import constants as const
|
||||||
|
import quantum.plugins.linuxbridge.db.l2network_db as l2network_db
|
||||||
|
|
||||||
|
|
||||||
LOG.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class L2networkDB(object):
|
class L2networkDB(object):
|
||||||
@ -42,7 +40,7 @@ class L2networkDB(object):
|
|||||||
try:
|
try:
|
||||||
for vlan_bind in l2network_db.get_all_vlan_bindings():
|
for vlan_bind in l2network_db.get_all_vlan_bindings():
|
||||||
LOG.debug("Getting vlan bindings for vlan: %s" %
|
LOG.debug("Getting vlan bindings for vlan: %s" %
|
||||||
vlan_bind.vlan_id)
|
vlan_bind.vlan_id)
|
||||||
vlan_dict = {}
|
vlan_dict = {}
|
||||||
vlan_dict["vlan-id"] = str(vlan_bind.vlan_id)
|
vlan_dict["vlan-id"] = str(vlan_bind.vlan_id)
|
||||||
vlan_dict["net-id"] = str(vlan_bind.network_id)
|
vlan_dict["net-id"] = str(vlan_bind.network_id)
|
||||||
@ -56,8 +54,8 @@ class L2networkDB(object):
|
|||||||
vlan = []
|
vlan = []
|
||||||
try:
|
try:
|
||||||
for vlan_bind in l2network_db.get_vlan_binding(network_id):
|
for vlan_bind in l2network_db.get_vlan_binding(network_id):
|
||||||
LOG.debug("Getting vlan binding for vlan: %s"
|
LOG.debug("Getting vlan binding for vlan: %s" %
|
||||||
% vlan_bind.vlan_id)
|
vlan_bind.vlan_id)
|
||||||
vlan_dict = {}
|
vlan_dict = {}
|
||||||
vlan_dict["vlan-id"] = str(vlan_bind.vlan_id)
|
vlan_dict["vlan-id"] = str(vlan_bind.vlan_id)
|
||||||
vlan_dict["net-id"] = str(vlan_bind.network_id)
|
vlan_dict["net-id"] = str(vlan_bind.network_id)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
'''
|
|
||||||
# Copyright 2012 Nicira Networks, Inc.
|
# Copyright 2012 Nicira Networks, Inc.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
@ -12,14 +11,18 @@
|
|||||||
# 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.
|
||||||
|
#
|
||||||
@author: Somik Behera, Nicira Networks, Inc.
|
#@author: Somik Behera, Nicira Networks, Inc.
|
||||||
'''
|
|
||||||
|
|
||||||
import httplib # basic HTTP library for HTTPS connections
|
import httplib # basic HTTP library for HTTPS connections
|
||||||
import logging
|
import logging
|
||||||
from api_client.client_eventlet import NvpApiClientEventlet
|
|
||||||
from api_client.request_eventlet import NvpGenericRequestEventlet
|
|
||||||
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.client_eventlet \
|
||||||
|
import NvpApiClientEventlet
|
||||||
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.request_eventlet \
|
||||||
|
import NvpGenericRequestEventlet
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger("NVPApiHelper")
|
LOG = logging.getLogger("NVPApiHelper")
|
||||||
LOG.setLevel(logging.INFO)
|
LOG.setLevel(logging.INFO)
|
||||||
@ -124,8 +127,9 @@ class NVPApiHelper(NvpApiClientEventlet):
|
|||||||
# Continue processing for non-error condition.
|
# Continue processing for non-error condition.
|
||||||
if (status != httplib.OK and status != httplib.CREATED
|
if (status != httplib.OK and status != httplib.CREATED
|
||||||
and status != httplib.NO_CONTENT):
|
and status != httplib.NO_CONTENT):
|
||||||
LOG.error("%s to %s, unexpected response code: %d (content = '%s')"
|
LOG.error(
|
||||||
% (method, url, response.status, response.body))
|
"%s to %s, unexpected response code: %d (content = '%s')" %
|
||||||
|
(method, url, response.status, response.body))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return response.body
|
return response.body
|
||||||
@ -145,14 +149,16 @@ class NVPApiHelper(NvpApiClientEventlet):
|
|||||||
def zero(self):
|
def zero(self):
|
||||||
raise NvpApiException()
|
raise NvpApiException()
|
||||||
|
|
||||||
error_codes = {404: fourZeroFour,
|
error_codes = {
|
||||||
409: fourZeroNine,
|
404: fourZeroFour,
|
||||||
503: fiveZeroThree,
|
409: fourZeroNine,
|
||||||
403: fourZeroThree,
|
503: fiveZeroThree,
|
||||||
301: zero,
|
403: fourZeroThree,
|
||||||
307: zero,
|
301: zero,
|
||||||
400: zero,
|
307: zero,
|
||||||
500: zero}
|
400: zero,
|
||||||
|
500: zero,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class NvpApiException(Exception):
|
class NvpApiException(Exception):
|
||||||
@ -191,13 +197,13 @@ class Conflict(NvpApiException):
|
|||||||
|
|
||||||
|
|
||||||
class ServiceUnavailable(NvpApiException):
|
class ServiceUnavailable(NvpApiException):
|
||||||
message = "Request could not completed because the associated " \
|
message = ("Request could not completed because the associated "
|
||||||
"resource could not be reached."
|
"resource could not be reached.")
|
||||||
|
|
||||||
|
|
||||||
class Forbidden(NvpApiException):
|
class Forbidden(NvpApiException):
|
||||||
message = "The request is forbidden from accessing the " \
|
message = ("The request is forbidden from accessing the "
|
||||||
"referenced resource."
|
"referenced resource.")
|
||||||
|
|
||||||
|
|
||||||
class RequestTimeout(NvpApiException):
|
class RequestTimeout(NvpApiException):
|
||||||
|
@ -17,19 +17,29 @@
|
|||||||
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import logging
|
import logging
|
||||||
import nvplib
|
|
||||||
import NvpApiClient
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from api_client.client_eventlet import DEFAULT_CONCURRENT_CONNECTIONS
|
import NvpApiClient
|
||||||
from api_client.client_eventlet import DEFAULT_FAILOVER_TIME
|
import nvplib
|
||||||
from api_client.request_eventlet import DEFAULT_REQUEST_TIMEOUT
|
|
||||||
from api_client.request_eventlet import DEFAULT_HTTP_TIMEOUT
|
|
||||||
from api_client.request_eventlet import DEFAULT_RETRIES
|
|
||||||
from api_client.request_eventlet import DEFAULT_REDIRECTS
|
|
||||||
|
|
||||||
from quantum.common import exceptions as exception
|
from quantum.common import exceptions as exception
|
||||||
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.client_eventlet \
|
||||||
|
import (
|
||||||
|
DEFAULT_CONCURRENT_CONNECTIONS,
|
||||||
|
DEFAULT_FAILOVER_TIME,
|
||||||
|
)
|
||||||
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.request_eventlet \
|
||||||
|
import (
|
||||||
|
DEFAULT_REQUEST_TIMEOUT,
|
||||||
|
DEFAULT_HTTP_TIMEOUT,
|
||||||
|
DEFAULT_RETRIES,
|
||||||
|
DEFAULT_REDIRECTS,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger("QuantumPlugin")
|
||||||
|
|
||||||
|
|
||||||
CONFIG_FILE = "nvp.ini"
|
CONFIG_FILE = "nvp.ini"
|
||||||
CONFIG_FILE_PATHS = []
|
CONFIG_FILE_PATHS = []
|
||||||
@ -38,7 +48,6 @@ if os.environ.get('QUANTUM_HOME', None):
|
|||||||
CONFIG_FILE_PATHS.append("/etc/quantum/plugins/nicira")
|
CONFIG_FILE_PATHS.append("/etc/quantum/plugins/nicira")
|
||||||
CONFIG_KEYS = ["DEFAULT_TZ_UUID", "NVP_CONTROLLER_IP", "PORT", "USER",
|
CONFIG_KEYS = ["DEFAULT_TZ_UUID", "NVP_CONTROLLER_IP", "PORT", "USER",
|
||||||
"PASSWORD"]
|
"PASSWORD"]
|
||||||
LOG = logging.getLogger("QuantumPlugin")
|
|
||||||
|
|
||||||
|
|
||||||
def initConfig(cfile=None):
|
def initConfig(cfile=None):
|
||||||
@ -50,8 +59,7 @@ def initConfig(cfile=None):
|
|||||||
cfile = find_config(os.path.abspath(os.path.dirname(__file__)))
|
cfile = find_config(os.path.abspath(os.path.dirname(__file__)))
|
||||||
|
|
||||||
if cfile == None:
|
if cfile == None:
|
||||||
raise Exception("Configuration file \"%s\" doesn't exist" %
|
raise Exception("Configuration file \"%s\" doesn't exist" % (cfile))
|
||||||
(cfile))
|
|
||||||
LOG.info("Using configuration file: %s" % cfile)
|
LOG.info("Using configuration file: %s" % cfile)
|
||||||
config.read(cfile)
|
config.read(cfile)
|
||||||
LOG.debug("Config: %s" % config)
|
LOG.debug("Config: %s" % config)
|
||||||
@ -71,7 +79,7 @@ def find_config(basepath):
|
|||||||
|
|
||||||
|
|
||||||
def parse_config(config):
|
def parse_config(config):
|
||||||
'''Backwards compatible parsing.
|
"""Backwards compatible parsing.
|
||||||
|
|
||||||
:param config: ConfigParser object initilized with nvp.ini.
|
:param config: ConfigParser object initilized with nvp.ini.
|
||||||
:returns: A tuple consisting of a control cluster object and a
|
:returns: A tuple consisting of a control cluster object and a
|
||||||
@ -81,7 +89,7 @@ def parse_config(config):
|
|||||||
At some point, error handling needs to be significantly
|
At some point, error handling needs to be significantly
|
||||||
enhanced to provide user friendly error messages, clean program
|
enhanced to provide user friendly error messages, clean program
|
||||||
exists, rather than exceptions propagated to the user.
|
exists, rather than exceptions propagated to the user.
|
||||||
'''
|
"""
|
||||||
# Extract plugin config parameters.
|
# Extract plugin config parameters.
|
||||||
try:
|
try:
|
||||||
failover_time = config.get('NVP', 'failover_time')
|
failover_time = config.get('NVP', 'failover_time')
|
||||||
@ -95,16 +103,15 @@ def parse_config(config):
|
|||||||
|
|
||||||
plugin_config = {
|
plugin_config = {
|
||||||
'failover_time': failover_time,
|
'failover_time': failover_time,
|
||||||
'concurrent_connections': concurrent_connections
|
'concurrent_connections': concurrent_connections,
|
||||||
}
|
}
|
||||||
LOG.info('parse_config(): plugin_config == "%s"' % plugin_config)
|
LOG.info('parse_config(): plugin_config == "%s"' % plugin_config)
|
||||||
|
|
||||||
cluster = NVPCluster('cluster1')
|
cluster = NVPCluster('cluster1')
|
||||||
|
|
||||||
# Extract connection information.
|
# Extract connection information.
|
||||||
try:
|
try:
|
||||||
defined_connections = config.get(
|
defined_connections = config.get('NVP', 'NVP_CONTROLLER_CONNECTIONS')
|
||||||
'NVP', 'NVP_CONTROLLER_CONNECTIONS')
|
|
||||||
|
|
||||||
for conn_key in defined_connections.split():
|
for conn_key in defined_connections.split():
|
||||||
args = [config.get('NVP', 'DEFAULT_TZ_UUID')]
|
args = [config.get('NVP', 'DEFAULT_TZ_UUID')]
|
||||||
@ -131,7 +138,7 @@ def parse_config(config):
|
|||||||
|
|
||||||
|
|
||||||
class NVPCluster(object):
|
class NVPCluster(object):
|
||||||
'''Encapsulates controller connection and api_client.
|
"""Encapsulates controller connection and api_client.
|
||||||
|
|
||||||
Initialized within parse_config().
|
Initialized within parse_config().
|
||||||
Accessed within the NvpPlugin class.
|
Accessed within the NvpPlugin class.
|
||||||
@ -142,7 +149,7 @@ class NVPCluster(object):
|
|||||||
|
|
||||||
There may be some redundancy here, but that has been done to provide
|
There may be some redundancy here, but that has been done to provide
|
||||||
future flexibility.
|
future flexibility.
|
||||||
'''
|
"""
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self._name = name
|
self._name = name
|
||||||
self.controllers = []
|
self.controllers = []
|
||||||
@ -162,7 +169,7 @@ class NVPCluster(object):
|
|||||||
request_timeout=DEFAULT_REQUEST_TIMEOUT,
|
request_timeout=DEFAULT_REQUEST_TIMEOUT,
|
||||||
http_timeout=DEFAULT_HTTP_TIMEOUT,
|
http_timeout=DEFAULT_HTTP_TIMEOUT,
|
||||||
retries=DEFAULT_RETRIES, redirects=DEFAULT_REDIRECTS):
|
retries=DEFAULT_RETRIES, redirects=DEFAULT_REDIRECTS):
|
||||||
'''Add a new set of controller parameters.
|
"""Add a new set of controller parameters.
|
||||||
|
|
||||||
:param ip: IP address of controller.
|
:param ip: IP address of controller.
|
||||||
:param port: port controller is listening on.
|
:param port: port controller is listening on.
|
||||||
@ -174,14 +181,12 @@ class NVPCluster(object):
|
|||||||
:param redirects: maximum number of server redirect responses to
|
:param redirects: maximum number of server redirect responses to
|
||||||
follow.
|
follow.
|
||||||
:param default_tz_uuid: default transport zone uuid.
|
:param default_tz_uuid: default transport zone uuid.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
keys = [
|
keys = ['ip', 'port', 'user', 'password', 'default_tz_uuid']
|
||||||
'ip', 'port', 'user', 'password', 'default_tz_uuid']
|
|
||||||
controller_dict = dict([(k, locals()[k]) for k in keys])
|
controller_dict = dict([(k, locals()[k]) for k in keys])
|
||||||
|
|
||||||
int_keys = [
|
int_keys = ['request_timeout', 'http_timeout', 'retries', 'redirects']
|
||||||
'request_timeout', 'http_timeout', 'retries', 'redirects']
|
|
||||||
for k in int_keys:
|
for k in int_keys:
|
||||||
controller_dict[k] = int(locals()[k])
|
controller_dict[k] = int(locals()[k])
|
||||||
|
|
||||||
@ -236,10 +241,10 @@ class NVPCluster(object):
|
|||||||
|
|
||||||
|
|
||||||
class NvpPlugin(object):
|
class NvpPlugin(object):
|
||||||
'''
|
"""
|
||||||
NvpPlugin is a Quantum plugin that provides L2 Virtual Network
|
NvpPlugin is a Quantum plugin that provides L2 Virtual Network
|
||||||
functionality using NVP.
|
functionality using NVP.
|
||||||
'''
|
"""
|
||||||
supported_extension_aliases = ["portstats"]
|
supported_extension_aliases = ["portstats"]
|
||||||
|
|
||||||
def __init__(self, configfile=None, loglevel=None, cli=False):
|
def __init__(self, configfile=None, loglevel=None, cli=False):
|
||||||
@ -251,8 +256,7 @@ class NvpPlugin(object):
|
|||||||
config = initConfig(configfile)
|
config = initConfig(configfile)
|
||||||
self.controller, self.plugin_config = parse_config(config)
|
self.controller, self.plugin_config = parse_config(config)
|
||||||
c = self.controller
|
c = self.controller
|
||||||
api_providers = [
|
api_providers = [(x['ip'], x['port'], True) for x in c.controllers]
|
||||||
(x['ip'], x['port'], True) for x in c.controllers]
|
|
||||||
|
|
||||||
c.api_client = NvpApiClient.NVPApiHelper(
|
c.api_client = NvpApiClient.NVPApiHelper(
|
||||||
api_providers, c.user, c.password,
|
api_providers, c.user, c.password,
|
||||||
@ -268,7 +272,7 @@ class NvpPlugin(object):
|
|||||||
self.api_client = self.controller.api_client
|
self.api_client = self.controller.api_client
|
||||||
|
|
||||||
def get_all_networks(self, tenant_id, **kwargs):
|
def get_all_networks(self, tenant_id, **kwargs):
|
||||||
'''
|
"""
|
||||||
Returns a dictionary containing all <network_uuid, network_name> for
|
Returns a dictionary containing all <network_uuid, network_name> for
|
||||||
the specified tenant.
|
the specified tenant.
|
||||||
|
|
||||||
@ -286,15 +290,14 @@ class NvpPlugin(object):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
:raises: None
|
:raises: None
|
||||||
'''
|
"""
|
||||||
networks = nvplib.get_all_networks(self.controller, tenant_id,
|
networks = nvplib.get_all_networks(self.controller, tenant_id, [])
|
||||||
[])
|
LOG.debug("get_all_networks() completed for tenant %s: %s" %
|
||||||
LOG.debug("get_all_networks() completed for tenant %s: %s" % (
|
(tenant_id, networks))
|
||||||
tenant_id, networks))
|
|
||||||
return networks
|
return networks
|
||||||
|
|
||||||
def create_network(self, tenant_id, net_name, **kwargs):
|
def create_network(self, tenant_id, net_name, **kwargs):
|
||||||
'''
|
"""
|
||||||
Creates a new Virtual Network, and assigns it a symbolic name.
|
Creates a new Virtual Network, and assigns it a symbolic name.
|
||||||
:returns: a sequence of mappings with the following signature:
|
:returns: a sequence of mappings with the following signature:
|
||||||
{'net-id': uuid that uniquely identifies the
|
{'net-id': uuid that uniquely identifies the
|
||||||
@ -303,7 +306,7 @@ class NvpPlugin(object):
|
|||||||
with network referenced by net-id
|
with network referenced by net-id
|
||||||
}
|
}
|
||||||
:raises:
|
:raises:
|
||||||
'''
|
"""
|
||||||
kwargs["controller"] = self.controller
|
kwargs["controller"] = self.controller
|
||||||
return nvplib.create_network(tenant_id, net_name, **kwargs)
|
return nvplib.create_network(tenant_id, net_name, **kwargs)
|
||||||
|
|
||||||
@ -315,7 +318,7 @@ class NvpPlugin(object):
|
|||||||
controller=controller)
|
controller=controller)
|
||||||
|
|
||||||
def delete_network(self, tenant_id, netw_id):
|
def delete_network(self, tenant_id, netw_id):
|
||||||
'''
|
"""
|
||||||
Deletes the network with the specified network identifier
|
Deletes the network with the specified network identifier
|
||||||
belonging to the specified tenant.
|
belonging to the specified tenant.
|
||||||
|
|
||||||
@ -325,7 +328,7 @@ class NvpPlugin(object):
|
|||||||
}
|
}
|
||||||
:raises: exception.NetworkInUse
|
:raises: exception.NetworkInUse
|
||||||
:raises: exception.NetworkNotFound
|
:raises: exception.NetworkNotFound
|
||||||
'''
|
"""
|
||||||
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
||||||
raise exception.NetworkNotFound(net_id=netw_id)
|
raise exception.NetworkNotFound(net_id=netw_id)
|
||||||
nvplib.delete_network(self.controller, netw_id)
|
nvplib.delete_network(self.controller, netw_id)
|
||||||
@ -334,7 +337,7 @@ class NvpPlugin(object):
|
|||||||
return {'net-id': netw_id}
|
return {'net-id': netw_id}
|
||||||
|
|
||||||
def get_network_details(self, tenant_id, netw_id):
|
def get_network_details(self, tenant_id, netw_id):
|
||||||
'''
|
"""
|
||||||
Retrieves a list of all the remote vifs that
|
Retrieves a list of all the remote vifs that
|
||||||
are attached to the network.
|
are attached to the network.
|
||||||
|
|
||||||
@ -348,14 +351,14 @@ class NvpPlugin(object):
|
|||||||
}
|
}
|
||||||
:raises: exception.NetworkNotFound
|
:raises: exception.NetworkNotFound
|
||||||
:raises: exception.QuantumException
|
:raises: exception.QuantumException
|
||||||
'''
|
"""
|
||||||
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
||||||
raise exception.NetworkNotFound(net_id=netw_id)
|
raise exception.NetworkNotFound(net_id=netw_id)
|
||||||
result = None
|
result = None
|
||||||
remote_vifs = []
|
remote_vifs = []
|
||||||
switch = netw_id
|
switch = netw_id
|
||||||
lports = nvplib.query_ports(self.controller, switch,
|
lports = nvplib.query_ports(self.controller, switch,
|
||||||
relations="LogicalPortAttachment")
|
relations="LogicalPortAttachment")
|
||||||
|
|
||||||
for port in lports:
|
for port in lports:
|
||||||
relation = port["_relations"]
|
relation = port["_relations"]
|
||||||
@ -366,16 +369,18 @@ class NvpPlugin(object):
|
|||||||
if not result:
|
if not result:
|
||||||
result = nvplib.get_network(self.controller, switch)
|
result = nvplib.get_network(self.controller, switch)
|
||||||
|
|
||||||
d = {"net-id": netw_id,
|
d = {
|
||||||
"net-ifaces": remote_vifs,
|
"net-id": netw_id,
|
||||||
"net-name": result["display_name"],
|
"net-ifaces": remote_vifs,
|
||||||
"net-op-status": "UP"}
|
"net-name": result["display_name"],
|
||||||
LOG.debug("get_network_details() completed for tenant %s: %s" % (
|
"net-op-status": "UP",
|
||||||
tenant_id, d))
|
}
|
||||||
|
LOG.debug("get_network_details() completed for tenant %s: %s" %
|
||||||
|
(tenant_id, d))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def update_network(self, tenant_id, netw_id, **kwargs):
|
def update_network(self, tenant_id, netw_id, **kwargs):
|
||||||
'''
|
"""
|
||||||
Updates the properties of a particular Virtual Network.
|
Updates the properties of a particular Virtual Network.
|
||||||
|
|
||||||
:returns: a sequence of mappings representing the new network
|
:returns: a sequence of mappings representing the new network
|
||||||
@ -386,16 +391,19 @@ class NvpPlugin(object):
|
|||||||
associated with network referenced by net-id
|
associated with network referenced by net-id
|
||||||
}
|
}
|
||||||
:raises: exception.NetworkNotFound
|
:raises: exception.NetworkNotFound
|
||||||
'''
|
"""
|
||||||
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
||||||
raise exception.NetworkNotFound(net_id=netw_id)
|
raise exception.NetworkNotFound(net_id=netw_id)
|
||||||
result = nvplib.update_network(self.controller, netw_id, **kwargs)
|
result = nvplib.update_network(self.controller, netw_id, **kwargs)
|
||||||
LOG.debug("update_network() completed for tenant: %s" % tenant_id)
|
LOG.debug("update_network() completed for tenant: %s" % tenant_id)
|
||||||
return {'net-id': netw_id, 'net-name': result["display_name"],
|
return {
|
||||||
'net-op-status': "UP"}
|
'net-id': netw_id,
|
||||||
|
'net-name': result["display_name"],
|
||||||
|
'net-op-status': "UP",
|
||||||
|
}
|
||||||
|
|
||||||
def get_all_ports(self, tenant_id, netw_id, **kwargs):
|
def get_all_ports(self, tenant_id, netw_id, **kwargs):
|
||||||
'''
|
"""
|
||||||
Retrieves all port identifiers belonging to the
|
Retrieves all port identifiers belonging to the
|
||||||
specified Virtual Network.
|
specified Virtual Network.
|
||||||
|
|
||||||
@ -409,7 +417,7 @@ class NvpPlugin(object):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
:raises: exception.NetworkNotFound
|
:raises: exception.NetworkNotFound
|
||||||
'''
|
"""
|
||||||
ids = []
|
ids = []
|
||||||
filters = kwargs.get("filter_opts") or {}
|
filters = kwargs.get("filter_opts") or {}
|
||||||
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
||||||
@ -430,9 +438,8 @@ class NvpPlugin(object):
|
|||||||
LOG.debug(ids)
|
LOG.debug(ids)
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
def create_port(self, tenant_id, netw_id, port_init_state=None,
|
def create_port(self, tenant_id, netw_id, port_init_state=None, **params):
|
||||||
**params):
|
"""
|
||||||
'''
|
|
||||||
Creates a port on the specified Virtual Network.
|
Creates a port on the specified Virtual Network.
|
||||||
|
|
||||||
:returns: a mapping sequence with the following signature:
|
:returns: a mapping sequence with the following signature:
|
||||||
@ -441,7 +448,7 @@ class NvpPlugin(object):
|
|||||||
}
|
}
|
||||||
:raises: exception.NetworkNotFound
|
:raises: exception.NetworkNotFound
|
||||||
:raises: exception.StateInvalid
|
:raises: exception.StateInvalid
|
||||||
'''
|
"""
|
||||||
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
||||||
raise exception.NetworkNotFound(net_id=netw_id)
|
raise exception.NetworkNotFound(net_id=netw_id)
|
||||||
params["controller"] = self.controller
|
params["controller"] = self.controller
|
||||||
@ -449,13 +456,15 @@ class NvpPlugin(object):
|
|||||||
raise exception.NetworkNotFound(net_id=netw_id)
|
raise exception.NetworkNotFound(net_id=netw_id)
|
||||||
result = nvplib.create_port(tenant_id, netw_id, port_init_state,
|
result = nvplib.create_port(tenant_id, netw_id, port_init_state,
|
||||||
**params)
|
**params)
|
||||||
d = {"port-id": result["uuid"],
|
d = {
|
||||||
"port-op-status": result["port-op-status"]}
|
"port-id": result["uuid"],
|
||||||
|
"port-op-status": result["port-op-status"],
|
||||||
|
}
|
||||||
LOG.debug("create_port() completed for tenant %s: %s" % (tenant_id, d))
|
LOG.debug("create_port() completed for tenant %s: %s" % (tenant_id, d))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def update_port(self, tenant_id, netw_id, portw_id, **params):
|
def update_port(self, tenant_id, netw_id, portw_id, **params):
|
||||||
'''
|
"""
|
||||||
Updates the properties of a specific port on the
|
Updates the properties of a specific port on the
|
||||||
specified Virtual Network.
|
specified Virtual Network.
|
||||||
|
|
||||||
@ -466,21 +475,23 @@ class NvpPlugin(object):
|
|||||||
}
|
}
|
||||||
:raises: exception.StateInvalid
|
:raises: exception.StateInvalid
|
||||||
:raises: exception.PortNotFound
|
:raises: exception.PortNotFound
|
||||||
'''
|
"""
|
||||||
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
||||||
raise exception.NetworkNotFound(net_id=netw_id)
|
raise exception.NetworkNotFound(net_id=netw_id)
|
||||||
LOG.debug("Update port request: %s" % (params))
|
LOG.debug("Update port request: %s" % (params))
|
||||||
params["controller"] = self.controller
|
params["controller"] = self.controller
|
||||||
result = nvplib.update_port(netw_id, portw_id, **params)
|
result = nvplib.update_port(netw_id, portw_id, **params)
|
||||||
LOG.debug("update_port() completed for tenant: %s" % tenant_id)
|
LOG.debug("update_port() completed for tenant: %s" % tenant_id)
|
||||||
port = {'port-id': portw_id,
|
port = {
|
||||||
'port-state': result["admin_status_enabled"],
|
'port-id': portw_id,
|
||||||
'port-op-status': result["port-op-status"]}
|
'port-state': result["admin_status_enabled"],
|
||||||
|
'port-op-status': result["port-op-status"],
|
||||||
|
}
|
||||||
LOG.debug("returning updated port %s: " % port)
|
LOG.debug("returning updated port %s: " % port)
|
||||||
return port
|
return port
|
||||||
|
|
||||||
def delete_port(self, tenant_id, netw_id, portw_id):
|
def delete_port(self, tenant_id, netw_id, portw_id):
|
||||||
'''
|
"""
|
||||||
Deletes a port on a specified Virtual Network,
|
Deletes a port on a specified Virtual Network,
|
||||||
if the port contains a remote interface attachment,
|
if the port contains a remote interface attachment,
|
||||||
the remote interface is first un-plugged and then the port
|
the remote interface is first un-plugged and then the port
|
||||||
@ -493,7 +504,7 @@ class NvpPlugin(object):
|
|||||||
:raises: exception.PortInUse
|
:raises: exception.PortInUse
|
||||||
:raises: exception.PortNotFound
|
:raises: exception.PortNotFound
|
||||||
:raises: exception.NetworkNotFound
|
:raises: exception.NetworkNotFound
|
||||||
'''
|
"""
|
||||||
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
||||||
raise exception.NetworkNotFound(net_id=netw_id)
|
raise exception.NetworkNotFound(net_id=netw_id)
|
||||||
nvplib.delete_port(self.controller, netw_id, portw_id)
|
nvplib.delete_port(self.controller, netw_id, portw_id)
|
||||||
@ -501,7 +512,7 @@ class NvpPlugin(object):
|
|||||||
return {"port-id": portw_id}
|
return {"port-id": portw_id}
|
||||||
|
|
||||||
def get_port_details(self, tenant_id, netw_id, portw_id):
|
def get_port_details(self, tenant_id, netw_id, portw_id):
|
||||||
'''
|
"""
|
||||||
This method allows the user to retrieve a remote interface
|
This method allows the user to retrieve a remote interface
|
||||||
that is attached to this particular port.
|
that is attached to this particular port.
|
||||||
|
|
||||||
@ -515,7 +526,7 @@ class NvpPlugin(object):
|
|||||||
}
|
}
|
||||||
:raises: exception.PortNotFound
|
:raises: exception.PortNotFound
|
||||||
:raises: exception.NetworkNotFound
|
:raises: exception.NetworkNotFound
|
||||||
'''
|
"""
|
||||||
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
||||||
raise exception.NetworkNotFound(net_id=netw_id)
|
raise exception.NetworkNotFound(net_id=netw_id)
|
||||||
port = nvplib.get_port(self.controller, netw_id, portw_id,
|
port = nvplib.get_port(self.controller, netw_id, portw_id,
|
||||||
@ -530,15 +541,17 @@ class NvpPlugin(object):
|
|||||||
if attach_type == "VifAttachment":
|
if attach_type == "VifAttachment":
|
||||||
vif_uuid = relation["LogicalPortAttachment"]["vif_uuid"]
|
vif_uuid = relation["LogicalPortAttachment"]["vif_uuid"]
|
||||||
|
|
||||||
d = {"port-id": portw_id, "attachment": vif_uuid,
|
d = {
|
||||||
"net-id": netw_id, "port-state": state,
|
"port-id": portw_id, "attachment": vif_uuid,
|
||||||
"port-op-status": op_status}
|
"net-id": netw_id, "port-state": state,
|
||||||
|
"port-op-status": op_status,
|
||||||
|
}
|
||||||
LOG.debug("Port details for tenant %s: %s" % (tenant_id, d))
|
LOG.debug("Port details for tenant %s: %s" % (tenant_id, d))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def plug_interface(self, tenant_id, netw_id, portw_id,
|
def plug_interface(self, tenant_id, netw_id, portw_id,
|
||||||
remote_interface_id):
|
remote_interface_id):
|
||||||
'''
|
"""
|
||||||
Attaches a remote interface to the specified port on the
|
Attaches a remote interface to the specified port on the
|
||||||
specified Virtual Network.
|
specified Virtual Network.
|
||||||
|
|
||||||
@ -547,29 +560,29 @@ class NvpPlugin(object):
|
|||||||
:raises: exception.PortNotFound
|
:raises: exception.PortNotFound
|
||||||
:raises: exception.AlreadyAttached
|
:raises: exception.AlreadyAttached
|
||||||
(? should the network automatically unplug/replug)
|
(? should the network automatically unplug/replug)
|
||||||
'''
|
"""
|
||||||
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
||||||
raise exception.NetworkNotFound(net_id=netw_id)
|
raise exception.NetworkNotFound(net_id=netw_id)
|
||||||
result = nvplib.plug_interface(self.controller, netw_id, portw_id,
|
result = nvplib.plug_interface(self.controller, netw_id, portw_id,
|
||||||
"VifAttachment", attachment=remote_interface_id)
|
"VifAttachment", attachment=remote_interface_id)
|
||||||
LOG.debug("plug_interface() completed for %s: %s" % (
|
LOG.debug("plug_interface() completed for %s: %s" %
|
||||||
tenant_id, result))
|
(tenant_id, result))
|
||||||
|
|
||||||
def unplug_interface(self, tenant_id, netw_id, portw_id):
|
def unplug_interface(self, tenant_id, netw_id, portw_id):
|
||||||
'''
|
"""
|
||||||
Detaches a remote interface from the specified port on the
|
Detaches a remote interface from the specified port on the
|
||||||
specified Virtual Network.
|
specified Virtual Network.
|
||||||
|
|
||||||
:returns: None
|
:returns: None
|
||||||
:raises: exception.NetworkNotFound
|
:raises: exception.NetworkNotFound
|
||||||
:raises: exception.PortNotFound
|
:raises: exception.PortNotFound
|
||||||
'''
|
"""
|
||||||
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
|
||||||
raise exception.NetworkNotFound(net_id=netw_id)
|
raise exception.NetworkNotFound(net_id=netw_id)
|
||||||
result = nvplib.unplug_interface(self.controller, netw_id, portw_id)
|
result = nvplib.unplug_interface(self.controller, netw_id, portw_id)
|
||||||
|
|
||||||
LOG.debug("unplug_interface() completed for tenant %s: %s" %
|
LOG.debug("unplug_interface() completed for tenant %s: %s" %
|
||||||
(tenant_id, result))
|
(tenant_id, result))
|
||||||
|
|
||||||
def get_port_stats(self, tenant_id, network_id, port_id):
|
def get_port_stats(self, tenant_id, network_id, port_id):
|
||||||
"""
|
"""
|
||||||
|
@ -12,18 +12,22 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import client
|
|
||||||
import eventlet
|
|
||||||
import httplib
|
import httplib
|
||||||
import logging
|
import logging
|
||||||
import request_eventlet
|
|
||||||
import time
|
import time
|
||||||
from common import _conn_str
|
|
||||||
|
import eventlet
|
||||||
|
|
||||||
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.common import (
|
||||||
|
_conn_str,
|
||||||
|
)
|
||||||
|
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.client as client
|
||||||
|
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.request_eventlet
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
lg = logging.getLogger('nvp_api_client')
|
LOG = logging.getLogger('nvp_api_client')
|
||||||
|
|
||||||
|
|
||||||
# Default parameters.
|
# Default parameters.
|
||||||
DEFAULT_FAILOVER_TIME = 5
|
DEFAULT_FAILOVER_TIME = 5
|
||||||
@ -32,7 +36,7 @@ DEFAULT_CONNECT_TIMEOUT = 5
|
|||||||
|
|
||||||
|
|
||||||
class NvpApiClientEventlet(object):
|
class NvpApiClientEventlet(object):
|
||||||
'''Eventlet-based implementation of NvpApiClient ABC.'''
|
"""Eventlet-based implementation of NvpApiClient ABC."""
|
||||||
|
|
||||||
CONN_IDLE_TIMEOUT = 60 * 15
|
CONN_IDLE_TIMEOUT = 60 * 15
|
||||||
|
|
||||||
@ -41,7 +45,7 @@ class NvpApiClientEventlet(object):
|
|||||||
use_https=True,
|
use_https=True,
|
||||||
connect_timeout=DEFAULT_CONNECT_TIMEOUT,
|
connect_timeout=DEFAULT_CONNECT_TIMEOUT,
|
||||||
failover_time=DEFAULT_FAILOVER_TIME):
|
failover_time=DEFAULT_FAILOVER_TIME):
|
||||||
'''Constructor
|
"""Constructor
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
api_providers: a list of tuples of the form: (host, port, is_ssl).
|
api_providers: a list of tuples of the form: (host, port, is_ssl).
|
||||||
@ -50,7 +54,7 @@ class NvpApiClientEventlet(object):
|
|||||||
concurrent_connections: total number of concurrent connections.
|
concurrent_connections: total number of concurrent connections.
|
||||||
use_https: whether or not to use https for requests.
|
use_https: whether or not to use https for requests.
|
||||||
connect_timeout: connection timeout in seconds.
|
connect_timeout: connection timeout in seconds.
|
||||||
'''
|
"""
|
||||||
self._api_providers = set([tuple(p) for p in api_providers])
|
self._api_providers = set([tuple(p) for p in api_providers])
|
||||||
self._user = user
|
self._user = user
|
||||||
self._password = password
|
self._password = password
|
||||||
@ -107,13 +111,13 @@ class NvpApiClientEventlet(object):
|
|||||||
return self._cookie
|
return self._cookie
|
||||||
|
|
||||||
def acquire_connection(self):
|
def acquire_connection(self):
|
||||||
'''Check out an available HTTPConnection instance.
|
"""Check out an available HTTPConnection instance.
|
||||||
|
|
||||||
Blocks until a connection is available.
|
Blocks until a connection is available.
|
||||||
|
|
||||||
Returns: An available HTTPConnection instance or None if no
|
Returns: An available HTTPConnection instance or None if no
|
||||||
api_providers are configured.
|
api_providers are configured.
|
||||||
'''
|
"""
|
||||||
if not self._api_providers:
|
if not self._api_providers:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -121,47 +125,47 @@ class NvpApiClientEventlet(object):
|
|||||||
# there has been a change in the controller used as the api_provider.
|
# there has been a change in the controller used as the api_provider.
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if now < getattr(self, '_issue_conn_barrier', now):
|
if now < getattr(self, '_issue_conn_barrier', now):
|
||||||
lg.info("acquire_connection() waiting for timer to expire.")
|
LOG.info("acquire_connection() waiting for timer to expire.")
|
||||||
time.sleep(self._issue_conn_barrier - now)
|
time.sleep(self._issue_conn_barrier - now)
|
||||||
|
|
||||||
if self._active_conn_pool.empty():
|
if self._active_conn_pool.empty():
|
||||||
lg.debug("Waiting to acquire an API client connection")
|
LOG.debug("Waiting to acquire an API client connection")
|
||||||
|
|
||||||
# get() call is blocking.
|
# get() call is blocking.
|
||||||
conn = self._active_conn_pool.get()
|
conn = self._active_conn_pool.get()
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if getattr(conn, 'last_used', now) < now - self.CONN_IDLE_TIMEOUT:
|
if getattr(conn, 'last_used', now) < now - self.CONN_IDLE_TIMEOUT:
|
||||||
lg.info("Connection %s idle for %0.2f seconds; reconnecting."
|
LOG.info("Connection %s idle for %0.2f seconds; reconnecting." %
|
||||||
% (_conn_str(conn), now - conn.last_used))
|
(_conn_str(conn), now - conn.last_used))
|
||||||
conn = self._create_connection(*self._conn_params(conn))
|
conn = self._create_connection(*self._conn_params(conn))
|
||||||
|
|
||||||
# Stash conn pool so conn knows where to go when it releases.
|
# Stash conn pool so conn knows where to go when it releases.
|
||||||
conn.conn_pool = self._active_conn_pool
|
conn.conn_pool = self._active_conn_pool
|
||||||
|
|
||||||
conn.last_used = now
|
conn.last_used = now
|
||||||
lg.debug("API client connection %s acquired" % _conn_str(conn))
|
LOG.debug("API client connection %s acquired" % _conn_str(conn))
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
def release_connection(self, http_conn, bad_state=False):
|
def release_connection(self, http_conn, bad_state=False):
|
||||||
'''Mark HTTPConnection instance as available for check-out.
|
"""Mark HTTPConnection instance as available for check-out.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
http_conn: An HTTPConnection instance obtained from this
|
http_conn: An HTTPConnection instance obtained from this
|
||||||
instance.
|
instance.
|
||||||
bad_state: True if http_conn is known to be in a bad state
|
bad_state: True if http_conn is known to be in a bad state
|
||||||
(e.g. connection fault.)
|
(e.g. connection fault.)
|
||||||
'''
|
"""
|
||||||
if self._conn_params(http_conn) not in self._api_providers:
|
if self._conn_params(http_conn) not in self._api_providers:
|
||||||
lg.debug("Released connection '%s' is no longer an API provider "
|
LOG.debug(("Released connection '%s' is no longer an API provider "
|
||||||
"for the cluster" % _conn_str(http_conn))
|
"for the cluster") % _conn_str(http_conn))
|
||||||
return
|
return
|
||||||
|
|
||||||
# Retrieve "home" connection pool.
|
# Retrieve "home" connection pool.
|
||||||
conn_pool = http_conn.conn_pool
|
conn_pool = http_conn.conn_pool
|
||||||
if bad_state:
|
if bad_state:
|
||||||
# reconnect
|
# reconnect
|
||||||
lg.info("API connection fault, reconnecting to %s"
|
LOG.info("API connection fault, reconnecting to %s" %
|
||||||
% _conn_str(http_conn))
|
_conn_str(http_conn))
|
||||||
http_conn = self._create_connection(*self._conn_params(http_conn))
|
http_conn = self._create_connection(*self._conn_params(http_conn))
|
||||||
http_conn.conn_pool = conn_pool
|
http_conn.conn_pool = conn_pool
|
||||||
conn_pool.put(http_conn)
|
conn_pool.put(http_conn)
|
||||||
@ -169,14 +173,14 @@ class NvpApiClientEventlet(object):
|
|||||||
if self._active_conn_pool == http_conn.conn_pool:
|
if self._active_conn_pool == http_conn.conn_pool:
|
||||||
# Get next connection from the connection pool and make it
|
# Get next connection from the connection pool and make it
|
||||||
# active.
|
# active.
|
||||||
lg.info("API connection fault changing active_conn_pool.")
|
LOG.info("API connection fault changing active_conn_pool.")
|
||||||
self._conn_pool.put(self._active_conn_pool)
|
self._conn_pool.put(self._active_conn_pool)
|
||||||
self._active_conn_pool = self._conn_pool.get()
|
self._active_conn_pool = self._conn_pool.get()
|
||||||
self._issue_conn_barrier = time.time() + self._failover_time
|
self._issue_conn_barrier = time.time() + self._failover_time
|
||||||
else:
|
else:
|
||||||
conn_pool.put(http_conn)
|
conn_pool.put(http_conn)
|
||||||
|
|
||||||
lg.debug("API client connection %s released" % _conn_str(http_conn))
|
LOG.debug("API client connection %s released" % _conn_str(http_conn))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def need_login(self):
|
def need_login(self):
|
||||||
@ -192,13 +196,15 @@ class NvpApiClientEventlet(object):
|
|||||||
self.login()
|
self.login()
|
||||||
self._doing_login_sem.release()
|
self._doing_login_sem.release()
|
||||||
else:
|
else:
|
||||||
lg.debug("Waiting for auth to complete")
|
LOG.debug("Waiting for auth to complete")
|
||||||
self._doing_login_sem.acquire()
|
self._doing_login_sem.acquire()
|
||||||
self._doing_login_sem.release()
|
self._doing_login_sem.release()
|
||||||
return self._cookie
|
return self._cookie
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
'''Issue login request and update authentication cookie.'''
|
"""Issue login request and update authentication cookie."""
|
||||||
|
request_eventlet = (quantum.plugins.nicira.nicira_nvp_plugin.
|
||||||
|
api_client.request_eventlet)
|
||||||
g = request_eventlet.NvpLoginRequestEventlet(
|
g = request_eventlet.NvpLoginRequestEventlet(
|
||||||
self, self._user, self._password)
|
self, self._user, self._password)
|
||||||
g.start()
|
g.start()
|
||||||
@ -206,13 +212,13 @@ class NvpApiClientEventlet(object):
|
|||||||
|
|
||||||
if ret:
|
if ret:
|
||||||
if isinstance(ret, Exception):
|
if isinstance(ret, Exception):
|
||||||
lg.error('NvpApiClient: login error "%s"' % ret)
|
LOG.error('NvpApiClient: login error "%s"' % ret)
|
||||||
raise ret
|
raise ret
|
||||||
|
|
||||||
self._cookie = None
|
self._cookie = None
|
||||||
cookie = ret.getheader("Set-Cookie")
|
cookie = ret.getheader("Set-Cookie")
|
||||||
if cookie:
|
if cookie:
|
||||||
lg.debug("Saving new authentication cookie '%s'" % cookie)
|
LOG.debug("Saving new authentication cookie '%s'" % cookie)
|
||||||
self._cookie = cookie
|
self._cookie = cookie
|
||||||
self._need_login = False
|
self._need_login = False
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import httplib
|
import httplib
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# 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
|
from abc import ABCMeta
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from abc import abstractproperty
|
from abc import abstractproperty
|
||||||
|
@ -12,22 +12,27 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import client_eventlet
|
|
||||||
import eventlet
|
|
||||||
import httplib
|
import httplib
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
import urllib
|
import urllib
|
||||||
import urlparse
|
import urlparse
|
||||||
import logging
|
|
||||||
import request
|
import eventlet
|
||||||
import time
|
|
||||||
import json
|
|
||||||
from common import _conn_str
|
|
||||||
from eventlet import timeout
|
from eventlet import timeout
|
||||||
|
|
||||||
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.common import (
|
||||||
|
_conn_str,
|
||||||
|
)
|
||||||
|
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.request as request
|
||||||
|
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.client_eventlet
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
lg = logging.getLogger("nvp_api_request")
|
LOG = logging.getLogger("nvp_api_request")
|
||||||
|
|
||||||
|
|
||||||
USER_AGENT = "NVP gevent client/1.0"
|
USER_AGENT = "NVP gevent client/1.0"
|
||||||
|
|
||||||
# Default parameters.
|
# Default parameters.
|
||||||
@ -57,7 +62,7 @@ class NvpApiRequestEventlet:
|
|||||||
httplib.NOT_FOUND,
|
httplib.NOT_FOUND,
|
||||||
httplib.CONFLICT,
|
httplib.CONFLICT,
|
||||||
httplib.INTERNAL_SERVER_ERROR,
|
httplib.INTERNAL_SERVER_ERROR,
|
||||||
httplib.SERVICE_UNAVAILABLE
|
httplib.SERVICE_UNAVAILABLE,
|
||||||
]
|
]
|
||||||
|
|
||||||
API_REQUEST_POOL = eventlet.GreenPool(API_REQUEST_POOL_SIZE)
|
API_REQUEST_POOL = eventlet.GreenPool(API_REQUEST_POOL_SIZE)
|
||||||
@ -102,7 +107,7 @@ class NvpApiRequestEventlet:
|
|||||||
def join(self):
|
def join(self):
|
||||||
if self._green_thread is not None:
|
if self._green_thread is not None:
|
||||||
return self._green_thread.wait()
|
return self._green_thread.wait()
|
||||||
lg.error('Joining on invalid green thread')
|
LOG.error('Joining on invalid green thread')
|
||||||
return Exception('Joining an invalid green thread')
|
return Exception('Joining an invalid green thread')
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
@ -124,7 +129,7 @@ class NvpApiRequestEventlet:
|
|||||||
with timeout.Timeout(self._request_timeout, False):
|
with timeout.Timeout(self._request_timeout, False):
|
||||||
return self._handle_request()
|
return self._handle_request()
|
||||||
|
|
||||||
lg.info('Request timeout handling request.')
|
LOG.info('Request timeout handling request.')
|
||||||
self._request_error = Exception('Request timeout')
|
self._request_error = Exception('Request timeout')
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
@ -141,7 +146,7 @@ class NvpApiRequestEventlet:
|
|||||||
return error
|
return error
|
||||||
|
|
||||||
url = self._url
|
url = self._url
|
||||||
lg.info("Issuing request '%s'" % self._request_str(conn, url))
|
LOG.info("Issuing request '%s'" % self._request_str(conn, url))
|
||||||
issued_time = time.time()
|
issued_time = time.time()
|
||||||
is_conn_error = False
|
is_conn_error = False
|
||||||
try:
|
try:
|
||||||
@ -159,28 +164,29 @@ class NvpApiRequestEventlet:
|
|||||||
try:
|
try:
|
||||||
conn.request(self._method, url, self._body, self._headers)
|
conn.request(self._method, url, self._body, self._headers)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
lg.info('_issue_request: conn.request() exception: %s' % e)
|
LOG.info('_issue_request: conn.request() exception: %s' %
|
||||||
|
e)
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
response = conn.getresponse()
|
response = conn.getresponse()
|
||||||
response.body = response.read()
|
response.body = response.read()
|
||||||
response.headers = response.getheaders()
|
response.headers = response.getheaders()
|
||||||
lg.info("Request '%s' complete: %s (%0.2f seconds)"
|
LOG.info("Request '%s' complete: %s (%0.2f seconds)"
|
||||||
% (self._request_str(conn, url), response.status,
|
% (self._request_str(conn, url), response.status,
|
||||||
time.time() - issued_time))
|
time.time() - issued_time))
|
||||||
if response.status not in [httplib.MOVED_PERMANENTLY,
|
if response.status not in [httplib.MOVED_PERMANENTLY,
|
||||||
httplib.TEMPORARY_REDIRECT]:
|
httplib.TEMPORARY_REDIRECT]:
|
||||||
break
|
break
|
||||||
elif redirects >= self._redirects:
|
elif redirects >= self._redirects:
|
||||||
lg.warn("Maximum redirects exceeded, aborting request")
|
LOG.warn("Maximum redirects exceeded, aborting request")
|
||||||
break
|
break
|
||||||
redirects += 1
|
redirects += 1
|
||||||
conn, url = self._redirect_params(conn, response.headers)
|
conn, url = self._redirect_params(conn, response.headers)
|
||||||
if url is None:
|
if url is None:
|
||||||
response.status = httplib.INTERNAL_SERVER_ERROR
|
response.status = httplib.INTERNAL_SERVER_ERROR
|
||||||
break
|
break
|
||||||
lg.info("Redirecting request to: %s" % \
|
LOG.info("Redirecting request to: %s" %
|
||||||
self._request_str(conn, url))
|
self._request_str(conn, url))
|
||||||
|
|
||||||
# If we receive any of these responses, then our server did not
|
# If we receive any of these responses, then our server did not
|
||||||
# process our request and may be in an errored state. Raise an
|
# process our request and may be in an errored state. Raise an
|
||||||
@ -188,8 +194,8 @@ class NvpApiRequestEventlet:
|
|||||||
# is_conn_error == True which puts the conn on the back of the
|
# is_conn_error == True which puts the conn on the back of the
|
||||||
# client's priority queue.
|
# client's priority queue.
|
||||||
if response.status >= 500:
|
if response.status >= 500:
|
||||||
lg.warn("API Request '%s %s' received: %s"
|
LOG.warn("API Request '%s %s' received: %s" %
|
||||||
% (self._method, self._url, response.status))
|
(self._method, self._url, response.status))
|
||||||
raise Exception('Server error return: %s' %
|
raise Exception('Server error return: %s' %
|
||||||
response.status)
|
response.status)
|
||||||
return response
|
return response
|
||||||
@ -198,9 +204,9 @@ class NvpApiRequestEventlet:
|
|||||||
msg = "Invalid server response"
|
msg = "Invalid server response"
|
||||||
else:
|
else:
|
||||||
msg = unicode(e)
|
msg = unicode(e)
|
||||||
lg.warn("Request '%s' failed: %s (%0.2f seconds)"
|
LOG.warn("Request '%s' failed: %s (%0.2f seconds)"
|
||||||
% (self._request_str(conn, url), msg,
|
% (self._request_str(conn, url), msg,
|
||||||
time.time() - issued_time))
|
time.time() - issued_time))
|
||||||
self._request_error = e
|
self._request_error = e
|
||||||
is_conn_error = True
|
is_conn_error = True
|
||||||
return e
|
return e
|
||||||
@ -214,7 +220,7 @@ class NvpApiRequestEventlet:
|
|||||||
url = value
|
url = value
|
||||||
break
|
break
|
||||||
if not url:
|
if not url:
|
||||||
lg.warn("Received redirect status without location header field")
|
LOG.warn("Received redirect status without location header field")
|
||||||
return (conn, None)
|
return (conn, None)
|
||||||
# Accept location with the following format:
|
# Accept location with the following format:
|
||||||
# 1. /path, redirect to same node
|
# 1. /path, redirect to same node
|
||||||
@ -230,15 +236,18 @@ class NvpApiRequestEventlet:
|
|||||||
url = result.path
|
url = result.path
|
||||||
return (conn, url) # case 1
|
return (conn, url) # case 1
|
||||||
else:
|
else:
|
||||||
lg.warn("Received invalid redirect location: %s" % url)
|
LOG.warn("Received invalid redirect location: %s" % url)
|
||||||
return (conn, None) # case 3
|
return (conn, None) # case 3
|
||||||
elif result.scheme not in ["http", "https"] or not result.hostname:
|
elif result.scheme not in ["http", "https"] or not result.hostname:
|
||||||
lg.warn("Received malformed redirect location: %s" % url)
|
LOG.warn("Received malformed redirect location: %s" % url)
|
||||||
return (conn, None) # case 3
|
return (conn, None) # case 3
|
||||||
# case 2, redirect location includes a scheme
|
# case 2, redirect location includes a scheme
|
||||||
# so setup a new connection and authenticate
|
# so setup a new connection and authenticate
|
||||||
use_https = result.scheme == "https"
|
use_https = result.scheme == "https"
|
||||||
api_providers = [(result.hostname, result.port, use_https)]
|
api_providers = [(result.hostname, result.port, use_https)]
|
||||||
|
client_eventlet = (
|
||||||
|
quantum.plugins.nicira.nicira_nvp_plugin.api_client.client_eventlet
|
||||||
|
)
|
||||||
api_client = client_eventlet.NvpApiClientEventlet(
|
api_client = client_eventlet.NvpApiClientEventlet(
|
||||||
api_providers, self._api_client.user, self._api_client.password,
|
api_providers, self._api_client.user, self._api_client.password,
|
||||||
use_https=use_https)
|
use_https=use_https)
|
||||||
@ -268,7 +277,7 @@ class NvpApiRequestEventlet:
|
|||||||
|
|
||||||
req = self.spawn(self._issue_request).wait()
|
req = self.spawn(self._issue_request).wait()
|
||||||
# automatically raises any exceptions returned.
|
# automatically raises any exceptions returned.
|
||||||
lg.debug('req: %s' % type(req))
|
LOG.debug('req: %s' % type(req))
|
||||||
|
|
||||||
if isinstance(req, httplib.HTTPResponse):
|
if isinstance(req, httplib.HTTPResponse):
|
||||||
if (req.status == httplib.UNAUTHORIZED
|
if (req.status == httplib.UNAUTHORIZED
|
||||||
@ -278,15 +287,15 @@ class NvpApiRequestEventlet:
|
|||||||
continue
|
continue
|
||||||
# else fall through to return the error code
|
# else fall through to return the error code
|
||||||
|
|
||||||
lg.debug("API Request '%s %s' complete: %s"
|
LOG.debug("API Request '%s %s' complete: %s" %
|
||||||
% (self._method, self._url, req.status))
|
(self._method, self._url, req.status))
|
||||||
self._request_error = None
|
self._request_error = None
|
||||||
response = req
|
response = req
|
||||||
else:
|
else:
|
||||||
lg.info('_handle_request: caught an error - %s' % req)
|
LOG.info('_handle_request: caught an error - %s' % req)
|
||||||
self._request_error = req
|
self._request_error = req
|
||||||
|
|
||||||
lg.debug('_handle_request: response - %s' % response)
|
LOG.debug('_handle_request: response - %s' % response)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@ -332,7 +341,7 @@ class NvpGetApiProvidersRequestEventlet(NvpApiRequestEventlet):
|
|||||||
ret.append(_provider_from_listen_addr(addr))
|
ret.append(_provider_from_listen_addr(addr))
|
||||||
return ret
|
return ret
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
lg.warn("Failed to parse API provider: %s" % e)
|
LOG.warn("Failed to parse API provider: %s" % e)
|
||||||
# intentionally fall through
|
# intentionally fall through
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -12,17 +12,16 @@
|
|||||||
# 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 optparse import OptionParser
|
|
||||||
|
|
||||||
import gettext
|
|
||||||
import logging
|
import logging
|
||||||
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
gettext.install('nvp-plugin-cli', unicode=1)
|
from quantum.plugins.nicira.nicira_nvp_plugin import nvplib
|
||||||
|
from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import (
|
||||||
|
NvpPlugin as QuantumManager,
|
||||||
|
)
|
||||||
|
|
||||||
from QuantumPlugin import NvpPlugin as QuantumManager
|
|
||||||
import nvplib
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
LOG = logging.getLogger('nvp-plugin-cli')
|
LOG = logging.getLogger('nvp-plugin-cli')
|
||||||
|
@ -14,10 +14,12 @@
|
|||||||
#
|
#
|
||||||
# @author: Brad Hall, Nicira Networks, Inc.
|
# @author: Brad Hall, Nicira Networks, Inc.
|
||||||
|
|
||||||
from quantum.common import exceptions as exception
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import NvpApiClient
|
|
||||||
|
from quantum.common import exceptions as exception
|
||||||
|
from quantum.plugins.nicira.nicira_nvp_plugin import NvpApiClient
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger("nvplib")
|
LOG = logging.getLogger("nvplib")
|
||||||
LOG.setLevel(logging.INFO)
|
LOG.setLevel(logging.INFO)
|
||||||
@ -36,13 +38,14 @@ def check_default_transport_zone(c):
|
|||||||
msg = []
|
msg = []
|
||||||
# This will throw an exception on failure and that's ok since it will
|
# This will throw an exception on failure and that's ok since it will
|
||||||
# just propogate to the cli.
|
# just propogate to the cli.
|
||||||
resp = do_single_request("GET",
|
resp = do_single_request(
|
||||||
|
"GET",
|
||||||
"/ws.v1/transport-zone?uuid=%s" % c.default_tz_uuid,
|
"/ws.v1/transport-zone?uuid=%s" % c.default_tz_uuid,
|
||||||
controller=c)
|
controller=c)
|
||||||
result = json.loads(resp)
|
result = json.loads(resp)
|
||||||
if int(result["result_count"]) == 0:
|
if int(result["result_count"]) == 0:
|
||||||
msg.append("Unable to find zone \"%s\" for controller \"%s\"" %
|
msg.append("Unable to find zone \"%s\" for controller \"%s\"" %
|
||||||
(c.default_tz_uuid, c.name))
|
(c.default_tz_uuid, c.name))
|
||||||
if len(msg) > 0:
|
if len(msg) > 0:
|
||||||
raise Exception(' '.join(msg))
|
raise Exception(' '.join(msg))
|
||||||
|
|
||||||
@ -78,8 +81,8 @@ def create_lswitch(controller, lswitch_obj):
|
|||||||
# Warn if no tenant is specified
|
# Warn if no tenant is specified
|
||||||
found = "os_tid" in [x["scope"] for x in lswitch_obj["tags"]]
|
found = "os_tid" in [x["scope"] for x in lswitch_obj["tags"]]
|
||||||
if not found:
|
if not found:
|
||||||
LOG.warn("No tenant-id tag specified in logical switch: %s" % (
|
LOG.warn("No tenant-id tag specified in logical switch: %s" %
|
||||||
lswitch_obj))
|
lswitch_obj)
|
||||||
uri = "/ws.v1/lswitch"
|
uri = "/ws.v1/lswitch"
|
||||||
try:
|
try:
|
||||||
resp_obj = do_single_request("POST", uri,
|
resp_obj = do_single_request("POST", uri,
|
||||||
@ -102,8 +105,8 @@ def update_network(controller, network, **kwargs):
|
|||||||
if "name" in kwargs:
|
if "name" in kwargs:
|
||||||
lswitch_obj["display_name"] = kwargs["name"]
|
lswitch_obj["display_name"] = kwargs["name"]
|
||||||
try:
|
try:
|
||||||
resp_obj = do_single_request("PUT", uri,
|
resp_obj = do_single_request(
|
||||||
json.dumps(lswitch_obj), controller=controller)
|
"PUT", uri, json.dumps(lswitch_obj), controller=controller)
|
||||||
except NvpApiClient.ResourceNotFound as e:
|
except NvpApiClient.ResourceNotFound as e:
|
||||||
LOG.error("Network not found, Error: %s" % str(e))
|
LOG.error("Network not found, Error: %s" % str(e))
|
||||||
raise exception.NetworkNotFound(net_id=network)
|
raise exception.NetworkNotFound(net_id=network)
|
||||||
@ -148,7 +151,7 @@ def query_networks(controller, tenant_id, fields="*", tags=None):
|
|||||||
lswitches = json.loads(resp_obj)["results"]
|
lswitches = json.loads(resp_obj)["results"]
|
||||||
nets = [{'net-id': lswitch["uuid"],
|
nets = [{'net-id': lswitch["uuid"],
|
||||||
'net-name': lswitch["display_name"]}
|
'net-name': lswitch["display_name"]}
|
||||||
for lswitch in lswitches]
|
for lswitch in lswitches]
|
||||||
return nets
|
return nets
|
||||||
|
|
||||||
|
|
||||||
@ -175,13 +178,16 @@ def create_network(tenant_id, net_name, **kwargs):
|
|||||||
transport_zone = kwargs.get("transport_zone",
|
transport_zone = kwargs.get("transport_zone",
|
||||||
controller.default_tz_uuid)
|
controller.default_tz_uuid)
|
||||||
transport_type = kwargs.get("transport_type", "gre")
|
transport_type = kwargs.get("transport_type", "gre")
|
||||||
lswitch_obj = {"display_name": net_name,
|
lswitch_obj = {
|
||||||
"transport_zones": [
|
"display_name": net_name,
|
||||||
{"zone_uuid": transport_zone,
|
"transport_zones": [
|
||||||
"transport_type": transport_type}
|
{
|
||||||
],
|
"zone_uuid": transport_zone,
|
||||||
"tags": [{"tag": tenant_id, "scope": "os_tid"}]
|
"transport_type": transport_type,
|
||||||
}
|
},
|
||||||
|
],
|
||||||
|
"tags": [{"tag": tenant_id, "scope": "os_tid"}],
|
||||||
|
}
|
||||||
|
|
||||||
net = create_lswitch(controller, lswitch_obj)
|
net = create_lswitch(controller, lswitch_obj)
|
||||||
net['net-op-status'] = "UP"
|
net['net-op-status'] = "UP"
|
||||||
@ -216,8 +222,8 @@ def get_port_stats(controller, network_id, port_id):
|
|||||||
|
|
||||||
def check_port_state(state):
|
def check_port_state(state):
|
||||||
if state not in ["ACTIVE", "DOWN"]:
|
if state not in ["ACTIVE", "DOWN"]:
|
||||||
LOG.error("Invalid port state (ACTIVE and " \
|
LOG.error("Invalid port state (ACTIVE and DOWN are valid states): %s" %
|
||||||
"DOWN are valid states): %s" % state)
|
state)
|
||||||
raise exception.StateInvalid(port_state=state)
|
raise exception.StateInvalid(port_state=state)
|
||||||
|
|
||||||
|
|
||||||
@ -256,9 +262,10 @@ def delete_all_ports(controller, ls_uuid):
|
|||||||
controller=controller)
|
controller=controller)
|
||||||
res = json.loads(res)
|
res = json.loads(res)
|
||||||
for r in res["results"]:
|
for r in res["results"]:
|
||||||
do_single_request("DELETE",
|
do_single_request(
|
||||||
"/ws.v1/lswitch/%s/lport/%s" % (ls_uuid, r["uuid"]),
|
"DELETE",
|
||||||
controller=controller)
|
"/ws.v1/lswitch/%s/lport/%s" % (ls_uuid, r["uuid"]),
|
||||||
|
controller=controller)
|
||||||
|
|
||||||
|
|
||||||
def get_port(controller, network, port, relations=None):
|
def get_port(controller, network, port, relations=None):
|
||||||
@ -292,7 +299,7 @@ def plug_interface(controller, network, port, type, attachment=None):
|
|||||||
raise exception.PortNotFound(port_id=port, net_id=network)
|
raise exception.PortNotFound(port_id=port, net_id=network)
|
||||||
except NvpApiClient.Conflict as e:
|
except NvpApiClient.Conflict as e:
|
||||||
LOG.error("Conflict while making attachment to port, " \
|
LOG.error("Conflict while making attachment to port, " \
|
||||||
"Error: %s" % str(e))
|
"Error: %s" % str(e))
|
||||||
raise exception.AlreadyAttached(att_id=attachment,
|
raise exception.AlreadyAttached(att_id=attachment,
|
||||||
port_id=port,
|
port_id=port,
|
||||||
net_id=network,
|
net_id=network,
|
||||||
@ -308,8 +315,8 @@ def unplug_interface(controller, network, port):
|
|||||||
uri = "/ws.v1/lswitch/" + network + "/lport/" + port + "/attachment"
|
uri = "/ws.v1/lswitch/" + network + "/lport/" + port + "/attachment"
|
||||||
lport_obj = {"type": "NoAttachment"}
|
lport_obj = {"type": "NoAttachment"}
|
||||||
try:
|
try:
|
||||||
resp_obj = do_single_request("PUT",
|
resp_obj = do_single_request(
|
||||||
uri, json.dumps(lport_obj), controller=controller)
|
"PUT", uri, json.dumps(lport_obj), controller=controller)
|
||||||
except NvpApiClient.ResourceNotFound as e:
|
except NvpApiClient.ResourceNotFound as e:
|
||||||
LOG.error("Port or Network not found, Error: %s" % str(e))
|
LOG.error("Port or Network not found, Error: %s" % str(e))
|
||||||
raise exception.PortNotFound(port_id=port, net_id=network)
|
raise exception.PortNotFound(port_id=port, net_id=network)
|
||||||
@ -332,8 +339,8 @@ def update_port(network, port_id, **params):
|
|||||||
|
|
||||||
uri = "/ws.v1/lswitch/" + network + "/lport/" + port_id
|
uri = "/ws.v1/lswitch/" + network + "/lport/" + port_id
|
||||||
try:
|
try:
|
||||||
resp_obj = do_single_request("PUT", uri,
|
resp_obj = do_single_request(
|
||||||
json.dumps(lport_obj), controller=controller)
|
"PUT", uri, json.dumps(lport_obj), controller=controller)
|
||||||
except NvpApiClient.ResourceNotFound as e:
|
except NvpApiClient.ResourceNotFound as e:
|
||||||
LOG.error("Port or Network not found, Error: %s" % str(e))
|
LOG.error("Port or Network not found, Error: %s" % str(e))
|
||||||
raise exception.PortNotFound(port_id=port_id, net_id=network)
|
raise exception.PortNotFound(port_id=port_id, net_id=network)
|
||||||
@ -361,8 +368,8 @@ def create_port(tenant, network, port_init_state, **params):
|
|||||||
|
|
||||||
path = "/ws.v1/lswitch/" + ls_uuid + "/lport"
|
path = "/ws.v1/lswitch/" + ls_uuid + "/lport"
|
||||||
try:
|
try:
|
||||||
resp_obj = do_single_request("POST", path,
|
resp_obj = do_single_request(
|
||||||
json.dumps(lport_obj), controller=controller)
|
"POST", path, json.dumps(lport_obj), controller=controller)
|
||||||
except NvpApiClient.ResourceNotFound as e:
|
except NvpApiClient.ResourceNotFound as e:
|
||||||
LOG.error("Network not found, Error: %s" % str(e))
|
LOG.error("Network not found, Error: %s" % str(e))
|
||||||
raise exception.NetworkNotFound(net_id=network)
|
raise exception.NetworkNotFound(net_id=network)
|
||||||
@ -387,7 +394,8 @@ def get_port_status(controller, lswitch_id, port_id):
|
|||||||
except NvpApiClient.NvpApiException as e:
|
except NvpApiClient.NvpApiException as e:
|
||||||
raise exception.QuantumException()
|
raise exception.QuantumException()
|
||||||
try:
|
try:
|
||||||
r = do_single_request("GET",
|
r = do_single_request(
|
||||||
|
"GET",
|
||||||
"/ws.v1/lswitch/%s/lport/%s/status" % (lswitch_id, port_id),
|
"/ws.v1/lswitch/%s/lport/%s/status" % (lswitch_id, port_id),
|
||||||
controller=controller)
|
controller=controller)
|
||||||
r = json.loads(r)
|
r = json.loads(r)
|
||||||
|
@ -17,8 +17,9 @@
|
|||||||
import logging
|
import logging
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from nicira_nvp_plugin.QuantumPlugin import NvpPlugin
|
from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import NvpPlugin
|
||||||
from nicira_nvp_plugin import nvplib
|
from quantum.plugins.nicira.nicira_nvp_plugin import nvplib
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
LOG = logging.getLogger("test_check")
|
LOG = logging.getLogger("test_check")
|
||||||
|
@ -12,12 +12,14 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
|
||||||
import StringIO
|
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
from nicira_nvp_plugin.QuantumPlugin import parse_config
|
import StringIO
|
||||||
from nicira_nvp_plugin.QuantumPlugin import NVPCluster
|
import unittest
|
||||||
|
|
||||||
|
from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import (
|
||||||
|
NVPCluster,
|
||||||
|
parse_config,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ConfigParserTest(unittest.TestCase):
|
class ConfigParserTest(unittest.TestCase):
|
||||||
@ -46,7 +48,7 @@ class ConfigParserTest(unittest.TestCase):
|
|||||||
self.assertTrue(len(nvpc.controllers) == 3)
|
self.assertTrue(len(nvpc.controllers) == 3)
|
||||||
|
|
||||||
def test_old_config_parser_old_style(self):
|
def test_old_config_parser_old_style(self):
|
||||||
config = StringIO.StringIO('''
|
config = StringIO.StringIO("""
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
[NVP]
|
[NVP]
|
||||||
DEFAULT_TZ_UUID = <default uuid>
|
DEFAULT_TZ_UUID = <default uuid>
|
||||||
@ -54,7 +56,7 @@ NVP_CONTROLLER_IP = <controller ip>
|
|||||||
PORT = <port>
|
PORT = <port>
|
||||||
USER = <user>
|
USER = <user>
|
||||||
PASSWORD = <pass>
|
PASSWORD = <pass>
|
||||||
''')
|
""")
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = ConfigParser.ConfigParser()
|
||||||
cp.readfp(config)
|
cp.readfp(config)
|
||||||
cluster1, plugin_config = parse_config(cp)
|
cluster1, plugin_config = parse_config(cp)
|
||||||
@ -78,13 +80,13 @@ PASSWORD = <pass>
|
|||||||
cluster1.controllers[0]['redirects'] == 2)
|
cluster1.controllers[0]['redirects'] == 2)
|
||||||
|
|
||||||
def test_old_config_parser_new_style(self):
|
def test_old_config_parser_new_style(self):
|
||||||
config = StringIO.StringIO('''
|
config = StringIO.StringIO("""
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
[NVP]
|
[NVP]
|
||||||
DEFAULT_TZ_UUID = <default uuid>
|
DEFAULT_TZ_UUID = <default uuid>
|
||||||
NVP_CONTROLLER_CONNECTIONS = CONNECTION1
|
NVP_CONTROLLER_CONNECTIONS = CONNECTION1
|
||||||
CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
||||||
''')
|
""")
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = ConfigParser.ConfigParser()
|
||||||
cp.readfp(config)
|
cp.readfp(config)
|
||||||
cluster1, plugin_config = parse_config(cp)
|
cluster1, plugin_config = parse_config(cp)
|
||||||
@ -108,7 +110,7 @@ CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
|||||||
cluster1.controllers[0]['redirects'] == 45)
|
cluster1.controllers[0]['redirects'] == 45)
|
||||||
|
|
||||||
def test_old_config_parser_both_styles(self):
|
def test_old_config_parser_both_styles(self):
|
||||||
config = StringIO.StringIO('''
|
config = StringIO.StringIO("""
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
[NVP]
|
[NVP]
|
||||||
NVP_CONTROLLER_IP = <controller ip>
|
NVP_CONTROLLER_IP = <controller ip>
|
||||||
@ -118,7 +120,7 @@ PASSWORD = <pass>
|
|||||||
DEFAULT_TZ_UUID = <default uuid>
|
DEFAULT_TZ_UUID = <default uuid>
|
||||||
NVP_CONTROLLER_CONNECTIONS = CONNECTION1
|
NVP_CONTROLLER_CONNECTIONS = CONNECTION1
|
||||||
CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
||||||
''')
|
""")
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = ConfigParser.ConfigParser()
|
||||||
cp.readfp(config)
|
cp.readfp(config)
|
||||||
cluster1, plugin_config = parse_config(cp)
|
cluster1, plugin_config = parse_config(cp)
|
||||||
@ -142,7 +144,7 @@ CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
|||||||
cluster1.controllers[0]['redirects'] == 45)
|
cluster1.controllers[0]['redirects'] == 45)
|
||||||
|
|
||||||
def test_old_config_parser_both_styles(self):
|
def test_old_config_parser_both_styles(self):
|
||||||
config = StringIO.StringIO('''
|
config = StringIO.StringIO("""
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
[NVP]
|
[NVP]
|
||||||
NVP_CONTROLLER_IP = <controller ip>
|
NVP_CONTROLLER_IP = <controller ip>
|
||||||
@ -152,7 +154,7 @@ PASSWORD = <pass>
|
|||||||
DEFAULT_TZ_UUID = <default uuid>
|
DEFAULT_TZ_UUID = <default uuid>
|
||||||
NVP_CONTROLLER_CONNECTIONS = CONNECTION1
|
NVP_CONTROLLER_CONNECTIONS = CONNECTION1
|
||||||
CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
||||||
''')
|
""")
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = ConfigParser.ConfigParser()
|
||||||
cp.readfp(config)
|
cp.readfp(config)
|
||||||
cluster1, plugin_config = parse_config(cp)
|
cluster1, plugin_config = parse_config(cp)
|
||||||
@ -176,7 +178,7 @@ CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
|||||||
cluster1.controllers[0]['redirects'] == 45)
|
cluster1.controllers[0]['redirects'] == 45)
|
||||||
|
|
||||||
def test_failover_time(self):
|
def test_failover_time(self):
|
||||||
config = StringIO.StringIO('''
|
config = StringIO.StringIO("""
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
[NVP]
|
[NVP]
|
||||||
DEFAULT_TZ_UUID = <default uuid>
|
DEFAULT_TZ_UUID = <default uuid>
|
||||||
@ -185,28 +187,28 @@ PORT = 443
|
|||||||
USER = admin
|
USER = admin
|
||||||
PASSWORD = admin
|
PASSWORD = admin
|
||||||
FAILOVER_TIME = 10
|
FAILOVER_TIME = 10
|
||||||
''')
|
""")
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = ConfigParser.ConfigParser()
|
||||||
cp.readfp(config)
|
cp.readfp(config)
|
||||||
cluster1, plugin_config = parse_config(cp)
|
cluster1, plugin_config = parse_config(cp)
|
||||||
self.assertTrue(plugin_config['failover_time'] == '10')
|
self.assertTrue(plugin_config['failover_time'] == '10')
|
||||||
|
|
||||||
def test_failover_time_new_style(self):
|
def test_failover_time_new_style(self):
|
||||||
config = StringIO.StringIO('''
|
config = StringIO.StringIO("""
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
[NVP]
|
[NVP]
|
||||||
DEFAULT_TZ_UUID = <default uuid>
|
DEFAULT_TZ_UUID = <default uuid>
|
||||||
NVP_CONTROLLER_CONNECTIONS = CONNECTION1
|
NVP_CONTROLLER_CONNECTIONS = CONNECTION1
|
||||||
CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
||||||
FAILOVER_TIME = 10
|
FAILOVER_TIME = 10
|
||||||
''')
|
""")
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = ConfigParser.ConfigParser()
|
||||||
cp.readfp(config)
|
cp.readfp(config)
|
||||||
cluster1, plugin_config = parse_config(cp)
|
cluster1, plugin_config = parse_config(cp)
|
||||||
self.assertTrue(plugin_config['failover_time'] == '10')
|
self.assertTrue(plugin_config['failover_time'] == '10')
|
||||||
|
|
||||||
def test_concurrent_connections_time(self):
|
def test_concurrent_connections_time(self):
|
||||||
config = StringIO.StringIO('''
|
config = StringIO.StringIO("""
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
[NVP]
|
[NVP]
|
||||||
DEFAULT_TZ_UUID = <default uuid>
|
DEFAULT_TZ_UUID = <default uuid>
|
||||||
@ -215,21 +217,21 @@ PORT = 443
|
|||||||
USER = admin
|
USER = admin
|
||||||
PASSWORD = admin
|
PASSWORD = admin
|
||||||
CONCURRENT_CONNECTIONS = 5
|
CONCURRENT_CONNECTIONS = 5
|
||||||
''')
|
""")
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = ConfigParser.ConfigParser()
|
||||||
cp.readfp(config)
|
cp.readfp(config)
|
||||||
cluster1, plugin_config = parse_config(cp)
|
cluster1, plugin_config = parse_config(cp)
|
||||||
self.assertTrue(plugin_config['concurrent_connections'] == '5')
|
self.assertTrue(plugin_config['concurrent_connections'] == '5')
|
||||||
|
|
||||||
def test_concurrent_connections_time_new_style(self):
|
def test_concurrent_connections_time_new_style(self):
|
||||||
config = StringIO.StringIO('''
|
config = StringIO.StringIO("""
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
[NVP]
|
[NVP]
|
||||||
DEFAULT_TZ_UUID = <default uuid>
|
DEFAULT_TZ_UUID = <default uuid>
|
||||||
NVP_CONTROLLER_CONNECTIONS = CONNECTION1
|
NVP_CONTROLLER_CONNECTIONS = CONNECTION1
|
||||||
CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
CONNECTION1 = 10.0.0.1:4242:admin:admin:42:43:44:45
|
||||||
CONCURRENT_CONNECTIONS = 5
|
CONCURRENT_CONNECTIONS = 5
|
||||||
''')
|
""")
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = ConfigParser.ConfigParser()
|
||||||
cp.readfp(config)
|
cp.readfp(config)
|
||||||
cluster1, plugin_config = parse_config(cp)
|
cluster1, plugin_config = parse_config(cp)
|
||||||
|
@ -19,10 +19,14 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from quantum.common import exceptions as exception
|
from quantum.common import exceptions as exception
|
||||||
from nicira_nvp_plugin.QuantumPlugin import NvpPlugin
|
from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import NvpPlugin
|
||||||
from nicira_nvp_plugin import NvpApiClient
|
from quantum.plugins.nicira.nicira_nvp_plugin import (
|
||||||
from nicira_nvp_plugin import nvplib
|
NvpApiClient,
|
||||||
|
nvplib,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
LOG = logging.getLogger("test_network")
|
LOG = logging.getLogger("test_network")
|
||||||
@ -72,11 +76,11 @@ class NvpTests(unittest.TestCase):
|
|||||||
"quantum-test-tenant", "quantum-Private-TenantA",
|
"quantum-test-tenant", "quantum-Private-TenantA",
|
||||||
self.BRIDGE_TZ_UUID, self.quantum.controller)
|
self.BRIDGE_TZ_UUID, self.quantum.controller)
|
||||||
resp1 = self.quantum.create_network("quantum-test-tenant",
|
resp1 = self.quantum.create_network("quantum-test-tenant",
|
||||||
"quantum-Private-TenantB")
|
"quantum-Private-TenantB")
|
||||||
resp2 = self.quantum.create_network("quantum-test-tenant",
|
resp2 = self.quantum.create_network("quantum-test-tenant",
|
||||||
"quantum-Private-TenantC")
|
"quantum-Private-TenantC")
|
||||||
resp3 = self.quantum.create_network("quantum-test-tenant",
|
resp3 = self.quantum.create_network("quantum-test-tenant",
|
||||||
"quantum-Private-TenantD")
|
"quantum-Private-TenantD")
|
||||||
net_id = resp["net-id"]
|
net_id = resp["net-id"]
|
||||||
|
|
||||||
resp = self.quantum.create_port("quantum-test-tenant", net_id,
|
resp = self.quantum.create_port("quantum-test-tenant", net_id,
|
||||||
@ -88,7 +92,7 @@ class NvpTests(unittest.TestCase):
|
|||||||
self.assertTrue(old_vic == "None")
|
self.assertTrue(old_vic == "None")
|
||||||
|
|
||||||
self.quantum.plug_interface("quantum-test-tenant", net_id, port_id1,
|
self.quantum.plug_interface("quantum-test-tenant", net_id, port_id1,
|
||||||
"nova-instance-test-%s" % os.getpid())
|
"nova-instance-test-%s" % os.getpid())
|
||||||
resp = self.quantum.get_port_details("quantum-test-tenant", net_id,
|
resp = self.quantum.get_port_details("quantum-test-tenant", net_id,
|
||||||
port_id1)
|
port_id1)
|
||||||
new_vic = resp["attachment"]
|
new_vic = resp["attachment"]
|
||||||
@ -103,7 +107,7 @@ class NvpTests(unittest.TestCase):
|
|||||||
self.assertTrue(old_vic2 == "None")
|
self.assertTrue(old_vic2 == "None")
|
||||||
|
|
||||||
self.quantum.plug_interface("quantum-test-tenant", net_id, port_id2,
|
self.quantum.plug_interface("quantum-test-tenant", net_id, port_id2,
|
||||||
"nova-instance-test2-%s" % os.getpid())
|
"nova-instance-test2-%s" % os.getpid())
|
||||||
resp = self.quantum.get_port_details("quantum-test-tenant", net_id,
|
resp = self.quantum.get_port_details("quantum-test-tenant", net_id,
|
||||||
port_id2)
|
port_id2)
|
||||||
new_vic = resp["attachment"]
|
new_vic = resp["attachment"]
|
||||||
@ -130,7 +134,7 @@ class NvpTests(unittest.TestCase):
|
|||||||
net_id = resp["net-id"]
|
net_id = resp["net-id"]
|
||||||
try:
|
try:
|
||||||
resp = self.quantum.update_network("quantum-test-tenant", net_id,
|
resp = self.quantum.update_network("quantum-test-tenant", net_id,
|
||||||
name="new-name")
|
name="new-name")
|
||||||
except exception.NetworkNotFound:
|
except exception.NetworkNotFound:
|
||||||
self.assertTrue(False)
|
self.assertTrue(False)
|
||||||
|
|
||||||
@ -152,7 +156,7 @@ class NvpTests(unittest.TestCase):
|
|||||||
def test_negative_update_network(self):
|
def test_negative_update_network(self):
|
||||||
try:
|
try:
|
||||||
self.quantum.update_network("quantum-test-tenant", "xxx-no-net-id",
|
self.quantum.update_network("quantum-test-tenant", "xxx-no-net-id",
|
||||||
name="new-name")
|
name="new-name")
|
||||||
except exception.NetworkNotFound:
|
except exception.NetworkNotFound:
|
||||||
self.assertTrue(True)
|
self.assertTrue(True)
|
||||||
|
|
||||||
|
@ -12,11 +12,10 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import httplib
|
import httplib
|
||||||
import unittest
|
import unittest2 as unittest
|
||||||
|
|
||||||
import nicira_nvp_plugin.api_client.common as naco
|
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.common as naco
|
||||||
|
|
||||||
|
|
||||||
class NvpApiCommonTest(unittest.TestCase):
|
class NvpApiCommonTest(unittest.TestCase):
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user