use attribute functions/operations from neutron-lib

neutron-lib now contains the functionality from neutron's attributes
module. This patch moves the local references over to neturon-lib's
implementation.

Change-Id: I39c26b85f914f8310f2090c39a0a435300de995a
This commit is contained in:
Boden R 2017-05-25 14:11:02 -06:00
parent 65f779ea1d
commit b4455605f4

View File

@ -15,6 +15,7 @@
from neutron.api.v2 import attributes
from neutron_lib.api import attributes as lib_attrs
from oslo_config import cfg
from oslo_utils import uuidutils
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:
res_dict['id'] = uuidutils.generate_uuid()
attr_info = attributes.RESOURCE_ATTRIBUTE_MAP[attr_name]
attr_ops = lib_attrs.AttributeInfo(attr_info)
try:
attributes.populate_tenant_id(context, res_dict, attr_info, True)
attributes.verify_attributes(res_dict, attr_info)
attr_ops.populate_project_id(context, res_dict, True)
attributes.populate_project_info(attr_info)
attr_ops.verify_attributes(res_dict)
except webob.exc.HTTPBadRequest as e:
# convert webob exception into ValueError as these functions are
# for internal use. webob exception doesn't make sense.
raise ValueError(e.detail)
attributes.fill_default_value(attr_info, res_dict,
check_allow_post=check_allow_post)
attributes.convert_value(attr_info, res_dict)
attr_ops.fill_post_defaults(res_dict, check_allow_post=check_allow_post)
attr_ops.convert_values(res_dict)
return res_dict