diff --git a/docs/api-status.json b/docs/api-status.json index 4cccad4..4762f71 100644 --- a/docs/api-status.json +++ b/docs/api-status.json @@ -1159,6 +1159,12 @@ "comment": "Exec executes an OSD class method on an object.\nSee rados_exec() in the RADOS C api documentation for a general description.\n\nImplements:\n\n\tvoid rados_write_op_exec(rados_write_op_t write_op,\n\t const char *cls,\n\t const char *method,\n\t const char *in_buf,\n\t size_t in_len,\n\t int *prval)\n", "added_in_version": "v0.29.0", "expected_stable_version": "v0.31.0" + }, + { + "name": "Conn.GetAddrs", + "comment": "GetAddrs returns the addresses of the RADOS session,\nsuitable for blocklisting.\n\nImplements:\n\n\tint rados_getaddrs(rados_t cluster, char **addrs)\n", + "added_in_version": "$NEXT_RELEASE", + "expected_stable_version": "$NEXT_RELEASE_STABLE" } ] }, @@ -2356,4 +2362,4 @@ } ] } -} +} \ No newline at end of file diff --git a/docs/api-status.md b/docs/api-status.md index be6b183..ba2a2de 100644 --- a/docs/api-status.md +++ b/docs/api-status.md @@ -19,6 +19,7 @@ Name | Added in Version | Expected Stable Version | ReadOpExecStep.Bytes | v0.29.0 | v0.31.0 | ReadOp.Exec | v0.29.0 | v0.31.0 | WriteOp.Exec | v0.29.0 | v0.31.0 | +Conn.GetAddrs | $NEXT_RELEASE | $NEXT_RELEASE_STABLE | ## Package: rbd diff --git a/rados/rados_getaddrs.go b/rados/rados_getaddrs.go new file mode 100644 index 0000000..093e373 --- /dev/null +++ b/rados/rados_getaddrs.go @@ -0,0 +1,30 @@ +//go:build ceph_preview + +package rados + +// #cgo LDFLAGS: -lrados +// #include +// #include +import "C" + +import ( + "unsafe" +) + +// GetAddrs returns the addresses of the RADOS session, +// suitable for blocklisting. +// +// Implements: +// +// int rados_getaddrs(rados_t cluster, char **addrs) +func (c *Conn) GetAddrs() (string, error) { + var cAddrs *C.char + defer C.free(unsafe.Pointer(cAddrs)) + + ret := C.rados_getaddrs(c.cluster, &cAddrs) + if ret < 0 { + return "", getError(ret) + } + + return C.GoString(cAddrs), nil +} diff --git a/rados/rados_getaddrs_test.go b/rados/rados_getaddrs_test.go new file mode 100644 index 0000000..909f6ef --- /dev/null +++ b/rados/rados_getaddrs_test.go @@ -0,0 +1,15 @@ +//go:build ceph_preview + +package rados + +import ( + "github.com/stretchr/testify/assert" +) + +func (suite *RadosTestSuite) TestGetAddrs() { + suite.SetupConnection() + + addrs, err := suite.conn.GetAddrs() + assert.NoError(suite.T(), err) + assert.NotEmpty(suite.T(), addrs, "rados_getaddrs") +}