]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2017 Red Hat Ltd | |
7 | * | |
8 | * This is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License version 2.1, as published by the Free Software | |
11 | * Foundation. See file COPYING. | |
12 | * | |
13 | */ | |
14 | ||
15 | ||
16 | #ifndef FS_COMMANDS_H_ | |
17 | #define FS_COMMANDS_H_ | |
18 | ||
19 | #include "Monitor.h" | |
20 | ||
21 | #include "osd/OSDMap.h" | |
22 | #include "mds/FSMap.h" | |
23 | ||
24 | #include <string> | |
25 | #include <sstream> | |
26 | ||
27 | class FileSystemCommandHandler | |
28 | { | |
29 | protected: | |
30 | std::string prefix; | |
31 | ||
32 | /** | |
33 | * Parse true|yes|1 style boolean string from `bool_str` | |
34 | * `result` must be non-null. | |
35 | * `ss` will be populated with error message on error. | |
36 | * | |
37 | * @return 0 on success, else -EINVAL | |
38 | */ | |
39 | int parse_bool( | |
40 | const std::string &bool_str, | |
41 | bool *result, | |
42 | std::ostream &ss); | |
43 | ||
44 | /** | |
45 | * Return 0 if the pool is suitable for use with CephFS, or | |
46 | * in case of errors return a negative error code, and populate | |
47 | * the passed stringstream with an explanation. | |
48 | * | |
49 | * @param metadata whether the pool will be for metadata (stricter checks) | |
50 | */ | |
51 | int _check_pool( | |
52 | OSDMap &osd_map, | |
53 | const int64_t pool_id, | |
54 | bool metadata, | |
55 | std::stringstream *ss) const; | |
56 | ||
57 | virtual std::string const &get_prefix() {return prefix;} | |
58 | ||
59 | public: | |
60 | FileSystemCommandHandler(const std::string &prefix_) | |
61 | : prefix(prefix_) | |
62 | {} | |
63 | ||
64 | virtual ~FileSystemCommandHandler() | |
65 | {} | |
66 | ||
67 | bool can_handle(std::string const &prefix_) | |
68 | { | |
69 | return get_prefix() == prefix_; | |
70 | } | |
71 | ||
72 | static std::list<std::shared_ptr<FileSystemCommandHandler> > load(); | |
73 | ||
74 | virtual int handle( | |
75 | Monitor *mon, | |
76 | FSMap &fsmap, | |
77 | MonOpRequestRef op, | |
78 | map<string, cmd_vartype> &cmdmap, | |
79 | std::stringstream &ss) = 0; | |
80 | }; | |
81 | ||
82 | #endif |