Merge "use attribute functions/operations from neutron-lib"
This commit is contained in:
commit
4f8bef7356
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
from neutron.api.v2 import attributes
|
from neutron.api.v2 import attributes
|
||||||
|
from neutron_lib.api import attributes as lib_attrs
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
import webob.exc
|
import webob.exc
|
||||||
@ -27,15 +28,16 @@ def _fixup_res_dict(context, attr_name, res_dict, check_allow_post=True):
|
|||||||
if cfg.CONF.api_replay_mode and 'id' not in res_dict:
|
if cfg.CONF.api_replay_mode and 'id' not in res_dict:
|
||||||
res_dict['id'] = uuidutils.generate_uuid()
|
res_dict['id'] = uuidutils.generate_uuid()
|
||||||
attr_info = attributes.RESOURCE_ATTRIBUTE_MAP[attr_name]
|
attr_info = attributes.RESOURCE_ATTRIBUTE_MAP[attr_name]
|
||||||
|
attr_ops = lib_attrs.AttributeInfo(attr_info)
|
||||||
try:
|
try:
|
||||||
attributes.populate_tenant_id(context, res_dict, attr_info, True)
|
attr_ops.populate_project_id(context, res_dict, True)
|
||||||
attributes.verify_attributes(res_dict, attr_info)
|
attributes.populate_project_info(attr_info)
|
||||||
|
attr_ops.verify_attributes(res_dict)
|
||||||
except webob.exc.HTTPBadRequest as e:
|
except webob.exc.HTTPBadRequest as e:
|
||||||
# convert webob exception into ValueError as these functions are
|
# convert webob exception into ValueError as these functions are
|
||||||
# for internal use. webob exception doesn't make sense.
|
# for internal use. webob exception doesn't make sense.
|
||||||
raise ValueError(e.detail)
|
raise ValueError(e.detail)
|
||||||
|
|
||||||
attributes.fill_default_value(attr_info, res_dict,
|
attr_ops.fill_post_defaults(res_dict, check_allow_post=check_allow_post)
|
||||||
check_allow_post=check_allow_post)
|
attr_ops.convert_values(res_dict)
|
||||||
attributes.convert_value(attr_info, res_dict)
|
|
||||||
return res_dict
|
return res_dict
|
||||||
|
Loading…
Reference in New Issue
Block a user