

def createReservation(self, function_name, **kwargs):
    if (not isinstance(function_name, str)):
        for key in self.functions:
            if (self.functions[key]['function'] == function_name):
                function_name = key
                break
    if (function_name not in self.functions):
        raise Exception(('Function %s does not exist.' % function_name))
    function = self.functions[function_name]
    filtered_kwargs = {
        
    }
    for key in function['required_arguments']:
        if (key in kwargs):
            filtered_kwargs[key] = kwargs[key]
        else:
            raise Exception(("Required parameter '%s' not found. Required parameters are %s. Optional parameters are %s." % (key, function['required_arguments'], function['optional_arguments'])))
    for key in function['optional_arguments']:
        if (uuid in kwargs):
            filtered_kwargs[key] = kwargs[key]
    if (function['interval'] > 0):
        reserved_arguments = {
            
        }
        reserved_arguments['reservation_function_name'] = function_name
        reserved_arguments['reservation_created'] = sdb_now(offset=self.time_offset)
        reserved_arguments['reservation_next_request'] = reserved_arguments['reservation_created']
        reserved_arguments['reservation_error'] = '0'
        arguments = {
            
        }
        arguments.update(reserved_arguments)
        arguments.update(filtered_kwargs)
        uuid = uuid4().hex
        LOGGER.debug(('Creating reservation on SimpleDB for %s, %s.' % (function_name, uuid)))
        a = self.sdb.putAttributes(self.aws_sdb_reservation_domain, uuid, arguments)
        a.addCallback(self._createReservationCallback, function_name, uuid)
        a.addErrback(self._createReservationErrback, function_name, uuid)
        if (('call_immediately' in kwargs) and (not evaluateBoolean(kwargs['call_immediately']))):
            d = DeferredList([a], consumeErrors=True)
        else:
            LOGGER.debug(('Calling %s immediately with arguments:\n%s' % (function_name, PRETTYPRINTER.pformat(filtered_kwargs))))
            self.active_jobs[uuid] = True
            b = self.callExposedFunction(function['function'], filtered_kwargs, function_name, uuid=uuid)
            d = DeferredList([a, b], consumeErrors=True)
        d.addCallback(self._createReservationCallback2, function_name, uuid)
        d.addErrback(self._createReservationErrback2, function_name, uuid)
        return d
    else:
        LOGGER.debug(('Calling %s with arguments:\n%s' % (function_name, PRETTYPRINTER.pformat(filtered_kwargs))))
        d = self.callExposedFunction(function['function'], filtered_kwargs, function_name)
        return d

dataset/ETHPy150Open wehriam/awspider/awspider/servers/interface.py InterfaceServer.createReservation/VarMisuse@172/264 `key`->`uuid`