* Ceph distributed storage system
*
* Copyright (C) 2014 Cloudwatt <libre.licensing@cloudwatt.com>
+ * Copyright (C) 2014 Red Hat <contact@redhat.com>
*
* Author: Loic Dachary <loic@dachary.org>
*
public:
int setup(int argc, char** argv);
int run();
+ int plugin_exists();
+ int display_information();
};
int ErasureCodeCommand::setup(int argc, char** argv) {
("get_chunk_count", "display get_chunk_count()")
("parameter,P", po::value<vector<string> >(),
"parameters")
+ ("plugin_exists", po::value<string>(),
+ "succeeds if the plugin given in argument exists and can be loaded")
;
po::parsed_options parsed =
if (parameters.count("directory") == 0)
parameters["directory"] = ".libs";
- if (parameters.count("plugin") == 0) {
- cerr << "--parameter plugin=<plugin> is mandatory" << endl;
- return 1;
- }
return 0;
}
int ErasureCodeCommand::run() {
+ if (vm.count("plugin_exists"))
+ return plugin_exists();
+ else
+ return display_information();
+}
+
+int ErasureCodeCommand::plugin_exists() {
+ ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
+ ErasureCodePlugin *plugin = 0;
+ Mutex::Locker l(instance.lock);
+ stringstream ss;
+ int code = instance.load(vm["plugin_exists"].as<string>(), parameters["directory"], &plugin, ss);
+ if (code)
+ cerr << ss.str() << endl;
+ return code;
+}
+
+int ErasureCodeCommand::display_information() {
ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance();
ErasureCodeInterfaceRef erasure_code;
+
+ if (parameters.count("plugin") == 0) {
+ cerr << "--parameter plugin=<plugin> is mandatory" << endl;
+ return 1;
+ }
+
int code = instance.factory(parameters["plugin"],
parameters,
&erasure_code, cerr);
* Local Variables:
* compile-command: "cd ../.. ; make -j4 &&
* make -j4 ceph_erasure_code &&
- * valgrind --tool=memcheck --leak-check=full \
+ * libtool --mode=execute valgrind --tool=memcheck --leak-check=full \
* ./ceph_erasure_code \
* --parameter plugin=jerasure \
* --parameter directory=.libs \