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):
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
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)
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
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)
"""
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.
"""
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.
"""
'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.
'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.
"""
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.
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.