From: Francis Dupont Date: Sat, 6 Oct 2018 10:26:25 +0000 (+0200) Subject: [65-libyang-control-socket_rebased] Updated after pool merge X-Git-Tag: 165-netbsd-8-fixes_base^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5f91f0a3eefe677a156b5a2070d11bf79e177e3;p=thirdparty%2Fkea.git [65-libyang-control-socket_rebased] Updated after pool merge --- diff --git a/src/lib/yang/Makefile.am b/src/lib/yang/Makefile.am index dd3ebb1f43..5078360b70 100644 --- a/src/lib/yang/Makefile.am +++ b/src/lib/yang/Makefile.am @@ -36,7 +36,8 @@ libkea_yang_include_HEADERS = \ translator_control_socket.h \ translator_option_data.h \ translator_option_def.h \ - translator_pool.h + translator_pool.h \ + yang_models.h EXTRA_DIST = yang.dox # Distribute yang models. diff --git a/src/lib/yang/tests/translator_control_socket_unittests.cc b/src/lib/yang/tests/translator_control_socket_unittests.cc index 24fad8bff5..9889cc7487 100644 --- a/src/lib/yang/tests/translator_control_socket_unittests.cc +++ b/src/lib/yang/tests/translator_control_socket_unittests.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -37,7 +38,7 @@ public: // This test verifies that an empty control socket can be properly // translated from YANG to JSON. TEST_F(TranslatorControlSocketTest, getEmpty) { - useModel("kea-dhcp4-server"); + useModel(KEA_DHCP4_SERVER); // Get empty. const string& xpath = "/kea-dhcp4-server:config/control-socket"; @@ -45,11 +46,11 @@ TEST_F(TranslatorControlSocketTest, getEmpty) { EXPECT_NO_THROW(sock = t_obj_->getControlSocket(xpath)); EXPECT_FALSE(sock); } - + // This test verifies that a not empty control socket can be properly // translated from YANG to JSON. TEST_F(TranslatorControlSocketTest, get) { - useModel("kea-dhcp6-server"); + useModel(KEA_DHCP6_SERVER); // Set a value. const string& xpath = "/kea-dhcp6-server:config/control-socket"; @@ -85,7 +86,7 @@ TEST_F(TranslatorControlSocketTest, get) { // This test verifies that a not empty control socket can be properly // translated from JSON to YANG. TEST_F(TranslatorControlSocketTest, set) { - useModel("kea-ctrl-agent"); + useModel(KEA_CTRL_AGENT); // Set a value. const string& xpath = @@ -126,7 +127,7 @@ TEST_F(TranslatorControlSocketTest, set) { // This test verifies that an empty control socket can be properly // translated from JSON to YANG. TEST_F(TranslatorControlSocketTest, setEmpty) { - useModel("kea-dhcp4-server"); + useModel(KEA_DHCP4_SERVER); // Set a value. const string& xpath = "/kea-dhcp4-server:config/control-socket"; diff --git a/src/lib/yang/translator_control_socket.cc b/src/lib/yang/translator_control_socket.cc index 84f4bfb7b7..d4a1aba5d3 100644 --- a/src/lib/yang/translator_control_socket.cc +++ b/src/lib/yang/translator_control_socket.cc @@ -6,6 +6,7 @@ #include #include +#include #include using namespace std; @@ -25,10 +26,10 @@ TranslatorControlSocket::~TranslatorControlSocket() { ConstElementPtr TranslatorControlSocket::getControlSocket(const string& xpath) { try { - if ((model_ == "kea-dhcp4-server") || - (model_ == "kea-dhcp6-server") || - (model_ == "kea-dhcp-ddns") || - (model_ == "kea-ctrl-agent")) { + if ((model_ == KEA_DHCP4_SERVER) || + (model_ == KEA_DHCP6_SERVER) || + (model_ == KEA_DHCP_DDNS) || + (model_ == KEA_CTRL_AGENT)) { return (getControlSocketKea(xpath)); } } catch (const sysrepo_exception& ex) { @@ -62,10 +63,10 @@ void TranslatorControlSocket::setControlSocket(const string& xpath, ConstElementPtr elem) { try { - if ((model_ == "kea-dhcp4-server") || - (model_ == "kea-dhcp6-server") || - (model_ == "kea-dhcp-ddns") || - (model_ == "kea-ctrl-agent")) { + if ((model_ == KEA_DHCP4_SERVER) || + (model_ == KEA_DHCP6_SERVER) || + (model_ == KEA_DHCP_DDNS) || + (model_ == KEA_CTRL_AGENT)) { setControlSocketKea(xpath, elem); } else { isc_throw(NotImplemented,