'Executes the command'

def __call__(self, req, body):

    if (not isinstance(body, list)):
        msg = _('Request    must    be    a    list    of    commands')
        raise exc.HTTPBadRequest(explanation=msg)
    def validate(cmd):
        if (not isinstance(cmd, dict)):
            msg = (_('Bad    Command:    %s') % str(cmd))
            raise exc.HTTPBadRequest(explanation=msg)
        (command, kwargs) = (cmd.get('command'), cmd.get('kwargs'))
        if ((not command) or (not isinstance(command, six.string_types)) or (kwargs and (not isinstance(kwargs, dict)))):
            msg = (_('Wrong    command    structure:    %s') % str(cmd))
            raise exc.HTTPBadRequest(explanation=msg)
        method = self._registered.get(command)
        if (not method):
            raise exc.HTTPNotFound(explanation=_('Command    not    found'))
        return True
    commands = filter(validate, body)
    results = []
    for cmd in commands:
        (command, kwargs) = (cmd['command'], cmd.get('kwargs', {}))
        method = self._registered[command]
        try:
            result = method(req.context, **kwargs)
        except Exception as e:
            if self.raise_exc:
                raise
            (cls, val) = (e.__class__, encodeutils.exception_to_unicode(e))
            msg = (_LE('RPC    Call    Error:    %(val)s\n%(tb)s') % dict(val=val, tb=traceback.format_exc()))
            LOG.error(msg)
            module = cls.__module__
            if (module not in CONF.allowed_rpc_exception_modules):
                cls = exception.RPCError
                val = encodeutils.exception_to_unicode(exception.RPCError(cls=cls, val=val))
            cls_path = ('%s.%s' % (cls.__module__, cls.__name__))
            result = {'_error': {'cls': cls_path, 'val': val}}
        results.append(result)
    return results
