Module lua-rados
Functions
version () | Get the version of librados. |
create (id) | Create handle for communicating with RADOS cluster. |
Class Cluster
Cluster:conf_read_file (file) | Configure the cluster handle using a Ceph config file. |
Cluster:connect () | Connect to the cluster. |
Cluster:shutdown () | Disconnect from the cluster. |
Cluster:open_ioctx (name) | Create an I/O context. |
Class Ioctx
Ioctx:close () | Close the I/O context. |
Ioctx:stat (oid) | Get object stat info (size/mtime) |
Ioctx:write (oid, buf, length, offset) | Write data to an object. |
Ioctx:read (oid, length, offset) | Read data from an object. |
Ioctx:setxattr (oid, name, buf, size) | Set xattr name on object |
Ioctx:getxattr (oid, name) | Get xattr name from object. |
Ioctx:exec (oid, class, method, buf, length) | Execute an OSD class method on an object. |
Functions
- version ()
-
Get the version of librados.
Usage:
major, minor, extra = rados.version()
Returns:
- major version
- minor version
- extra version
- create (id)
-
Create handle for communicating with RADOS cluster.
Parameters:
id
: string the user to connect as (optional, or nil)
Usage:
cluster = rados.create()
cluster = rados.create('admin')
Returns:
- cluster handle object on success, nil otherwise
- error message and retval if failed
Class Cluster
- Cluster:conf_read_file (file)
-
Configure the cluster handle using a Ceph config file.
Parameters:
file
: string path to configuration file (optional, or nil)
Usage:
cluster:conf_read_file()
cluster:conf_read_file('/path/to/ceph.conf')
Returns:
- 0 on success, nil otherwise
- error message and retval if failed
- Cluster:connect ()
-
Connect to the cluster.
Usage:
cluster:connect()
status, errstr, ret = cluster:connect()
Returns:
- 0 on success, nil otherwise
- error message and retval if failed
- Cluster:shutdown ()
-
Disconnect from the cluster.
Usage:
cluster:shutdown()
- Cluster:open_ioctx (name)
-
Create an I/O context.
Parameters:
name
: string of pool
Usage:
ioctx = cluster:open_ioctx('my_pool')
Returns:
- I/O context object or nil on failure
- errstr, ret if failed
Class Ioctx
- Ioctx:close ()
-
Close the I/O context.
Usage:
ioctx:close()
- Ioctx:stat (oid)
-
Get object stat info (size/mtime)
Parameters:
oid
: string object name
Usage:
size, mtime = ioctx:stat('obj3')
Returns:
- len, mtime, or nil on failure
- errstr and retval if failed
- Ioctx:write (oid, buf, length, offset)
-
Write data to an object.
Parameters:
oid
: string object namebuf
: string buffer containing byteslength
: int number of bytes to writeoffset
: int offset in object from which to write
Usage:
ioctx:write('obj3', 'data', #'data', 0)
Returns:
- number of bytes written, or nil on error
- errstr and retval if failed
- Ioctx:read (oid, length, offset)
-
Read data from an object.
Parameters:
oid
: string object namelength
: int number of bytes readoffset
: int offset in object from which to read
Usage:
data = ioctx:read('obj3', 1000, 0)
Returns:
- string with at most
length
bytes, or nil on error - errstr and retval if failed
- Ioctx:setxattr (oid, name, buf, size)
-
Set xattr name on object
Parameters:
oid
: string object namename
: string xattr namebuf
: string value to set xattr name tosize
: int of buf
Usage:
ioctx:setxattr('obj3', 'name', 'data', #'data')
Returns:
- 0 on success, or nil on error
- errstr and retval if failed
- Ioctx:getxattr (oid, name)
-
Get xattr name from object.
Parameters:
Usage:
data = ioctx:getxattr('obj3', 'name')
Returns:
- string containing xattr name
- errstr and retval if failed
- Ioctx:exec (oid, class, method, buf, length)
-
Execute an OSD class method on an object.
Parameters:
oid
: string the name of the objectclass
: string the name of the classmethod
: string the name of the methodbuf
: string buffer containing method inputlength
: int length of input buffer
Usage:
ret, reply = ioctx:exec('oid', 'cls', 'func', input, #input)
Returns:
- retval, output on success, else nil
- strerr, errval on failure