|
|
|
@ -5,25 +5,25 @@ std::vector<sk::host> sk::config::loadHostsFromToml(const fs::path& confFile) {
|
|
|
|
|
std::vector<sk::host> hosts;
|
|
|
|
|
|
|
|
|
|
auto config = toml::parse_file( confFile.string() );
|
|
|
|
|
toml::table *server_section = config.get_as<toml::table>("serveurs");
|
|
|
|
|
if (server_section == nullptr) {
|
|
|
|
|
toml::table *serverSection = config.get_as<toml::table>("serveurs");
|
|
|
|
|
if (serverSection == nullptr) {
|
|
|
|
|
return hosts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Parcourir les serveurs
|
|
|
|
|
for (const auto& [server_name_key, server_info_value] : *server_section) {
|
|
|
|
|
std::string server_name{server_name_key};
|
|
|
|
|
toml::table *server_info_ptr = server_info_value.as_table();
|
|
|
|
|
if (server_info_ptr == nullptr) {
|
|
|
|
|
for (const auto& [serverNameKey, serverInfoValue] : *serverSection) {
|
|
|
|
|
std::string serverName{serverNameKey};
|
|
|
|
|
toml::table *serverInfoPtr = serverInfoValue.as_table();
|
|
|
|
|
if (serverInfoPtr == nullptr) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
toml::table &server_info = *server_info_ptr;
|
|
|
|
|
toml::table &serverInfo = *serverInfoPtr;
|
|
|
|
|
|
|
|
|
|
if(server_info.get_as<std::string>("ip") && server_info.get_as<int64_t>("nbContainerMax")){
|
|
|
|
|
std::string server_ip = server_info.get_as<std::string>("ip")->get();
|
|
|
|
|
int server_max_containers = server_info.get_as<int64_t>("nbContainerMax")->get();
|
|
|
|
|
if(serverInfo.get_as<std::string>("ip") && serverInfo.get_as<int64_t>("nbContainerMax")){
|
|
|
|
|
std::string serverIp = serverInfo.get_as<std::string>("ip")->get();
|
|
|
|
|
int serverMaxContainers = serverInfo.get_as<int64_t>("nbContainerMax")->get();
|
|
|
|
|
|
|
|
|
|
hosts.push_back(sk::host(server_ip,server_max_containers));
|
|
|
|
|
hosts.push_back(sk::host(serverIp,serverMaxContainers));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|