]> git.proxmox.com Git - ceph.git/blob - ceph/src/mon/FSCommands.h
update sources to v12.1.2
[ceph.git] / ceph / src / mon / FSCommands.h
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 bool force,
56 std::stringstream *ss) const;
57
58 virtual std::string const &get_prefix() {return prefix;}
59
60 public:
61 FileSystemCommandHandler(const std::string &prefix_)
62 : prefix(prefix_)
63 {}
64
65 virtual ~FileSystemCommandHandler()
66 {}
67
68 bool can_handle(std::string const &prefix_)
69 {
70 return get_prefix() == prefix_;
71 }
72
73 static std::list<std::shared_ptr<FileSystemCommandHandler> > load(Paxos *paxos);
74
75 virtual bool batched_propose() {
76 return false;
77 }
78
79 virtual int handle(
80 Monitor *mon,
81 FSMap &fsmap,
82 MonOpRequestRef op,
83 map<string, cmd_vartype> &cmdmap,
84 std::stringstream &ss) = 0;
85 };
86
87 #endif