Merge "Additional logging for placement API"
This commit is contained in:
@@ -14,14 +14,18 @@
|
|||||||
import collections
|
import collections
|
||||||
|
|
||||||
import jsonschema
|
import jsonschema
|
||||||
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from nova.api.openstack.placement import util
|
from nova.api.openstack.placement import util
|
||||||
from nova import exception
|
from nova import exception
|
||||||
|
from nova.i18n import _LE
|
||||||
from nova import objects
|
from nova import objects
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
ALLOCATION_SCHEMA = {
|
ALLOCATION_SCHEMA = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -248,16 +252,20 @@ def set_allocations(req):
|
|||||||
allocation_objects.append(allocation)
|
allocation_objects.append(allocation)
|
||||||
|
|
||||||
allocations = objects.AllocationList(context, objects=allocation_objects)
|
allocations = objects.AllocationList(context, objects=allocation_objects)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
allocations.create_all()
|
allocations.create_all()
|
||||||
|
LOG.debug("Successfully wrote allocations %s", allocations)
|
||||||
# InvalidInventory is a parent for several exceptions that
|
# InvalidInventory is a parent for several exceptions that
|
||||||
# indicate either that Inventory is not present, or that
|
# indicate either that Inventory is not present, or that
|
||||||
# capacity limits have been exceeded.
|
# capacity limits have been exceeded.
|
||||||
except exception.InvalidInventory as exc:
|
except exception.InvalidInventory as exc:
|
||||||
|
LOG.exception(_LE("Bad inventory"))
|
||||||
raise webob.exc.HTTPConflict(
|
raise webob.exc.HTTPConflict(
|
||||||
'Unable to allocate inventory: %s' % exc,
|
'Unable to allocate inventory: %s' % exc,
|
||||||
json_formatter=util.json_error_formatter)
|
json_formatter=util.json_error_formatter)
|
||||||
except exception.ConcurrentUpdateDetected as exc:
|
except exception.ConcurrentUpdateDetected as exc:
|
||||||
|
LOG.exception(_LE("Concurrent Update"))
|
||||||
raise webob.exc.HTTPConflict(
|
raise webob.exc.HTTPConflict(
|
||||||
'Inventory changed while attempting to allocate: %s' % exc,
|
'Inventory changed while attempting to allocate: %s' % exc,
|
||||||
json_formatter=util.json_error_formatter)
|
json_formatter=util.json_error_formatter)
|
||||||
@@ -279,6 +287,7 @@ def delete_allocations(req):
|
|||||||
"No allocations for consumer '%s'" % consumer_uuid,
|
"No allocations for consumer '%s'" % consumer_uuid,
|
||||||
json_formatter=util.json_error_formatter)
|
json_formatter=util.json_error_formatter)
|
||||||
allocations.delete_all()
|
allocations.delete_all()
|
||||||
|
LOG.debug("Successfully deleted allocations %s", allocations)
|
||||||
|
|
||||||
req.response.status = 204
|
req.response.status = 204
|
||||||
req.response.content_type = None
|
req.response.content_type = None
|
||||||
|
@@ -871,6 +871,10 @@ class AllocationList(base.ObjectListBase, base.NovaObject):
|
|||||||
def delete_all(self):
|
def delete_all(self):
|
||||||
self._delete_allocations(self._context, self.objects)
|
self._delete_allocations(self._context, self.objects)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
strings = [repr(x) for x in self.objects]
|
||||||
|
return "AllocationList[" + ", ".join(strings) + "]"
|
||||||
|
|
||||||
|
|
||||||
@base.NovaObjectRegistry.register
|
@base.NovaObjectRegistry.register
|
||||||
class Usage(base.NovaObject):
|
class Usage(base.NovaObject):
|
||||||
@@ -930,3 +934,7 @@ class UsageList(base.ObjectListBase, base.NovaObject):
|
|||||||
def get_all_by_resource_provider_uuid(cls, context, rp_uuid):
|
def get_all_by_resource_provider_uuid(cls, context, rp_uuid):
|
||||||
usage_list = cls._get_all_by_resource_provider_uuid(context, rp_uuid)
|
usage_list = cls._get_all_by_resource_provider_uuid(context, rp_uuid)
|
||||||
return base.obj_make_list(context, cls(context), Usage, usage_list)
|
return base.obj_make_list(context, cls(context), Usage, usage_list)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
strings = [repr(x) for x in self.objects]
|
||||||
|
return "UsageList[" + ", ".join(strings) + "]"
|
||||||
|
Reference in New Issue
Block a user