From 40f80cc846e40332de552a9dff21e41153010fb9 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 20 May 2020 13:39:03 -0400 Subject: [PATCH] rados: add OsdCommand & OsdCommandWithInputBuffer functions These functions wrap rados_osd_command and allow the user to send "command JSON" to OSDs. Signed-off-by: John Mulligan --- rados/command.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/rados/command.go b/rados/command.go index 7e94ee7..4c25291 100644 --- a/rados/command.go +++ b/rados/command.go @@ -116,3 +116,40 @@ func (c *Conn) MgrCommandWithInputBuffer(args [][]byte, inputBuffer []byte) ([]b buf, status := co.GoValues() return buf, status, getError(ret) } + +// OsdCommand sends a command to the specified ceph OSD. +func (c *Conn) OsdCommand(osd int, args [][]byte) ([]byte, string, error) { + return c.OsdCommandWithInputBuffer(osd, args, nil) +} + +// OsdCommandWithInputBuffer sends a command, with an input buffer, to the +// specified ceph OSD. +// +// Implements: +// int rados_osd_command(rados_t cluster, int osdid, +// const char **cmd, size_t cmdlen, +// const char *inbuf, size_t inbuflen, +// char **outbuf, size_t *outbuflen, +// char **outs, size_t *outslen); +func (c *Conn) OsdCommandWithInputBuffer( + osd int, args [][]byte, inputBuffer []byte) ([]byte, string, error) { + + ci := cutil.NewCommandInput(args, inputBuffer) + defer ci.Free() + co := cutil.NewCommandOutput().SetFreeFunc(radosBufferFree) + defer co.Free() + + ret := C.rados_osd_command( + c.cluster, + C.int(osd), + (**C.char)(ci.Cmd()), + C.size_t(ci.CmdLen()), + (*C.char)(ci.InBuf()), + C.size_t(ci.InBufLen()), + (**C.char)(co.OutBuf()), + (*C.size_t)(co.OutBufLen()), + (**C.char)(co.Outs()), + (*C.size_t)(co.OutsLen())) + buf, status := co.GoValues() + return buf, status, getError(ret) +}