Bug #1013967 - Quantum is breaking on tests with pep 1.3
Fixing files 93/93 files fixed Change-Id: Ia30f2e2253806fa5f447d44208d13d2c0beba9cd
This commit is contained in:
parent
ab87bf4d8f
commit
e5b9078f4c
@ -58,7 +58,7 @@ class OVSBridge:
|
|||||||
|
|
||||||
def delete_port(self, port_name):
|
def delete_port(self, port_name):
|
||||||
self.run_vsctl(["--", "--if-exists", "del-port", self.br_name,
|
self.run_vsctl(["--", "--if-exists", "del-port", self.br_name,
|
||||||
port_name])
|
port_name])
|
||||||
|
|
||||||
def set_db_attribute(self, table_name, record, column, value):
|
def set_db_attribute(self, table_name, record, column, value):
|
||||||
args = ["set", table_name, record, "%s=%s" % (column, value)]
|
args = ["set", table_name, record, "%s=%s" % (column, value)]
|
||||||
@ -87,10 +87,10 @@ class OVSBridge:
|
|||||||
is_delete_expr = kwargs.get('delete', False)
|
is_delete_expr = kwargs.get('delete', False)
|
||||||
print "kwargs = %s" % kwargs
|
print "kwargs = %s" % kwargs
|
||||||
if not is_delete_expr:
|
if not is_delete_expr:
|
||||||
prefix = ("hard_timeout=%s,idle_timeout=%s,priority=%s"
|
prefix = ("hard_timeout=%s,idle_timeout=%s,priority=%s" %
|
||||||
% (kwargs.get('hard_timeout', '0'),
|
(kwargs.get('hard_timeout', '0'),
|
||||||
kwargs.get('idle_timeout', '0'),
|
kwargs.get('idle_timeout', '0'),
|
||||||
kwargs.get('priority', '1')))
|
kwargs.get('priority', '1')))
|
||||||
flow_expr_arr.append(prefix)
|
flow_expr_arr.append(prefix)
|
||||||
elif 'priority' in kwargs:
|
elif 'priority' in kwargs:
|
||||||
raise Exception("Cannot match priority on flow deletion")
|
raise Exception("Cannot match priority on flow deletion")
|
||||||
@ -179,7 +179,7 @@ class OVSBridge:
|
|||||||
return utils.execute(["xe", "vif-param-get", "param-name=other-config",
|
return utils.execute(["xe", "vif-param-get", "param-name=other-config",
|
||||||
"param-key=nicira-iface-id",
|
"param-key=nicira-iface-id",
|
||||||
"uuid=%s" % xs_vif_uuid],
|
"uuid=%s" % xs_vif_uuid],
|
||||||
root_helper=self.root_helper).strip()
|
root_helper=self.root_helper).strip()
|
||||||
|
|
||||||
# returns a VIF object for each VIF port
|
# returns a VIF object for each VIF port
|
||||||
def get_vif_ports(self):
|
def get_vif_ports(self):
|
||||||
|
@ -31,7 +31,7 @@ def create_resource(plugin, version):
|
|||||||
'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)
|
||||||
|
|
||||||
|
|
||||||
@ -44,16 +44,16 @@ class Controller(common.QuantumController):
|
|||||||
{
|
{
|
||||||
'param-name': 'id',
|
'param-name': 'id',
|
||||||
'required': True,
|
'required': True,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"attachment": ["id"],
|
"attachment": ["id"],
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
|
||||||
@common.APIFaultWrapper([exception.NetworkNotFound,
|
@common.APIFaultWrapper([exception.NetworkNotFound,
|
||||||
exception.PortNotFound])
|
exception.PortNotFound])
|
||||||
|
@ -47,8 +47,8 @@ def fault_body_function_v10(wrapped_exc):
|
|||||||
'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
|
||||||
|
|
||||||
@ -71,8 +71,8 @@ def fault_body_function_v11(wrapped_exc):
|
|||||||
'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
|
||||||
|
|
||||||
@ -90,41 +90,41 @@ def fault_body_function(version):
|
|||||||
class Quantum10HTTPError(webob.exc.HTTPClientError):
|
class Quantum10HTTPError(webob.exc.HTTPClientError):
|
||||||
|
|
||||||
_fault_dict = {
|
_fault_dict = {
|
||||||
exceptions.NetworkNotFound: {
|
exceptions.NetworkNotFound: {
|
||||||
'code': 420,
|
'code': 420,
|
||||||
'title': 'networkNotFound',
|
'title': 'networkNotFound',
|
||||||
'explanation': _NETNOTFOUND_EXPL
|
'explanation': _NETNOTFOUND_EXPL
|
||||||
},
|
},
|
||||||
exceptions.NetworkInUse: {
|
exceptions.NetworkInUse: {
|
||||||
'code': 421,
|
'code': 421,
|
||||||
'title': 'networkInUse',
|
'title': 'networkInUse',
|
||||||
'explanation': _NETINUSE_EXPL
|
'explanation': _NETINUSE_EXPL
|
||||||
},
|
},
|
||||||
exceptions.PortNotFound: {
|
exceptions.PortNotFound: {
|
||||||
'code': 430,
|
'code': 430,
|
||||||
'title': 'portNotFound',
|
'title': 'portNotFound',
|
||||||
'explanation': _PORTNOTFOUND_EXPL
|
'explanation': _PORTNOTFOUND_EXPL
|
||||||
},
|
},
|
||||||
exceptions.StateInvalid: {
|
exceptions.StateInvalid: {
|
||||||
'code': 431,
|
'code': 431,
|
||||||
'title': 'requestedStateInvalid',
|
'title': 'requestedStateInvalid',
|
||||||
'explanation': _STATEINVALID_EXPL
|
'explanation': _STATEINVALID_EXPL
|
||||||
},
|
},
|
||||||
exceptions.PortInUse: {
|
exceptions.PortInUse: {
|
||||||
'code': 432,
|
'code': 432,
|
||||||
'title': 'portInUse',
|
'title': 'portInUse',
|
||||||
'explanation': _PORTINUSE_EXPL
|
'explanation': _PORTINUSE_EXPL
|
||||||
},
|
},
|
||||||
exceptions.AlreadyAttached: {
|
exceptions.AlreadyAttached: {
|
||||||
'code': 440,
|
'code': 440,
|
||||||
'title': 'alreadyAttached',
|
'title': 'alreadyAttached',
|
||||||
'explanation': _ALREADYATTACHED_EXPL
|
'explanation': _ALREADYATTACHED_EXPL
|
||||||
},
|
},
|
||||||
exceptions.NotImplementedError: {
|
exceptions.NotImplementedError: {
|
||||||
'code': 501,
|
'code': 501,
|
||||||
'title': 'notImplemented',
|
'title': 'notImplemented',
|
||||||
'explanation': _NOTIMPLEMENTED_EXPL
|
'explanation': _NOTIMPLEMENTED_EXPL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, inner_exc):
|
def __init__(self, inner_exc):
|
||||||
@ -139,42 +139,42 @@ class Quantum10HTTPError(webob.exc.HTTPClientError):
|
|||||||
class Quantum11HTTPError(webob.exc.HTTPClientError):
|
class Quantum11HTTPError(webob.exc.HTTPClientError):
|
||||||
|
|
||||||
_fault_dict = {
|
_fault_dict = {
|
||||||
exceptions.NetworkNotFound: {
|
exceptions.NetworkNotFound: {
|
||||||
'code': webob.exc.HTTPNotFound.code,
|
'code': webob.exc.HTTPNotFound.code,
|
||||||
'title': webob.exc.HTTPNotFound.title,
|
'title': webob.exc.HTTPNotFound.title,
|
||||||
'type': 'NetworkNotFound',
|
'type': 'NetworkNotFound',
|
||||||
'explanation': _NETNOTFOUND_EXPL
|
'explanation': _NETNOTFOUND_EXPL
|
||||||
},
|
},
|
||||||
exceptions.NetworkInUse: {
|
exceptions.NetworkInUse: {
|
||||||
'code': webob.exc.HTTPConflict.code,
|
'code': webob.exc.HTTPConflict.code,
|
||||||
'title': webob.exc.HTTPConflict.title,
|
'title': webob.exc.HTTPConflict.title,
|
||||||
'type': 'NetworkInUse',
|
'type': 'NetworkInUse',
|
||||||
'explanation': _NETINUSE_EXPL
|
'explanation': _NETINUSE_EXPL
|
||||||
},
|
},
|
||||||
exceptions.PortNotFound: {
|
exceptions.PortNotFound: {
|
||||||
'code': webob.exc.HTTPNotFound.code,
|
'code': webob.exc.HTTPNotFound.code,
|
||||||
'title': webob.exc.HTTPNotFound.title,
|
'title': webob.exc.HTTPNotFound.title,
|
||||||
'type': 'PortNotFound',
|
'type': 'PortNotFound',
|
||||||
'explanation': _PORTNOTFOUND_EXPL
|
'explanation': _PORTNOTFOUND_EXPL
|
||||||
},
|
},
|
||||||
exceptions.StateInvalid: {
|
exceptions.StateInvalid: {
|
||||||
'code': webob.exc.HTTPBadRequest.code,
|
'code': webob.exc.HTTPBadRequest.code,
|
||||||
'title': webob.exc.HTTPBadRequest.title,
|
'title': webob.exc.HTTPBadRequest.title,
|
||||||
'type': 'RequestedStateInvalid',
|
'type': 'RequestedStateInvalid',
|
||||||
'explanation': _STATEINVALID_EXPL
|
'explanation': _STATEINVALID_EXPL
|
||||||
},
|
},
|
||||||
exceptions.PortInUse: {
|
exceptions.PortInUse: {
|
||||||
'code': webob.exc.HTTPConflict.code,
|
'code': webob.exc.HTTPConflict.code,
|
||||||
'title': webob.exc.HTTPConflict.title,
|
'title': webob.exc.HTTPConflict.title,
|
||||||
'type': 'PortInUse',
|
'type': 'PortInUse',
|
||||||
'explanation': _PORTINUSE_EXPL
|
'explanation': _PORTINUSE_EXPL
|
||||||
},
|
},
|
||||||
exceptions.AlreadyAttached: {
|
exceptions.AlreadyAttached: {
|
||||||
'code': webob.exc.HTTPConflict.code,
|
'code': webob.exc.HTTPConflict.code,
|
||||||
'title': webob.exc.HTTPConflict.title,
|
'title': webob.exc.HTTPConflict.title,
|
||||||
'type': 'AlreadyAttached',
|
'type': 'AlreadyAttached',
|
||||||
'explanation': _ALREADYATTACHED_EXPL
|
'explanation': _ALREADYATTACHED_EXPL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, inner_exc):
|
def __init__(self, inner_exc):
|
||||||
|
@ -33,7 +33,7 @@ def create_resource(plugin, version):
|
|||||||
'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)
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ class Controller(common.QuantumController):
|
|||||||
version = None
|
version = None
|
||||||
_network_ops_param_list = [
|
_network_ops_param_list = [
|
||||||
{'param-name': 'name', 'required': True},
|
{'param-name': 'name', 'required': True},
|
||||||
]
|
]
|
||||||
|
|
||||||
def _item(self, request, tenant_id, network_id,
|
def _item(self, request, tenant_id, network_id,
|
||||||
net_details=True, port_details=False):
|
net_details=True, port_details=False):
|
||||||
@ -154,12 +154,12 @@ class ControllerV10(Controller):
|
|||||||
"network": ["id", "name"],
|
"network": ["id", "name"],
|
||||||
"port": ["id", "state"],
|
"port": ["id", "state"],
|
||||||
"attachment": ["id"],
|
"attachment": ["id"],
|
||||||
},
|
},
|
||||||
"plurals": {
|
"plurals": {
|
||||||
"networks": "network",
|
"networks": "network",
|
||||||
"ports": "port",
|
"ports": "port",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|
||||||
@ -178,11 +178,11 @@ class ControllerV11(Controller):
|
|||||||
"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": {
|
"plurals": {
|
||||||
"networks": "network",
|
"networks": "network",
|
||||||
"ports": "port",
|
"ports": "port",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "1.1"
|
version = "1.1"
|
||||||
|
@ -32,7 +32,7 @@ def create_resource(plugin, version):
|
|||||||
'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)
|
||||||
|
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class Controller(common.QuantumController):
|
|||||||
version = None
|
version = None
|
||||||
_port_ops_param_list = [
|
_port_ops_param_list = [
|
||||||
{'param-name': 'state', 'default-value': 'DOWN', 'required': False},
|
{'param-name': 'state', 'default-value': 'DOWN', 'required': False},
|
||||||
]
|
]
|
||||||
|
|
||||||
def _items(self, request, tenant_id, network_id,
|
def _items(self, request, tenant_id, network_id,
|
||||||
port_details=False):
|
port_details=False):
|
||||||
@ -160,11 +160,11 @@ class ControllerV10(Controller):
|
|||||||
"attributes": {
|
"attributes": {
|
||||||
"port": ["id", "state"],
|
"port": ["id", "state"],
|
||||||
"attachment": ["id"],
|
"attachment": ["id"],
|
||||||
},
|
},
|
||||||
"plurals": {
|
"plurals": {
|
||||||
"ports": "port",
|
"ports": "port",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|
||||||
@ -176,10 +176,10 @@ class ControllerV11(Controller):
|
|||||||
"attributes": {
|
"attributes": {
|
||||||
"port": ["id", "state", "op-status"],
|
"port": ["id", "state", "op-status"],
|
||||||
"attachment": ["id"],
|
"attachment": ["id"],
|
||||||
},
|
},
|
||||||
"plurals": {
|
"plurals": {
|
||||||
"ports": "port",
|
"ports": "port",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "1.1"
|
version = "1.1"
|
||||||
|
@ -158,9 +158,9 @@ class Controller(object):
|
|||||||
if self._resource not in ['network', 'port']:
|
if self._resource not in ['network', 'port']:
|
||||||
return
|
return
|
||||||
|
|
||||||
if ('tenant_id' in res_dict and
|
if (('tenant_id' in res_dict and
|
||||||
res_dict['tenant_id'] != context.tenant_id and
|
res_dict['tenant_id'] != context.tenant_id and
|
||||||
not context.is_admin):
|
not context.is_admin)):
|
||||||
msg = _("Specifying 'tenant_id' other than authenticated"
|
msg = _("Specifying 'tenant_id' other than authenticated"
|
||||||
"tenant in request requires admin privileges")
|
"tenant in request requires admin privileges")
|
||||||
raise webob.exc.HTTPBadRequest(msg)
|
raise webob.exc.HTTPBadRequest(msg)
|
||||||
@ -170,7 +170,7 @@ class Controller(object):
|
|||||||
res_dict['tenant_id'] = context.tenant_id
|
res_dict['tenant_id'] = context.tenant_id
|
||||||
else:
|
else:
|
||||||
msg = _("Running without keystyone AuthN requires "
|
msg = _("Running without keystyone AuthN requires "
|
||||||
" that tenant_id is specified")
|
" that tenant_id is specified")
|
||||||
raise webob.exc.HTTPBadRequest(msg)
|
raise webob.exc.HTTPBadRequest(msg)
|
||||||
|
|
||||||
def _prepare_request_body(self, context, body, is_create,
|
def _prepare_request_body(self, context, body, is_create,
|
||||||
@ -242,13 +242,11 @@ def create_resource(collection, resource, plugin, conf, params):
|
|||||||
|
|
||||||
# NOTE(jkoelker) To anyone wishing to add "proper" xml support
|
# NOTE(jkoelker) To anyone wishing to add "proper" xml support
|
||||||
# this is where you do it
|
# this is where you do it
|
||||||
serializers = {
|
serializers = {}
|
||||||
# 'application/xml': wsgi.XMLDictSerializer(metadata, XML_NS_V20),
|
# 'application/xml': wsgi.XMLDictSerializer(metadata, XML_NS_V20),
|
||||||
}
|
|
||||||
|
|
||||||
deserializers = {
|
deserializers = {}
|
||||||
# 'application/xml': wsgi.XMLDeserializer(metadata),
|
# 'application/xml': wsgi.XMLDeserializer(metadata),
|
||||||
}
|
|
||||||
|
|
||||||
return wsgi_resource.Resource(controller, FAULT_MAP, deserializers,
|
return wsgi_resource.Resource(controller, FAULT_MAP, deserializers,
|
||||||
serializers)
|
serializers)
|
||||||
|
@ -95,13 +95,9 @@ class Index(wsgi.Application):
|
|||||||
|
|
||||||
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
@webob.dec.wsgify(RequestClass=wsgi.Request)
|
||||||
def __call__(self, req):
|
def __call__(self, req):
|
||||||
metadata = {'application/xml': {
|
metadata = {'application/xml': {'attributes': {
|
||||||
'attributes': {
|
'resource': ['name', 'collection'],
|
||||||
'resource': ['name', 'collection'],
|
'link': ['href', 'rel']}}}
|
||||||
'link': ['href', 'rel'],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
layout = []
|
layout = []
|
||||||
for name, collection in self.resources.iteritems():
|
for name, collection in self.resources.iteritems():
|
||||||
@ -153,6 +149,6 @@ class APIRouter(wsgi.Router):
|
|||||||
for resource in resources:
|
for resource in resources:
|
||||||
_map_resource(resources[resource], resource,
|
_map_resource(resources[resource], resource,
|
||||||
RESOURCE_ATTRIBUTE_MAP.get(resources[resource],
|
RESOURCE_ATTRIBUTE_MAP.get(resources[resource],
|
||||||
dict()))
|
dict()))
|
||||||
|
|
||||||
super(APIRouter, self).__init__(mapper)
|
super(APIRouter, self).__init__(mapper)
|
||||||
|
@ -65,8 +65,8 @@ class Versions(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
content_type = req.best_match_content_type()
|
content_type = req.best_match_content_type()
|
||||||
body = wsgi.Serializer(metadata=metadata). \
|
body = (wsgi.Serializer(metadata=metadata).
|
||||||
serialize(response, content_type)
|
serialize(response, content_type))
|
||||||
|
|
||||||
response = webob.Response()
|
response = webob.Response()
|
||||||
response.content_type = content_type
|
response.content_type = content_type
|
||||||
|
@ -30,8 +30,8 @@ def _load_network_ports_details(network, **kwargs):
|
|||||||
# Don't pass filter options, don't care about unused filters
|
# Don't pass filter options, don't care about unused filters
|
||||||
port_list = plugin.get_all_ports(tenant_id, network['net-id'])
|
port_list = plugin.get_all_ports(tenant_id, network['net-id'])
|
||||||
ports_data = [plugin.get_port_details(
|
ports_data = [plugin.get_port_details(
|
||||||
tenant_id, network['net-id'],
|
tenant_id, network['net-id'],
|
||||||
port['port-id'])
|
port['port-id'])
|
||||||
for port in port_list]
|
for port in port_list]
|
||||||
network['net-ports'] = ports_data
|
network['net-ports'] = ports_data
|
||||||
|
|
||||||
@ -150,8 +150,7 @@ def filter_ports(ports, plugin, tenant_id, network_id, filter_opts):
|
|||||||
'attachment': _filter_port_by_interface}
|
'attachment': _filter_port_by_interface}
|
||||||
# port details are need for filtering
|
# port details are need for filtering
|
||||||
ports = [plugin.get_port_details(tenant_id, network_id,
|
ports = [plugin.get_port_details(tenant_id, network_id,
|
||||||
port['port-id'])
|
port['port-id']) for port in ports]
|
||||||
for port in ports]
|
|
||||||
# filter ports
|
# filter ports
|
||||||
return _do_filtering(ports,
|
return _do_filtering(ports,
|
||||||
filters,
|
filters,
|
||||||
|
@ -54,7 +54,7 @@ class ViewBuilder10(object):
|
|||||||
def _build_detail(self, network_data):
|
def _build_detail(self, network_data):
|
||||||
"""Return a detailed model of a network."""
|
"""Return a detailed model of a network."""
|
||||||
return dict(network=dict(id=network_data['net-id'],
|
return dict(network=dict(id=network_data['net-id'],
|
||||||
name=network_data['net-name']))
|
name=network_data['net-name']))
|
||||||
|
|
||||||
def _build_port(self, port_data):
|
def _build_port(self, port_data):
|
||||||
"""Return details about a specific logical port."""
|
"""Return details about a specific logical port."""
|
||||||
@ -82,7 +82,7 @@ class ViewBuilder11(ViewBuilder10):
|
|||||||
def _build_port(self, port_data):
|
def _build_port(self, port_data):
|
||||||
"""Return details about a specific logical port."""
|
"""Return details about a specific logical port."""
|
||||||
op_status = port_data.get('port-op-status',
|
op_status = port_data.get('port-op-status',
|
||||||
OperationalStatus.UNKNOWN)
|
OperationalStatus.UNKNOWN)
|
||||||
port_dict = {'id': port_data['port-id'],
|
port_dict = {'id': port_data['port-id'],
|
||||||
'state': port_data['port-state'],
|
'state': port_data['port-state'],
|
||||||
'op-status': op_status}
|
'op-status': op_status}
|
||||||
|
@ -53,7 +53,8 @@ class ViewBuilder11(ViewBuilder10):
|
|||||||
if port_details:
|
if port_details:
|
||||||
port['port']['state'] = port_data['port-state']
|
port['port']['state'] = port_data['port-state']
|
||||||
port['port']['op-status'] = port_data.get('port-op-status',
|
port['port']['op-status'] = port_data.get('port-op-status',
|
||||||
OperationalStatus.UNKNOWN)
|
OperationalStatus.
|
||||||
|
UNKNOWN)
|
||||||
if att_details and port_data['attachment']:
|
if att_details and port_data['attachment']:
|
||||||
port['port']['attachment'] = dict(id=port_data['attachment'])
|
port['port']['attachment'] = dict(id=port_data['attachment'])
|
||||||
return port
|
return port
|
||||||
|
@ -106,18 +106,18 @@ def add_log_options(parser):
|
|||||||
"the Python logging module documentation for "
|
"the Python logging module documentation for "
|
||||||
"details on logging configuration files.")
|
"details on logging configuration files.")
|
||||||
group.add_option('--log-date-format', metavar="FORMAT",
|
group.add_option('--log-date-format', metavar="FORMAT",
|
||||||
default=DEFAULT_LOG_DATE_FORMAT,
|
default=DEFAULT_LOG_DATE_FORMAT,
|
||||||
help="Format string for %(asctime)s in log records. "
|
help="Format string for %(asctime)s in log records. "
|
||||||
"Default: %default")
|
"Default: %default")
|
||||||
group.add_option('--use-syslog', default=False,
|
group.add_option('--use-syslog', default=False,
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Output logs to syslog.")
|
help="Output logs to syslog.")
|
||||||
group.add_option('--log-file', default=None, metavar="PATH",
|
group.add_option('--log-file', default=None, metavar="PATH",
|
||||||
help="(Optional) Name of log file to output to. "
|
help="(Optional) Name of log file to output to. "
|
||||||
"If not set, logging will go to stdout.")
|
"If not set, logging will go to stdout.")
|
||||||
group.add_option("--log-dir", default=None,
|
group.add_option("--log-dir", default=None,
|
||||||
help="(Optional) The directory to keep log files in "
|
help="(Optional) The directory to keep log files in "
|
||||||
"(will be prepended to --logfile)")
|
"(will be prepended to --logfile)")
|
||||||
parser.add_option_group(group)
|
parser.add_option_group(group)
|
||||||
|
|
||||||
|
|
||||||
@ -237,10 +237,9 @@ def find_config_file(options, args, config_file='quantum.conf'):
|
|||||||
'/etc']
|
'/etc']
|
||||||
|
|
||||||
if 'plugin' in options:
|
if 'plugin' in options:
|
||||||
config_file_dirs = [
|
config_file_dirs = [os.path.join(x, 'quantum',
|
||||||
os.path.join(x, 'quantum', 'plugins', options['plugin'])
|
'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'))
|
||||||
@ -282,7 +281,7 @@ def load_paste_config(app_name, options, args):
|
|||||||
conf_file = find_config_file(options, args)
|
conf_file = find_config_file(options, args)
|
||||||
if not conf_file:
|
if not conf_file:
|
||||||
raise RuntimeError("Unable to locate any configuration file. "
|
raise RuntimeError("Unable to locate any configuration file. "
|
||||||
"Cannot load application %s" % app_name)
|
"Cannot load application %s" % app_name)
|
||||||
try:
|
try:
|
||||||
conf = deploy.appconfig("config:%s" % conf_file, name=app_name)
|
conf = deploy.appconfig("config:%s" % conf_file, name=app_name)
|
||||||
return conf_file, conf
|
return conf_file, conf
|
||||||
|
@ -99,9 +99,9 @@ class _Win32Colorizer(object):
|
|||||||
See _AnsiColorizer docstring.
|
See _AnsiColorizer docstring.
|
||||||
"""
|
"""
|
||||||
def __init__(self, stream):
|
def __init__(self, stream):
|
||||||
from win32console import GetStdHandle, STD_OUT_HANDLE, \
|
from win32console import GetStdHandle, STD_OUT_HANDLE
|
||||||
FOREGROUND_RED, FOREGROUND_BLUE, FOREGROUND_GREEN, \
|
from win32console import FOREGROUND_RED, FOREGROUND_BLUE
|
||||||
FOREGROUND_INTENSITY
|
from win32console import FOREGROUND_GREEN, FOREGROUND_INTENSITY
|
||||||
red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN,
|
red, green, blue, bold = (FOREGROUND_RED, FOREGROUND_GREEN,
|
||||||
FOREGROUND_BLUE, FOREGROUND_INTENSITY)
|
FOREGROUND_BLUE, FOREGROUND_INTENSITY)
|
||||||
self.stream = stream
|
self.stream = stream
|
||||||
@ -251,9 +251,9 @@ class QuantumTestResult(result.TextTestResult):
|
|||||||
class QuantumTestRunner(core.TextTestRunner):
|
class QuantumTestRunner(core.TextTestRunner):
|
||||||
def _makeResult(self):
|
def _makeResult(self):
|
||||||
return QuantumTestResult(self.stream,
|
return QuantumTestResult(self.stream,
|
||||||
self.descriptions,
|
self.descriptions,
|
||||||
self.verbosity,
|
self.verbosity,
|
||||||
self.config)
|
self.config)
|
||||||
|
|
||||||
|
|
||||||
def run_tests(c=None):
|
def run_tests(c=None):
|
||||||
@ -273,8 +273,8 @@ def run_tests(c=None):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
runner = QuantumTestRunner(stream=c.stream,
|
runner = QuantumTestRunner(stream=c.stream,
|
||||||
verbosity=c.verbosity,
|
verbosity=c.verbosity,
|
||||||
config=c)
|
config=c)
|
||||||
return not core.run(config=c, testRunner=runner)
|
return not core.run(config=c, testRunner=runner)
|
||||||
|
|
||||||
# describes parameters used by different unit/functional tests
|
# describes parameters used by different unit/functional tests
|
||||||
|
@ -91,7 +91,8 @@ def execute(cmd, process_input=None, addl_env=None, check_exit_code=True):
|
|||||||
if addl_env:
|
if addl_env:
|
||||||
env.update(addl_env)
|
env.update(addl_env)
|
||||||
obj = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
|
obj = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
|
env=env)
|
||||||
result = None
|
result = None
|
||||||
if process_input is not None:
|
if process_input is not None:
|
||||||
result = obj.communicate(process_input)
|
result = obj.communicate(process_input)
|
||||||
|
@ -42,8 +42,8 @@ class Context(object):
|
|||||||
*only* deleted records are visible.
|
*only* deleted records are visible.
|
||||||
"""
|
"""
|
||||||
if kwargs:
|
if kwargs:
|
||||||
LOG.warn(_('Arguments dropped when creating context: %s') %
|
LOG.warn(_('Arguments dropped when creating '
|
||||||
str(kwargs))
|
'context: %s') % str(kwargs))
|
||||||
|
|
||||||
self.user_id = user_id
|
self.user_id = user_id
|
||||||
self.tenant_id = tenant_id
|
self.tenant_id = tenant_id
|
||||||
|
@ -137,7 +137,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
|
|||||||
'admin_state_up': network['admin_state_up'],
|
'admin_state_up': network['admin_state_up'],
|
||||||
'status': network['status'],
|
'status': network['status'],
|
||||||
'subnets': [subnet['id']
|
'subnets': [subnet['id']
|
||||||
for subnet in network['subnets']]}
|
for subnet in network['subnets']]}
|
||||||
|
|
||||||
return self._fields(res, fields)
|
return self._fields(res, fields)
|
||||||
|
|
||||||
|
@ -73,5 +73,5 @@ class Network(model_base.BASE):
|
|||||||
self.op_status = op_status
|
self.op_status = op_status
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Network(%s,%s,%s,%s)>" % \
|
return "<Network(%s,%s,%s,%s)>" % (self.uuid, self.name,
|
||||||
(self.uuid, self.name, self.op_status, self.tenant_id)
|
self.op_status, self.tenant_id)
|
||||||
|
@ -32,14 +32,14 @@ class IPAllocation(model_base.BASEV2):
|
|||||||
port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'))
|
port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id'))
|
||||||
address = sa.Column(sa.String(16), nullable=False, primary_key=True)
|
address = sa.Column(sa.String(16), nullable=False, primary_key=True)
|
||||||
subnet_id = sa.Column(sa.String(36), sa.ForeignKey('subnets.id'),
|
subnet_id = sa.Column(sa.String(36), sa.ForeignKey('subnets.id'),
|
||||||
primary_key=True)
|
primary_key=True)
|
||||||
allocated = sa.Column(sa.Boolean(), nullable=False)
|
allocated = sa.Column(sa.Boolean(), nullable=False)
|
||||||
|
|
||||||
|
|
||||||
class Port(model_base.BASEV2, HasTenant):
|
class Port(model_base.BASEV2, HasTenant):
|
||||||
"""Represents a port on a quantum v2 network"""
|
"""Represents a port on a quantum v2 network"""
|
||||||
network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id"),
|
network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id"),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
fixed_ips = orm.relationship(IPAllocation, backref='ports')
|
fixed_ips = orm.relationship(IPAllocation, backref='ports')
|
||||||
mac_address = sa.Column(sa.String(32), nullable=False)
|
mac_address = sa.Column(sa.String(32), nullable=False)
|
||||||
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
|
admin_state_up = sa.Column(sa.Boolean(), nullable=False)
|
||||||
|
@ -50,14 +50,12 @@ class ViewBuilder(object):
|
|||||||
"""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(
|
return dict(portprofile=dict(
|
||||||
id=portprofile_data['profile_id'],
|
id=portprofile_data['profile_id'],
|
||||||
name=portprofile_data['profile_name'],
|
name=portprofile_data['profile_name'],
|
||||||
qos_name=portprofile_data['qos_name'],
|
qos_name=portprofile_data['qos_name']))
|
||||||
))
|
|
||||||
else:
|
else:
|
||||||
return dict(portprofile=dict(
|
return dict(portprofile=dict(
|
||||||
id=portprofile_data['profile_id'],
|
id=portprofile_data['profile_id'],
|
||||||
name=portprofile_data['profile_name'],
|
name=portprofile_data['profile_name'],
|
||||||
qos_name=portprofile_data['qos_name'],
|
qos_name=portprofile_data['qos_name'],
|
||||||
assignment=portprofile_data['assignment'],
|
assignment=portprofile_data['assignment']))
|
||||||
))
|
|
||||||
|
@ -80,7 +80,7 @@ class CredentialController(common.QuantumController, wsgi.Controller):
|
|||||||
{'param-name': 'credential_name', 'required': True},
|
{'param-name': 'credential_name', 'required': True},
|
||||||
{'param-name': 'user_name', 'required': True},
|
{'param-name': 'user_name', 'required': True},
|
||||||
{'param-name': 'password', 'required': True},
|
{'param-name': 'password', 'required': True},
|
||||||
]
|
]
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
|
@ -228,7 +228,7 @@ class ExtensionMiddleware(wsgi.Middleware):
|
|||||||
# extended resources
|
# extended resources
|
||||||
for resource in self.ext_mgr.get_resources():
|
for resource in self.ext_mgr.get_resources():
|
||||||
LOG.debug(_('Extended resource: %s'),
|
LOG.debug(_('Extended resource: %s'),
|
||||||
resource.collection)
|
resource.collection)
|
||||||
for action, method in resource.collection_actions.iteritems():
|
for action, method in resource.collection_actions.iteritems():
|
||||||
path_prefix = ""
|
path_prefix = ""
|
||||||
parent = resource.parent
|
parent = resource.parent
|
||||||
@ -459,8 +459,8 @@ class ExtensionManager(object):
|
|||||||
LOG.warn(_('Loaded extension: %s'), alias)
|
LOG.warn(_('Loaded extension: %s'), alias)
|
||||||
|
|
||||||
if alias in self.extensions:
|
if alias in self.extensions:
|
||||||
raise exceptions.Error("Found duplicate extension: %s"
|
raise exceptions.Error("Found duplicate extension: %s" %
|
||||||
% alias)
|
alias)
|
||||||
self.extensions[alias] = ext
|
self.extensions[alias] = ext
|
||||||
|
|
||||||
|
|
||||||
@ -474,7 +474,7 @@ class PluginAwareExtensionManager(ExtensionManager):
|
|||||||
"""Checks if plugin supports extension and implements the
|
"""Checks if plugin supports extension and implements the
|
||||||
extension contract."""
|
extension contract."""
|
||||||
extension_is_valid = super(PluginAwareExtensionManager,
|
extension_is_valid = super(PluginAwareExtensionManager,
|
||||||
self)._check_extension(extension)
|
self)._check_extension(extension)
|
||||||
return (extension_is_valid and
|
return (extension_is_valid and
|
||||||
self._plugin_supports(extension) and
|
self._plugin_supports(extension) and
|
||||||
self._plugin_implements_interface(extension))
|
self._plugin_implements_interface(extension))
|
||||||
|
@ -79,7 +79,7 @@ class MultiportController(common.QuantumController, wsgi.Controller):
|
|||||||
{'param-name': 'net_id_list', 'required': True},
|
{'param-name': 'net_id_list', 'required': True},
|
||||||
{'param-name': 'status', 'required': True},
|
{'param-name': 'status', 'required': True},
|
||||||
{'param-name': 'ports_desc', 'required': True},
|
{'param-name': 'ports_desc', 'required': True},
|
||||||
]
|
]
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
|
@ -77,12 +77,12 @@ class NovatenantsController(common.QuantumController, wsgi.Controller):
|
|||||||
|
|
||||||
_Novatenant_ops_param_list = [
|
_Novatenant_ops_param_list = [
|
||||||
{'param-name': 'novatenant_name', 'required': True},
|
{'param-name': 'novatenant_name', 'required': True},
|
||||||
]
|
]
|
||||||
|
|
||||||
_schedule_host_ops_param_list = [
|
_schedule_host_ops_param_list = [
|
||||||
{'param-name': 'instance_id', 'required': True},
|
{'param-name': 'instance_id', 'required': True},
|
||||||
{'param-name': 'instance_desc', 'required': True},
|
{'param-name': 'instance_desc', 'required': True},
|
||||||
]
|
]
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
|
@ -80,26 +80,28 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
|
|||||||
self._plugin = plugin
|
self._plugin = plugin
|
||||||
|
|
||||||
self._portprofile_ops_param_list = [{
|
self._portprofile_ops_param_list = [{
|
||||||
'param-name': 'portprofile_name',
|
'param-name': 'portprofile_name',
|
||||||
'required': True}, {
|
'required': True}, {
|
||||||
'param-name': 'qos_name',
|
'param-name': 'qos_name',
|
||||||
'required': True}, {
|
'required': True}, {
|
||||||
'param-name': 'assignment',
|
'param-name': 'assignment',
|
||||||
'required': False}]
|
'required': False}
|
||||||
|
]
|
||||||
|
|
||||||
self._assignprofile_ops_param_list = [{
|
self._assignprofile_ops_param_list = [{
|
||||||
'param-name': 'network-id',
|
'param-name': 'network-id',
|
||||||
'required': True}, {
|
'required': True}, {
|
||||||
'param-name': 'port-id',
|
'param-name': 'port-id',
|
||||||
'required': True}]
|
'required': True}
|
||||||
|
]
|
||||||
|
|
||||||
self._serialization_metadata = {
|
self._serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"portprofile": ["id", "name"],
|
"portprofile": ["id", "name"],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
def index(self, request, tenant_id):
|
def index(self, request, tenant_id):
|
||||||
""" Returns a list of portprofile ids """
|
""" Returns a list of portprofile ids """
|
||||||
@ -117,8 +119,7 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
|
|||||||
def show(self, request, tenant_id, id):
|
def show(self, request, tenant_id, id):
|
||||||
""" Returns portprofile details for the given portprofile id """
|
""" Returns portprofile details for the given portprofile id """
|
||||||
try:
|
try:
|
||||||
portprofile = self._plugin.get_portprofile_details(
|
portprofile = self._plugin.get_portprofile_details(tenant_id, id)
|
||||||
tenant_id, id)
|
|
||||||
builder = pprofiles_view.get_view_builder(request)
|
builder = pprofiles_view.get_view_builder(request)
|
||||||
#build response with details
|
#build response with details
|
||||||
result = builder.build(portprofile, True)
|
result = builder.build(portprofile, True)
|
||||||
@ -137,10 +138,10 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
|
|||||||
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)
|
||||||
portprofile = self._plugin.\
|
portprofile = \
|
||||||
create_portprofile(tenant_id,
|
self._plugin.create_portprofile(tenant_id,
|
||||||
req_params['portprofile_name'],
|
req_params['portprofile_name'],
|
||||||
req_params['qos_name'])
|
req_params['qos_name'])
|
||||||
builder = pprofiles_view.get_view_builder(request)
|
builder = pprofiles_view.get_view_builder(request)
|
||||||
result = builder.build(portprofile)
|
result = builder.build(portprofile)
|
||||||
return dict(portprofiles=result)
|
return dict(portprofiles=result)
|
||||||
@ -156,9 +157,9 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
|
|||||||
except exc.HTTPError as exp:
|
except exc.HTTPError as exp:
|
||||||
return faults.Fault(exp)
|
return faults.Fault(exp)
|
||||||
try:
|
try:
|
||||||
portprofile = self._plugin.\
|
portprofile = \
|
||||||
rename_portprofile(tenant_id,
|
self._plugin.rename_portprofile(tenant_id, id,
|
||||||
id, req_params['portprofile_name'])
|
req_params['portprofile_name'])
|
||||||
|
|
||||||
builder = pprofiles_view.get_view_builder(request)
|
builder = pprofiles_view.get_view_builder(request)
|
||||||
result = builder.build(portprofile, True)
|
result = builder.build(portprofile, True)
|
||||||
@ -190,8 +191,8 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
|
|||||||
port_id = req_params['port-id'].strip()
|
port_id = req_params['port-id'].strip()
|
||||||
try:
|
try:
|
||||||
self._plugin.associate_portprofile(tenant_id,
|
self._plugin.associate_portprofile(tenant_id,
|
||||||
net_id, port_id,
|
net_id, port_id,
|
||||||
id)
|
id)
|
||||||
return exc.HTTPOk()
|
return exc.HTTPOk()
|
||||||
except exception.PortProfileNotFound as exp:
|
except exception.PortProfileNotFound as exp:
|
||||||
return faults.Fault(faults.PortprofileNotFound(exp))
|
return faults.Fault(faults.PortprofileNotFound(exp))
|
||||||
@ -212,9 +213,8 @@ class PortprofilesController(common.QuantumController, wsgi.Controller):
|
|||||||
net_id = req_params['network-id'].strip()
|
net_id = req_params['network-id'].strip()
|
||||||
port_id = req_params['port-id'].strip()
|
port_id = req_params['port-id'].strip()
|
||||||
try:
|
try:
|
||||||
self._plugin. \
|
self._plugin.disassociate_portprofile(tenant_id,
|
||||||
disassociate_portprofile(tenant_id,
|
net_id, port_id, id)
|
||||||
net_id, port_id, id)
|
|
||||||
return exc.HTTPOk()
|
return exc.HTTPOk()
|
||||||
except exception.PortProfileNotFound as exp:
|
except exception.PortProfileNotFound as exp:
|
||||||
return faults.Fault(faults.PortprofileNotFound(exp))
|
return faults.Fault(faults.PortprofileNotFound(exp))
|
||||||
|
@ -69,10 +69,10 @@ class StatsController(wsgi.Controller):
|
|||||||
"application/xml": {
|
"application/xml": {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"stats": ["rx_bytes", "rx_packets", "rx_errors",
|
"stats": ["rx_bytes", "rx_packets", "rx_errors",
|
||||||
"tx_bytes", "tx_packets", "tx_errors"],
|
"tx_bytes", "tx_packets", "tx_errors"]
|
||||||
},
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, plugin):
|
def __init__(self, plugin):
|
||||||
self._resource_name = 'stats'
|
self._resource_name = 'stats'
|
||||||
|
@ -80,7 +80,7 @@ class QosController(common.QuantumController, wsgi.Controller):
|
|||||||
_qos_ops_param_list = [
|
_qos_ops_param_list = [
|
||||||
{'param-name': 'qos_name', 'required': True},
|
{'param-name': 'qos_name', 'required': True},
|
||||||
{'param-name': 'qos_desc', 'required': True},
|
{'param-name': 'qos_desc', 'required': True},
|
||||||
]
|
]
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
|
@ -375,7 +375,7 @@ def _get_config_dirs(project=None):
|
|||||||
fix_path('~'),
|
fix_path('~'),
|
||||||
os.path.join('/etc', project) if project else None,
|
os.path.join('/etc', project) if project else None,
|
||||||
'/etc'
|
'/etc'
|
||||||
]
|
]
|
||||||
|
|
||||||
return filter(bool, cfg_dirs)
|
return filter(bool, cfg_dirs)
|
||||||
|
|
||||||
@ -575,11 +575,9 @@ class Opt(object):
|
|||||||
dest = self.dest
|
dest = self.dest
|
||||||
if group is not None:
|
if group is not None:
|
||||||
dest = group.name + '_' + dest
|
dest = group.name + '_' + dest
|
||||||
kwargs.update({
|
kwargs.update({'dest': dest,
|
||||||
'dest': dest,
|
'metavar': self.metavar,
|
||||||
'metavar': self.metavar,
|
'help': self.help})
|
||||||
'help': self.help,
|
|
||||||
})
|
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def _get_optparse_prefix(self, prefix, group):
|
def _get_optparse_prefix(self, prefix, group):
|
||||||
@ -892,14 +890,14 @@ class ConfigOpts(collections.Mapping):
|
|||||||
self.__cache = {}
|
self.__cache = {}
|
||||||
|
|
||||||
opts = [
|
opts = [
|
||||||
MultiStrOpt('config-file',
|
MultiStrOpt('config-file',
|
||||||
default=self.default_config_files,
|
default=self.default_config_files,
|
||||||
metavar='PATH',
|
metavar='PATH',
|
||||||
help='Path to a config file to use. Multiple config '
|
help='Path to a config file to use. Multiple config '
|
||||||
'files can be specified, with values in later '
|
'files can be specified, with values in later '
|
||||||
'files taking precedence. The default files '
|
'files taking precedence. The default files '
|
||||||
' used are: %s' %
|
' used are: %s' %
|
||||||
(self.default_config_files, )),
|
(self.default_config_files)),
|
||||||
StrOpt('config-dir',
|
StrOpt('config-dir',
|
||||||
metavar='DIR',
|
metavar='DIR',
|
||||||
help='Path to a config directory to pull *.conf '
|
help='Path to a config directory to pull *.conf '
|
||||||
@ -909,7 +907,7 @@ class ConfigOpts(collections.Mapping):
|
|||||||
'the file(s), if any, specified via --config-file, '
|
'the file(s), if any, specified via --config-file, '
|
||||||
'hence over-ridden options in the directory take '
|
'hence over-ridden options in the directory take '
|
||||||
'precedence.'),
|
'precedence.'),
|
||||||
]
|
]
|
||||||
self.register_cli_opts(opts)
|
self.register_cli_opts(opts)
|
||||||
|
|
||||||
def __clear_cache(f):
|
def __clear_cache(f):
|
||||||
@ -1352,8 +1350,7 @@ class ConfigOpts(collections.Mapping):
|
|||||||
default, opt, override = [info[k] for k in sorted(info.keys())]
|
default, opt, override = [info[k] for k in sorted(info.keys())]
|
||||||
|
|
||||||
if opt.required:
|
if opt.required:
|
||||||
if (default is not None or
|
if (default is not None or override is not None):
|
||||||
override is not None):
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if self._get(opt.name, group) is None:
|
if self._get(opt.name, group) is None:
|
||||||
@ -1447,7 +1444,7 @@ class CommonConfigOpts(ConfigOpts):
|
|||||||
short='v',
|
short='v',
|
||||||
default=False,
|
default=False,
|
||||||
help='Print more verbose output'),
|
help='Print more verbose output'),
|
||||||
]
|
]
|
||||||
|
|
||||||
logging_cli_opts = [
|
logging_cli_opts = [
|
||||||
StrOpt('log-config',
|
StrOpt('log-config',
|
||||||
@ -1481,7 +1478,7 @@ class CommonConfigOpts(ConfigOpts):
|
|||||||
StrOpt('syslog-log-facility',
|
StrOpt('syslog-log-facility',
|
||||||
default='LOG_USER',
|
default='LOG_USER',
|
||||||
help='syslog facility to receive log lines')
|
help='syslog facility to receive log lines')
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(CommonConfigOpts, self).__init__(**kwargs)
|
super(CommonConfigOpts, self).__init__(**kwargs)
|
||||||
|
@ -30,7 +30,7 @@ def import_class(import_str):
|
|||||||
return getattr(sys.modules[mod_str], class_str)
|
return getattr(sys.modules[mod_str], class_str)
|
||||||
except (ImportError, ValueError, AttributeError), exc:
|
except (ImportError, ValueError, AttributeError), exc:
|
||||||
raise ImportError('Class %s cannot be found (%s)' %
|
raise ImportError('Class %s cannot be found (%s)' %
|
||||||
(class_str, str(exc)))
|
(class_str, str(exc)))
|
||||||
|
|
||||||
|
|
||||||
def import_object(import_str, *args, **kwargs):
|
def import_object(import_str, *args, **kwargs):
|
||||||
|
@ -99,9 +99,9 @@ def schedule_host(tenant_id, instance_id, user_id=None):
|
|||||||
'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,
|
||||||
@ -138,16 +138,16 @@ COMMANDS = {
|
|||||||
"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": {
|
"list_extensions": {
|
||||||
"func": list_extensions,
|
"func": list_extensions,
|
||||||
"args": [],
|
"args": [],
|
||||||
},
|
},
|
||||||
"schedule_host": {
|
"schedule_host": {
|
||||||
"func": schedule_host,
|
"func": schedule_host,
|
||||||
"args": ["tenant-id", "instance-id"],
|
"args": ["tenant-id", "instance-id"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -27,7 +27,7 @@ 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):
|
||||||
@ -83,7 +83,7 @@ class PortProfileAlreadyExists(exceptions.QuantumException):
|
|||||||
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")
|
||||||
|
|
||||||
|
|
||||||
class VlanIDNotFound(exceptions.QuantumException):
|
class VlanIDNotFound(exceptions.QuantumException):
|
||||||
|
@ -25,16 +25,17 @@ class Fault(webob.exc.HTTPException):
|
|||||||
"""Error codes for API faults"""
|
"""Error codes for API faults"""
|
||||||
|
|
||||||
_fault_names = {
|
_fault_names = {
|
||||||
400: "malformedRequest",
|
400: "malformedRequest",
|
||||||
401: "unauthorized",
|
401: "unauthorized",
|
||||||
421: "PortprofileInUse",
|
421: "PortprofileInUse",
|
||||||
450: "PortprofileNotFound",
|
450: "PortprofileNotFound",
|
||||||
451: "CredentialNotFound",
|
451: "CredentialNotFound",
|
||||||
452: "QoSNotFound",
|
452: "QoSNotFound",
|
||||||
453: "NovatenantNotFound",
|
453: "NovatenantNotFound",
|
||||||
454: "MultiportNotFound",
|
454: "MultiportNotFound",
|
||||||
470: "serviceUnavailable",
|
470: "serviceUnavailable",
|
||||||
471: "pluginFault"}
|
471: "pluginFault"
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, exception):
|
def __init__(self, exception):
|
||||||
"""Create a Fault for the given webob.exc.exception."""
|
"""Create a Fault for the given webob.exc.exception."""
|
||||||
|
@ -49,8 +49,8 @@ def make_port_dict(port_id, port_state, net_id, attachment):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def make_portprofile_dict(tenant_id, profile_id, profile_name,
|
def make_portprofile_dict(tenant_id, profile_id,
|
||||||
qos):
|
profile_name, qos):
|
||||||
"""Helper funciton"""
|
"""Helper funciton"""
|
||||||
profile_associations = make_portprofile_assc_list(tenant_id,
|
profile_associations = make_portprofile_assc_list(tenant_id,
|
||||||
profile_id)
|
profile_id)
|
||||||
|
@ -88,19 +88,19 @@ def network_create(tenant_id, name):
|
|||||||
|
|
||||||
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).
|
||||||
options(joinedload(models.Network.ports)). \
|
options(joinedload(models.Network.ports)).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
all()
|
all())
|
||||||
|
|
||||||
|
|
||||||
def network_id(net_name):
|
def network_id(net_name):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
try:
|
try:
|
||||||
return session.query(models.Network).\
|
return (session.query(models.Network).
|
||||||
options(joinedload(models.Network.ports)). \
|
options(joinedload(models.Network.ports)).
|
||||||
filter_by(name=net_name).\
|
filter_by(name=net_name).
|
||||||
all()
|
all())
|
||||||
except exc.NoResultFound, e:
|
except exc.NoResultFound, e:
|
||||||
raise q_exc.NetworkNotFound(net_name=net_name)
|
raise q_exc.NetworkNotFound(net_name=net_name)
|
||||||
|
|
||||||
@ -129,9 +129,9 @@ 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())
|
||||||
session.delete(net)
|
session.delete(net)
|
||||||
session.flush()
|
session.flush()
|
||||||
return net
|
return net
|
||||||
@ -142,10 +142,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)
|
||||||
|
|
||||||
@ -165,10 +165,10 @@ def port_create(net_id, state=None):
|
|||||||
|
|
||||||
def port_list(net_id):
|
def port_list(net_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
return session.query(models.Port).\
|
return (session.query(models.Port).
|
||||||
options(joinedload(models.Port.network)). \
|
options(joinedload(models.Port.network)).
|
||||||
filter_by(network_id=net_id).\
|
filter_by(network_id=net_id).
|
||||||
all()
|
all())
|
||||||
|
|
||||||
|
|
||||||
def port_get(net_id, port_id):
|
def port_get(net_id, port_id):
|
||||||
@ -176,10 +176,10 @@ def port_get(net_id, port_id):
|
|||||||
network_get(net_id)
|
network_get(net_id)
|
||||||
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)
|
||||||
|
|
||||||
@ -211,16 +211,16 @@ def port_set_attachment(net_id, port_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
|
||||||
@ -248,13 +248,13 @@ def port_destroy(net_id, port_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
|
||||||
@ -266,8 +266,8 @@ def port_destroy(net_id, port_id):
|
|||||||
def port_get_by_id(port_id):
|
def port_get_by_id(port_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
try:
|
try:
|
||||||
return session.query(models.Port).\
|
return (session.query(models.Port).
|
||||||
filter_by(uuid=port_id).one()
|
filter_by(uuid=port_id).one())
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise q_exc.PortNotFound(port_id=port_id)
|
raise q_exc.PortNotFound(port_id=port_id)
|
||||||
|
|
||||||
@ -286,8 +286,8 @@ def port_set_attachment_by_id(port_id, new_interface_id):
|
|||||||
filter_by(interface_id=new_interface_id).\
|
filter_by(interface_id=new_interface_id).\
|
||||||
one()
|
one()
|
||||||
raise q_exc.AlreadyAttached(port_id=port_id,
|
raise q_exc.AlreadyAttached(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:
|
||||||
pass
|
pass
|
||||||
port.interface_id = new_interface_id
|
port.interface_id = new_interface_id
|
||||||
|
@ -29,7 +29,7 @@ import quantum.plugins.cisco.db.api as db
|
|||||||
def initialize():
|
def initialize():
|
||||||
'Establish database connection and load models'
|
'Establish database connection and load models'
|
||||||
options = {"sql_connection": "mysql://%s:%s@%s/%s" % (conf.DB_USER,
|
options = {"sql_connection": "mysql://%s:%s@%s/%s" % (conf.DB_USER,
|
||||||
conf.DB_PASS, conf.DB_HOST, conf.DB_NAME)}
|
conf.DB_PASS, conf.DB_HOST, conf.DB_NAME)}
|
||||||
db.configure_db(options)
|
db.configure_db(options)
|
||||||
|
|
||||||
|
|
||||||
@ -38,8 +38,7 @@ def create_vlanids():
|
|||||||
LOG.debug("create_vlanids() called")
|
LOG.debug("create_vlanids() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
vlanid = session.query(l2network_models.VlanID).\
|
vlanid = session.query(l2network_models.VlanID).one()
|
||||||
one()
|
|
||||||
except exc.MultipleResultsFound:
|
except exc.MultipleResultsFound:
|
||||||
pass
|
pass
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
@ -58,8 +57,7 @@ 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 []
|
||||||
@ -70,9 +68,8 @@ 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)
|
||||||
@ -83,9 +80,8 @@ 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()
|
||||||
@ -100,9 +96,8 @@ 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
|
||||||
@ -115,14 +110,12 @@ 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).
|
||||||
filter_by(vlan_used=False).\
|
filter_by(vlan_used=False).first())
|
||||||
first()
|
|
||||||
if not rvlan:
|
if not rvlan:
|
||||||
raise exc.NoResultFound
|
raise exc.NoResultFound
|
||||||
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()
|
||||||
@ -136,9 +129,8 @@ 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 []
|
||||||
@ -149,8 +141,7 @@ 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 []
|
||||||
@ -161,9 +152,8 @@ 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 q_exc.NetworkNotFound(net_id=netid)
|
raise q_exc.NetworkNotFound(net_id=netid)
|
||||||
@ -174,9 +164,8 @@ def add_vlan_binding(vlanid, vlanname, 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:
|
||||||
@ -191,9 +180,8 @@ 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
|
||||||
@ -206,9 +194,8 @@ def update_vlan_binding(netid, newvlanid=None, newvlanname=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
|
||||||
if newvlanname:
|
if newvlanname:
|
||||||
@ -225,8 +212,7 @@ def get_all_portprofiles():
|
|||||||
LOG.debug("get_all_portprofiles() called")
|
LOG.debug("get_all_portprofiles() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
pps = session.query(l2network_models.PortProfile).\
|
pps = session.query(l2network_models.PortProfile).all()
|
||||||
all()
|
|
||||||
return pps
|
return pps
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -237,13 +223,12 @@ def get_portprofile(tenantid, ppid):
|
|||||||
LOG.debug("get_portprofile() called")
|
LOG.debug("get_portprofile() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
pp = session.query(l2network_models.PortProfile).\
|
pp = (session.query(l2network_models.PortProfile).
|
||||||
filter_by(uuid=ppid).\
|
filter_by(uuid=ppid).one())
|
||||||
one()
|
|
||||||
return pp
|
return pp
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.PortProfileNotFound(tenant_id=tenantid,
|
raise c_exc.PortProfileNotFound(tenant_id=tenantid,
|
||||||
portprofile_id=ppid)
|
portprofile_id=ppid)
|
||||||
|
|
||||||
|
|
||||||
def add_portprofile(tenantid, ppname, vlanid, qos):
|
def add_portprofile(tenantid, ppname, vlanid, qos):
|
||||||
@ -251,11 +236,10 @@ def add_portprofile(tenantid, ppname, vlanid, qos):
|
|||||||
LOG.debug("add_portprofile() called")
|
LOG.debug("add_portprofile() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
pp = session.query(l2network_models.PortProfile).\
|
pp = (session.query(l2network_models.PortProfile).
|
||||||
filter_by(name=ppname).\
|
filter_by(name=ppname).one())
|
||||||
one()
|
|
||||||
raise c_exc.PortProfileAlreadyExists(tenant_id=tenantid,
|
raise c_exc.PortProfileAlreadyExists(tenant_id=tenantid,
|
||||||
pp_name=ppname)
|
pp_name=ppname)
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
pp = l2network_models.PortProfile(ppname, vlanid, qos)
|
pp = l2network_models.PortProfile(ppname, vlanid, qos)
|
||||||
session.add(pp)
|
session.add(pp)
|
||||||
@ -268,9 +252,8 @@ def remove_portprofile(tenantid, ppid):
|
|||||||
LOG.debug("remove_portprofile() called")
|
LOG.debug("remove_portprofile() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
pp = session.query(l2network_models.PortProfile).\
|
pp = (session.query(l2network_models.PortProfile).
|
||||||
filter_by(uuid=ppid).\
|
filter_by(uuid=ppid).one())
|
||||||
one()
|
|
||||||
session.delete(pp)
|
session.delete(pp)
|
||||||
session.flush()
|
session.flush()
|
||||||
return pp
|
return pp
|
||||||
@ -284,9 +267,8 @@ def update_portprofile(tenantid, ppid, newppname=None, newvlanid=None,
|
|||||||
LOG.debug("update_portprofile() called")
|
LOG.debug("update_portprofile() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
pp = session.query(l2network_models.PortProfile).\
|
pp = (session.query(l2network_models.PortProfile).
|
||||||
filter_by(uuid=ppid).\
|
filter_by(uuid=ppid).one())
|
||||||
one()
|
|
||||||
if newppname:
|
if newppname:
|
||||||
pp["name"] = newppname
|
pp["name"] = newppname
|
||||||
if newvlanid:
|
if newvlanid:
|
||||||
@ -298,7 +280,7 @@ def update_portprofile(tenantid, ppid, newppname=None, newvlanid=None,
|
|||||||
return pp
|
return pp
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.PortProfileNotFound(tenant_id=tenantid,
|
raise c_exc.PortProfileNotFound(tenant_id=tenantid,
|
||||||
portprofile_id=ppid)
|
portprofile_id=ppid)
|
||||||
|
|
||||||
|
|
||||||
def get_all_pp_bindings():
|
def get_all_pp_bindings():
|
||||||
@ -306,8 +288,7 @@ def get_all_pp_bindings():
|
|||||||
LOG.debug("get_all_pp_bindings() called")
|
LOG.debug("get_all_pp_bindings() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
bindings = session.query(l2network_models.PortProfileBinding).\
|
bindings = session.query(l2network_models.PortProfileBinding).all()
|
||||||
all()
|
|
||||||
return bindings
|
return bindings
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -318,9 +299,8 @@ def get_pp_binding(tenantid, ppid):
|
|||||||
LOG.debug("get_pp_binding() called")
|
LOG.debug("get_pp_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(l2network_models.PortProfileBinding).\
|
binding = (session.query(l2network_models.PortProfileBinding).
|
||||||
filter_by(portprofile_id=ppid).\
|
filter_by(portprofile_id=ppid).one())
|
||||||
one()
|
|
||||||
return binding
|
return binding
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -331,9 +311,8 @@ def add_pp_binding(tenantid, portid, ppid, default):
|
|||||||
LOG.debug("add_pp_binding() called")
|
LOG.debug("add_pp_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(l2network_models.PortProfileBinding).\
|
binding = (session.query(l2network_models.PortProfileBinding).
|
||||||
filter_by(portprofile_id=ppid).\
|
filter_by(portprofile_id=ppid).one())
|
||||||
one()
|
|
||||||
raise c_exc.PortProfileBindingAlreadyExists(pp_id=ppid,
|
raise c_exc.PortProfileBindingAlreadyExists(pp_id=ppid,
|
||||||
port_id=portid)
|
port_id=portid)
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
@ -349,10 +328,9 @@ def remove_pp_binding(tenantid, portid, ppid):
|
|||||||
LOG.debug("remove_pp_binding() called")
|
LOG.debug("remove_pp_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(l2network_models.PortProfileBinding).\
|
binding = (session.query(l2network_models.PortProfileBinding).
|
||||||
filter_by(portprofile_id=ppid).\
|
filter_by(portprofile_id=ppid).filter_by(port_id=portid).
|
||||||
filter_by(port_id=portid).\
|
one())
|
||||||
one()
|
|
||||||
session.delete(binding)
|
session.delete(binding)
|
||||||
session.flush()
|
session.flush()
|
||||||
return binding
|
return binding
|
||||||
@ -360,15 +338,14 @@ def remove_pp_binding(tenantid, portid, ppid):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def update_pp_binding(tenantid, ppid, newtenantid=None, newportid=None,
|
def update_pp_binding(tenantid, ppid, newtenantid=None,
|
||||||
newdefault=None):
|
newportid=None, newdefault=None):
|
||||||
"""Updates port profile binding"""
|
"""Updates port profile binding"""
|
||||||
LOG.debug("update_pp_binding() called")
|
LOG.debug("update_pp_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(l2network_models.PortProfileBinding).\
|
binding = (session.query(l2network_models.PortProfileBinding).
|
||||||
filter_by(portprofile_id=ppid).\
|
filter_by(portprofile_id=ppid).one())
|
||||||
one()
|
|
||||||
if newtenantid:
|
if newtenantid:
|
||||||
binding["tenant_id"] = newtenantid
|
binding["tenant_id"] = newtenantid
|
||||||
if newportid:
|
if newportid:
|
||||||
@ -380,7 +357,7 @@ def update_pp_binding(tenantid, ppid, newtenantid=None, newportid=None,
|
|||||||
return binding
|
return binding
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.PortProfileNotFound(tenant_id=tenantid,
|
raise c_exc.PortProfileNotFound(tenant_id=tenantid,
|
||||||
portprofile_id=ppid)
|
portprofile_id=ppid)
|
||||||
|
|
||||||
|
|
||||||
def get_all_qoss(tenant_id):
|
def get_all_qoss(tenant_id):
|
||||||
@ -388,9 +365,8 @@ def get_all_qoss(tenant_id):
|
|||||||
LOG.debug("get_all_qoss() called")
|
LOG.debug("get_all_qoss() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
qoss = session.query(l2network_models.QoS).\
|
qoss = (session.query(l2network_models.QoS).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).all())
|
||||||
all()
|
|
||||||
return qoss
|
return qoss
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -401,10 +377,9 @@ def get_qos(tenant_id, qos_id):
|
|||||||
LOG.debug("get_qos() called")
|
LOG.debug("get_qos() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
qos = session.query(l2network_models.QoS).\
|
qos = (session.query(l2network_models.QoS).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
filter_by(qos_id=qos_id).\
|
filter_by(qos_id=qos_id).one())
|
||||||
one()
|
|
||||||
return qos
|
return qos
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.QosNotFound(qos_id=qos_id,
|
raise c_exc.QosNotFound(qos_id=qos_id,
|
||||||
@ -416,12 +391,11 @@ def add_qos(tenant_id, qos_name, qos_desc):
|
|||||||
LOG.debug("add_qos() called")
|
LOG.debug("add_qos() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
qos = session.query(l2network_models.QoS).\
|
qos = (session.query(l2network_models.QoS).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
filter_by(qos_name=qos_name).\
|
filter_by(qos_name=qos_name).one())
|
||||||
one()
|
|
||||||
raise c_exc.QosNameAlreadyExists(qos_name=qos_name,
|
raise c_exc.QosNameAlreadyExists(qos_name=qos_name,
|
||||||
tenant_id=tenant_id)
|
tenant_id=tenant_id)
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
qos = l2network_models.QoS(tenant_id, qos_name, qos_desc)
|
qos = l2network_models.QoS(tenant_id, qos_name, qos_desc)
|
||||||
session.add(qos)
|
session.add(qos)
|
||||||
@ -433,10 +407,9 @@ def remove_qos(tenant_id, qos_id):
|
|||||||
"""Removes a qos to tenant association"""
|
"""Removes a qos to tenant association"""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
qos = session.query(l2network_models.QoS).\
|
qos = (session.query(l2network_models.QoS).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
filter_by(qos_id=qos_id).\
|
filter_by(qos_id=qos_id).one())
|
||||||
one()
|
|
||||||
session.delete(qos)
|
session.delete(qos)
|
||||||
session.flush()
|
session.flush()
|
||||||
return qos
|
return qos
|
||||||
@ -448,10 +421,9 @@ def update_qos(tenant_id, qos_id, new_qos_name=None):
|
|||||||
"""Updates a qos to tenant association"""
|
"""Updates a qos to tenant association"""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
qos = session.query(l2network_models.QoS).\
|
qos = (session.query(l2network_models.QoS).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
filter_by(qos_id=qos_id).\
|
filter_by(qos_id=qos_id).one())
|
||||||
one()
|
|
||||||
if new_qos_name:
|
if new_qos_name:
|
||||||
qos["qos_name"] = new_qos_name
|
qos["qos_name"] = new_qos_name
|
||||||
session.merge(qos)
|
session.merge(qos)
|
||||||
@ -466,9 +438,8 @@ def get_all_credentials(tenant_id):
|
|||||||
"""Lists all the creds for a tenant"""
|
"""Lists all the creds for a tenant"""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
creds = session.query(l2network_models.Credential).\
|
creds = (session.query(l2network_models.Credential).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).all())
|
||||||
all()
|
|
||||||
return creds
|
return creds
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -478,43 +449,40 @@ def get_credential(tenant_id, credential_id):
|
|||||||
"""Lists the creds for given a cred_id and tenant_id"""
|
"""Lists the creds for given a cred_id and tenant_id"""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = session.query(l2network_models.Credential).\
|
cred = (session.query(l2network_models.Credential).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
filter_by(credential_id=credential_id).\
|
filter_by(credential_id=credential_id).one())
|
||||||
one()
|
|
||||||
return cred
|
return cred
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.CredentialNotFound(credential_id=credential_id,
|
raise c_exc.CredentialNotFound(credential_id=credential_id,
|
||||||
tenant_id=tenant_id)
|
tenant_id=tenant_id)
|
||||||
|
|
||||||
|
|
||||||
def get_credential_name(tenant_id, credential_name):
|
def get_credential_name(tenant_id, credential_name):
|
||||||
"""Lists the creds for given a cred_name and tenant_id"""
|
"""Lists the creds for given a cred_name and tenant_id"""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = session.query(l2network_models.Credential).\
|
cred = (session.query(l2network_models.Credential).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
filter_by(credential_name=credential_name).\
|
filter_by(credential_name=credential_name).one())
|
||||||
one()
|
|
||||||
return cred
|
return cred
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.CredentialNameNotFound(credential_name=credential_name,
|
raise c_exc.CredentialNameNotFound(credential_name=credential_name,
|
||||||
tenant_id=tenant_id)
|
tenant_id=tenant_id)
|
||||||
|
|
||||||
|
|
||||||
def add_credential(tenant_id, credential_name, user_name, password):
|
def add_credential(tenant_id, credential_name, user_name, password):
|
||||||
"""Adds a qos to tenant association"""
|
"""Adds a qos to tenant association"""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = session.query(l2network_models.Credential).\
|
cred = (session.query(l2network_models.Credential).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
filter_by(credential_name=credential_name).\
|
filter_by(credential_name=credential_name).one())
|
||||||
one()
|
|
||||||
raise c_exc.CredentialAlreadyExists(credential_name=credential_name,
|
raise c_exc.CredentialAlreadyExists(credential_name=credential_name,
|
||||||
tenant_id=tenant_id)
|
tenant_id=tenant_id)
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
cred = l2network_models.Credential(tenant_id,
|
cred = l2network_models.Credential(tenant_id, credential_name,
|
||||||
credential_name, user_name, password)
|
user_name, password)
|
||||||
session.add(cred)
|
session.add(cred)
|
||||||
session.flush()
|
session.flush()
|
||||||
return cred
|
return cred
|
||||||
@ -524,10 +492,9 @@ def remove_credential(tenant_id, credential_id):
|
|||||||
"""Removes a credential from a tenant"""
|
"""Removes a credential from a tenant"""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = session.query(l2network_models.Credential).\
|
cred = (session.query(l2network_models.Credential).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
filter_by(credential_id=credential_id).\
|
filter_by(credential_id=credential_id).one())
|
||||||
one()
|
|
||||||
session.delete(cred)
|
session.delete(cred)
|
||||||
session.flush()
|
session.flush()
|
||||||
return cred
|
return cred
|
||||||
@ -540,10 +507,9 @@ def update_credential(tenant_id, credential_id,
|
|||||||
"""Updates a credential for a tenant"""
|
"""Updates a credential for a tenant"""
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
cred = session.query(l2network_models.Credential).\
|
cred = (session.query(l2network_models.Credential).
|
||||||
filter_by(tenant_id=tenant_id).\
|
filter_by(tenant_id=tenant_id).
|
||||||
filter_by(credential_id=credential_id).\
|
filter_by(credential_id=credential_id).one())
|
||||||
one()
|
|
||||||
if new_user_name:
|
if new_user_name:
|
||||||
cred["user_name"] = new_user_name
|
cred["user_name"] = new_user_name
|
||||||
if new_password:
|
if new_password:
|
||||||
@ -553,4 +519,4 @@ def update_credential(tenant_id, credential_id,
|
|||||||
return cred
|
return cred
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.CredentialNotFound(credential_id=credential_id,
|
raise c_exc.CredentialNotFound(credential_id=credential_id,
|
||||||
tenant_id=tenant_id)
|
tenant_id=tenant_id)
|
||||||
|
@ -60,7 +60,7 @@ class L2NetworkBase(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()
|
||||||
|
|
||||||
@ -77,8 +77,7 @@ class VlanID(BASE, L2NetworkBase):
|
|||||||
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, L2NetworkBase):
|
class VlanBinding(BASE, L2NetworkBase):
|
||||||
@ -96,8 +95,9 @@ class VlanBinding(BASE, L2NetworkBase):
|
|||||||
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.vlan_id, self.vlan_name, self.network_id)
|
self.vlan_name,
|
||||||
|
self.network_id)
|
||||||
|
|
||||||
|
|
||||||
class PortProfile(BASE, L2NetworkBase):
|
class PortProfile(BASE, L2NetworkBase):
|
||||||
@ -116,8 +116,10 @@ class PortProfile(BASE, L2NetworkBase):
|
|||||||
self.qos = qos
|
self.qos = qos
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<PortProfile(%s,%s,%d,%s)>" % \
|
return "<PortProfile(%s,%s,%d,%s)>" % (self.uuid,
|
||||||
(self.uuid, self.name, self.vlan_id, self.qos)
|
self.name,
|
||||||
|
self.vlan_id,
|
||||||
|
self.qos)
|
||||||
|
|
||||||
|
|
||||||
class PortProfileBinding(BASE, L2NetworkBase):
|
class PortProfileBinding(BASE, L2NetworkBase):
|
||||||
@ -127,8 +129,7 @@ class PortProfileBinding(BASE, L2NetworkBase):
|
|||||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
tenant_id = Column(String(255))
|
tenant_id = Column(String(255))
|
||||||
|
|
||||||
port_id = Column(String(255), ForeignKey("ports.uuid"),
|
port_id = Column(String(255), ForeignKey("ports.uuid"), nullable=False)
|
||||||
nullable=False)
|
|
||||||
portprofile_id = Column(String(255), ForeignKey("portprofiles.uuid"),
|
portprofile_id = Column(String(255), ForeignKey("portprofiles.uuid"),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
default = Column(Boolean)
|
default = Column(Boolean)
|
||||||
@ -142,8 +143,10 @@ class PortProfileBinding(BASE, L2NetworkBase):
|
|||||||
self.default = default
|
self.default = default
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<PortProfile Binding(%s,%s,%s,%s)>" % \
|
return "<PortProfile Binding(%s,%s,%s,%s)>" % (self.tenant_id,
|
||||||
(self.tenant_id, self.port_id, self.portprofile_id, self.default)
|
self.port_id,
|
||||||
|
self.portprofile_id,
|
||||||
|
self.default)
|
||||||
|
|
||||||
|
|
||||||
class QoS(BASE, L2NetworkBase):
|
class QoS(BASE, L2NetworkBase):
|
||||||
@ -162,8 +165,8 @@ class QoS(BASE, L2NetworkBase):
|
|||||||
self.qos_desc = qos_desc
|
self.qos_desc = qos_desc
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<QoS(%s,%s,%s,%s)>" % \
|
return "<QoS(%s,%s,%s,%s)>" % (self.qos_id, self.tenant_id,
|
||||||
(self.qos_id, self.tenant_id, self.qos_name, self.qos_desc)
|
self.qos_name, self.qos_desc)
|
||||||
|
|
||||||
|
|
||||||
class Credential(BASE, L2NetworkBase):
|
class Credential(BASE, L2NetworkBase):
|
||||||
@ -184,6 +187,8 @@ class Credential(BASE, L2NetworkBase):
|
|||||||
self.password = password
|
self.password = password
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Credentials(%s,%s,%s,%s,%s)>" % \
|
return "<Credentials(%s,%s,%s,%s,%s)>" % (self.credential_id,
|
||||||
(self.credential_id, self.tenant_id, self.credential_name,
|
self.tenant_id,
|
||||||
self.user_name, self.password)
|
self.credential_name,
|
||||||
|
self.user_name,
|
||||||
|
self.password)
|
||||||
|
@ -57,7 +57,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()
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class Port(BASE, QuantumBase):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Port(%s,%s,%s,%s)>" % (self.uuid, self.network_id,
|
return "<Port(%s,%s,%s,%s)>" % (self.uuid, self.network_id,
|
||||||
self.state, self.interface_id)
|
self.state, self.interface_id)
|
||||||
|
|
||||||
|
|
||||||
class Network(BASE, QuantumBase):
|
class Network(BASE, QuantumBase):
|
||||||
@ -98,5 +98,4 @@ class Network(BASE, QuantumBase):
|
|||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Network(%s,%s,%s)>" % \
|
return "<Network(%s,%s,%s)>" % (self.uuid, self.name, self.tenant_id)
|
||||||
(self.uuid, self.name, self.tenant_id)
|
|
||||||
|
@ -30,8 +30,7 @@ def get_all_nexusport_bindings():
|
|||||||
LOG.debug("get_all_nexusport_bindings() called")
|
LOG.debug("get_all_nexusport_bindings() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
bindings = session.query(nexus_models.NexusPortBinding).\
|
bindings = session.query(nexus_models.NexusPortBinding).all()
|
||||||
all()
|
|
||||||
return bindings
|
return bindings
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -42,9 +41,8 @@ def get_nexusport_binding(vlan_id):
|
|||||||
LOG.debug("get_nexusport_binding() called")
|
LOG.debug("get_nexusport_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(nexus_models.NexusPortBinding).\
|
binding = (session.query(nexus_models.NexusPortBinding).
|
||||||
filter_by(vlan_id=vlan_id).\
|
filter_by(vlan_id=vlan_id).all())
|
||||||
all()
|
|
||||||
return binding
|
return binding
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.NexusPortBindingNotFound(vlan_id=vlan_id)
|
raise c_exc.NexusPortBindingNotFound(vlan_id=vlan_id)
|
||||||
@ -65,9 +63,8 @@ def remove_nexusport_binding(vlan_id):
|
|||||||
LOG.debug("remove_nexusport_binding() called")
|
LOG.debug("remove_nexusport_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(nexus_models.NexusPortBinding).\
|
binding = (session.query(nexus_models.NexusPortBinding).
|
||||||
filter_by(vlan_id=vlan_id).\
|
filter_by(vlan_id=vlan_id).all())
|
||||||
all()
|
|
||||||
for bind in binding:
|
for bind in binding:
|
||||||
session.delete(bind)
|
session.delete(bind)
|
||||||
session.flush()
|
session.flush()
|
||||||
@ -81,9 +78,8 @@ def update_nexusport_binding(port_id, new_vlan_id):
|
|||||||
LOG.debug("update_nexusport_binding called")
|
LOG.debug("update_nexusport_binding called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(nexus_models.NexusPortBinding).\
|
binding = (session.query(nexus_models.NexusPortBinding).
|
||||||
filter_by(port_id=port_id).\
|
filter_by(port_id=port_id).one())
|
||||||
one()
|
|
||||||
if new_vlan_id:
|
if new_vlan_id:
|
||||||
binding["vlan_id"] = new_vlan_id
|
binding["vlan_id"] = new_vlan_id
|
||||||
session.merge(binding)
|
session.merge(binding)
|
||||||
|
@ -34,5 +34,4 @@ class NexusPortBinding(BASE, L2NetworkBase):
|
|||||||
self.vlan_id = vlan_id
|
self.vlan_id = vlan_id
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<NexusPortBinding (%s,%d)>" % \
|
return "<NexusPortBinding (%s,%d)>" % (self.port_id, self.vlan_id)
|
||||||
(self.port_id, self.vlan_id)
|
|
||||||
|
@ -30,8 +30,7 @@ def get_all_services_bindings():
|
|||||||
LOG.debug("get_all_services_bindings() called")
|
LOG.debug("get_all_services_bindings() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
bindings = session.query(services_models.ServicesBinding).\
|
bindings = session.query(services_models.ServicesBinding).all()
|
||||||
all()
|
|
||||||
return bindings
|
return bindings
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -42,9 +41,8 @@ def get_service_bindings(service_id):
|
|||||||
LOG.debug("get_service_bindings() called")
|
LOG.debug("get_service_bindings() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
bindings = session.query(services_models.ServicesBinding).\
|
bindings = (session.query(services_models.ServicesBinding).
|
||||||
filter_by(service_id=service_id).\
|
filter_by(service_id=service_id).one())
|
||||||
one()
|
|
||||||
return bindings
|
return bindings
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -66,9 +64,8 @@ def remove_services_binding(service_id):
|
|||||||
LOG.debug("remove_services_binding() called")
|
LOG.debug("remove_services_binding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
binding = session.query(services_models.ServicesBinding).\
|
binding = (session.query(services_models.ServicesBinding).
|
||||||
filter_by(service_id=service_id).\
|
filter_by(service_id=service_id).all())
|
||||||
all()
|
|
||||||
for bind in binding:
|
for bind in binding:
|
||||||
session.delete(bind)
|
session.delete(bind)
|
||||||
session.flush()
|
session.flush()
|
||||||
|
@ -38,5 +38,5 @@ class ServicesBinding(BASE, L2NetworkBase):
|
|||||||
self.sbnet_id = sbnet_id
|
self.sbnet_id = sbnet_id
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<ServicesBinding (%s,%d)>" % \
|
return "<ServicesBinding (%s,%d)>" % (self.service_id, self.mngnet_id,
|
||||||
(self.service_id, self.mngnet_id, self.nbnet_id, self.sbnet_id)
|
self.nbnet_id, self.sbnet_id)
|
||||||
|
@ -30,8 +30,7 @@ def get_all_portbindings():
|
|||||||
LOG.debug("db get_all_portbindings() called")
|
LOG.debug("db get_all_portbindings() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
port_bindings = session.query(ucs_models.PortBinding).\
|
port_bindings = session.query(ucs_models.PortBinding).all()
|
||||||
all()
|
|
||||||
return port_bindings
|
return port_bindings
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
@ -42,23 +41,21 @@ def get_portbinding(port_id):
|
|||||||
LOG.debug("get_portbinding() called")
|
LOG.debug("get_portbinding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
port_binding = session.query(ucs_models.PortBinding).\
|
port_binding = (session.query(ucs_models.PortBinding).
|
||||||
filter_by(port_id=port_id).\
|
filter_by(port_id=port_id).one())
|
||||||
one()
|
|
||||||
return port_binding
|
return port_binding
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
raise c_exc.PortVnicNotFound(port_id=port_id)
|
raise c_exc.PortVnicNotFound(port_id=port_id)
|
||||||
|
|
||||||
|
|
||||||
def add_portbinding(port_id, blade_intf_dn, portprofile_name,
|
def add_portbinding(port_id, blade_intf_dn, portprofile_name,
|
||||||
vlan_name, vlan_id, qos):
|
vlan_name, vlan_id, qos):
|
||||||
"""Adds a port binding"""
|
"""Adds a port binding"""
|
||||||
LOG.debug("add_portbinding() called")
|
LOG.debug("add_portbinding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
port_binding = session.query(ucs_models.PortBinding).\
|
port_binding = (session.query(ucs_models.PortBinding).
|
||||||
filter_by(port_id=port_id).\
|
filter_by(port_id=port_id).one())
|
||||||
one()
|
|
||||||
raise c_exc.PortVnicBindingAlreadyExists(port_id=port_id)
|
raise c_exc.PortVnicBindingAlreadyExists(port_id=port_id)
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
port_binding = ucs_models.PortBinding(port_id, blade_intf_dn,
|
port_binding = ucs_models.PortBinding(port_id, blade_intf_dn,
|
||||||
@ -74,9 +71,8 @@ def remove_portbinding(port_id):
|
|||||||
LOG.debug("db remove_portbinding() called")
|
LOG.debug("db remove_portbinding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
port_binding = session.query(ucs_models.PortBinding).\
|
port_binding = (session.query(ucs_models.PortBinding).
|
||||||
filter_by(port_id=port_id).\
|
filter_by(port_id=port_id).one())
|
||||||
one()
|
|
||||||
session.delete(port_binding)
|
session.delete(port_binding)
|
||||||
session.flush()
|
session.flush()
|
||||||
return port_binding
|
return port_binding
|
||||||
@ -92,9 +88,8 @@ def update_portbinding(port_id, blade_intf_dn=None, portprofile_name=None,
|
|||||||
LOG.debug("db update_portbinding() called")
|
LOG.debug("db update_portbinding() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
port_binding = session.query(ucs_models.PortBinding).\
|
port_binding = (session.query(ucs_models.PortBinding).
|
||||||
filter_by(port_id=port_id).\
|
filter_by(port_id=port_id).one())
|
||||||
one()
|
|
||||||
if blade_intf_dn:
|
if blade_intf_dn:
|
||||||
port_binding.blade_intf_dn = blade_intf_dn
|
port_binding.blade_intf_dn = blade_intf_dn
|
||||||
if portprofile_name:
|
if portprofile_name:
|
||||||
@ -123,9 +118,8 @@ def update_portbinding_instance_id(port_id, instance_id):
|
|||||||
LOG.debug("db update_portbinding_instance_id() called")
|
LOG.debug("db update_portbinding_instance_id() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
port_binding = session.query(ucs_models.PortBinding).\
|
port_binding = (session.query(ucs_models.PortBinding).
|
||||||
filter_by(port_id=port_id).\
|
filter_by(port_id=port_id).one())
|
||||||
one()
|
|
||||||
port_binding.instance_id = instance_id
|
port_binding.instance_id = instance_id
|
||||||
session.merge(port_binding)
|
session.merge(port_binding)
|
||||||
session.flush()
|
session.flush()
|
||||||
@ -139,9 +133,8 @@ def update_portbinding_vif_id(port_id, vif_id):
|
|||||||
LOG.debug("db update_portbinding_vif_id() called")
|
LOG.debug("db update_portbinding_vif_id() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
port_binding = session.query(ucs_models.PortBinding).\
|
port_binding = (session.query(ucs_models.PortBinding).
|
||||||
filter_by(port_id=port_id).\
|
filter_by(port_id=port_id).one())
|
||||||
one()
|
|
||||||
port_binding.vif_id = vif_id
|
port_binding.vif_id = vif_id
|
||||||
session.merge(port_binding)
|
session.merge(port_binding)
|
||||||
session.flush()
|
session.flush()
|
||||||
@ -155,9 +148,8 @@ def get_portbinding_dn(blade_intf_dn):
|
|||||||
LOG.debug("get_portbinding_dn() called")
|
LOG.debug("get_portbinding_dn() called")
|
||||||
session = db.get_session()
|
session = db.get_session()
|
||||||
try:
|
try:
|
||||||
port_binding = session.query(ucs_models.PortBinding).\
|
port_binding = (session.query(ucs_models.PortBinding).
|
||||||
filter_by(blade_intf_dn=blade_intf_dn).\
|
filter_by(blade_intf_dn=blade_intf_dn).one())
|
||||||
one()
|
|
||||||
return port_binding
|
return port_binding
|
||||||
except exc.NoResultFound:
|
except exc.NoResultFound:
|
||||||
return []
|
return []
|
||||||
|
@ -50,6 +50,6 @@ class PortBinding(BASE, L2NetworkBase):
|
|||||||
self.qos = qos
|
self.qos = qos
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<PortProfile Binding(%s,%s,%s,%s,%s,%s)>" % \
|
return "<PortProfile Binding(%s,%s,%s,%s,%s,%s)>" % (
|
||||||
(self.port_id, self.blade_intf_dn, self.portprofile_name,
|
self.port_id, self.blade_intf_dn, self.portprofile_name,
|
||||||
self.vlan_name, self.vlan_id, self.qos)
|
self.vlan_name, self.vlan_id, self.qos)
|
||||||
|
@ -391,7 +391,7 @@ class L2Network(QuantumPluginBase):
|
|||||||
portprofile = cdb.get_portprofile(tenant_id, portprofile_id)
|
portprofile = cdb.get_portprofile(tenant_id, portprofile_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise cexc.PortProfileNotFound(tenant_id=tenant_id,
|
raise cexc.PortProfileNotFound(tenant_id=tenant_id,
|
||||||
portprofile_id=portprofile_id)
|
portprofile_id=portprofile_id)
|
||||||
|
|
||||||
cdb.remove_pp_binding(tenant_id, port_id, portprofile_id)
|
cdb.remove_pp_binding(tenant_id, port_id, portprofile_id)
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ class L2NetworkSingleBlade(L2NetworkModelBase):
|
|||||||
if args and isinstance(args[-1], dict):
|
if args and isinstance(args[-1], dict):
|
||||||
kwargs.update(args.pop())
|
kwargs.update(args.pop())
|
||||||
|
|
||||||
return getattr(self._plugins[plugin_key], function_name)(*args,
|
return getattr(self._plugins[plugin_key],
|
||||||
**kwargs)
|
function_name)(*args, **kwargs)
|
||||||
|
|
||||||
def get_all_networks(self, args):
|
def get_all_networks(self, args):
|
||||||
"""Not implemented for this model"""
|
"""Not implemented for this model"""
|
||||||
|
@ -43,7 +43,7 @@ quantum_opts = [
|
|||||||
cfg.StrOpt('quantum_default_tenant_id',
|
cfg.StrOpt('quantum_default_tenant_id',
|
||||||
default="default",
|
default="default",
|
||||||
help='Default tenant id when creating quantum networks'),
|
help='Default tenant id when creating quantum networks'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
@ -39,7 +39,7 @@ quantum_opts = [
|
|||||||
cfg.StrOpt('quantum_default_tenant_id',
|
cfg.StrOpt('quantum_default_tenant_id',
|
||||||
default="default",
|
default="default",
|
||||||
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)
|
||||||
|
@ -23,7 +23,7 @@ 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 import (
|
from quantum.plugins.cisco.l2network_segmentation_base import (
|
||||||
L2NetworkSegmentationMgrBase,
|
L2NetworkSegmentationMgrBase,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -270,20 +270,20 @@ SERVICE_COMMANDS = {
|
|||||||
"func": insert_inpath_service,
|
"func": insert_inpath_service,
|
||||||
"args": ["tenant_id", "service_image_id", "management_net_name",
|
"args": ["tenant_id", "service_image_id", "management_net_name",
|
||||||
"northbound_net_name", "southbound_net_name"],
|
"northbound_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": {
|
"connect_vm": {
|
||||||
"func": connect_vm,
|
"func": connect_vm,
|
||||||
"args": ["tenant_id", "vm_image_id", "service_instance_id"],
|
"args": ["tenant_id", "vm_image_id", "service_instance_id"],
|
||||||
},
|
},
|
||||||
"disconnect_vm": {
|
"disconnect_vm": {
|
||||||
"func": disconnect_vm,
|
"func": disconnect_vm,
|
||||||
"args": ["vm_instance_id"],
|
"args": ["vm_instance_id"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -35,11 +35,11 @@ from quantum.extensions import (
|
|||||||
novatenant,
|
novatenant,
|
||||||
portprofile,
|
portprofile,
|
||||||
qos,
|
qos,
|
||||||
)
|
)
|
||||||
from quantum.extensions.extensions import (
|
from quantum.extensions.extensions import (
|
||||||
ExtensionMiddleware,
|
ExtensionMiddleware,
|
||||||
PluginAwareExtensionManager,
|
PluginAwareExtensionManager,
|
||||||
)
|
)
|
||||||
from quantum.manager import QuantumManager
|
from quantum.manager import QuantumManager
|
||||||
from quantum.openstack.common import jsonutils
|
from quantum.openstack.common import jsonutils
|
||||||
from quantum.plugins.cisco.db import api as db
|
from quantum.plugins.cisco.db import api as db
|
||||||
@ -93,8 +93,8 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
'portprofile': {
|
'portprofile': {
|
||||||
'portprofile_name': 'cisco_test_portprofile',
|
'portprofile_name': 'cisco_test_portprofile',
|
||||||
'qos_name': 'test-qos1',
|
'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 = {}
|
||||||
@ -111,13 +111,14 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
req_body1 = jsonutils.dumps(self.test_port_profile)
|
req_body1 = jsonutils.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 = jsonutils.dumps({
|
req_body2 = jsonutils.dumps({
|
||||||
'portprofile': {
|
'portprofile': {
|
||||||
'portprofile_name': 'cisco_test_portprofile2',
|
'portprofile_name': 'cisco_test_portprofile2',
|
||||||
'qos_name': 'test-qos2',
|
'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)
|
||||||
@ -236,8 +237,8 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
'portprofile': {
|
'portprofile': {
|
||||||
'portprofile_name': 'cisco_rename_portprofile',
|
'portprofile_name': 'cisco_rename_portprofile',
|
||||||
'qos_name': 'test-qos1',
|
'qos_name': 'test-qos1',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
rename_req_body = jsonutils.dumps(rename_port_profile)
|
rename_req_body = jsonutils.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'])
|
||||||
@ -289,8 +290,8 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
'portprofile': {
|
'portprofile': {
|
||||||
'portprofile_name': 'cisco_rename_portprofile',
|
'portprofile_name': 'cisco_rename_portprofile',
|
||||||
'qos_name': 'test-qos1',
|
'qos_name': 'test-qos1',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
rename_req_body = jsonutils.dumps(rename_port_profile)
|
rename_req_body = jsonutils.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)
|
||||||
@ -416,8 +417,8 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
'portprofile': {
|
'portprofile': {
|
||||||
'network-id': net_id,
|
'network-id': net_id,
|
||||||
'port-id': port_id,
|
'port-id': port_id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
req_assign_body = jsonutils.dumps(test_port_assign_data)
|
req_assign_body = jsonutils.dumps(test_port_assign_data)
|
||||||
associate_path_temp = (
|
associate_path_temp = (
|
||||||
self.portprofile_path +
|
self.portprofile_path +
|
||||||
@ -452,8 +453,8 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
'portprofile': {
|
'portprofile': {
|
||||||
'network-id': '001',
|
'network-id': '001',
|
||||||
'port-id': '1',
|
'port-id': '1',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
req_assign_body = jsonutils.dumps(test_port_assign_data)
|
req_assign_body = jsonutils.dumps(test_port_assign_data)
|
||||||
associate_path = (self.portprofile_path +
|
associate_path = (self.portprofile_path +
|
||||||
portprofile_id +
|
portprofile_id +
|
||||||
@ -483,8 +484,8 @@ class PortprofileExtensionTest(unittest.TestCase):
|
|||||||
'portprofile': {
|
'portprofile': {
|
||||||
'network-id': net_id,
|
'network-id': net_id,
|
||||||
'port-id': port_id,
|
'port-id': port_id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
req_assign_body = jsonutils.dumps(test_port_assign_data)
|
req_assign_body = jsonutils.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'] +
|
||||||
@ -565,18 +566,18 @@ class NovatenantExtensionTest(unittest.TestCase):
|
|||||||
'project_id': 'demo',
|
'project_id': 'demo',
|
||||||
'user_id': 'root',
|
'user_id': 'root',
|
||||||
'vif_id': '23432423',
|
'vif_id': '23432423',
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
self.test_associate_data = {
|
self.test_associate_data = {
|
||||||
'novatenant': {
|
'novatenant': {
|
||||||
'instance_id': 1,
|
'instance_id': 1,
|
||||||
'instance_desc': {
|
'instance_desc': {
|
||||||
'project_id': 'demo',
|
'project_id': 'demo',
|
||||||
'user_id': 'root',
|
'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):
|
||||||
@ -640,9 +641,9 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
'qos_desc': {
|
'qos_desc': {
|
||||||
'PPS': 50,
|
'PPS': 50,
|
||||||
'TTL': 5,
|
'TTL': 5,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
self._l2network_plugin = l2network_plugin.L2Network()
|
self._l2network_plugin = l2network_plugin.L2Network()
|
||||||
|
|
||||||
def test_create_qos(self):
|
def test_create_qos(self):
|
||||||
@ -690,9 +691,9 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
'qos_desc': {
|
'qos_desc': {
|
||||||
'PPS': 50,
|
'PPS': 50,
|
||||||
'TTL': 5,
|
'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)
|
||||||
@ -767,9 +768,9 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
'qos_desc': {
|
'qos_desc': {
|
||||||
'PPS': 50,
|
'PPS': 50,
|
||||||
'TTL': 5,
|
'TTL': 5,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
|
})
|
||||||
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)
|
||||||
@ -778,9 +779,8 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
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')
|
|
||||||
self.tearDownQos(rename_path)
|
self.tearDownQos(rename_path)
|
||||||
LOG.debug("test_update_qos - END")
|
LOG.debug("test_update_qos - END")
|
||||||
|
|
||||||
@ -795,9 +795,9 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
'qos_desc': {
|
'qos_desc': {
|
||||||
'PPS': 50,
|
'PPS': 50,
|
||||||
'TTL': 5,
|
'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,
|
||||||
@ -838,9 +838,9 @@ class QosExtensionTest(unittest.TestCase):
|
|||||||
'qos_desc': {
|
'qos_desc': {
|
||||||
'PPS': 50,
|
'PPS': 50,
|
||||||
'TTL': 5,
|
'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,
|
||||||
@ -881,12 +881,12 @@ class CredentialExtensionTest(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 = credential.CredentialController(
|
controller = credential.CredentialController(QuantumManager.
|
||||||
QuantumManager.get_plugin())
|
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(
|
||||||
SimpleExtensionManager(res_ext))
|
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/'
|
||||||
@ -895,8 +895,8 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
'credential_name': 'cred8',
|
'credential_name': 'cred8',
|
||||||
'user_name': 'newUser2',
|
'user_name': 'newUser2',
|
||||||
'password': 'newPasswd1',
|
'password': 'newPasswd1',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
self._l2network_plugin = l2network_plugin.L2Network()
|
self._l2network_plugin = l2network_plugin.L2Network()
|
||||||
|
|
||||||
def test_list_credentials(self):
|
def test_list_credentials(self):
|
||||||
@ -914,8 +914,8 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
'credential_name': 'cred9',
|
'credential_name': 'cred9',
|
||||||
'user_name': 'newUser2',
|
'user_name': 'newUser2',
|
||||||
'password': 'newPasswd2',
|
'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)
|
||||||
@ -1027,8 +1027,8 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
'credential_name': 'cred3',
|
'credential_name': 'cred3',
|
||||||
'user_name': 'RenamedUser',
|
'user_name': 'RenamedUser',
|
||||||
'password': 'Renamedpassword',
|
'password': 'Renamedpassword',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
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)
|
||||||
@ -1075,8 +1075,8 @@ class CredentialExtensionTest(unittest.TestCase):
|
|||||||
'credential_name': 'cred3',
|
'credential_name': 'cred3',
|
||||||
'user_name': 'RenamedUser',
|
'user_name': 'RenamedUser',
|
||||||
'password': 'Renamedpassword',
|
'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,
|
||||||
@ -1143,8 +1143,8 @@ class MultiPortExtensionTest(unittest.TestCase):
|
|||||||
'net_id_list': '1',
|
'net_id_list': '1',
|
||||||
'status': 'test-qos1',
|
'status': 'test-qos1',
|
||||||
'ports_desc': 'Port Descr',
|
'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 = {}
|
||||||
@ -1209,9 +1209,9 @@ class MultiPortExtensionTest(unittest.TestCase):
|
|||||||
'status': 'ACTIVE',
|
'status': 'ACTIVE',
|
||||||
'ports_desc': {
|
'ports_desc': {
|
||||||
'key': 'value',
|
'key': 'value',
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
req_body = jsonutils.dumps(test_multi_port)
|
req_body = jsonutils.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)
|
||||||
|
@ -178,7 +178,7 @@ class NexusDB(object):
|
|||||||
return bindings
|
return bindings
|
||||||
except Exception, exc:
|
except Exception, exc:
|
||||||
raise Exception("Failed to delete nexus port binding: %s"
|
raise Exception("Failed to delete nexus port binding: %s"
|
||||||
% str(exc))
|
% str(exc))
|
||||||
|
|
||||||
def update_nexusport_binding(self, port_id, new_vlan_id):
|
def update_nexusport_binding(self, port_id, new_vlan_id):
|
||||||
"""update nexus port binding"""
|
"""update nexus port binding"""
|
||||||
@ -244,7 +244,7 @@ class ServicesDB(object):
|
|||||||
LOG.debug("Deleted service binding: %s" % res.service_id)
|
LOG.debug("Deleted service binding: %s" % res.service_id)
|
||||||
except Exception, exc:
|
except Exception, exc:
|
||||||
raise Exception("Failed to delete service binding: %s"
|
raise Exception("Failed to delete service binding: %s"
|
||||||
% str(exc))
|
% str(exc))
|
||||||
|
|
||||||
|
|
||||||
class L2networkDB(object):
|
class L2networkDB(object):
|
||||||
@ -309,7 +309,7 @@ class L2networkDB(object):
|
|||||||
"""Update a vlan binding"""
|
"""Update a vlan binding"""
|
||||||
try:
|
try:
|
||||||
res = l2network_db.update_vlan_binding(network_id, vlan_id,
|
res = l2network_db.update_vlan_binding(network_id, vlan_id,
|
||||||
vlan_name)
|
vlan_name)
|
||||||
LOG.debug("Updating vlan binding for vlan: %s" % res.vlan_id)
|
LOG.debug("Updating vlan binding for vlan: %s" % res.vlan_id)
|
||||||
vlan_dict = {}
|
vlan_dict = {}
|
||||||
vlan_dict["vlan-id"] = str(res.vlan_id)
|
vlan_dict["vlan-id"] = str(res.vlan_id)
|
||||||
@ -1166,7 +1166,7 @@ class QuantumDBTest(unittest.TestCase):
|
|||||||
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
net1 = self.dbtest.create_network(self.tenant_id, "plugin_test1")
|
||||||
self.assertTrue(net1["net-name"] == "plugin_test1")
|
self.assertTrue(net1["net-name"] == "plugin_test1")
|
||||||
net = self.dbtest.update_network(self.tenant_id, net1["net-id"],
|
net = self.dbtest.update_network(self.tenant_id, net1["net-id"],
|
||||||
name="plugin_test1_renamed")
|
name="plugin_test1_renamed")
|
||||||
self.assertTrue(net["net-name"] == "plugin_test1_renamed")
|
self.assertTrue(net["net-name"] == "plugin_test1_renamed")
|
||||||
self.teardown_network_port()
|
self.teardown_network_port()
|
||||||
|
|
||||||
|
@ -90,10 +90,11 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
tenant_id, net_id)
|
tenant_id, net_id)
|
||||||
LOG.debug("test_delete_network_not_found - END")
|
LOG.debug("test_delete_network_not_found - END")
|
||||||
|
|
||||||
def test_delete_networkInUse(
|
def test_delete_networkInUse(self, tenant_id='test_tenant',
|
||||||
self, tenant_id='test_tenant', instance_tenant_id='nova',
|
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 deletion of a Virtual Network when Network is in Use.
|
Tests deletion of a Virtual Network when Network is in Use.
|
||||||
@ -492,10 +493,11 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
LOG.debug("test_plug_interface - START")
|
LOG.debug("test_plug_interface - 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)
|
||||||
port_dict = self._l2network_plugin.create_port(
|
port_dict = self._l2network_plugin.create_port(tenant_id,
|
||||||
tenant_id, new_net_dict[const.NET_ID], self.state)
|
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,
|
||||||
@ -551,11 +553,13 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
self.tearDownNetwork(tenant_id, new_net_dict[const.NET_ID])
|
||||||
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',
|
||||||
self, tenant_id='test_tenant', instance_tenant_id='nova',
|
instance_tenant_id='nova',
|
||||||
nova_user_id='novaadmin', instance_id=10,
|
nova_user_id='novaadmin',
|
||||||
vif_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
instance_id=10,
|
||||||
remote_interface='new_interface'):
|
vif_id='fe701ddf-26a2-42ea-'
|
||||||
|
'b9e6-7313d1c522cc',
|
||||||
|
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
|
||||||
@ -588,10 +592,10 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
|
|
||||||
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',
|
||||||
self, tenant_id='test_tenant', instance_tenant_id='nova',
|
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
|
||||||
"""
|
"""
|
||||||
@ -730,8 +734,8 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
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,
|
||||||
tenant_id, 'test_network')
|
'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)
|
||||||
@ -919,7 +923,8 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
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',
|
||||||
net_id='0005', port_id='p00005', profile_id='pr0005'):
|
net_id='0005', port_id='p00005',
|
||||||
|
profile_id='pr0005'):
|
||||||
"""
|
"""
|
||||||
Tests disassociation of a port-profile when network does not exist
|
Tests disassociation of a port-profile when network does not exist
|
||||||
"""
|
"""
|
||||||
@ -1010,8 +1015,8 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
self.tearDownNetwork(tenant_id, network_dict_id)
|
self.tearDownNetwork(tenant_id, network_dict_id)
|
||||||
|
|
||||||
def tearDownNetworkPortInterface(self, tenant_id, instance_tenant_id,
|
def tearDownNetworkPortInterface(self, tenant_id, instance_tenant_id,
|
||||||
instance_id, instance_desc, network_dict_id,
|
instance_id, instance_desc,
|
||||||
port_id):
|
network_dict_id, port_id):
|
||||||
"""
|
"""
|
||||||
Tear down Network Port Interface
|
Tear down Network Port Interface
|
||||||
"""
|
"""
|
||||||
@ -1061,7 +1066,7 @@ class CoreAPITestFunc(unittest.TestCase):
|
|||||||
const.PROFILE_ASSOCIATIONS: profile_associations,
|
const.PROFILE_ASSOCIATIONS: profile_associations,
|
||||||
const.PROFILE_VLAN_ID: None,
|
const.PROFILE_VLAN_ID: None,
|
||||||
const.PROFILE_QOS: qos,
|
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):
|
||||||
|
@ -116,7 +116,7 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
self.net_id,
|
self.net_id,
|
||||||
vlan_name(self.net_id),
|
vlan_name(self.net_id),
|
||||||
vlan_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:
|
||||||
@ -177,7 +177,7 @@ class TestMultiBlade(unittest.TestCase):
|
|||||||
tenant_id,
|
tenant_id,
|
||||||
self.net_id,
|
self.net_id,
|
||||||
{'name': new_net_name},
|
{'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)
|
||||||
|
@ -26,50 +26,63 @@ 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\" "
|
CREATE_VLAN_OUTPUT = ('<configConfMos cookie="cookie_placeholder" '
|
||||||
"inHierarchical=\"true\"> <inConfigs><pair key=\"fabric/lan/net-New Vlan\"> "
|
'inHierarchical="true"> <inConfigs><pair '
|
||||||
"<fabricVlan defaultNet=\"no\" dn=\"fabric/lan/net-New Vlan\" id=\"200\" "
|
'key="fabric/lan/net-New Vlan"> '
|
||||||
"name=\"New Vlan\" status=\"created\"></fabricVlan> </pair> </inConfigs> "
|
'<fabricVlan defaultNet="no" '
|
||||||
"</configConfMos>")
|
'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_PROFILE_OUTPUT = ('<configConfMos cookie="cookie_placeholder" '
|
||||||
"inHierarchical=\"true\"> <inConfigs><pair key=\"fabric/lan/profiles/vnic-"
|
'inHierarchical="true"> <inConfigs><pair '
|
||||||
"New Profile\"> <vnicProfile descr=\"Profile created by Cisco OpenStack "
|
'key="fabric/lan/profiles/vnic-'
|
||||||
"Quantum Plugin\" dn=\"fabric/lan/profiles/vnic-New Profile\" maxPorts="
|
'New Profile"> <vnicProfile descr="Profile created '
|
||||||
"\"64\" name=\"New Profile\" nwCtrlPolicyName=\"\" pinToGroupName=\"\" "
|
'by Cisco OpenStack Quantum Plugin" '
|
||||||
"qosPolicyName=\"\" status=\"created\"> <vnicEtherIf defaultNet=\"yes\" "
|
'dn="fabric/lan/profiles/vnic-New Profile" maxPorts='
|
||||||
"name=\"New Vlan\" rn=\"if-New Vlan\" > </vnicEtherIf> </vnicProfile> "
|
'"64" name="New Profile" nwCtrlPolicyName="" '
|
||||||
"</pair> </inConfigs> </configConfMos>")
|
'pinToGroupName="" 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\" "
|
CHANGE_VLAN_OUTPUT = ('<configConfMos cookie="cookie_placeholder" '
|
||||||
"inHierarchical=\"true\"> <inConfigs><pair key=\""
|
'inHierarchical="true"> <inConfigs><pair key="'
|
||||||
"fabric/lan/profiles/vnic-New Profile\"> <vnicProfile descr=\"Profile "
|
'fabric/lan/profiles/vnic-New Profile"> '
|
||||||
"created by Cisco OpenStack Quantum Plugin\" "
|
'<vnicProfile descr="Profile '
|
||||||
"dn=\"fabric/lan/profiles/vnic-New Profile\" maxPorts=\"64\" "
|
'created by Cisco OpenStack Quantum Plugin" '
|
||||||
"name=\"New Profile\" nwCtrlPolicyName=\"\" pinToGroupName=\"\" "
|
'dn="fabric/lan/profiles/vnic-New Profile" maxPorts="64"'
|
||||||
"qosPolicyName=\"\" status=\"created,modified\"><vnicEtherIf "
|
' name="New Profile" nwCtrlPolicyName="" '
|
||||||
"rn=\"if-Old Vlan\" status=\"deleted\"> </vnicEtherIf> "
|
'pinToGroupName="" qosPolicyName="" '
|
||||||
"<vnicEtherIf defaultNet=\"yes\" name=\"New Vlan\" rn=\"if-New Vlan\" > "
|
'status="created,modified"><vnicEtherIf '
|
||||||
"</vnicEtherIf> </vnicProfile> </pair></inConfigs> </configConfMos>")
|
'rn="if-Old Vlan" status="deleted"> </vnicEtherIf> '
|
||||||
|
'<vnicEtherIf defaultNet="yes" name="New Vlan" '
|
||||||
|
'rn="if-New Vlan" > </vnicEtherIf> </vnicProfile> '
|
||||||
|
'</pair></inConfigs> </configConfMos>')
|
||||||
|
|
||||||
DELETE_VLAN_OUTPUT = ("<configConfMos cookie=\"cookie_placeholder\" "
|
DELETE_VLAN_OUTPUT = ('<configConfMos cookie="cookie_placeholder" '
|
||||||
"inHierarchical=\"true\"> <inConfigs><pair key=\"fabric/lan/net-New Vlan\"> "
|
'inHierarchical="true"> <inConfigs><pair '
|
||||||
"<fabricVlan dn=\"fabric/lan/net-New Vlan\" status=\"deleted\"> "
|
'key="fabric/lan/net-New Vlan"> '
|
||||||
"</fabricVlan> </pair> </inConfigs></configConfMos>")
|
'<fabricVlan dn="fabric/lan/net-New Vlan" '
|
||||||
|
'status="deleted"> </fabricVlan> '
|
||||||
|
'</pair> </inConfigs></configConfMos>')
|
||||||
|
|
||||||
DELETE_PROFILE_OUTPUT = ("<configConfMos cookie=\"cookie_placeholder\" "
|
DELETE_PROFILE_OUTPUT = ('<configConfMos cookie="cookie_placeholder" '
|
||||||
"inHierarchical=\"false\"> <inConfigs><pair key=\""
|
'inHierarchical="false"> <inConfigs><pair key="'
|
||||||
"fabric/lan/profiles/vnic-New Profile\"> <vnicProfile "
|
'fabric/lan/profiles/vnic-New Profile"> <vnicProfile '
|
||||||
"dn=\"fabric/lan/profiles/vnic-New Profile\" status=\"deleted\"> "
|
'dn="fabric/lan/profiles/vnic-New Profile" '
|
||||||
"</vnicProfile></pair> </inConfigs> </configConfMos>")
|
'status="deleted"> </vnicProfile></pair> '
|
||||||
|
'</inConfigs> </configConfMos>')
|
||||||
|
|
||||||
ASSOCIATE_PROFILE_OUTPUT = ("<configConfMos cookie=\"cookie_placeholder\" "
|
ASSOCIATE_PROFILE_OUTPUT = ('<configConfMos cookie="cookie_placeholder" '
|
||||||
"inHierarchical=\"true\"> <inConfigs> <pair key="
|
'inHierarchical="true"> <inConfigs> <pair key='
|
||||||
"\"fabric/lan/profiles/vnic-New Profile/cl-New Profile Client\">"
|
'"fabric/lan/profiles/vnic-New Profile/cl-New '
|
||||||
" <vmVnicProfCl dcName=\".*\" descr=\"\" dn=\"fabric/lan/profiles/vnic-"
|
'Profile Client"> <vmVnicProfCl dcName=".*" '
|
||||||
"New Profile/cl-New Profile Client\"name=\"New Profile Client\" "
|
'descr="" dn="fabric/lan/profiles/vnic-'
|
||||||
"orgPath=\".*\" status=\"created\" swName=\"default$\"> </vmVnicProfCl>"
|
'New Profile/cl-New Profile Client"name="New '
|
||||||
"</pair> </inConfigs> </configConfMos>")
|
'Profile Client" orgPath=".*" status="created" '
|
||||||
|
'swName="default$"> </vmVnicProfCl>'
|
||||||
|
'</pair> </inConfigs> </configConfMos>')
|
||||||
|
|
||||||
|
|
||||||
class TestUCSDriver(unittest.TestCase):
|
class TestUCSDriver(unittest.TestCase):
|
||||||
@ -94,8 +107,8 @@ class TestUCSDriver(unittest.TestCase):
|
|||||||
self.assertEqual(vlan_details, expected_output)
|
self.assertEqual(vlan_details, expected_output)
|
||||||
LOG.debug("test_create_vlan - END")
|
LOG.debug("test_create_vlan - END")
|
||||||
|
|
||||||
def test_create_profile_post_data(
|
def test_create_profile_post_data(self,
|
||||||
self, expected_output=CREATE_PROFILE_OUTPUT):
|
expected_output=CREATE_PROFILE_OUTPUT):
|
||||||
"""
|
"""
|
||||||
Tests creation of profile post Data
|
Tests creation of profile post Data
|
||||||
"""
|
"""
|
||||||
@ -106,8 +119,8 @@ class TestUCSDriver(unittest.TestCase):
|
|||||||
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")
|
||||||
|
|
||||||
def test_change_vlan_profile_data(
|
def test_change_vlan_profile_data(self,
|
||||||
self, expected_output=CHANGE_VLAN_OUTPUT):
|
expected_output=CHANGE_VLAN_OUTPUT):
|
||||||
"""
|
"""
|
||||||
Tests creation of change vlan in profile post Data
|
Tests creation of change vlan in profile post Data
|
||||||
"""
|
"""
|
||||||
@ -146,8 +159,9 @@ class TestUCSDriver(unittest.TestCase):
|
|||||||
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,
|
||||||
self, expected_output=ASSOCIATE_PROFILE_OUTPUT):
|
expected_output=
|
||||||
|
ASSOCIATE_PROFILE_OUTPUT):
|
||||||
"""
|
"""
|
||||||
Tests creation of profile client post Data
|
Tests creation of profile client post Data
|
||||||
"""
|
"""
|
||||||
|
@ -27,7 +27,7 @@ from quantum.plugins.cisco.db import l2network_db as cdb
|
|||||||
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
from quantum.plugins.cisco import l2network_plugin_configuration as conf
|
||||||
from quantum.plugins.cisco.segmentation.l2network_vlan_mgr import (
|
from quantum.plugins.cisco.segmentation.l2network_vlan_mgr import (
|
||||||
L2NetworkVLANMgr,
|
L2NetworkVLANMgr,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARN)
|
logging.basicConfig(level=logging.WARN)
|
||||||
|
@ -66,7 +66,7 @@ import logging
|
|||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
from quantum.plugins.cisco.l2device_inventory_base import (
|
from quantum.plugins.cisco.l2device_inventory_base import (
|
||||||
L2NetworkDeviceInventoryBase,
|
L2NetworkDeviceInventoryBase,
|
||||||
)
|
)
|
||||||
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_exceptions as cexc
|
||||||
@ -74,7 +74,7 @@ from quantum.plugins.cisco.db import api as db
|
|||||||
from quantum.plugins.cisco.db import ucs_db as udb
|
from quantum.plugins.cisco.db import ucs_db as udb
|
||||||
from quantum.plugins.cisco.ucs import (
|
from quantum.plugins.cisco.ucs import (
|
||||||
cisco_ucs_inventory_configuration as conf,
|
cisco_ucs_inventory_configuration as conf,
|
||||||
)
|
)
|
||||||
from quantum.plugins.cisco.ucs import cisco_ucs_network_driver
|
from quantum.plugins.cisco.ucs import cisco_ucs_network_driver
|
||||||
|
|
||||||
|
|
||||||
@ -198,8 +198,8 @@ 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.
|
||||||
const.BLADE_INTF_UNRESERVED):
|
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)
|
||||||
@ -334,7 +334,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
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"
|
LOG.debug(("Found reserved dynamic nic: %s"
|
||||||
"associated with port %s") %
|
"associated with port %s") %
|
||||||
(intf_data, port_id))
|
(intf_data, port_id))
|
||||||
@ -398,8 +398,8 @@ 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] ==
|
||||||
@ -430,8 +430,8 @@ 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
|
||||||
@ -450,7 +450,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
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
|
||||||
@ -519,7 +519,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
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,
|
||||||
@ -597,7 +597,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
const.DEVICE_IP: [ucsm_ip],
|
const.DEVICE_IP: [ucsm_ip],
|
||||||
const.UCS_INVENTORY: self,
|
const.UCS_INVENTORY: self,
|
||||||
const.LEAST_RSVD_BLADE_DICT: 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):
|
||||||
@ -612,7 +612,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
rsvd_info = self._get_rsvd_blade_intf_by_port(tenant_id, port_id)
|
rsvd_info = self._get_rsvd_blade_intf_by_port(tenant_id, port_id)
|
||||||
if not rsvd_info:
|
if not rsvd_info:
|
||||||
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]],
|
||||||
@ -620,7 +620,7 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
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):
|
||||||
@ -709,5 +709,5 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
|
|||||||
const.UCS_INVENTORY: self,
|
const.UCS_INVENTORY: self,
|
||||||
const.LEAST_RSVD_BLADE_DICT:
|
const.LEAST_RSVD_BLADE_DICT:
|
||||||
least_reserved_blade_dict,
|
least_reserved_blade_dict,
|
||||||
}
|
}
|
||||||
return device_params
|
return device_params
|
||||||
|
@ -48,89 +48,90 @@ HEADERS = {"Content-Type": "text/xml"}
|
|||||||
METHOD = "POST"
|
METHOD = "POST"
|
||||||
URL = "/nuova"
|
URL = "/nuova"
|
||||||
|
|
||||||
CREATE_VLAN = "<configConfMos cookie=\"" + COOKIE_VALUE + \
|
CREATE_VLAN = ('<configConfMos cookie="' + COOKIE_VALUE +
|
||||||
"\" inHierarchical=\"true\"> <inConfigs>" \
|
'" inHierarchical="true"> <inConfigs>'
|
||||||
"<pair key=\"fabric/lan/net-" + VLAN_NAME + \
|
'<pair key="fabric/lan/net-"' + VLAN_NAME +
|
||||||
"\"> <fabricVlan defaultNet=\"no\" " \
|
'"> <fabricVlan defaultNet="no" '
|
||||||
"dn=\"fabric/lan/net-" + VLAN_NAME + \
|
'dn="fabric/lan/net-' + VLAN_NAME +
|
||||||
"\" id=\"" + VLAN_ID + "\" name=\"" + \
|
'" id="' + VLAN_ID + '" name="' +
|
||||||
VLAN_NAME + "\" status=\"created\">" \
|
VLAN_NAME + '" status="created">'
|
||||||
"</fabricVlan> </pair> </inConfigs> </configConfMos>"
|
'</fabricVlan> </pair> </inConfigs> </configConfMos>')
|
||||||
|
|
||||||
CREATE_PROFILE = "<configConfMos cookie=\"" + COOKIE_VALUE + \
|
CREATE_PROFILE = ('<configConfMos cookie="' + COOKIE_VALUE +
|
||||||
"\" inHierarchical=\"true\"> <inConfigs>" \
|
'" inHierarchical="true"> <inConfigs>'
|
||||||
"<pair key=\"fabric/lan/profiles/vnic-" + PROFILE_NAME + \
|
'<pair key="fabric/lan/profiles/vnic-' + PROFILE_NAME +
|
||||||
"\"> <vnicProfile descr=\"Profile created by " \
|
'"> <vnicProfile descr="Profile created by '
|
||||||
"Cisco OpenStack Quantum Plugin\" " \
|
'Cisco OpenStack Quantum Plugin" '
|
||||||
"dn=\"fabric/lan/profiles/vnic-" + PROFILE_NAME + \
|
'dn="fabric/lan/profiles/vnic' + PROFILE_NAME +
|
||||||
"\" maxPorts=\"64\" name=\"" + PROFILE_NAME + \
|
'" maxPorts="64" name="' + PROFILE_NAME +
|
||||||
"\" nwCtrlPolicyName=\"\" pinToGroupName=\"\" " \
|
'" nwCtrlPolicyName="" pinToGroupName="" '
|
||||||
"qosPolicyName=\"\" status=\"created\"> " \
|
'qosPolicyName="" status="created"> '
|
||||||
"<vnicEtherIf defaultNet=\"yes\" name=\"" + VLAN_NAME + \
|
'<vnicEtherIf defaultNet="yes" name="' + VLAN_NAME +
|
||||||
"\" rn=\"if-" + VLAN_NAME + "\" > </vnicEtherIf> " \
|
'" rn="if' + VLAN_NAME + '" > </vnicEtherIf> '
|
||||||
"</vnicProfile> </pair> </inConfigs> </configConfMos>"
|
'</vnicProfile> </pair> </inConfigs> </configConfMos>')
|
||||||
|
|
||||||
ASSOCIATE_PROFILE = "<configConfMos cookie=\"" + COOKIE_VALUE + \
|
ASSOCIATE_PROFILE = ('<configConfMos cookie="' + COOKIE_VALUE +
|
||||||
"\" inHierarchical=\"true\"> <inConfigs> <pair " \
|
'" inHierarchical="true"> <inConfigs> <pair '
|
||||||
"key=\"fabric/lan/profiles/vnic-" + PROFILE_NAME + \
|
'key="fabric/lan/profiles/vnic' + PROFILE_NAME +
|
||||||
"/cl-" + PROFILE_CLIENT + "\"> <vmVnicProfCl dcName=\".*\" " \
|
'/cl' + PROFILE_CLIENT + '"> <vmVnicProfCl dcName=".*" '
|
||||||
"descr=\"\" dn=\"fabric/lan/profiles/vnic-" + \
|
'descr="" dn="fabric/lan/profiles/vnic' +
|
||||||
PROFILE_NAME + "/cl-" + PROFILE_CLIENT + \
|
PROFILE_NAME + '/cl' + PROFILE_CLIENT +
|
||||||
"\"name=\"" + PROFILE_CLIENT + "\" orgPath=\".*\" " \
|
'"name="' + PROFILE_CLIENT + '" orgPath=".*" '
|
||||||
"status=\"created\" swName=\"default$\"> </vmVnicProfCl>" \
|
'status="created" swName="default$"> </vmVnicProfCl>'
|
||||||
"</pair> </inConfigs> </configConfMos>"
|
'</pair> </inConfigs> </configConfMos>')
|
||||||
|
|
||||||
CHANGE_VLAN_IN_PROFILE = "<configConfMos cookie=\"" + COOKIE_VALUE + \
|
CHANGE_VLAN_IN_PROFILE = ('<configConfMos cookie="' + COOKIE_VALUE +
|
||||||
"\" inHierarchical=\"true\"> <inConfigs>" \
|
'" inHierarchical="true"> <inConfigs'
|
||||||
"<pair key=\"fabric/lan/profiles/vnic-" + \
|
'<pair key="fabric/lan/profiles/vnic' +
|
||||||
PROFILE_NAME + "\"> <vnicProfile descr=\"Profile " \
|
PROFILE_NAME + '"> <vnicProfile descr="Profile'
|
||||||
"created by Cisco OpenStack Quantum Plugin\" " \
|
'created by Cisco OpenStack Quantum Plugin"'
|
||||||
"dn=\"fabric/lan/profiles/vnic-" + \
|
'dn="fabric/lan/profiles/vnic' +
|
||||||
PROFILE_NAME + "\" maxPorts=\"64\" name=\"" + \
|
PROFILE_NAME + '" maxPorts="64" name="' +
|
||||||
PROFILE_NAME + "\" nwCtrlPolicyName=\"\" " \
|
PROFILE_NAME + '" nwCtrlPolicyName=""'
|
||||||
"pinToGroupName=\"\" qosPolicyName=\"\" " \
|
'pinToGroupName="" qosPolicyName=""'
|
||||||
"status=\"created,modified\">" \
|
'status="created,modified"'
|
||||||
"<vnicEtherIf rn=\"if-" + OLD_VLAN_NAME + \
|
'<vnicEtherIf rn="if' + OLD_VLAN_NAME +
|
||||||
"\" status=\"deleted\"> </vnicEtherIf> <vnicEtherIf " \
|
'" status="deleted"> </vnicEtherIf> <vnicEtherIf'
|
||||||
"defaultNet=\"yes\" name=\"" + \
|
'defaultNet="yes" name="' +
|
||||||
VLAN_NAME + "\" rn=\"if-" + VLAN_NAME + \
|
VLAN_NAME + '" rn="if' + VLAN_NAME +
|
||||||
"\" > </vnicEtherIf> </vnicProfile> </pair>" \
|
'" > </vnicEtherIf> </vnicProfile> </pair'
|
||||||
"</inConfigs> </configConfMos>"
|
'</inConfigs> </configConfMos>')
|
||||||
|
|
||||||
DELETE_VLAN = "<configConfMos cookie=\"" + COOKIE_VALUE + \
|
DELETE_VLAN = ('<configConfMos cookie="' + COOKIE_VALUE +
|
||||||
"\" inHierarchical=\"true\"> <inConfigs>" \
|
'" inHierarchical="true"> <inConfigs'
|
||||||
"<pair key=\"fabric/lan/net-" + VLAN_NAME + \
|
'<pair key="fabric/lan/net' + VLAN_NAME +
|
||||||
"\"> <fabricVlan dn=\"fabric/lan/net-" + VLAN_NAME + \
|
'"> <fabricVlan dn="fabric/lan/net' + VLAN_NAME +
|
||||||
"\" status=\"deleted\"> </fabricVlan> </pair> </inConfigs>" \
|
'" status="deleted"> </fabricVlan> </pair> </inConfigs'
|
||||||
"</configConfMos>"
|
'</configConfMos')
|
||||||
|
|
||||||
DELETE_PROFILE = "<configConfMos cookie=\"" + COOKIE_VALUE + \
|
DELETE_PROFILE = ('<configConfMos cookie="' + COOKIE_VALUE +
|
||||||
"\" inHierarchical=\"false\"> <inConfigs>" \
|
'" inHierarchical="false"> <inConfigs'
|
||||||
"<pair key=\"fabric/lan/profiles/vnic-" + PROFILE_NAME + \
|
'<pair key="fabric/lan/profiles/vnic' + PROFILE_NAME +
|
||||||
"\"> <vnicProfile dn=\"fabric/lan/profiles/vnic-" + \
|
'"> <vnicProfile dn="fabric/lan/profiles/vnic' +
|
||||||
PROFILE_NAME + "\" status=\"deleted\"> </vnicProfile>" \
|
PROFILE_NAME + '" status="deleted"> </vnicProfile'
|
||||||
"</pair> </inConfigs> </configConfMos>"
|
'</pair> </inConfigs> </configConfMos')
|
||||||
|
|
||||||
GET_BLADE_INTERFACE_STATE = "<configScope cookie=\"" + COOKIE_VALUE + \
|
GET_BLADE_INTERFACE_STATE = ('<configScope cookie="' + COOKIE_VALUE +
|
||||||
"\" dn=\"" + BLADE_DN_VALUE + "\" inClass=\"dcxVIf\" " + \
|
'" dn="' + BLADE_DN_VALUE + '" inClass="dcxVIf"' +
|
||||||
"inHierarchical=\"false\" inRecursive=\"false\"> " + \
|
'inHierarchical="false" inRecursive="false">' +
|
||||||
"<inFilter> </inFilter> </configScope>"
|
'<inFilter> </inFilter> </configScope')
|
||||||
|
|
||||||
GET_BLADE_INTERFACE = "<configResolveClass cookie=\"" + COOKIE_VALUE + \
|
GET_BLADE_INTERFACE = ('<configResolveClass cookie="' + COOKIE_VALUE +
|
||||||
"\" classId=\"vnicEther\"" + \
|
'" classId="vnicEther"' +
|
||||||
" inHierarchical=\"false\">" + \
|
' inHierarchical="false"' +
|
||||||
" <inFilter> <eq class=\"vnicEther\" property=\"equipmentDn\"" + \
|
' <inFilter> <eq class="vnicEther" ' +
|
||||||
" value=\"sys/chassis-" + CHASSIS_VALUE + "/blade-" + \
|
'property="equipmentDn"' +
|
||||||
BLADE_VALUE + "/adaptor-1/host-eth-?\"/> " + \
|
' value="sys/chassis' + CHASSIS_VALUE + '/blade' +
|
||||||
"</inFilter> </configResolveClass>"
|
BLADE_VALUE + '/adaptor-1/host-eth-?"/>' +
|
||||||
|
'</inFilter> </configResolveClass')
|
||||||
|
|
||||||
# TODO (Sumit): Assumes "adaptor-1", check if this has to be discovered too
|
# TODO (Sumit): Assumes "adaptor-1", check if this has to be discovered too
|
||||||
GET_BLADE_INTERFACES = "<configResolveChildren cookie=\"" + \
|
GET_BLADE_INTERFACES = ('<configResolveChildren cookie="' +
|
||||||
COOKIE_VALUE + "\" inDn=\"sys/chassis-" + \
|
COOKIE_VALUE + '" inDn="sys/chassis' +
|
||||||
CHASSIS_VALUE + "/blade-" + BLADE_VALUE + \
|
CHASSIS_VALUE + '/blade' + BLADE_VALUE +
|
||||||
"/adaptor-1\"" + \
|
'/adaptor-1"' +
|
||||||
" inHierarchical=\"false\"> <inFilter> </inFilter>" + \
|
' inHierarchical="false"> <inFilter> </inFilter' +
|
||||||
" </configResolveChildren>"
|
' </configResolveChildren')
|
||||||
|
|
||||||
|
|
||||||
class CiscoUCSMDriver():
|
class CiscoUCSMDriver():
|
||||||
@ -218,7 +219,7 @@ class CiscoUCSMDriver():
|
|||||||
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)
|
||||||
@ -232,17 +233,16 @@ class CiscoUCSMDriver():
|
|||||||
const.BLADE_INTF_INST_TYPE: None,
|
const.BLADE_INTF_INST_TYPE: None,
|
||||||
const.BLADE_INTF_RHEL_DEVICE_NAME:
|
const.BLADE_INTF_RHEL_DEVICE_NAME:
|
||||||
self._get_rhel_device_name(order),
|
self._get_rhel_device_name(order),
|
||||||
}
|
}
|
||||||
blade_interfaces[dist_name] = blade_interface
|
blade_interfaces[dist_name] = blade_interface
|
||||||
|
|
||||||
return blade_interfaces
|
return blade_interfaces
|
||||||
|
|
||||||
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(
|
||||||
self._get_blade_intf_st_post_data(blade_intf[const.BLADE_INTF_DN])
|
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 = et.XML(response).find("outConfigs").findall("dcxVIf")
|
elements = et.XML(response).find("outConfigs").findall("dcxVIf")
|
||||||
for element in elements:
|
for element in elements:
|
||||||
@ -295,8 +295,8 @@ class CiscoUCSMDriver():
|
|||||||
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,
|
||||||
ucsm_password)
|
ucsm_password)
|
||||||
if blade_interfaces[blade_intf][const.BLADE_INTF_INST_TYPE] != \
|
if ((blade_interfaces[blade_intf][const.BLADE_INTF_INST_TYPE] !=
|
||||||
const.BLADE_INTF_DYNAMIC:
|
const.BLADE_INTF_DYNAMIC)):
|
||||||
blade_interfaces.pop(blade_intf)
|
blade_interfaces.pop(blade_intf)
|
||||||
|
|
||||||
return blade_interfaces
|
return blade_interfaces
|
||||||
|
@ -252,8 +252,8 @@ class UCSVICPlugin(L2DevicePluginBase):
|
|||||||
return udb.update_portbinding(port_id, vlan_name=new_vlan_name,
|
return udb.update_portbinding(port_id, vlan_name=new_vlan_name,
|
||||||
vlan_id=conf.DEFAULT_VLAN_ID)
|
vlan_id=conf.DEFAULT_VLAN_ID)
|
||||||
|
|
||||||
def create_multiport(self, tenant_id, net_id_list, ports_num, port_id_list,
|
def create_multiport(self, tenant_id, net_id_list, ports_num,
|
||||||
**kwargs):
|
port_id_list, **kwargs):
|
||||||
"""
|
"""
|
||||||
Creates a port on the specified Virtual Network.
|
Creates a port on the specified Virtual Network.
|
||||||
"""
|
"""
|
||||||
|
@ -113,7 +113,7 @@ class LinuxBridgePlugin(QuantumPluginBase):
|
|||||||
const.NET_NAME: net_name,
|
const.NET_NAME: net_name,
|
||||||
const.NET_PORTS: [],
|
const.NET_PORTS: [],
|
||||||
const.NET_OP_STATUS: new_network[const.OPSTATUS],
|
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):
|
||||||
|
@ -173,12 +173,12 @@ class LinuxBridge:
|
|||||||
LOG.debug("Creating subinterface %s for VLAN %s on interface %s" %
|
LOG.debug("Creating subinterface %s for VLAN %s on interface %s" %
|
||||||
(interface, vlan_id, self.physical_interface))
|
(interface, vlan_id, self.physical_interface))
|
||||||
if utils.execute(['ip', 'link', 'add', 'link',
|
if utils.execute(['ip', 'link', 'add', 'link',
|
||||||
self.physical_interface,
|
self.physical_interface,
|
||||||
'name', interface, 'type', 'vlan', 'id',
|
'name', interface, 'type', 'vlan', 'id',
|
||||||
vlan_id], root_wrapper=self.root_helper):
|
vlan_id], root_wrapper=self.root_helper):
|
||||||
return
|
return
|
||||||
if utils.execute(['ip', 'link', 'set',
|
if utils.execute(['ip', 'link', 'set',
|
||||||
interface, 'up'], root_wrapper=self.root_helper):
|
interface, 'up'], root_wrapper=self.root_helper):
|
||||||
return
|
return
|
||||||
LOG.debug("Done creating subinterface %s" % interface)
|
LOG.debug("Done creating subinterface %s" % interface)
|
||||||
return interface
|
return interface
|
||||||
@ -194,13 +194,13 @@ class LinuxBridge:
|
|||||||
root_wrapper=self.root_helper):
|
root_wrapper=self.root_helper):
|
||||||
return
|
return
|
||||||
if utils.execute(['brctl', 'setfd', bridge_name,
|
if utils.execute(['brctl', 'setfd', bridge_name,
|
||||||
str(0)], root_wrapper=self.root_helper):
|
str(0)], root_wrapper=self.root_helper):
|
||||||
return
|
return
|
||||||
if utils.execute(['brctl', 'stp', bridge_name,
|
if utils.execute(['brctl', 'stp', bridge_name,
|
||||||
'off'], root_wrapper=self.root_helper):
|
'off'], root_wrapper=self.root_helper):
|
||||||
return
|
return
|
||||||
if utils.execute(['ip', 'link', 'set', bridge_name,
|
if utils.execute(['ip', 'link', 'set', bridge_name,
|
||||||
'up'], root_wrapper=self.root_helper):
|
'up'], root_wrapper=self.root_helper):
|
||||||
return
|
return
|
||||||
LOG.debug("Done starting bridge %s for subinterface %s" %
|
LOG.debug("Done starting bridge %s for subinterface %s" %
|
||||||
(bridge_name, interface))
|
(bridge_name, interface))
|
||||||
@ -229,7 +229,7 @@ class LinuxBridge:
|
|||||||
bridge_name))
|
bridge_name))
|
||||||
if current_bridge_name:
|
if current_bridge_name:
|
||||||
if utils.execute(['brctl', 'delif', current_bridge_name,
|
if utils.execute(['brctl', 'delif', current_bridge_name,
|
||||||
tap_device_name], root_wrapper=self.root_helper):
|
tap_device_name], root_wrapper=self.root_helper):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.ensure_vlan_bridge(network_id, vlan_id)
|
self.ensure_vlan_bridge(network_id, vlan_id)
|
||||||
@ -463,7 +463,8 @@ def main():
|
|||||||
usagestr = "%prog [OPTIONS] <config file>"
|
usagestr = "%prog [OPTIONS] <config file>"
|
||||||
parser = OptionParser(usage=usagestr)
|
parser = OptionParser(usage=usagestr)
|
||||||
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")
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ def make_net_dict(net_id, net_name, ports, op_status):
|
|||||||
const.NET_ID: net_id,
|
const.NET_ID: net_id,
|
||||||
const.NET_NAME: net_name,
|
const.NET_NAME: net_name,
|
||||||
const.NET_OP_STATUS: op_status,
|
const.NET_OP_STATUS: op_status,
|
||||||
}
|
}
|
||||||
if ports:
|
if ports:
|
||||||
res[const.NET_PORTS] = ports
|
res[const.NET_PORTS] = ports
|
||||||
return res
|
return res
|
||||||
@ -50,4 +50,4 @@ def make_port_dict(port):
|
|||||||
const.PORT_OP_STATUS: op_status,
|
const.PORT_OP_STATUS: op_status,
|
||||||
const.NET_ID: port[const.NETWORKID],
|
const.NET_ID: port[const.NETWORKID],
|
||||||
const.ATTACHMENT: port[const.INTERFACEID],
|
const.ATTACHMENT: port[const.INTERFACEID],
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ from quantum.plugins.linuxbridge.common import config
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
CONF_FILE = find_config_file({'plugin': 'linuxbridge'}, None,
|
CONF_FILE = find_config_file({'plugin': 'linuxbridge'}, None,
|
||||||
"linuxbridge_conf.ini")
|
"linuxbridge_conf.ini")
|
||||||
CONF = config.parse(CONF_FILE)
|
CONF = config.parse(CONF_FILE)
|
||||||
|
|
||||||
|
|
||||||
@ -47,8 +47,7 @@ def create_vlanids():
|
|||||||
start = CONF.VLANS.vlan_start
|
start = CONF.VLANS.vlan_start
|
||||||
end = CONF.VLANS.vlan_end
|
end = CONF.VLANS.vlan_end
|
||||||
try:
|
try:
|
||||||
vlanid = session.query(l2network_models.VlanID).\
|
vlanid = session.query(l2network_models.VlanID).one()
|
||||||
one()
|
|
||||||
except exc.MultipleResultsFound:
|
except exc.MultipleResultsFound:
|
||||||
"""
|
"""
|
||||||
TODO (Sumit): Salvatore rightly points out that this will not handle
|
TODO (Sumit): Salvatore rightly points out that this will not handle
|
||||||
|
@ -29,7 +29,7 @@ import quantum.db.api as db
|
|||||||
from quantum.plugins.linuxbridge import LinuxBridgePlugin
|
from quantum.plugins.linuxbridge import LinuxBridgePlugin
|
||||||
from quantum.plugins.linuxbridge.agent import (
|
from quantum.plugins.linuxbridge.agent import (
|
||||||
linuxbridge_quantum_agent as linux_agent,
|
linuxbridge_quantum_agent as linux_agent,
|
||||||
)
|
)
|
||||||
from quantum.plugins.linuxbridge.common import constants as lconst
|
from quantum.plugins.linuxbridge.common import constants as lconst
|
||||||
from quantum.plugins.linuxbridge.db import l2network_db as cdb
|
from quantum.plugins.linuxbridge.db import l2network_db as cdb
|
||||||
|
|
||||||
@ -39,10 +39,11 @@ LOG = logging.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",
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
interface_id='fe701ddf-26a2-42ea-'
|
||||||
mac_address='fe:16:3e:51:60:dd'):
|
'b9e6-7313d1c522cc',
|
||||||
|
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 = (
|
||||||
@ -77,10 +78,11 @@ 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",
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
interface_id='fe701ddf-26a2-42ea-'
|
||||||
mac_address='fe:16:3e:51:60:dd'):
|
'b9e6-7313d1c522cc',
|
||||||
|
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 = (
|
||||||
@ -115,10 +117,11 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_add_tap_interface -END")
|
LOG.debug("test_add_tap_interface -END")
|
||||||
|
|
||||||
def test_remove_interface(
|
def test_remove_interface(self, tenant_id="test_tenant",
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
interface_id='fe701ddf-26a2-42ea-'
|
||||||
mac_address='fe:16:3e:51:60:dd'):
|
'b9e6-7313d1c522cc',
|
||||||
|
mac_address='fe:16:3e:51:60:dd'):
|
||||||
|
|
||||||
LOG.debug("test_remove_interface - START")
|
LOG.debug("test_remove_interface - START")
|
||||||
new_network = (
|
new_network = (
|
||||||
@ -158,10 +161,10 @@ 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",
|
||||||
self, tenant_id="test_tenant",
|
network_name="test_network",
|
||||||
network_name="test_network",
|
interface_id='fe701ddf-26a2-42ea-'
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc'):
|
'b9e6-7313d1c522cc'):
|
||||||
|
|
||||||
LOG.debug("test_ensure_vlan_bridge - START")
|
LOG.debug("test_ensure_vlan_bridge - START")
|
||||||
new_network = (
|
new_network = (
|
||||||
@ -179,7 +182,7 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
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))
|
||||||
@ -195,9 +198,10 @@ 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",
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
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 = (
|
||||||
@ -224,9 +228,10 @@ 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",
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
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 = (
|
||||||
@ -254,10 +259,12 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
self.assertEquals(self.device_exists(bridge_name), False)
|
self.assertEquals(self.device_exists(bridge_name), False)
|
||||||
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",
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
interface_id='fe701ddf-26a2-'
|
||||||
mac_address='fe:16:3e:51:60:dd'):
|
'42ea-b9e6-'
|
||||||
|
'7313d1c522cc',
|
||||||
|
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 = (
|
||||||
@ -278,8 +285,8 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
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])
|
||||||
@ -287,7 +294,7 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
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(
|
||||||
@ -300,8 +307,8 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_test_process_unplugged_tap_interface -END")
|
LOG.debug("test_test_process_unplugged_tap_interface -END")
|
||||||
|
|
||||||
def test_process_unplugged_interface_empty(
|
def test_process_unplugged_interface_empty(self, tenant_id="test_tenant",
|
||||||
self, tenant_id="test_tenant", network_name="test_network"):
|
network_name="test_network"):
|
||||||
""" test to unplug not plugged port. It should not raise exception
|
""" test to unplug not plugged port. It should not raise exception
|
||||||
"""
|
"""
|
||||||
LOG.debug("test_process_unplugged_interface_empty - START")
|
LOG.debug("test_process_unplugged_interface_empty - START")
|
||||||
@ -317,10 +324,11 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
|
|
||||||
LOG.debug("test_process_unplugged_interface_empty -END")
|
LOG.debug("test_process_unplugged_interface_empty -END")
|
||||||
|
|
||||||
def test_process_unplugged_gw_interface(
|
def test_process_unplugged_gw_interface(self, tenant_id="test_tenant",
|
||||||
self, tenant_id="test_tenant", network_name="test_network",
|
network_name="test_network",
|
||||||
interface_id='fe701ddf-26a2-42ea-b9e6-7313d1c522cc',
|
interface_id='fe701ddf-26a2-42ea-'
|
||||||
mac_address='fe:16:3e:51:60:dd'):
|
'b9e6-7313d1c522cc',
|
||||||
|
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 = (
|
||||||
@ -350,7 +358,7 @@ class LinuxBridgeAgentTest(unittest.TestCase):
|
|||||||
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(
|
||||||
|
@ -19,9 +19,9 @@ import logging
|
|||||||
|
|
||||||
|
|
||||||
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.client_eventlet \
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.client_eventlet \
|
||||||
import NvpApiClientEventlet
|
import NvpApiClientEventlet
|
||||||
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.request_eventlet \
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.request_eventlet \
|
||||||
import NvpGenericRequestEventlet
|
import NvpGenericRequestEventlet
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger("NVPApiHelper")
|
LOG = logging.getLogger("NVPApiHelper")
|
||||||
@ -158,7 +158,7 @@ class NVPApiHelper(NvpApiClientEventlet):
|
|||||||
307: zero,
|
307: zero,
|
||||||
400: zero,
|
400: zero,
|
||||||
500: zero,
|
500: zero,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class NvpApiException(Exception):
|
class NvpApiException(Exception):
|
||||||
|
@ -25,16 +25,16 @@ import nvplib
|
|||||||
|
|
||||||
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 \
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.client_eventlet \
|
||||||
import (
|
import (
|
||||||
DEFAULT_CONCURRENT_CONNECTIONS,
|
DEFAULT_CONCURRENT_CONNECTIONS,
|
||||||
DEFAULT_FAILOVER_TIME,
|
DEFAULT_FAILOVER_TIME,
|
||||||
)
|
)
|
||||||
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.request_eventlet \
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.request_eventlet \
|
||||||
import (
|
import (
|
||||||
DEFAULT_REQUEST_TIMEOUT,
|
DEFAULT_REQUEST_TIMEOUT,
|
||||||
DEFAULT_HTTP_TIMEOUT,
|
DEFAULT_HTTP_TIMEOUT,
|
||||||
DEFAULT_RETRIES,
|
DEFAULT_RETRIES,
|
||||||
DEFAULT_REDIRECTS,
|
DEFAULT_REDIRECTS,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ 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')
|
||||||
@ -374,7 +374,7 @@ class NvpPlugin(object):
|
|||||||
"net-ifaces": remote_vifs,
|
"net-ifaces": remote_vifs,
|
||||||
"net-name": result["display_name"],
|
"net-name": result["display_name"],
|
||||||
"net-op-status": "UP",
|
"net-op-status": "UP",
|
||||||
}
|
}
|
||||||
LOG.debug("get_network_details() completed for tenant %s: %s" %
|
LOG.debug("get_network_details() completed for tenant %s: %s" %
|
||||||
(tenant_id, d))
|
(tenant_id, d))
|
||||||
return d
|
return d
|
||||||
@ -400,7 +400,7 @@ class NvpPlugin(object):
|
|||||||
'net-id': netw_id,
|
'net-id': netw_id,
|
||||||
'net-name': result["display_name"],
|
'net-name': result["display_name"],
|
||||||
'net-op-status': "UP",
|
'net-op-status': "UP",
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_all_ports(self, tenant_id, netw_id, **kwargs):
|
def get_all_ports(self, tenant_id, netw_id, **kwargs):
|
||||||
"""
|
"""
|
||||||
@ -455,11 +455,11 @@ class NvpPlugin(object):
|
|||||||
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.create_port(tenant_id, netw_id, port_init_state,
|
result = nvplib.create_port(tenant_id, netw_id, port_init_state,
|
||||||
**params)
|
**params)
|
||||||
d = {
|
d = {
|
||||||
"port-id": result["uuid"],
|
"port-id": result["uuid"],
|
||||||
"port-op-status": result["port-op-status"],
|
"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
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ class NvpPlugin(object):
|
|||||||
'port-id': portw_id,
|
'port-id': portw_id,
|
||||||
'port-state': result["admin_status_enabled"],
|
'port-state': result["admin_status_enabled"],
|
||||||
'port-op-status': result["port-op-status"],
|
'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
|
||||||
|
|
||||||
@ -530,7 +530,7 @@ class NvpPlugin(object):
|
|||||||
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,
|
||||||
"LogicalPortAttachment")
|
"LogicalPortAttachment")
|
||||||
state = "ACTIVE" if port["admin_status_enabled"] else "DOWN"
|
state = "ACTIVE" if port["admin_status_enabled"] else "DOWN"
|
||||||
op_status = nvplib.get_port_status(self.controller, netw_id, portw_id)
|
op_status = nvplib.get_port_status(self.controller, netw_id, portw_id)
|
||||||
|
|
||||||
@ -545,7 +545,7 @@ class NvpPlugin(object):
|
|||||||
"port-id": portw_id, "attachment": vif_uuid,
|
"port-id": portw_id, "attachment": vif_uuid,
|
||||||
"net-id": netw_id, "port-state": state,
|
"net-id": netw_id, "port-state": state,
|
||||||
"port-op-status": op_status,
|
"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
|
||||||
|
|
||||||
@ -563,8 +563,9 @@ class NvpPlugin(object):
|
|||||||
"""
|
"""
|
||||||
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,
|
||||||
"VifAttachment", attachment=remote_interface_id)
|
portw_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))
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import eventlet
|
|||||||
|
|
||||||
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.common import (
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.common import (
|
||||||
_conn_str,
|
_conn_str,
|
||||||
)
|
)
|
||||||
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.client as client
|
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.client as client
|
||||||
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.request_eventlet
|
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.request_eventlet
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ from eventlet import timeout
|
|||||||
from quantum.openstack.common import jsonutils
|
from quantum.openstack.common import jsonutils
|
||||||
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.common import (
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client.common import (
|
||||||
_conn_str,
|
_conn_str,
|
||||||
)
|
)
|
||||||
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.request as request
|
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.request as request
|
||||||
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.client_eventlet
|
import quantum.plugins.nicira.nicira_nvp_plugin.api_client.client_eventlet
|
||||||
|
|
||||||
@ -172,8 +172,8 @@ class NvpApiRequestEventlet:
|
|||||||
response.body = response.read()
|
response.body = response.read()
|
||||||
response.headers = response.getheaders()
|
response.headers = response.getheaders()
|
||||||
LOG.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
|
||||||
@ -247,7 +247,7 @@ class NvpApiRequestEventlet:
|
|||||||
api_providers = [(result.hostname, result.port, use_https)]
|
api_providers = [(result.hostname, result.port, use_https)]
|
||||||
client_eventlet = (
|
client_eventlet = (
|
||||||
quantum.plugins.nicira.nicira_nvp_plugin.api_client.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)
|
||||||
@ -280,8 +280,8 @@ class NvpApiRequestEventlet:
|
|||||||
LOG.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
|
||||||
or req.status == httplib.FORBIDDEN):
|
or req.status == httplib.FORBIDDEN)):
|
||||||
self._api_client.need_login = True
|
self._api_client.need_login = True
|
||||||
if attempt <= self._retries:
|
if attempt <= self._retries:
|
||||||
continue
|
continue
|
||||||
|
@ -20,7 +20,7 @@ import sys
|
|||||||
from quantum.plugins.nicira.nicira_nvp_plugin import nvplib
|
from quantum.plugins.nicira.nicira_nvp_plugin import nvplib
|
||||||
from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import (
|
from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import (
|
||||||
NvpPlugin as QuantumManager,
|
NvpPlugin as QuantumManager,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
@ -31,8 +31,8 @@ def print_help():
|
|||||||
"""Help for CLI"""
|
"""Help for CLI"""
|
||||||
print "\nNVP Plugin Commands:"
|
print "\nNVP Plugin 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):
|
||||||
@ -45,15 +45,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
|
||||||
|
|
||||||
@ -76,21 +76,23 @@ def check_config(manager):
|
|||||||
|
|
||||||
|
|
||||||
COMMANDS = {
|
COMMANDS = {
|
||||||
"check_config": {
|
"check_config": {
|
||||||
"need_login": True,
|
"need_login": True,
|
||||||
"func": check_config,
|
"func": check_config,
|
||||||
"args": []},
|
"args": []
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def main():
|
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("-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,
|
||||||
PARSER.add_option("-c", "--configfile", dest="configfile",
|
help="turn on verbose logging")
|
||||||
type="string", default="/etc/quantum/plugins/nvp/nvp.ini",
|
PARSER.add_option("-c", "--configfile", dest="configfile", type="string",
|
||||||
help="nvp plugin config file path (nvp.ini)")
|
default="/etc/quantum/plugins/nvp/nvp.ini",
|
||||||
|
help="nvp plugin config file path (nvp.ini)")
|
||||||
options, args = PARSER.parse_args()
|
options, args = PARSER.parse_args()
|
||||||
|
|
||||||
loglevel = logging.INFO
|
loglevel = logging.INFO
|
||||||
|
@ -178,18 +178,16 @@ def create_network(tenant_id, net_name, **kwargs):
|
|||||||
controller = kwargs["controller"]
|
controller = kwargs["controller"]
|
||||||
|
|
||||||
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 = {
|
lswitch_obj = {
|
||||||
"display_name": net_name,
|
"display_name": net_name,
|
||||||
"transport_zones": [
|
"transport_zones": [{
|
||||||
{
|
"zone_uuid": transport_zone,
|
||||||
"zone_uuid": transport_zone,
|
"transport_type": transport_type,
|
||||||
"transport_type": transport_type,
|
}],
|
||||||
},
|
|
||||||
],
|
|
||||||
"tags": [{"tag": tenant_id, "scope": "os_tid"}],
|
"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"
|
||||||
@ -237,8 +235,7 @@ def query_ports(controller, network, relations=None, fields="*", filters=None):
|
|||||||
if filters and "attachment" in filters:
|
if filters and "attachment" in filters:
|
||||||
uri += "&attachment_vif_uuid=%s" % filters["attachment"]
|
uri += "&attachment_vif_uuid=%s" % filters["attachment"]
|
||||||
try:
|
try:
|
||||||
resp_obj = do_single_request("GET", uri,
|
resp_obj = do_single_request("GET", uri, controller=controller)
|
||||||
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)
|
||||||
@ -259,9 +256,8 @@ def delete_port(controller, network, port):
|
|||||||
|
|
||||||
|
|
||||||
def delete_all_ports(controller, ls_uuid):
|
def delete_all_ports(controller, ls_uuid):
|
||||||
res = do_single_request("GET",
|
res = do_single_request("GET", "/ws.v1/lswitch/%s/lport?fields=uuid" %
|
||||||
"/ws.v1/lswitch/%s/lport?fields=uuid" % ls_uuid,
|
ls_uuid, controller=controller)
|
||||||
controller=controller)
|
|
||||||
res = jsonutils.loads(res)
|
res = jsonutils.loads(res)
|
||||||
for r in res["results"]:
|
for r in res["results"]:
|
||||||
do_single_request(
|
do_single_request(
|
||||||
|
@ -19,7 +19,7 @@ import unittest
|
|||||||
from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import (
|
from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import (
|
||||||
NVPCluster,
|
NVPCluster,
|
||||||
parse_config,
|
parse_config,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ConfigParserTest(unittest.TestCase):
|
class ConfigParserTest(unittest.TestCase):
|
||||||
|
@ -25,7 +25,7 @@ from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import NvpPlugin
|
|||||||
from quantum.plugins.nicira.nicira_nvp_plugin import (
|
from quantum.plugins.nicira.nicira_nvp_plugin import (
|
||||||
NvpApiClient,
|
NvpApiClient,
|
||||||
nvplib,
|
nvplib,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
@ -55,8 +55,8 @@ class NvpTests(unittest.TestCase):
|
|||||||
body = {"display_name": name,
|
body = {"display_name": name,
|
||||||
"tags": [{"tag": "plugin-test"}]}
|
"tags": [{"tag": "plugin-test"}]}
|
||||||
try:
|
try:
|
||||||
resp_obj = self.quantum.api_client.request("POST",
|
resp_obj = self.quantum.api_client.request("POST", post_uri,
|
||||||
post_uri, jsonutils.dumps(body))
|
jsonutils.dumps(body))
|
||||||
except NvpApiClient.NvpApiException as e:
|
except NvpApiClient.NvpApiException as e:
|
||||||
print("Unknown API Error: %s" % str(e))
|
print("Unknown API Error: %s" % str(e))
|
||||||
raise exception.QuantumException()
|
raise exception.QuantumException()
|
||||||
@ -130,7 +130,7 @@ class NvpTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_update_network(self):
|
def test_update_network(self):
|
||||||
resp = self.quantum.create_network("quantum-test-tenant",
|
resp = self.quantum.create_network("quantum-test-tenant",
|
||||||
"quantum-Private-TenantA")
|
"quantum-Private-TenantA")
|
||||||
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,
|
||||||
|
@ -26,7 +26,7 @@ from mock import patch
|
|||||||
from quantum.plugins.nicira.nicira_nvp_plugin.api_client import (
|
from quantum.plugins.nicira.nicira_nvp_plugin.api_client import (
|
||||||
client_eventlet as nace,
|
client_eventlet as nace,
|
||||||
request_eventlet as nare,
|
request_eventlet as nare,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
@ -24,7 +24,7 @@ from quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin import NvpPlugin
|
|||||||
from quantum.plugins.nicira.nicira_nvp_plugin import (
|
from quantum.plugins.nicira.nicira_nvp_plugin import (
|
||||||
NvpApiClient,
|
NvpApiClient,
|
||||||
nvplib,
|
nvplib,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
@ -142,12 +142,12 @@ class NvpTests(unittest.TestCase):
|
|||||||
{
|
{
|
||||||
"ip_address": "172.168.17.5",
|
"ip_address": "172.168.17.5",
|
||||||
"mac_address": "10:9a:dd:61:4e:89",
|
"mac_address": "10:9a:dd:61:4e:89",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ip_address": "172.168.17.6",
|
"ip_address": "172.168.17.6",
|
||||||
"mac_address": "10:9a:dd:61:4e:88",
|
"mac_address": "10:9a:dd:61:4e:88",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
resp = self.quantum.create_port("quantum-test-tenant", net_id,
|
resp = self.quantum.create_port("quantum-test-tenant", net_id,
|
||||||
"ACTIVE", **params)
|
"ACTIVE", **params)
|
||||||
port_id = resp["port-id"]
|
port_id = resp["port-id"]
|
||||||
@ -186,7 +186,7 @@ class NvpTests(unittest.TestCase):
|
|||||||
old_vic = resp["attachment"]
|
old_vic = resp["attachment"]
|
||||||
self.assertTrue(old_vic == "None")
|
self.assertTrue(old_vic == "None")
|
||||||
self.quantum.plug_interface("quantum-test-tenant", net_id, port_id,
|
self.quantum.plug_interface("quantum-test-tenant", net_id, port_id,
|
||||||
"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_id)
|
port_id)
|
||||||
new_vic = resp["attachment"]
|
new_vic = resp["attachment"]
|
||||||
@ -202,9 +202,10 @@ class NvpTests(unittest.TestCase):
|
|||||||
self.assertTrue(True)
|
self.assertTrue(True)
|
||||||
|
|
||||||
def test_create_multi_port_attachment(self):
|
def test_create_multi_port_attachment(self):
|
||||||
resp = self.quantum.create_custom_network(
|
resp = self.quantum.create_custom_network("quantum-test-tenant",
|
||||||
"quantum-test-tenant", "quantum-Private-TenantA",
|
"quantum-Private-TenantA",
|
||||||
self.BRIDGE_TZ_UUID, self.quantum.controller)
|
self.BRIDGE_TZ_UUID,
|
||||||
|
self.quantum.controller)
|
||||||
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,
|
||||||
@ -216,7 +217,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"]
|
||||||
@ -231,7 +232,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"]
|
||||||
@ -508,7 +509,8 @@ class NvpTests(unittest.TestCase):
|
|||||||
|
|
||||||
# Make sure we only get the filtered ones back
|
# Make sure we only get the filtered ones back
|
||||||
ports = self.quantum.get_all_ports("quantum-test-tenant", net_id,
|
ports = self.quantum.get_all_ports("quantum-test-tenant", net_id,
|
||||||
filter_opts={"attachment": "attachment2"})
|
filter_opts={"attachment":
|
||||||
|
"attachment2"})
|
||||||
self.assertTrue(len(ports) == 1)
|
self.assertTrue(len(ports) == 1)
|
||||||
self.assertTrue(ports[0]["port-id"] == port_id2)
|
self.assertTrue(ports[0]["port-id"] == port_id2)
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ class OVSQuantumAgent(object):
|
|||||||
if old_b != new_b:
|
if old_b != new_b:
|
||||||
if old_b is not None:
|
if old_b is not None:
|
||||||
LOG.info("Removing binding to net-id = %s for %s"
|
LOG.info("Removing binding to net-id = %s for %s"
|
||||||
% (old_b, str(p)))
|
% (old_b, str(p)))
|
||||||
self.port_unbound(p, True)
|
self.port_unbound(p, True)
|
||||||
if p.vif_id in all_bindings:
|
if p.vif_id in all_bindings:
|
||||||
all_bindings[p.vif_id].op_status = OP_STATUS_DOWN
|
all_bindings[p.vif_id].op_status = OP_STATUS_DOWN
|
||||||
@ -475,9 +475,9 @@ class OVSQuantumTunnelAgent(object):
|
|||||||
lsw_id = lsw_id_bindings[new_net_uuid]
|
lsw_id = lsw_id_bindings[new_net_uuid]
|
||||||
self.port_bound(p, new_net_uuid, lsw_id)
|
self.port_bound(p, new_net_uuid, lsw_id)
|
||||||
all_bindings[p.vif_id].op_status = OP_STATUS_UP
|
all_bindings[p.vif_id].op_status = OP_STATUS_UP
|
||||||
LOG.info("Port " + str(p) + " on net-id = "
|
LOG.info("Port %s on net-id = %s bound to %s " % (
|
||||||
+ new_net_uuid + " bound to " +
|
str(p), new_net_uuid,
|
||||||
str(self.local_vlan_map[new_net_uuid]))
|
str(self.local_vlan_map[new_net_uuid])))
|
||||||
|
|
||||||
for vif_id in disappeared_vif_ports_ids:
|
for vif_id in disappeared_vif_ports_ids:
|
||||||
LOG.info("Port Disappeared: " + vif_id)
|
LOG.info("Port Disappeared: " + vif_id)
|
||||||
@ -506,7 +506,8 @@ def main():
|
|||||||
usagestr = "%prog [OPTIONS] <config file>"
|
usagestr = "%prog [OPTIONS] <config file>"
|
||||||
parser = OptionParser(usage=usagestr)
|
parser = OptionParser(usage=usagestr)
|
||||||
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")
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -34,8 +34,7 @@ class VlanBinding(BASE):
|
|||||||
self.vlan_id = vlan_id
|
self.vlan_id = vlan_id
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<VlanBinding(%s,%s)>" % \
|
return "<VlanBinding(%s,%s)>" % (self.vlan_id, self.network_id)
|
||||||
(self.vlan_id, self.network_id)
|
|
||||||
|
|
||||||
|
|
||||||
class TunnelIP(BASE):
|
class TunnelIP(BASE):
|
||||||
|
@ -125,7 +125,7 @@ class OVSQuantumPlugin(QuantumPluginBase):
|
|||||||
'net-id': net_id,
|
'net-id': net_id,
|
||||||
'net-name': net_name,
|
'net-name': net_name,
|
||||||
'net-op-status': op_status,
|
'net-op-status': op_status,
|
||||||
}
|
}
|
||||||
if ports:
|
if ports:
|
||||||
res['net-ports'] = ports
|
res['net-ports'] = ports
|
||||||
return res
|
return res
|
||||||
@ -176,7 +176,7 @@ class OVSQuantumPlugin(QuantumPluginBase):
|
|||||||
'port-op-status': op_status,
|
'port-op-status': op_status,
|
||||||
'net-id': port.network_id,
|
'net-id': port.network_id,
|
||||||
'attachment': port.interface_id,
|
'attachment': port.interface_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_all_ports(self, tenant_id, net_id, **kwargs):
|
def get_all_ports(self, tenant_id, net_id, **kwargs):
|
||||||
ids = []
|
ids = []
|
||||||
|
@ -31,8 +31,8 @@ LV_IDS = [42, 43]
|
|||||||
LVM = ovs_quantum_agent.LocalVLANMapping(LV_ID, LS_ID, LV_IDS)
|
LVM = ovs_quantum_agent.LocalVLANMapping(LV_ID, LS_ID, LV_IDS)
|
||||||
VIF_ID = '404deaec-5d37-11e1-a64b-000c29d5f0a8'
|
VIF_ID = '404deaec-5d37-11e1-a64b-000c29d5f0a8'
|
||||||
VIF_MAC = '3c:09:24:1e:78:23'
|
VIF_MAC = '3c:09:24:1e:78:23'
|
||||||
VIF_PORT = ovs_lib.VifPort('port', 'ofport', VIF_ID, VIF_MAC,
|
VIF_PORT = ovs_lib.VifPort('port', 'ofport',
|
||||||
'switch')
|
VIF_ID, VIF_MAC, 'switch')
|
||||||
|
|
||||||
|
|
||||||
class DummyPort:
|
class DummyPort:
|
||||||
@ -57,16 +57,14 @@ class TunnelTest(unittest.TestCase):
|
|||||||
self.TUN_OFPORT = 'PATCH_TUN_OFPORT'
|
self.TUN_OFPORT = 'PATCH_TUN_OFPORT'
|
||||||
|
|
||||||
self.mox.StubOutClassWithMocks(ovs_lib, 'OVSBridge')
|
self.mox.StubOutClassWithMocks(ovs_lib, 'OVSBridge')
|
||||||
self.mock_int_bridge = ovs_lib.OVSBridge(self.INT_BRIDGE,
|
self.mock_int_bridge = ovs_lib.OVSBridge(self.INT_BRIDGE, 'sudo')
|
||||||
'sudo')
|
|
||||||
self.mock_int_bridge.delete_port('patch-tun')
|
self.mock_int_bridge.delete_port('patch-tun')
|
||||||
self.mock_int_bridge.add_patch_port(
|
self.mock_int_bridge.add_patch_port(
|
||||||
'patch-tun', 'patch-int').AndReturn(self.TUN_OFPORT)
|
'patch-tun', 'patch-int').AndReturn(self.TUN_OFPORT)
|
||||||
self.mock_int_bridge.remove_all_flows()
|
self.mock_int_bridge.remove_all_flows()
|
||||||
self.mock_int_bridge.add_flow(priority=1, actions='normal')
|
self.mock_int_bridge.add_flow(priority=1, actions='normal')
|
||||||
|
|
||||||
self.mock_tun_bridge = ovs_lib.OVSBridge(self.TUN_BRIDGE,
|
self.mock_tun_bridge = ovs_lib.OVSBridge(self.TUN_BRIDGE, 'sudo')
|
||||||
'sudo')
|
|
||||||
self.mock_tun_bridge.reset_bridge()
|
self.mock_tun_bridge.reset_bridge()
|
||||||
self.mock_tun_bridge.add_patch_port(
|
self.mock_tun_bridge.add_patch_port(
|
||||||
'patch-int', 'patch-tun').AndReturn(self.INT_OFPORT)
|
'patch-int', 'patch-tun').AndReturn(self.INT_OFPORT)
|
||||||
|
@ -19,7 +19,7 @@ import unittest
|
|||||||
from quantum.plugins.openvswitch.ovs_quantum_plugin import (
|
from quantum.plugins.openvswitch.ovs_quantum_plugin import (
|
||||||
NoFreeVLANException,
|
NoFreeVLANException,
|
||||||
VlanMap,
|
VlanMap,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class VlanMapTest(unittest.TestCase):
|
class VlanMapTest(unittest.TestCase):
|
||||||
|
@ -112,7 +112,7 @@ class OVSBridge:
|
|||||||
"param-name=other-config",
|
"param-name=other-config",
|
||||||
"param-key=nicira-iface-id",
|
"param-key=nicira-iface-id",
|
||||||
"uuid=%s" % xs_vif_uuid],
|
"uuid=%s" % xs_vif_uuid],
|
||||||
root_helper=self.root_helper).strip()
|
root_helper=self.root_helper).strip()
|
||||||
|
|
||||||
def _vifport(self, name, external_ids):
|
def _vifport(self, name, external_ids):
|
||||||
ofport = self.db_get_val("Interface", name, "ofport")
|
ofport = self.db_get_val("Interface", name, "ofport")
|
||||||
@ -271,7 +271,8 @@ def main():
|
|||||||
usagestr = "%prog [OPTIONS] <config file>"
|
usagestr = "%prog [OPTIONS] <config file>"
|
||||||
parser = OptionParser(usage=usagestr)
|
parser = OptionParser(usage=usagestr)
|
||||||
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")
|
||||||
|
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -72,9 +72,9 @@ class DnsmasqFilter(CommandFilter):
|
|||||||
"""Specific filter for the dnsmasq call (which includes env)"""
|
"""Specific filter for the dnsmasq call (which includes env)"""
|
||||||
|
|
||||||
def match(self, userargs):
|
def match(self, userargs):
|
||||||
if (userargs[0].startswith("FLAGFILE=") and
|
if ((userargs[0].startswith("FLAGFILE=") and
|
||||||
userargs[1].startswith("NETWORK_ID=") and
|
userargs[1].startswith("NETWORK_ID=") and
|
||||||
userargs[2] == "dnsmasq"):
|
userargs[2] == "dnsmasq")):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -43,4 +43,4 @@ filterlist = [
|
|||||||
# 'ip', 'tuntap'
|
# 'ip', 'tuntap'
|
||||||
filters.CommandFilter("/usr/sbin/ip", "root"),
|
filters.CommandFilter("/usr/sbin/ip", "root"),
|
||||||
filters.CommandFilter("/sbin/ip", "root"),
|
filters.CommandFilter("/sbin/ip", "root"),
|
||||||
]
|
]
|
||||||
|
@ -33,4 +33,4 @@ filterlist = [
|
|||||||
# "xe", "vif-param-get", ...
|
# "xe", "vif-param-get", ...
|
||||||
filters.CommandFilter("/usr/bin/xe", "root"),
|
filters.CommandFilter("/usr/bin/xe", "root"),
|
||||||
filters.CommandFilter("/usr/sbin/xe", "root"),
|
filters.CommandFilter("/usr/sbin/xe", "root"),
|
||||||
]
|
]
|
||||||
|
@ -28,4 +28,4 @@ filterlist = [
|
|||||||
# "xe", "vif-param-get", ...
|
# "xe", "vif-param-get", ...
|
||||||
filters.CommandFilter("/usr/bin/xe", "root"),
|
filters.CommandFilter("/usr/bin/xe", "root"),
|
||||||
filters.CommandFilter("/usr/sbin/xe", "root"),
|
filters.CommandFilter("/usr/sbin/xe", "root"),
|
||||||
]
|
]
|
||||||
|
@ -22,8 +22,7 @@ import sys
|
|||||||
|
|
||||||
FILTERS_MODULES = ['quantum.rootwrap.linuxbridge-agent',
|
FILTERS_MODULES = ['quantum.rootwrap.linuxbridge-agent',
|
||||||
'quantum.rootwrap.openvswitch-agent',
|
'quantum.rootwrap.openvswitch-agent',
|
||||||
'quantum.rootwrap.ryu-agent',
|
'quantum.rootwrap.ryu-agent']
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def load_filters():
|
def load_filters():
|
||||||
|
@ -219,8 +219,9 @@ class BaseAPIOperationsTest(AbstractAPITest):
|
|||||||
# Create a network and a port
|
# Create a network and a port
|
||||||
network_id = self._create_network(fmt)
|
network_id = self._create_network(fmt)
|
||||||
port_id = self._create_port(network_id, "ACTIVE", fmt)
|
port_id = self._create_port(network_id, "ACTIVE", fmt)
|
||||||
show_network_req = testlib.show_network_detail_request(
|
show_network_req = testlib.show_network_detail_request(self.tenant_id,
|
||||||
self.tenant_id, network_id, fmt)
|
network_id,
|
||||||
|
fmt)
|
||||||
show_network_res = show_network_req.get_response(self.api)
|
show_network_res = show_network_req.get_response(self.api)
|
||||||
self.assertEqual(show_network_res.status_int, 200)
|
self.assertEqual(show_network_res.status_int, 200)
|
||||||
network_data = self._deserialize_net_response(content_type,
|
network_data = self._deserialize_net_response(content_type,
|
||||||
@ -371,7 +372,7 @@ class BaseAPIOperationsTest(AbstractAPITest):
|
|||||||
|
|
||||||
def _test_list_ports_networknotfound(self, fmt):
|
def _test_list_ports_networknotfound(self, fmt):
|
||||||
LOG.debug("_test_list_ports_networknotfound"
|
LOG.debug("_test_list_ports_networknotfound"
|
||||||
" - fmt:%s - START", fmt)
|
" - fmt:%s - START", fmt)
|
||||||
list_port_req = testlib.port_list_request(self.tenant_id,
|
list_port_req = testlib.port_list_request(self.tenant_id,
|
||||||
"A_BAD_ID", fmt)
|
"A_BAD_ID", fmt)
|
||||||
list_port_res = list_port_req.get_response(self.api)
|
list_port_res = list_port_req.get_response(self.api)
|
||||||
@ -414,7 +415,7 @@ class BaseAPIOperationsTest(AbstractAPITest):
|
|||||||
port_data = self._deserialize_port_response(content_type,
|
port_data = self._deserialize_port_response(content_type,
|
||||||
show_port_res)
|
show_port_res)
|
||||||
self.assert_port(id=port_id, state=port_state,
|
self.assert_port(id=port_id, state=port_state,
|
||||||
port_data=port_data['port'])
|
port_data=port_data['port'])
|
||||||
LOG.debug("_test_show_port - fmt:%s - END", fmt)
|
LOG.debug("_test_show_port - fmt:%s - END", fmt)
|
||||||
|
|
||||||
def _test_show_port_detail(self, fmt):
|
def _test_show_port_detail(self, fmt):
|
||||||
|
@ -67,11 +67,11 @@ class Foxinsocks(object):
|
|||||||
|
|
||||||
def get_actions(self):
|
def get_actions(self):
|
||||||
return [extensions.ActionExtension('dummy_resources',
|
return [extensions.ActionExtension('dummy_resources',
|
||||||
'FOXNSOX:add_tweedle',
|
'FOXNSOX:add_tweedle',
|
||||||
self._add_tweedle_handler),
|
self._add_tweedle_handler),
|
||||||
extensions.ActionExtension('dummy_resources',
|
extensions.ActionExtension('dummy_resources',
|
||||||
'FOXNSOX:delete_tweedle',
|
'FOXNSOX:delete_tweedle',
|
||||||
self._delete_tweedle_handler)]
|
self._delete_tweedle_handler)]
|
||||||
|
|
||||||
def get_request_extensions(self):
|
def get_request_extensions(self):
|
||||||
request_exts = []
|
request_exts = []
|
||||||
|
@ -32,7 +32,7 @@ class AgentUtilsExecuteTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_with_helper(self):
|
def test_with_helper(self):
|
||||||
result = utils.execute(["ls", self.test_file],
|
result = utils.execute(["ls", self.test_file],
|
||||||
self.root_helper)
|
self.root_helper)
|
||||||
self.assertEqual(result, "ls %s\n" % self.test_file)
|
self.assertEqual(result, "ls %s\n" % self.test_file)
|
||||||
|
|
||||||
def test_stderr(self):
|
def test_stderr(self):
|
||||||
|
@ -62,7 +62,8 @@ class APITestV10(test_api.BaseAPIOperationsTest):
|
|||||||
test_api.NETS: nets.ControllerV10._serialization_metadata,
|
test_api.NETS: nets.ControllerV10._serialization_metadata,
|
||||||
test_api.PORTS: ports.ControllerV10._serialization_metadata,
|
test_api.PORTS: ports.ControllerV10._serialization_metadata,
|
||||||
test_api.ATTS: atts.ControllerV10._serialization_metadata,
|
test_api.ATTS: atts.ControllerV10._serialization_metadata,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
self._successful_create_code = exc.HTTPOk.code
|
self._successful_create_code = exc.HTTPOk.code
|
||||||
self._network_not_found_code = 420
|
self._network_not_found_code = 420
|
||||||
self._network_in_use_code = 421
|
self._network_in_use_code = 421
|
||||||
@ -112,7 +113,8 @@ class APITestV11(test_api.BaseAPIOperationsTest):
|
|||||||
test_api.NETS: nets.ControllerV11._serialization_metadata,
|
test_api.NETS: nets.ControllerV11._serialization_metadata,
|
||||||
test_api.PORTS: ports.ControllerV11._serialization_metadata,
|
test_api.PORTS: ports.ControllerV11._serialization_metadata,
|
||||||
test_api.ATTS: atts.ControllerV11._serialization_metadata,
|
test_api.ATTS: atts.ControllerV11._serialization_metadata,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
self._successful_create_code = exc.HTTPAccepted.code
|
self._successful_create_code = exc.HTTPAccepted.code
|
||||||
self._network_not_found_code = exc.HTTPNotFound.code
|
self._network_not_found_code = exc.HTTPNotFound.code
|
||||||
self._network_in_use_code = exc.HTTPConflict.code
|
self._network_in_use_code = exc.HTTPConflict.code
|
||||||
@ -155,7 +157,8 @@ class APIFiltersTest(test_api.AbstractAPITest):
|
|||||||
test_api.NETS: nets.ControllerV11._serialization_metadata,
|
test_api.NETS: nets.ControllerV11._serialization_metadata,
|
||||||
test_api.PORTS: ports.ControllerV11._serialization_metadata,
|
test_api.PORTS: ports.ControllerV11._serialization_metadata,
|
||||||
test_api.ATTS: atts.ControllerV11._serialization_metadata,
|
test_api.ATTS: atts.ControllerV11._serialization_metadata,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
self._successful_create_code = exc.HTTPAccepted.code
|
self._successful_create_code = exc.HTTPAccepted.code
|
||||||
self.net_op_status = test_config.get('default_net_op_status',
|
self.net_op_status = test_config.get('default_net_op_status',
|
||||||
'UNKNOWN')
|
'UNKNOWN')
|
||||||
|
@ -80,8 +80,7 @@ class QuantumDbPluginV2TestCase(unittest.TestCase):
|
|||||||
|
|
||||||
def deserialize(self, content_type, response):
|
def deserialize(self, content_type, response):
|
||||||
ctype = 'application/%s' % content_type
|
ctype = 'application/%s' % content_type
|
||||||
data = self._deserializers[ctype].\
|
data = self._deserializers[ctype].deserialize(response.body)['body']
|
||||||
deserialize(response.body)['body']
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _create_network(self, fmt, name, admin_status_up):
|
def _create_network(self, fmt, name, admin_status_up):
|
||||||
|
@ -28,7 +28,7 @@ from quantum.extensions.extensions import (
|
|||||||
ExtensionManager,
|
ExtensionManager,
|
||||||
ExtensionMiddleware,
|
ExtensionMiddleware,
|
||||||
PluginAwareExtensionManager,
|
PluginAwareExtensionManager,
|
||||||
)
|
)
|
||||||
from quantum.openstack.common import jsonutils
|
from quantum.openstack.common import jsonutils
|
||||||
from quantum.plugins.sample.SamplePlugin import QuantumEchoPlugin
|
from quantum.plugins.sample.SamplePlugin import QuantumEchoPlugin
|
||||||
from quantum.tests.unit import BaseTest
|
from quantum.tests.unit import BaseTest
|
||||||
@ -37,7 +37,7 @@ from quantum.tests.unit.extension_stubs import (
|
|||||||
StubBaseAppController,
|
StubBaseAppController,
|
||||||
StubExtension,
|
StubExtension,
|
||||||
StubPlugin,
|
StubPlugin,
|
||||||
)
|
)
|
||||||
import quantum.tests.unit.extensions
|
import quantum.tests.unit.extensions
|
||||||
from quantum import wsgi
|
from quantum import wsgi
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ class RequestExtensionTest(BaseTest):
|
|||||||
self.assertEqual(response.json['uneditable'], "original_value")
|
self.assertEqual(response.json['uneditable'], "original_value")
|
||||||
|
|
||||||
ext_app = self._setup_app_with_request_handler(_update_handler,
|
ext_app = self._setup_app_with_request_handler(_update_handler,
|
||||||
'PUT')
|
'PUT')
|
||||||
ext_response = ext_app.put("/dummy_resources/1",
|
ext_response = ext_app.put("/dummy_resources/1",
|
||||||
{'uneditable': "new_value"})
|
{'uneditable': "new_value"})
|
||||||
self.assertEqual(ext_response.json['uneditable'], "new_value")
|
self.assertEqual(ext_response.json['uneditable'], "new_value")
|
||||||
|
@ -67,7 +67,7 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
def test_reset_bridge(self):
|
def test_reset_bridge(self):
|
||||||
utils.execute(["ovs-vsctl", self.TO, "--",
|
utils.execute(["ovs-vsctl", self.TO, "--",
|
||||||
"--if-exists", "del-br", self.BR_NAME],
|
"--if-exists", "del-br", self.BR_NAME],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-vsctl", self.TO, "add-br", self.BR_NAME],
|
utils.execute(["ovs-vsctl", self.TO, "add-br", self.BR_NAME],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
@ -79,7 +79,7 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
pname = "tap5"
|
pname = "tap5"
|
||||||
utils.execute(["ovs-vsctl", self.TO, "--", "--if-exists",
|
utils.execute(["ovs-vsctl", self.TO, "--", "--if-exists",
|
||||||
"del-port", self.BR_NAME, pname],
|
"del-port", self.BR_NAME, pname],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
|
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
self.br.delete_port(pname)
|
self.br.delete_port(pname)
|
||||||
@ -93,25 +93,25 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
"hard_timeout=0,idle_timeout=0,"
|
"hard_timeout=0,idle_timeout=0,"
|
||||||
"priority=2,dl_src=ca:fe:de:ad:be:ef"
|
"priority=2,dl_src=ca:fe:de:ad:be:ef"
|
||||||
",actions=strip_vlan,output:0"],
|
",actions=strip_vlan,output:0"],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
|
utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
|
||||||
"hard_timeout=0,idle_timeout=0,"
|
"hard_timeout=0,idle_timeout=0,"
|
||||||
"priority=1,actions=normal"],
|
"priority=1,actions=normal"],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
|
utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
|
||||||
"hard_timeout=0,idle_timeout=0,"
|
"hard_timeout=0,idle_timeout=0,"
|
||||||
"priority=2,actions=drop"],
|
"priority=2,actions=drop"],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
|
utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
|
||||||
"hard_timeout=0,idle_timeout=0,"
|
"hard_timeout=0,idle_timeout=0,"
|
||||||
"priority=2,in_port=%s,actions=drop" % ofport],
|
"priority=2,in_port=%s,actions=drop" % ofport],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
|
utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
|
||||||
"hard_timeout=0,idle_timeout=0,"
|
"hard_timeout=0,idle_timeout=0,"
|
||||||
"priority=4,in_port=%s,dl_vlan=%s,"
|
"priority=4,in_port=%s,dl_vlan=%s,"
|
||||||
"actions=strip_vlan,set_tunnel:%s,normal"
|
"actions=strip_vlan,set_tunnel:%s,normal"
|
||||||
% (ofport, vid, lsw_id)],
|
% (ofport, vid, lsw_id)],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
|
utils.execute(["ovs-ofctl", "add-flow", self.BR_NAME,
|
||||||
"hard_timeout=0,idle_timeout=0,"
|
"hard_timeout=0,idle_timeout=0,"
|
||||||
"priority=3,tun_id=%s,actions="
|
"priority=3,tun_id=%s,actions="
|
||||||
@ -120,17 +120,17 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
self.br.add_flow(priority=2, dl_src="ca:fe:de:ad:be:ef",
|
self.br.add_flow(priority=2, dl_src="ca:fe:de:ad:be:ef",
|
||||||
actions="strip_vlan,output:0")
|
actions="strip_vlan,output:0")
|
||||||
self.br.add_flow(priority=1, actions="normal")
|
self.br.add_flow(priority=1, actions="normal")
|
||||||
self.br.add_flow(priority=2, actions="drop")
|
self.br.add_flow(priority=2, actions="drop")
|
||||||
self.br.add_flow(priority=2, in_port=ofport, actions="drop")
|
self.br.add_flow(priority=2, in_port=ofport, actions="drop")
|
||||||
|
|
||||||
self.br.add_flow(priority=4, in_port=ofport, dl_vlan=vid,
|
self.br.add_flow(priority=4, in_port=ofport, dl_vlan=vid,
|
||||||
actions="strip_vlan,set_tunnel:%s,normal" %
|
actions="strip_vlan,set_tunnel:%s,normal" %
|
||||||
(lsw_id))
|
(lsw_id))
|
||||||
self.br.add_flow(priority=3, tun_id=lsw_id,
|
self.br.add_flow(priority=3, tun_id=lsw_id,
|
||||||
actions="mod_vlan_vid:%s,output:%s" %
|
actions="mod_vlan_vid:%s,output:%s" %
|
||||||
(vid, ofport))
|
(vid, ofport))
|
||||||
self.mox.VerifyAll()
|
self.mox.VerifyAll()
|
||||||
|
|
||||||
def test_get_port_ofport(self):
|
def test_get_port_ofport(self):
|
||||||
@ -138,7 +138,7 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
ofport = "6"
|
ofport = "6"
|
||||||
utils.execute(["ovs-vsctl", self.TO, "get",
|
utils.execute(["ovs-vsctl", self.TO, "get",
|
||||||
"Interface", pname, "ofport"],
|
"Interface", pname, "ofport"],
|
||||||
root_helper=self.root_helper).AndReturn(ofport)
|
root_helper=self.root_helper).AndReturn(ofport)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
self.assertEqual(self.br.get_port_ofport(pname), ofport)
|
self.assertEqual(self.br.get_port_ofport(pname), ofport)
|
||||||
@ -146,8 +146,8 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
|
|
||||||
def test_count_flows(self):
|
def test_count_flows(self):
|
||||||
utils.execute(["ovs-ofctl", "dump-flows", self.BR_NAME],
|
utils.execute(["ovs-ofctl", "dump-flows", self.BR_NAME],
|
||||||
root_helper=self.root_helper).\
|
root_helper=self.root_helper).AndReturn('ignore'
|
||||||
AndReturn("ignore\nflow-1\n")
|
'\nflow-1\n')
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
# counts the number of flows as total lines of output - 2
|
# counts the number of flows as total lines of output - 2
|
||||||
@ -159,11 +159,11 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
lsw_id = 40
|
lsw_id = 40
|
||||||
vid = 39
|
vid = 39
|
||||||
utils.execute(["ovs-ofctl", "del-flows", self.BR_NAME,
|
utils.execute(["ovs-ofctl", "del-flows", self.BR_NAME,
|
||||||
"in_port=" + ofport], root_helper=self.root_helper)
|
"in_port=" + ofport], root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-ofctl", "del-flows", self.BR_NAME,
|
utils.execute(["ovs-ofctl", "del-flows", self.BR_NAME,
|
||||||
"tun_id=%s" % lsw_id], root_helper=self.root_helper)
|
"tun_id=%s" % lsw_id], root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-ofctl", "del-flows", self.BR_NAME,
|
utils.execute(["ovs-ofctl", "del-flows", self.BR_NAME,
|
||||||
"dl_vlan=%s" % vid], root_helper=self.root_helper)
|
"dl_vlan=%s" % vid], root_helper=self.root_helper)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
self.br.delete_flows(in_port=ofport)
|
self.br.delete_flows(in_port=ofport)
|
||||||
@ -177,20 +177,20 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
ofport = "6"
|
ofport = "6"
|
||||||
|
|
||||||
utils.execute(["ovs-vsctl", self.TO, "add-port",
|
utils.execute(["ovs-vsctl", self.TO, "add-port",
|
||||||
self.BR_NAME, pname], root_helper=self.root_helper)
|
self.BR_NAME, pname], root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
|
utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
|
||||||
pname, "type=gre"], root_helper=self.root_helper)
|
pname, "type=gre"], root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
|
utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
|
||||||
pname, "options:remote_ip=" + ip],
|
pname, "options:remote_ip=" + ip],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
|
utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
|
||||||
pname, "options:in_key=flow"],
|
pname, "options:in_key=flow"],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
|
utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
|
||||||
pname, "options:out_key=flow"],
|
pname, "options:out_key=flow"],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-vsctl", self.TO, "get",
|
utils.execute(["ovs-vsctl", self.TO, "get",
|
||||||
"Interface", pname, "ofport"],
|
"Interface", pname, "ofport"],
|
||||||
root_helper=self.root_helper).AndReturn(ofport)
|
root_helper=self.root_helper).AndReturn(ofport)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
@ -203,14 +203,14 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
ofport = "6"
|
ofport = "6"
|
||||||
|
|
||||||
utils.execute(["ovs-vsctl", self.TO, "add-port",
|
utils.execute(["ovs-vsctl", self.TO, "add-port",
|
||||||
self.BR_NAME, pname], root_helper=self.root_helper)
|
self.BR_NAME, pname], root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
|
utils.execute(["ovs-vsctl", self.TO, "set", "Interface",
|
||||||
pname, "type=patch"], root_helper=self.root_helper)
|
pname, "type=patch"], root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-vsctl", self.TO, "set",
|
utils.execute(["ovs-vsctl", self.TO, "set",
|
||||||
"Interface", pname, "options:peer=" + peer],
|
"Interface", pname, "options:peer=" + peer],
|
||||||
root_helper=self.root_helper)
|
root_helper=self.root_helper)
|
||||||
utils.execute(["ovs-vsctl", self.TO, "get",
|
utils.execute(["ovs-vsctl", self.TO, "get",
|
||||||
"Interface", pname, "ofport"],
|
"Interface", pname, "ofport"],
|
||||||
root_helper=self.root_helper).AndReturn(ofport)
|
root_helper=self.root_helper).AndReturn(ofport)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
@ -234,14 +234,14 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
% (vif_id, mac))
|
% (vif_id, mac))
|
||||||
|
|
||||||
utils.execute(["ovs-vsctl", self.TO, "get",
|
utils.execute(["ovs-vsctl", self.TO, "get",
|
||||||
"Interface", pname, "external_ids"],
|
"Interface", pname, "external_ids"],
|
||||||
root_helper=self.root_helper).AndReturn(external_ids)
|
root_helper=self.root_helper).AndReturn(external_ids)
|
||||||
utils.execute(["ovs-vsctl", self.TO, "get",
|
utils.execute(["ovs-vsctl", self.TO, "get",
|
||||||
"Interface", pname, "ofport"],
|
"Interface", pname, "ofport"],
|
||||||
root_helper=self.root_helper).AndReturn(ofport)
|
root_helper=self.root_helper).AndReturn(ofport)
|
||||||
if is_xen:
|
if is_xen:
|
||||||
utils.execute(["xe", "vif-param-get", "param-name=other-config",
|
utils.execute(["xe", "vif-param-get", "param-name=other-config",
|
||||||
"param-key=nicira-iface-id", "uuid=" + vif_id],
|
"param-key=nicira-iface-id", "uuid=" + vif_id],
|
||||||
root_helper=self.root_helper).AndReturn(vif_id)
|
root_helper=self.root_helper).AndReturn(vif_id)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ class OVS_Lib_Test(unittest.TestCase):
|
|||||||
def test_clear_db_attribute(self):
|
def test_clear_db_attribute(self):
|
||||||
pname = "tap77"
|
pname = "tap77"
|
||||||
utils.execute(["ovs-vsctl", self.TO, "clear", "Port",
|
utils.execute(["ovs-vsctl", self.TO, "clear", "Port",
|
||||||
pname, "tag"], root_helper=self.root_helper)
|
pname, "tag"], root_helper=self.root_helper)
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
self.br.clear_db_attribute("Port", pname, "tag")
|
self.br.clear_db_attribute("Port", pname, "tag")
|
||||||
self.mox.VerifyAll()
|
self.mox.VerifyAll()
|
||||||
|
@ -38,19 +38,19 @@ class SetupTest(unittest.TestCase):
|
|||||||
with open(self.mailmap, 'w') as mm_fh:
|
with open(self.mailmap, 'w') as mm_fh:
|
||||||
mm_fh.write("Foo Bar <email@foo.com> Foo Bar <email@bar.com>\n")
|
mm_fh.write("Foo Bar <email@foo.com> Foo Bar <email@bar.com>\n")
|
||||||
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
||||||
parse_mailmap(self.mailmap))
|
parse_mailmap(self.mailmap))
|
||||||
|
|
||||||
def test_mailmap_with_firstname(self):
|
def test_mailmap_with_firstname(self):
|
||||||
with open(self.mailmap, 'w') as mm_fh:
|
with open(self.mailmap, 'w') as mm_fh:
|
||||||
mm_fh.write("Foo <email@foo.com> Foo <email@bar.com>\n")
|
mm_fh.write("Foo <email@foo.com> Foo <email@bar.com>\n")
|
||||||
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
||||||
parse_mailmap(self.mailmap))
|
parse_mailmap(self.mailmap))
|
||||||
|
|
||||||
def test_mailmap_with_noname(self):
|
def test_mailmap_with_noname(self):
|
||||||
with open(self.mailmap, 'w') as mm_fh:
|
with open(self.mailmap, 'w') as mm_fh:
|
||||||
mm_fh.write("<email@foo.com> <email@bar.com>\n")
|
mm_fh.write("<email@foo.com> <email@bar.com>\n")
|
||||||
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
||||||
parse_mailmap(self.mailmap))
|
parse_mailmap(self.mailmap))
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
if os.path.exists(self.mailmap):
|
if os.path.exists(self.mailmap):
|
||||||
|
@ -485,8 +485,8 @@ class RequestDeserializer(object):
|
|||||||
}
|
}
|
||||||
self.body_deserializers.update(body_deserializers or {})
|
self.body_deserializers.update(body_deserializers or {})
|
||||||
|
|
||||||
self.headers_deserializer = headers_deserializer or \
|
self.headers_deserializer = (headers_deserializer or
|
||||||
RequestHeadersDeserializer()
|
RequestHeadersDeserializer())
|
||||||
|
|
||||||
def deserialize(self, request):
|
def deserialize(self, request):
|
||||||
"""Extract necessary pieces of the request.
|
"""Extract necessary pieces of the request.
|
||||||
@ -767,7 +767,7 @@ class Resource(Application):
|
|||||||
"""WSGI method that controls (de)serialization and method dispatch."""
|
"""WSGI method that controls (de)serialization and method dispatch."""
|
||||||
|
|
||||||
LOG.info("%(method)s %(url)s" % {"method": request.method,
|
LOG.info("%(method)s %(url)s" % {"method": request.method,
|
||||||
"url": request.url})
|
"url": request.url})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
action, args, accept = self.deserializer.deserialize(request)
|
action, args, accept = self.deserializer.deserialize(request)
|
||||||
|
@ -61,15 +61,15 @@ def run_command(cmd, redirect_output=True, check_exit_code=True):
|
|||||||
HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'],
|
HAS_EASY_INSTALL = bool(run_command(['which', 'easy_install'],
|
||||||
check_exit_code=False).strip())
|
check_exit_code=False).strip())
|
||||||
HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'],
|
HAS_VIRTUALENV = bool(run_command(['which', 'virtualenv'],
|
||||||
check_exit_code=False).strip())
|
check_exit_code=False).strip())
|
||||||
|
|
||||||
|
|
||||||
def check_dependencies():
|
def check_dependencies():
|
||||||
"""Make sure virtualenv is in the path."""
|
"""Make sure virtualenv is in the path."""
|
||||||
|
|
||||||
if not HAS_VIRTUALENV:
|
if not HAS_VIRTUALENV:
|
||||||
raise Exception('Virtualenv not found. ' +
|
raise Exception('Virtualenv not found. '
|
||||||
'Try installing python-virtualenv')
|
'Try installing python-virtualenv')
|
||||||
print 'done.'
|
print 'done.'
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user