downgrade ceph

This commit is contained in:
chessman
2019-06-12 20:03:19 +03:00
parent 48da8d6281
commit f339c5e70c
6 changed files with 129 additions and 286 deletions
+15 -17
View File
@@ -17,8 +17,6 @@ func (e RadosError) Error() string {
return fmt.Sprintf("rados: %s", C.GoString(C.strerror(C.int(-e))))
}
var RadosAllNamespaces = C.LIBRADOS_ALL_NSPACES
var RadosErrorNotFound = RadosError(-C.ENOENT)
var RadosErrorPermissionDenied = RadosError(-C.EPERM)
@@ -37,13 +35,11 @@ func Version() (int, int, int) {
return int(c_major), int(c_minor), int(c_patch)
}
func makeConn() *Conn {
return &Conn{connected: false}
}
func newConn(user *C.char) (*Conn, error) {
conn := makeConn()
ret := C.rados_create(&conn.cluster, user)
// NewConn creates a new connection object. It returns the connection and an
// error, if any.
func NewConn() (*Conn, error) {
conn := &Conn{}
ret := C.rados_create(&conn.cluster, nil)
if ret == 0 {
return conn, nil
@@ -52,18 +48,20 @@ func newConn(user *C.char) (*Conn, error) {
}
}
// NewConn creates a new connection object. It returns the connection and an
// error, if any.
func NewConn() (*Conn, error) {
return newConn(nil)
}
// NewConnWithUser creates a new connection object with a custom username.
// It returns the connection and an error, if any.
func NewConnWithUser(user string) (*Conn, error) {
c_user := C.CString(user)
defer C.free(unsafe.Pointer(c_user))
return newConn(c_user)
conn := &Conn{}
ret := C.rados_create(&conn.cluster, c_user)
if ret == 0 {
return conn, nil
} else {
return nil, RadosError(int(ret))
}
}
// NewConnWithClusterAndUser creates a new connection object for a specific cluster and username.
@@ -75,7 +73,7 @@ func NewConnWithClusterAndUser(clusterName string, userName string) (*Conn, erro
c_name := C.CString(userName)
defer C.free(unsafe.Pointer(c_name))
conn := makeConn()
conn := &Conn{}
ret := C.rados_create2(&conn.cluster, c_cluster_name, c_name, 0)
if ret == 0 {
return conn, nil