FIX: nfv event list failed with internal server error

In case of invalid id of resource-id, event list command failed
with inappropriate error(i.e. internal server error). Fixing this issue
with propper error handling.

Change-Id: I0e23da2d63bf3bcedfea78e6e88575cb7a7adfeb
Closes-Bug:#1834178
This commit is contained in:
dharmendra 2019-06-26 07:22:05 +00:00 committed by dharmendra kushwaha
parent 047f3a7409
commit ecd78c6048
2 changed files with 14 additions and 4 deletions

View File

@ -16,6 +16,7 @@
from sqlalchemy.orm import exc as orm_exc
from oslo_db import exception
from oslo_log import log as logging
from tacker.common import log
@ -82,7 +83,12 @@ class CommonServicesPluginDb(common_services.CommonServicesPluginBase,
@log.log
def get_events(self, context, filters=None, fields=None, sorts=None,
limit=None, marker_obj=None, page_reverse=False):
try:
return self._get_collection(context, common_services_db.Event,
self._make_event_dict,
filters, fields, sorts, limit,
marker_obj, page_reverse)
except exception.DBError as e:
LOG.error("Failed to get event: %s", e.message)
msg = "Id should be in UUID v4 format"
raise common_services.InvalidFormat(error=msg)

View File

@ -46,6 +46,10 @@ class ParamYAMLInputMissing(exceptions.InvalidInput):
message = _("Parameter YAML input missing")
class InvalidFormat(exceptions.InvalidInput):
message = _("Invalid format. '%(error)s'")
RESOURCE_ATTRIBUTE_MAP = {
'events': {