From a26d4b8563319e1348dd846bde3fde591cbd3b48 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 15 Nov 2021 10:22:38 -0500 Subject: [PATCH] cephfs admin: add a private function for getting mgr modules Add a function for getting the lists of enabled/disabled mgr modules from ceph. This is private for the moment as general module management probably shouldn't be part of cephfs admin. It's bad enough we hacked in the functions for enabling mirroring. :-) Signed-off-by: John Mulligan --- cephfs/admin/mgrmodule.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/cephfs/admin/mgrmodule.go b/cephfs/admin/mgrmodule.go index 50a9157..7efcd0c 100644 --- a/cephfs/admin/mgrmodule.go +++ b/cephfs/admin/mgrmodule.go @@ -52,3 +52,32 @@ func (fsa *FSAdmin) EnableMirroringModule(force bool) error { 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)) +}