common admin: enhance and make public APIs for mgr module admin

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2022-01-17 15:09:41 -05:00 committed by mergify[bot]
parent 0757a9acf9
commit bd93e9c6d6
1 changed files with 20 additions and 10 deletions

View File

@ -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",