Remove unused method in api utils

Closes-Bug: #1651247

Change-Id: I4d3bb558afdcc2283864cd177279779a24e40aa4
This commit is contained in:
Feng Shengqin 2016-12-20 18:45:26 +08:00 committed by feng.shengqin
parent 676a554205
commit 67f6d1c6d8

View File

@ -18,7 +18,6 @@ from oslo_utils import uuidutils
import pecan
import wsme
from zun.common import exception
from zun.common.i18n import _
import zun.conf
from zun import objects
@ -86,34 +85,6 @@ def get_resource(resource, resource_ident):
return resource.get_by_name(pecan.request.context, resource_ident)
def get_openstack_resource(manager, resource_ident, resource_type):
"""Get the openstack resource from the uuid or logical name.
:param manager: the resource manager class.
:param resource_ident: the UUID or logical name of the resource.
:param resource_type: the type of the resource
:returns: The openstack resource.
:raises: ResourceNotFound if the openstack resource is not exist.
Conflict if multi openstack resources have same name.
"""
if uuidutils.is_uuid_like(resource_ident):
resource_data = manager.get(resource_ident)
else:
filters = {'name': resource_ident}
matches = list(manager.list(filters=filters))
if len(matches) == 0:
raise exception.ResourceNotFound(name=resource_type,
id=resource_ident)
if len(matches) > 1:
msg = ("Multiple '%s' exist with same name '%s'. "
"Please use the resource id instead." %
(resource_type, resource_ident))
raise exception.Conflict(msg)
resource_data = matches[0]
return resource_data
def _do_enforce_content_types(pecan_req, valid_content_types):
"""Content type enforcement