]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[65-libyang-control-socket_rebased] Updated after pool merge
authorFrancis Dupont <fdupont@isc.org>
Sat, 6 Oct 2018 10:26:25 +0000 (12:26 +0200)
committerFrancis Dupont <fdupont@isc.org>
Sat, 6 Oct 2018 10:26:25 +0000 (12:26 +0200)
src/lib/yang/Makefile.am
src/lib/yang/tests/translator_control_socket_unittests.cc
src/lib/yang/translator_control_socket.cc

index dd3ebb1f43a467419492dbb6578049221137b7f4..5078360b70707276595afe2dde3ff5c37fd585c1 100644 (file)
@@ -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.
index 24fad8bff57e375d8c33dd4ef5dda7299b54c41a..9889cc7487df142401f8865bc0c3c07e2463d68a 100644 (file)
@@ -7,6 +7,7 @@
 #include <config.h>
 
 #include <yang/translator_control_socket.h>
+#include <yang/yang_models.h>
 #include <yang/tests/sysrepo_setup.h>
 
 #include <gtest/gtest.h>
@@ -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";
index 84f4bfb7b7e32e7fec1807a0af3686000646c3da..d4a1aba5d3ffe9076ebd2689067192b0d81ccb85 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <yang/translator_control_socket.h>
 #include <yang/adaptor.h>
+#include <yang/yang_models.h>
 #include <sstream>
 
 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,