Merge "Remove unused method in api utils"
This commit is contained in:
commit
3ecb80083f
@ -18,7 +18,6 @@ from oslo_utils import uuidutils
|
|||||||
import pecan
|
import pecan
|
||||||
import wsme
|
import wsme
|
||||||
|
|
||||||
from zun.common import exception
|
|
||||||
from zun.common.i18n import _
|
from zun.common.i18n import _
|
||||||
import zun.conf
|
import zun.conf
|
||||||
from zun import objects
|
from zun import objects
|
||||||
@ -86,34 +85,6 @@ def get_resource(resource, resource_ident):
|
|||||||
return resource.get_by_name(pecan.request.context, 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):
|
def _do_enforce_content_types(pecan_req, valid_content_types):
|
||||||
"""Content type enforcement
|
"""Content type enforcement
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user