Extend utils create methods to accept check_allow_post

Just like create_port, these methods should also accept the parameter
that is used to control whether to validate that the request body
contains attributes not allowed during POST requests.

Change-Id: Ibbdb7960342dbd298e81b5ae17f50c1a279a2284
This commit is contained in:
Armando Migliaccio 2016-06-13 03:35:05 -07:00
parent 260ce9c161
commit 5089f41d50

View File

@ -143,15 +143,17 @@ def _fixup_res_dict(context, attr_name, res_dict, check_allow_post=True):
return res_dict return res_dict
def create_network(core_plugin, context, net): def create_network(core_plugin, context, net, check_allow_post=True):
net_data = _fixup_res_dict(context, attributes.NETWORKS, net_data = _fixup_res_dict(context, attributes.NETWORKS,
net.get('network', {})) net.get('network', {}),
check_allow_post=check_allow_post)
return core_plugin.create_network(context, {'network': net_data}) return core_plugin.create_network(context, {'network': net_data})
def create_subnet(core_plugin, context, subnet): def create_subnet(core_plugin, context, subnet, check_allow_post=True):
subnet_data = _fixup_res_dict(context, attributes.SUBNETS, subnet_data = _fixup_res_dict(context, attributes.SUBNETS,
subnet.get('subnet', {})) subnet.get('subnet', {}),
check_allow_post=check_allow_post)
return core_plugin.create_subnet(context, {'subnet': subnet_data}) return core_plugin.create_subnet(context, {'subnet': subnet_data})