1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2025-06-14 18:53:35 +00:00

rebase: update go-ceph to v0.10.0

This commit updates the go-ceph to latest
release. More details about release at
https://github.com/ceph/go-ceph/releases/tag/v0.10.0

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2021-06-09 10:24:52 +05:30
committed by mergify[bot]
parent 17b0091cba
commit 5b7b5f1e3a
27 changed files with 1099 additions and 272 deletions

@ -3,18 +3,16 @@
package admin
import (
"encoding/json"
"strconv"
ccom "github.com/ceph/go-ceph/common/commands"
"github.com/ceph/go-ceph/internal/commands"
"github.com/ceph/go-ceph/rados"
)
// RadosCommander provides an interface to execute JSON-formatted commands that
// allow the cephfs administrative functions to interact with the Ceph cluster.
type RadosCommander interface {
MgrCommand(buf [][]byte) ([]byte, string, error)
MonCommand(buf []byte) ([]byte, string, error)
}
type RadosCommander = ccom.RadosCommander
// FSAdmin is used to administrate CephFS within a ceph cluster.
type FSAdmin struct {
@ -60,39 +58,25 @@ func (fsa *FSAdmin) validate() error {
// rawMgrCommand takes a byte buffer and sends it to the MGR as a command.
// The buffer is expected to contain preformatted JSON.
func (fsa *FSAdmin) rawMgrCommand(buf []byte) response {
if err := fsa.validate(); err != nil {
return response{err: err}
}
return newResponse(fsa.conn.MgrCommand([][]byte{buf}))
return commands.RawMgrCommand(fsa.conn, buf)
}
// marshalMgrCommand takes an generic interface{} value, converts it to JSON and
// sends the json to the MGR as a command.
func (fsa *FSAdmin) marshalMgrCommand(v interface{}) response {
b, err := json.Marshal(v)
if err != nil {
return response{err: err}
}
return fsa.rawMgrCommand(b)
return commands.MarshalMgrCommand(fsa.conn, v)
}
// rawMonCommand takes a byte buffer and sends it to the MON as a command.
// The buffer is expected to contain preformatted JSON.
func (fsa *FSAdmin) rawMonCommand(buf []byte) response {
if err := fsa.validate(); err != nil {
return response{err: err}
}
return newResponse(fsa.conn.MonCommand(buf))
return commands.RawMonCommand(fsa.conn, buf)
}
// marshalMonCommand takes an generic interface{} value, converts it to JSON and
// sends the json to the MGR as a command.
func (fsa *FSAdmin) marshalMonCommand(v interface{}) response {
b, err := json.Marshal(v)
if err != nil {
return response{err: err}
}
return fsa.rawMonCommand(b)
return commands.MarshalMonCommand(fsa.conn, v)
}
type listNamedResult struct {
@ -101,7 +85,7 @@ type listNamedResult struct {
func parseListNames(res response) ([]string, error) {
var r []listNamedResult
if err := res.noStatus().unmarshal(&r).End(); err != nil {
if err := res.NoStatus().Unmarshal(&r).End(); err != nil {
return nil, err
}
vl := make([]string, len(r))
@ -114,10 +98,10 @@ func parseListNames(res response) ([]string, error) {
// parsePathResponse returns a cleaned up path from requests that get a path
// unless an error is encountered, then an error is returned.
func parsePathResponse(res response) (string, error) {
if res2 := res.noStatus(); !res2.Ok() {
if res2 := res.NoStatus(); !res2.Ok() {
return "", res.End()
}
b := res.body
b := res.Body()
// if there's a trailing newline in the buffer strip it.
// ceph assumes a CLI wants the output of the buffer and there's
// no format=json mode available currently.