Change port/net create calls to take an additional kwargs param
This is to allow data extensions to flow through the middleware to the actual plugin. Change-Id: Ief95b806504e10dd05ce7e941437628ac11a215b
This commit is contained in:
@@ -61,6 +61,12 @@ class QuantumController(wsgi.Controller):
|
||||
raise exc.HTTPBadRequest(msg)
|
||||
results[param_name] = param_value or param.get('default-value')
|
||||
|
||||
# There may be other parameters (data extensions), so we
|
||||
# should include those in the results dict as well.
|
||||
for key in data.keys():
|
||||
if key not in params:
|
||||
results[key] = data[key]
|
||||
|
||||
return results
|
||||
|
||||
def _build_response(self, req, res_data, status_code=200):
|
||||
|
||||
@@ -95,16 +95,22 @@ class Controller(common.QuantumController):
|
||||
|
||||
def create(self, request, tenant_id):
|
||||
""" Creates a new network for a given tenant """
|
||||
#look for network name in request
|
||||
try:
|
||||
request_params = \
|
||||
self._parse_request_params(request,
|
||||
self._network_ops_param_list)
|
||||
except exc.HTTPError as e:
|
||||
return faults.Fault(e)
|
||||
# NOTE(bgh): We're currently passing both request_params['name'] and
|
||||
# the entire request_params dict because their may be pieces of
|
||||
# information (data extensions) inside the request params that the
|
||||
# actual plugin will want to parse. We could just pass only
|
||||
# request_params but that would mean all the plugins would need to
|
||||
# change.
|
||||
network = self._plugin.\
|
||||
create_network(tenant_id,
|
||||
request_params['name'])
|
||||
request_params['name'],
|
||||
**request_params)
|
||||
builder = networks_view.get_view_builder(request)
|
||||
result = builder.build(network)['network']
|
||||
# Wsgi middleware allows us to build the response
|
||||
|
||||
@@ -104,7 +104,6 @@ class Controller(common.QuantumController):
|
||||
|
||||
def create(self, request, tenant_id, network_id):
|
||||
""" Creates a new port for a given network """
|
||||
#look for port state in request
|
||||
try:
|
||||
request_params = \
|
||||
self._parse_request_params(request, self._port_ops_param_list)
|
||||
@@ -113,7 +112,8 @@ class Controller(common.QuantumController):
|
||||
try:
|
||||
port = self._plugin.create_port(tenant_id,
|
||||
network_id,
|
||||
request_params['state'])
|
||||
request_params['state'],
|
||||
**request_params)
|
||||
builder = ports_view.get_view_builder(request)
|
||||
result = builder.build(port)['port']
|
||||
# Wsgi middleware allows us to build the response
|
||||
@@ -128,7 +128,6 @@ class Controller(common.QuantumController):
|
||||
|
||||
def update(self, request, tenant_id, network_id, id):
|
||||
""" Updates the state of a port for a given network """
|
||||
#look for port state in request
|
||||
try:
|
||||
request_params = \
|
||||
self._parse_request_params(request, self._port_ops_param_list)
|
||||
|
||||
@@ -42,7 +42,7 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("get_all_networks() called\n")
|
||||
|
||||
def create_network(self, tenant_id, net_name):
|
||||
def create_network(self, tenant_id, net_name, **kwargs):
|
||||
"""
|
||||
Creates a new Virtual Network, and assigns it
|
||||
a symbolic name.
|
||||
@@ -77,7 +77,7 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("get_all_ports() called\n")
|
||||
|
||||
def create_port(self, tenant_id, net_id):
|
||||
def create_port(self, tenant_id, net_id, **kwargs):
|
||||
"""
|
||||
Creates a port on the specified Virtual Network.
|
||||
"""
|
||||
@@ -195,7 +195,7 @@ class FakePlugin(object):
|
||||
'net-name': net.name,
|
||||
'net-ports': ports}
|
||||
|
||||
def create_network(self, tenant_id, net_name):
|
||||
def create_network(self, tenant_id, net_name, **kwargs):
|
||||
"""
|
||||
Creates a new Virtual Network, and assigns it
|
||||
a symbolic name.
|
||||
@@ -256,7 +256,7 @@ class FakePlugin(object):
|
||||
'attachment': port.interface_id,
|
||||
'port-state': port.state}
|
||||
|
||||
def create_port(self, tenant_id, net_id, port_state=None):
|
||||
def create_port(self, tenant_id, net_id, port_state=None, **kwargs):
|
||||
"""
|
||||
Creates a port on the specified Virtual Network.
|
||||
"""
|
||||
|
||||
@@ -54,7 +54,7 @@ class QuantumPluginBase(object):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def create_network(self, tenant_id, net_name):
|
||||
def create_network(self, tenant_id, net_name, **kwargs):
|
||||
"""
|
||||
Creates a new Virtual Network, and assigns it
|
||||
a symbolic name.
|
||||
@@ -139,7 +139,7 @@ class QuantumPluginBase(object):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def create_port(self, tenant_id, net_id, port_state=None):
|
||||
def create_port(self, tenant_id, net_id, port_state=None, **kwargs):
|
||||
"""
|
||||
Creates a port on the specified Virtual Network.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user