1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2017 Red Hat
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.
15 #ifndef CEPH_ADMIN_SOCKET_OUTPUT_H
16 #define CEPH_ADMIN_SOCKET_OUTPUT_H
23 #include <boost/filesystem/path.hpp> // For path
24 #include <boost/filesystem/operations.hpp> // For exists, is_directory
26 namespace bfs = boost::filesystem;
28 using socket_results = std::map<std::string, std::string>;
29 using test_functions =
30 std::vector<std::pair<std::string, bool (*)(std::string &)>>;
32 class AdminSocketClient;
34 class AdminSocketOutput {
36 AdminSocketOutput() {}
38 void add_target(const std::string &target);
39 void add_command(const std::string &target, const std::string &command);
40 void add_test(const std::string &target, const std::string &command,
41 bool (*test)(std::string &));
42 void postpone(const std::string &target, const std::string &command);
46 void mod_for_vstart() {
52 bool init_directories() const {
53 std::cout << "Checking " << socketdir << std::endl;
54 return exists(socketdir) && is_directory(socketdir);
58 bool gather_socket_output();
59 std::string get_result(const std::string target, const std::string command) const;
61 std::pair<std::string, std::string>
62 run_command(AdminSocketClient &client, const std::string raw_command,
63 bool send_untouched = false);
65 bool run_tests() const;
67 std::set<std::string> targets;
68 std::map<std::string, std::string> sockets;
69 std::map<std::string, socket_results> results;
70 std::map<std::string, std::vector<std::string>> custom_commands;
71 std::map<std::string, std::vector<std::string>> postponed_commands;
72 std::map<std::string, test_functions> tests;
74 std::string prefix = "ceph-";
75 bfs::path socketdir = "/var/run/ceph";
78 #endif // CEPH_ADMIN_SOCKET_OUTPUT_H