Move json_is_true/json_is_false to json_util.cpp
This commit is contained in:
@@ -88,7 +88,7 @@ add_executable(test_cluster_client
|
||||
EXCLUDE_FROM_ALL
|
||||
../test/test_cluster_client.cpp
|
||||
pg_states.cpp osd_ops.cpp cluster_client.cpp cluster_client_list.cpp cluster_client_wb.cpp msgr_op.cpp ../test/mock/messenger.cpp msgr_stop.cpp
|
||||
etcd_state_client.cpp ../util/timerfd_manager.cpp ../util/str_util.cpp ../../json11/json11.cpp
|
||||
etcd_state_client.cpp ../util/timerfd_manager.cpp ../util/str_util.cpp ../util/json_util.cpp ../../json11/json11.cpp
|
||||
)
|
||||
target_compile_definitions(test_cluster_client PUBLIC -D__MOCK__)
|
||||
target_include_directories(test_cluster_client BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/src/test/mock)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <stdexcept>
|
||||
#include <assert.h>
|
||||
#include "cluster_client_impl.h"
|
||||
#include "http_client.h" // json_is_true
|
||||
#include "json_util.h"
|
||||
|
||||
cluster_client_t::cluster_client_t(ring_loop_t *ringloop, timerfd_manager_t *tfd, json11::Json config)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "addr_util.h"
|
||||
#include "str_util.h"
|
||||
#include "json_util.h"
|
||||
#include "json11/json11.hpp"
|
||||
#include "http_client.h"
|
||||
#include "timerfd_manager.h"
|
||||
@@ -724,22 +725,3 @@ static bool ws_parse_frame(std::string & buf, int & type, std::string & res)
|
||||
buf = buf.substr(hdr+len);
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: move to utils
|
||||
bool json_is_true(const json11::Json & val)
|
||||
{
|
||||
if (val.is_string())
|
||||
return val == "true" || val == "yes" || val == "1";
|
||||
return val.bool_value();
|
||||
}
|
||||
|
||||
bool json_is_false(const json11::Json & val)
|
||||
{
|
||||
if (val.is_string())
|
||||
return val.string_value() == "false" || val.string_value() == "no" || val.string_value() == "0";
|
||||
if (val.is_number())
|
||||
return val.number_value() == 0;
|
||||
if (val.is_bool())
|
||||
return !val.bool_value();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,9 +48,3 @@ void http_request(http_co_t *handler, const std::string & host, const std::strin
|
||||
const http_options_t & options, std::function<void(const http_response_t *response)> response_callback);
|
||||
void http_post_message(http_co_t *handler, int type, const std::string & msg);
|
||||
void http_close(http_co_t *co);
|
||||
|
||||
// Utils
|
||||
std::string strtolower(const std::string & in);
|
||||
// FIXME: move to json11
|
||||
bool json_is_true(const json11::Json & val);
|
||||
bool json_is_false(const json11::Json & val);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "cluster_client.h"
|
||||
#include "pg_states.h"
|
||||
#include "str_util.h"
|
||||
#include "json_util.h"
|
||||
|
||||
struct cli_fix_t
|
||||
{
|
||||
|
||||
@@ -21,6 +21,3 @@ template<class T> void remove_duplicates(std::vector<T> & ret)
|
||||
}
|
||||
ret.resize(j+1);
|
||||
}
|
||||
|
||||
// from http_client.cpp...
|
||||
bool json_is_false(const json11::Json & val);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "cli.h"
|
||||
#include "cluster_client.h"
|
||||
#include "str_util.h"
|
||||
#include "json_util.h"
|
||||
#include "http_client.h"
|
||||
|
||||
// Reweight OSD, change tags or set noout flag
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "cli.h"
|
||||
#include "cluster_client.h"
|
||||
#include "str_util.h"
|
||||
#include "json_util.h"
|
||||
#include "pg_states.h"
|
||||
#include "http_client.h"
|
||||
|
||||
|
||||
@@ -136,7 +136,6 @@ uint64_t sscanf_json(const char *fmt, const json11::Json & str);
|
||||
void fromhexstr(const std::string & from, int bytes, uint8_t *to);
|
||||
int disable_cache(std::string dev);
|
||||
std::string get_parent_device(std::string dev);
|
||||
bool json_is_true(const json11::Json & val);
|
||||
int shell_exec(const std::vector<std::string> & cmd, const std::string & in, std::string *out, std::string *err);
|
||||
int write_zero(int fd, uint64_t offset, uint64_t size);
|
||||
json11::Json read_parttable(std::string dev);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "disk_tool.h"
|
||||
#include "str_util.h"
|
||||
#include "json_util.h"
|
||||
#include "osd_id.h"
|
||||
|
||||
int disk_tool_t::prepare_one(std::map<std::string, std::string> options, int is_hdd)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "disk_tool.h"
|
||||
#include "rw_blocking.h"
|
||||
#include "str_util.h"
|
||||
#include "json_util.h"
|
||||
|
||||
struct __attribute__((__packed__)) vitastor_disk_superblock_t
|
||||
{
|
||||
|
||||
@@ -147,13 +147,6 @@ std::string get_parent_device(std::string dev)
|
||||
return dev.substr(0, i);
|
||||
}
|
||||
|
||||
bool json_is_true(const json11::Json & val)
|
||||
{
|
||||
if (val.is_string())
|
||||
return val == "true" || val == "yes" || val == "1";
|
||||
return val.bool_value();
|
||||
}
|
||||
|
||||
int shell_exec(const std::vector<std::string> & cmd, const std::string & in, std::string *out, std::string *err)
|
||||
{
|
||||
int child_stdin[2], child_stdout[2], child_stderr[2];
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "addr_util.h"
|
||||
#include "str_util.h"
|
||||
#include "json_util.h"
|
||||
#include "nfs_proxy.h"
|
||||
#include "nfs_kv.h"
|
||||
#include "nfs_block.h"
|
||||
|
||||
@@ -55,10 +55,3 @@ json11::Json::object osd_messenger_t::merge_configs(const json11::Json::object &
|
||||
{
|
||||
return cli_config;
|
||||
}
|
||||
|
||||
bool json_is_true(const json11::Json & val)
|
||||
{
|
||||
if (val.is_string())
|
||||
return val == "true" || val == "yes" || val == "1";
|
||||
return val.bool_value();
|
||||
}
|
||||
|
||||
@@ -15,3 +15,21 @@ std::map<std::string, std::string> json_to_string_map(const json11::Json::object
|
||||
}
|
||||
return bs;
|
||||
}
|
||||
|
||||
bool json_is_true(const json11::Json & val)
|
||||
{
|
||||
if (val.is_string())
|
||||
return val == "true" || val == "yes" || val == "1";
|
||||
return val.bool_value();
|
||||
}
|
||||
|
||||
bool json_is_false(const json11::Json & val)
|
||||
{
|
||||
if (val.is_string())
|
||||
return val.string_value() == "false" || val.string_value() == "no" || val.string_value() == "0";
|
||||
if (val.is_number())
|
||||
return val.number_value() == 0;
|
||||
if (val.is_bool())
|
||||
return !val.bool_value();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9,3 +9,5 @@
|
||||
#include "json11/json11.hpp"
|
||||
|
||||
std::map<std::string, std::string> json_to_string_map(const json11::Json::object & config);
|
||||
bool json_is_true(const json11::Json & val);
|
||||
bool json_is_false(const json11::Json & val);
|
||||
|
||||
Reference in New Issue
Block a user