Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / cls / lua / cls_lua_client.cc
1 #include <string>
2 #include <vector>
3 #include "include/encoding.h"
4 #include "include/rados/librados.hpp"  // for IoCtx
5 #include "cls_lua_client.h"
6 #include "cls_lua_ops.h"
7
8 using std::string;
9 using std::vector;
10 using librados::IoCtx;
11 using librados::bufferlist;
12
13 namespace cls_lua_client {
14   /*
15    * Currently the return code and return bufferlist are not wrapped in a
16    * protocol that allows object class vs Lua to be distinguished. For
17    * instance, -EOPNOTSUPP might refer to cls_lua not being found, but would
18    * also be returned when cls_lua is found, but a Lua handler is not found.
19    */
20   int exec(IoCtx& ioctx, const string& oid, const string& script,
21       const string& handler, bufferlist& input, bufferlist& output)
22   {
23     cls_lua_eval_op op;
24
25     op.script = script;
26     op.handler = handler;
27     op.input = input;
28
29     bufferlist inbl;
30     ::encode(op, inbl);
31
32     return ioctx.exec(oid, "lua", "eval_bufferlist", inbl, output);
33   }
34 }