X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fmgr%2FActivePyModule.h;fp=src%2Fceph%2Fsrc%2Fmgr%2FActivePyModule.h;h=0c2ee12f34e109af1d0a356afcddbcab5f7e127f;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/mgr/ActivePyModule.h b/src/ceph/src/mgr/ActivePyModule.h new file mode 100644 index 0000000..0c2ee12 --- /dev/null +++ b/src/ceph/src/mgr/ActivePyModule.h @@ -0,0 +1,98 @@ + +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2016 John Spray + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + */ + + +#pragma once + +// Python.h comes first because otherwise it clobbers ceph's assert +#include "Python.h" + +#include "common/cmdparse.h" +#include "common/LogEntry.h" +#include "common/Mutex.h" +#include "common/Thread.h" +#include "mon/health_check.h" +#include "mgr/Gil.h" + +#include "PyModuleRunner.h" + +#include +#include + + +class ActivePyModule; +class ActivePyModules; + +/** + * A Ceph CLI command description provided from a Python module + */ +class ModuleCommand { +public: + std::string cmdstring; + std::string helpstring; + std::string perm; + ActivePyModule *handler; +}; + +class ActivePyModule : public PyModuleRunner +{ +private: + health_check_map_t health_checks; + + std::vector commands; + + int load_commands(); + + // Optional, URI exposed by plugins that implement serve() + std::string uri; + +public: + ActivePyModule(const std::string &module_name_, + PyObject *pClass_, + const SafeThreadState &my_ts_) + : PyModuleRunner(module_name_, pClass_, my_ts_) + {} + + int load(ActivePyModules *py_modules); + void notify(const std::string ¬ify_type, const std::string ¬ify_id); + void notify_clog(const LogEntry &le); + + const std::vector &get_commands() const + { + return commands; + } + + int handle_command( + const cmdmap_t &cmdmap, + std::stringstream *ds, + std::stringstream *ss); + + void set_health_checks(health_check_map_t&& c) { + health_checks = std::move(c); + } + void get_health_checks(health_check_map_t *checks); + + void set_uri(const std::string &str) + { + uri = str; + } + + std::string get_uri() const + { + return uri; + } +}; + +std::string handle_pyerror(); +