40 lines
718 B
Go
40 lines
718 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/ceph/go-ceph/rados"
|
|
)
|
|
|
|
func connect() (_ CephConnection, err error) {
|
|
var cephConn CephConnection = CephConnection{}
|
|
|
|
defer func() {
|
|
if err != nil {
|
|
err = fmt.Errorf("Error in func connect() %w", err)
|
|
}
|
|
}()
|
|
|
|
cephConn.conn, err = rados.NewConnWithClusterAndUser("ceph", "client.admin")
|
|
if err != nil {
|
|
return CephConnection{}, err
|
|
}
|
|
|
|
err = cephConn.conn.ReadConfigFile(params.config)
|
|
if err != nil {
|
|
return CephConnection{}, err
|
|
}
|
|
|
|
err = cephConn.conn.SetConfigOption("keyring", params.keyring)
|
|
if err != nil {
|
|
return CephConnection{}, err
|
|
}
|
|
|
|
err = cephConn.conn.Connect()
|
|
if err != nil {
|
|
return CephConnection{}, err
|
|
}
|
|
|
|
return cephConn, nil
|
|
}
|