From 2835eeac35d23dc885b030da2f542be3870ac611 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Tue, 16 Jun 2015 15:32:09 -0700 Subject: [PATCH] Add an overload for creating a connection to a cluster other than the default cluster name of "ceph". --- rados/rados.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rados/rados.go b/rados/rados.go index 935bc24..b7880e9 100644 --- a/rados/rados.go +++ b/rados/rados.go @@ -52,3 +52,21 @@ func NewConnWithUser(user string) (*Conn, error) { return nil, RadosError(int(ret)) } } + +// NewConnWithClusterAndUser creates a new connection object for a specific cluster and username. +// It returns the connection and an error, if any. +func NewConnWithClusterAndUser(clusterName string, userName string) (*Conn, error) { + c_cluster_name := C.CString(clusterName) + defer C.free(unsafe.Pointer(c_cluster_name)) + + c_name := C.CString(userName) + defer C.free(unsafe.Pointer(c_name)) + + conn := &Conn{} + ret := C.rados_create2(&conn.cluster, c_cluster_name, c_name, 0) + if ret == 0 { + return conn, nil + } else { + return nil, RadosError(int(ret)) + } +}