Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / tools / cephfs / cephfs-table-tool.cc
1
2 #include "include/types.h"
3 #include "common/config.h"
4 #include "common/ceph_argparse.h"
5 #include "common/errno.h"
6 #include "global/global_init.h"
7
8 #include "TableTool.h"
9
10
11 int main(int argc, const char **argv)
12 {
13   vector<const char*> args;
14   argv_to_vec(argc, argv, args);
15   env_to_vec(args);
16
17   auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT,
18                          CODE_ENVIRONMENT_UTILITY, 0);
19   common_init_finish(g_ceph_context);
20
21   TableTool tt;
22
23   // Handle --help before calling init() so we don't depend on network.
24   if (args.empty() || (args.size() == 1 && (std::string(args[0]) == "--help" || std::string(args[0]) == "-h"))) {
25     tt.usage();
26     return 0;
27   }
28
29   // Connect to mon cluster, download MDS map etc
30   int rc = tt.init();
31   if (rc != 0) {
32       std::cerr << "Error in initialization: " << cpp_strerror(rc) << std::endl;
33       return rc;
34   }
35
36   // Finally, execute the user's commands
37   rc = tt.main(args);
38   if (rc != 0) {
39     std::cerr << "Error (" << cpp_strerror(rc) << ")" << std::endl;
40   }
41
42   tt.shutdown();
43
44   return rc;
45 }
46
47