Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Add common logging and notification.
Browse files Browse the repository at this point in the history
This code is migrated from Nova, and will soon replace it.

Change-Id: I2dacac3ef251d419c7049154f6aaf0c18fdb9bb4
  • Loading branch information
Andrew Bogott committed Jun 25, 2012
1 parent 2db4e68 commit 16916b6
Show file tree
Hide file tree
Showing 13 changed files with 1,419 additions and 0 deletions.
18 changes: 18 additions & 0 deletions openstack/common/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Exceptions common to OpenStack projects
"""

import itertools
import logging


Expand Down Expand Up @@ -145,3 +146,20 @@ class MalformedRequestBody(OpenstackException):

class InvalidContentType(OpenstackException):
message = "Invalid content type %(content_type)s"


def get_context_from_function_and_args(function, args, kwargs):
"""Find an arg of type RequestContext and return it.
This is useful in a couple of decorators where we don't
know much about the function we're wrapping.
"""

# import here to avoid circularity:
from openstack.common import context

for arg in itertools.chain(kwargs.values(), args):
if isinstance(arg, context.RequestContext):
return arg

return None
Loading

0 comments on commit 16916b6

Please sign in to comment.