Beispiel #1
0
        def new_function(self, request, *args, **kwargs):
            """
            Wrapped function
            """
            # Log the call
            log_entry = Log()
            log_entry.source = 'API'
            log_entry.module = f.__module__
            log_entry.method = f.__name__
            log_entry.method_args = list(args)
            log_entry.method_kwargs = kwargs
            log_entry.time = time.time()
            log_entry.user = getattr(request, 'client').user if hasattr(
                request, 'client') else None
            log_entry.metadata = {
                'meta':
                dict((str(key), str(value))
                     for key, value in request.META.iteritems()),
                'request':
                dict((str(key), str(value))
                     for key, value in request.REQUEST.iteritems()),
                'cookies':
                dict((str(key), str(value))
                     for key, value in request.COOKIES.iteritems())
            }
            log_entry.save()

            # Call the function
            return f(self, request, *args, **kwargs)
Beispiel #2
0
def _log(task, kwargs, storagedriver_id):
    log = Log()
    log.source = 'VOLUMEDRIVER_EVENT'
    log.module = task.__class__.__module__
    log.method = task.__class__.__name__
    log.method_kwargs = kwargs
    log.time = time.time()
    log.storagedriver = StorageDriverList.get_by_storagedriver_id(storagedriver_id)
    log.save()
Beispiel #3
0
def _log(task, kwargs, storagedriver_id):
    log = Log()
    log.source = 'VOLUMEDRIVER_EVENT'
    log.module = task.__class__.__module__
    log.method = task.__class__.__name__
    log.method_kwargs = kwargs
    log.time = time.time()
    log.storagedriver = StorageDriverList.get_by_storagedriver_id(
        storagedriver_id)
    log.save()
Beispiel #4
0
        def new_function(self, request, *args, **kwargs):
            """
            Wrapped function
            """
            # Log the call
            log_entry = Log()
            log_entry.source = 'API'
            log_entry.module = f.__module__
            log_entry.method = f.__name__
            log_entry.method_args = list(args)
            log_entry.method_kwargs = kwargs
            log_entry.time = time.time()
            log_entry.user = getattr(request, 'client').user if hasattr(request, 'client') else None
            log_entry.metadata = {'meta': dict((str(key), str(value)) for key, value in request.META.iteritems()),
                                  'request': dict((str(key), str(value)) for key, value in request.REQUEST.iteritems()),
                                  'cookies': dict((str(key), str(value)) for key, value in request.COOKIES.iteritems())}
            log_entry.save()

            # Call the function
            return f(self, request, *args, **kwargs)
Beispiel #5
0
        def new_function(*args, **kwargs):
            """
            Wrapped function
            """
            # Log the call
            log_entry = Log()
            log_entry.source = event_type
            log_entry.module = f.__module__
            log_entry.method = f.__name__
            log_entry.method_args = list(args)
            log_entry.method_kwargs = kwargs
            log_entry.time = time.time()
            if event_type == 'VOLUMEDRIVER_TASK':
                try:
                    log_entry.storagedriver = StorageDriverList.get_by_storagedriver_id(kwargs['storagedriver_id'])
                    log_entry.save()
                except ObjectNotFoundException:
                    pass
            else:
                log_entry.save()

            # Call the function
            return f(*args, **kwargs)
Beispiel #6
0
        def new_function(*args, **kwargs):
            """
            Wrapped function
            """
            # Log the call
            log_entry = Log()
            log_entry.source = event_type
            log_entry.module = f.__module__
            log_entry.method = f.__name__
            log_entry.method_args = list(args)
            log_entry.method_kwargs = kwargs
            log_entry.time = time.time()
            if event_type == 'VOLUMEDRIVER_TASK':
                try:
                    log_entry.storagedriver = StorageDriverList.get_by_storagedriver_id(kwargs['storagedriver_id'])
                    log_entry.save()
                except ObjectNotFoundException:
                    pass
            else:
                log_entry.save()

            # Call the function
            return f(*args, **kwargs)