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

index 9e6ae14ab7fe3fd3160feccf587b72890a38c3eb..d72f434c2f2c035d72ca5bec3c187a95beeebefe 100644 (file)
@@ -36,7 +36,8 @@ libkea_yang_include_HEADERS = \
        translator_database.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 2d3fc6b2679d24589ca0089b2dd5e18e2438331f..d575b08072a5bddf76a273ae1b6c98d728120045 100644 (file)
@@ -7,6 +7,7 @@
 #include <config.h>
 
 #include <yang/translator_database.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 database can be properly
 // translated from YANG to JSON.
 TEST_F(TranslatorDatabaseTest, getEmpty) {
-    useModel("kea-dhcp4-server");
+    useModel(KEA_DHCP4_SERVER);
 
     // Get empty.
     const string& xpath = "/kea-dhcp4-server:config/lease-database";
@@ -49,7 +50,7 @@ TEST_F(TranslatorDatabaseTest, getEmpty) {
 // This test verifies that a database can be properly
 // translated from YANG to JSON.
 TEST_F(TranslatorDatabaseTest, get) {
-    useModel("kea-dhcp4-server");
+    useModel(KEA_DHCP4_SERVER);
 
     // Set a value.
     const string& xpath = "/kea-dhcp4-server:config/lease-database";
@@ -79,7 +80,7 @@ TEST_F(TranslatorDatabaseTest, get) {
 // This test verifies that a database can be properly
 // translated from JSON to YANG.
 TEST_F(TranslatorDatabaseTest, set) {
-    useModel("kea-dhcp4-server");
+    useModel(KEA_DHCP4_SERVER);
 
     // Set a value.
     const string& xpath = "/kea-dhcp4-server:config/lease-database";
@@ -107,7 +108,7 @@ TEST_F(TranslatorDatabaseTest, set) {
 // This test verifies that an empty database can be properly
 // translated from JSON to YANG.
 TEST_F(TranslatorDatabaseTest, setEmpty) {
-    useModel("kea-dhcp4-server");
+    useModel(KEA_DHCP4_SERVER);
 
     // Set a value.
     const string& xpath = "/kea-dhcp4-server:config/lease-database";
@@ -146,7 +147,7 @@ public:
 // This test verifies that an empty database list can be properly
 // translated from YANG to JSON.
 TEST_F(TranslatorDatabasesTest, getEmpty) {
-    useModel("kea-dhcp6-server");
+    useModel(KEA_DHCP6_SERVER);
 
     // Get empty.
     const string& xpath = "/kea-dhcp6-server:config/hosts-databases";
@@ -158,7 +159,7 @@ TEST_F(TranslatorDatabasesTest, getEmpty) {
 // This test verifies that a database list can be properly
 // translated from YANG to JSON.
 TEST_F(TranslatorDatabasesTest, get) {
-    useModel("kea-dhcp4-server");
+    useModel(KEA_DHCP4_SERVER);
 
     // Set a value.
     const string& xpath = "/kea-dhcp4-server:config/hosts-databases";
@@ -218,7 +219,7 @@ TEST_F(TranslatorDatabasesTest, get) {
 // This test verifies that a database list can be properly
 // translated from JSON to YANG.
 TEST_F(TranslatorDatabasesTest, set) {
-    useModel("kea-dhcp6-server");
+    useModel(KEA_DHCP6_SERVER);
 
     // Set a value.
     const string& xpath = "/kea-dhcp6-server:config/hosts-databases";
@@ -255,7 +256,7 @@ TEST_F(TranslatorDatabasesTest, set) {
 // This test verifies that an emptied database list can be properly
 // translated from JSON to YANG.
 TEST_F(TranslatorDatabasesTest, setEmpty) {
-    useModel("kea-dhcp4-server");
+    useModel(KEA_DHCP4_SERVER);
 
     // Set a value.
     const string& xpath = "/kea-dhcp4-server:config/hosts-databases";
@@ -290,7 +291,7 @@ TEST_F(TranslatorDatabasesTest, setEmpty) {
 // This test verifies that an empty database list can be properly
 // translated from JSON to YANG.
 TEST_F(TranslatorDatabasesTest, setEmpties) {
-    useModel("kea-dhcp4-server");
+    useModel(KEA_DHCP4_SERVER);
 
     // Set a value.
     const string& xpath = "/kea-dhcp4-server:config/hosts-databases";
index 1fdc8d7bc420748e7c87a5777ec8122917a12c37..2ceaa4e39d3e74ff228d29a72488e20b8f1b3410 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <yang/translator_database.h>
 #include <yang/adaptor.h>
+#include <yang/yang_models.h>
 #include <sstream>
 
 using namespace std;
@@ -24,8 +25,8 @@ TranslatorDatabase::~TranslatorDatabase() {
 ElementPtr
 TranslatorDatabase::getDatabase(const string& xpath) {
     try {
-        if ((model_ == "kea-dhcp4-server") ||
-            (model_ == "kea-dhcp6-server")) {
+        if ((model_ == KEA_DHCP4_SERVER) ||
+            (model_ == KEA_DHCP6_SERVER)) {
             return (getDatabaseKea(xpath));
         }
     } catch (const sysrepo_exception& ex) {
@@ -121,8 +122,8 @@ TranslatorDatabase::setDatabase(const string& xpath,
                                 ConstElementPtr elem,
                                 bool skip) {
     try {
-        if ((model_ == "kea-dhcp4-server") ||
-            (model_ == "kea-dhcp6-server")) {
+        if ((model_ == KEA_DHCP4_SERVER) ||
+            (model_ == KEA_DHCP6_SERVER)) {
             setDatabaseKea(xpath, elem, skip);
         } else {
             isc_throw(NotImplemented,
@@ -235,8 +236,8 @@ TranslatorDatabases::~TranslatorDatabases() {
 ConstElementPtr
 TranslatorDatabases::getDatabases(const string& xpath) {
     try {
-        if ((model_ == "kea-dhcp4-server") ||
-            (model_ == "kea-dhcp6-server")) {
+        if ((model_ == KEA_DHCP4_SERVER) ||
+            (model_ == KEA_DHCP6_SERVER)) {
             return (getDatabasesKea(xpath));
         }
     } catch (const sysrepo_exception& ex) {
@@ -273,8 +274,8 @@ TranslatorDatabases::getDatabasesKea(const string& xpath) {
 void
 TranslatorDatabases::setDatabases(const string& xpath, ConstElementPtr elem) {
     try {
-        if ((model_ == "kea-dhcp4-server") ||
-            (model_ == "kea-dhcp6-server")) {
+        if ((model_ == KEA_DHCP4_SERVER) ||
+            (model_ == KEA_DHCP6_SERVER)) {
             setDatabasesKea(xpath, elem);
         } else {
             isc_throw(NotImplemented,