// Add the ha servers info to arguments.
ElementPtr mutable_resp_args =
boost::const_pointer_cast<Element>(resp_args);
+
+ /// @todo Today we support only one HA relationship per Kea server.
+ /// In the future there will be more of them. Therefore we enclose
+ /// our sole relationship in a list.
+ auto ha_relationships = Element::createList();
+ auto ha_relationship = Element::createMap();
ConstElementPtr ha_servers = service_->processStatusGet();
- mutable_resp_args->set("ha-servers", ha_servers);
- mutable_resp_args->set("ha-mode", Element::create(HAConfig::HAModeToString(config_->getHAMode())));
+ ha_relationship->set("ha-servers", ha_servers);
+ ha_relationship->set("ha-mode", Element::create(HAConfig::HAModeToString(config_->getHAMode())));
+ ha_relationships->add(ha_relationship);
+ mutable_resp_args->set("high-availability", ha_relationships);
}
}
std::string expected =
"{"
" \"arguments\": {"
- " \"ha-mode\": \"load-balancing\","
- " \"ha-servers\": {"
- " \"local\": {"
- " \"role\": \"primary\","
- " \"scopes\": [ ],"
- " \"state\": \"waiting\""
- " },"
- " \"remote\": {"
- " \"age\": 0,"
- " \"in-touch\": false,"
- " \"last-scopes\": [ ],"
- " \"last-state\": \"\","
- " \"role\": \"secondary\","
- " \"communication-interrupted\": false,"
- " \"connecting-clients\": 0,"
- " \"unacked-clients\": 0,"
- " \"unacked-clients-left\": 0,"
- " \"analyzed-packets\": 0"
+ " \"high-availability\": ["
+ " {"
+ " \"ha-mode\": \"load-balancing\","
+ " \"ha-servers\": {"
+ " \"local\": {"
+ " \"role\": \"primary\","
+ " \"scopes\": [ ],"
+ " \"state\": \"waiting\""
+ " },"
+ " \"remote\": {"
+ " \"age\": 0,"
+ " \"in-touch\": false,"
+ " \"last-scopes\": [ ],"
+ " \"last-state\": \"\","
+ " \"role\": \"secondary\","
+ " \"communication-interrupted\": false,"
+ " \"connecting-clients\": 0,"
+ " \"unacked-clients\": 0,"
+ " \"unacked-clients-left\": 0,"
+ " \"analyzed-packets\": 0"
+ " }"
+ " }"
" }"
- " },"
+ " ],"
" \"pid\": 1"
" },"
" \"result\": 0"
std::string expected =
"{"
" \"arguments\": {"
- " \"ha-mode\": \"load-balancing\","
- " \"ha-servers\": {"
- " \"local\": {"
- " \"role\": \"backup\","
- " \"scopes\": [ ],"
- " \"state\": \"backup\""
+ " \"high-availability\": ["
+ " {"
+ " \"ha-mode\": \"load-balancing\","
+ " \"ha-servers\": {"
+ " \"local\": {"
+ " \"role\": \"backup\","
+ " \"scopes\": [ ],"
+ " \"state\": \"backup\""
+ " }"
+ " }"
" }"
- " },"
+ " ],"
" \"pid\": 1"
" },"
" \"result\": 0"
std::string expected =
"{"
" \"arguments\": {"
- " \"ha-mode\": \"passive-backup\","
- " \"ha-servers\": {"
- " \"local\": {"
- " \"role\": \"primary\","
- " \"scopes\": [ \"server1\" ],"
- " \"state\": \"passive-backup\""
+ " \"high-availability\": ["
+ " {"
+ " \"ha-mode\": \"passive-backup\","
+ " \"ha-servers\": {"
+ " \"local\": {"
+ " \"role\": \"primary\","
+ " \"scopes\": [ \"server1\" ],"
+ " \"state\": \"passive-backup\""
+ " }"
+ " }"
" }"
- " },"
+ " ],"
" \"pid\": 1"
" },"
" \"result\": 0"