From bd93e9c6d6b2673910476abc108ff3019b49196f Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 17 Jan 2022 15:09:41 -0500 Subject: [PATCH] common admin: enhance and make public APIs for mgr module admin Signed-off-by: John Mulligan --- common/admin/manager/module.go | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/common/admin/manager/module.go b/common/admin/manager/module.go index 010c51b..925b873 100644 --- a/common/admin/manager/module.go +++ b/common/admin/manager/module.go @@ -35,14 +35,25 @@ func (fsa *MgrAdmin) DisableModule(module string) error { return commands.MarshalMonCommand(fsa.conn, m).NoData().End() } +// DisabledModule describes a disabled Ceph mgr module. +// The Ceph JSON structure contains a complex module_options +// substructure that go-ceph does not currently implement. +type DisabledModule struct { + Name string `json:"name"` + CanRun bool `json:"can_run"` + ErrorString string `json:"error_string"` +} + +// ModuleInfo contains fields that report the status of modules within the +// ceph mgr. type ModuleInfo struct { + // EnabledModules lists the names of the enabled modules. 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. + // AlwaysOnModules lists the names of the always-on modules. + AlwaysOnModules []string `json:"always_on_modules"` + // DisabledModules lists structures describing modules that are + // not currently enabled. + DisabledModules []DisabledModule `json:"disabled_modules"` } func parseModuleInfo(res commands.Response) (*ModuleInfo, error) { @@ -53,10 +64,9 @@ func parseModuleInfo(res commands.Response) (*ModuleInfo, error) { 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 *MgrAdmin) listModules() (*ModuleInfo, error) { +// ListModules returns a module info struct reporting the lists of +// enabled, disabled, and always-on modules in the Ceph mgr. +func (fsa *MgrAdmin) ListModules() (*ModuleInfo, error) { m := map[string]string{ "prefix": "mgr module ls", "format": "json",