mirror of https://github.com/ceph/go-ceph
cephfs admin: reimplement cephfs mgr module calls via common admin
Now that we've moved the logic over to common admin, replace the implementation in cephfs admin. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
bd93e9c6d6
commit
85208d213f
|
@ -1,7 +1,7 @@
|
|||
package admin
|
||||
|
||||
import (
|
||||
"github.com/ceph/go-ceph/internal/commands"
|
||||
"github.com/ceph/go-ceph/common/admin/manager"
|
||||
)
|
||||
|
||||
const mirroring = "mirroring"
|
||||
|
@ -11,17 +11,8 @@ const mirroring = "mirroring"
|
|||
// Similar To:
|
||||
// ceph mgr module enable <module> [--force]
|
||||
func (fsa *FSAdmin) EnableModule(module string, force bool) error {
|
||||
m := map[string]string{
|
||||
"prefix": "mgr module enable",
|
||||
"module": module,
|
||||
"format": "json",
|
||||
}
|
||||
if force {
|
||||
m["force"] = "--force"
|
||||
}
|
||||
// Why is this _only_ part of the mon command json? You'd think a mgr
|
||||
// command would be available as a MgrCommand but I couldn't figure it out.
|
||||
return commands.MarshalMonCommand(fsa.conn, m).NoData().End()
|
||||
mgradmin := manager.NewFromConn(fsa.conn)
|
||||
return mgradmin.EnableModule(module, force)
|
||||
}
|
||||
|
||||
// DisableModule will disable the specified manager module.
|
||||
|
@ -29,12 +20,8 @@ func (fsa *FSAdmin) EnableModule(module string, force bool) error {
|
|||
// Similar To:
|
||||
// ceph mgr module disable <module>
|
||||
func (fsa *FSAdmin) DisableModule(module string) error {
|
||||
m := map[string]string{
|
||||
"prefix": "mgr module disable",
|
||||
"module": module,
|
||||
"format": "json",
|
||||
}
|
||||
return commands.MarshalMonCommand(fsa.conn, m).NoData().End()
|
||||
mgradmin := manager.NewFromConn(fsa.conn)
|
||||
return mgradmin.DisableModule(module)
|
||||
}
|
||||
|
||||
// EnableMirroringModule will enable the mirroring module for cephfs.
|
||||
|
@ -42,7 +29,8 @@ func (fsa *FSAdmin) DisableModule(module string) error {
|
|||
// Similar To:
|
||||
// ceph mgr module enable mirroring [--force]
|
||||
func (fsa *FSAdmin) EnableMirroringModule(force bool) error {
|
||||
return fsa.EnableModule(mirroring, force)
|
||||
mgradmin := manager.NewFromConn(fsa.conn)
|
||||
return mgradmin.EnableModule(mirroring, force)
|
||||
}
|
||||
|
||||
// DisableMirroringModule will disable the mirroring module for cephfs.
|
||||
|
@ -50,34 +38,6 @@ func (fsa *FSAdmin) EnableMirroringModule(force bool) error {
|
|||
// Similar To:
|
||||
// ceph mgr module disable mirroring
|
||||
func (fsa *FSAdmin) DisableMirroringModule() error {
|
||||
return fsa.DisableModule(mirroring)
|
||||
}
|
||||
|
||||
type moduleInfo struct {
|
||||
EnabledModules []string `json:"enabled_modules"`
|
||||
//DisabledModules []string `json:"disabled_modules"`
|
||||
// DisabledModules is documented in ceph as a list of string
|
||||
// but that's not what comes back from the server (on pacific).
|
||||
// Since we don't need this today, we're just going to ignore
|
||||
// it, but if we ever want to support this for external consumers
|
||||
// we'll need to figure out the real structure of this.
|
||||
}
|
||||
|
||||
func parseModuleInfo(res response) (*moduleInfo, error) {
|
||||
m := &moduleInfo{}
|
||||
if err := res.NoStatus().Unmarshal(m).End(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// listModules returns moduleInfo or error. it is not exported because
|
||||
// this is really not a cephfs specific thing but we needed it
|
||||
// for cephfs tests. maybe lift it somewhere else someday.
|
||||
func (fsa *FSAdmin) listModules() (*moduleInfo, error) {
|
||||
m := map[string]string{
|
||||
"prefix": "mgr module ls",
|
||||
"format": "json",
|
||||
}
|
||||
return parseModuleInfo(commands.MarshalMonCommand(fsa.conn, m))
|
||||
mgradmin := manager.NewFromConn(fsa.conn)
|
||||
return mgradmin.DisableModule(mirroring)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ceph/go-ceph/cephfs"
|
||||
"github.com/ceph/go-ceph/common/admin/manager"
|
||||
)
|
||||
|
||||
func mirrorConfig() string {
|
||||
|
@ -26,8 +27,9 @@ const (
|
|||
)
|
||||
|
||||
func waitForMirroring(t *testing.T, fsa *FSAdmin) {
|
||||
mgradmin := manager.NewFromConn(fsa.conn)
|
||||
for i := 0; i < 20; i++ {
|
||||
modinfo, err := fsa.listModules()
|
||||
modinfo, err := mgradmin.ListModules()
|
||||
require.NoError(t, err)
|
||||
for _, emod := range modinfo.EnabledModules {
|
||||
if emod == "mirroring" {
|
||||
|
|
Loading…
Reference in New Issue