From: Francis Dupont Date: Fri, 19 Oct 2018 22:10:53 +0000 (+0200) Subject: [65-libyang-class] Fixed rebased errors X-Git-Tag: 65-libyang-shared-network-translator_base~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8354fff55b8c0b9e6af47d9e6e1d950b3f816eaf;p=thirdparty%2Fkea.git [65-libyang-class] Fixed rebased errors --- diff --git a/src/lib/yang/tests/translator_class_unittests.cc b/src/lib/yang/tests/translator_class_unittests.cc index 3b2a218331..d6eea31ffd 100644 --- a/src/lib/yang/tests/translator_class_unittests.cc +++ b/src/lib/yang/tests/translator_class_unittests.cc @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -38,7 +39,7 @@ public: // This test verifies that an empty client class list can be properly // translated from YANG to JSON. TEST_F(TranslatorClassesTest, getEmpty) { - useModel("kea-dhcp4-server"); + useModel(KEA_DHCP4_SERVER); // Get the client class list and checks it is empty. const string& xpath = "/kea-dhcp4-server:config/client-classes"; @@ -50,7 +51,7 @@ TEST_F(TranslatorClassesTest, getEmpty) { // This test verifies that one client class can be properly translated // from YANG to JSON. TEST_F(TranslatorClassesTest, get) { - useModel("kea-dhcp6-server"); + useModel(KEA_DHCP6_SERVER); // Create the client class. const string& xpath = "/kea-dhcp6-server:config/client-classes"; @@ -80,7 +81,7 @@ TEST_F(TranslatorClassesTest, get) { // This test verifies that an empty client class list can be properly // translated from JSON to YANG. TEST_F(TranslatorClassesTest, setEmpty) { - useModel("kea-dhcp4-server"); + useModel(KEA_DHCP4_SERVER); // Set empty list. const string& xpath = "/kea-dhcp4-server:config/client-classes"; @@ -101,7 +102,7 @@ TEST_F(TranslatorClassesTest, setEmpty) { // This test verifies that one client class can be properly translated // from JSON to YANG. TEST_F(TranslatorClassesTest, set) { - useModel("kea-dhcp6-server"); + useModel(KEA_DHCP6_SERVER); // Set one client class. const string& xpath = "/kea-dhcp6-server:config/client-classes"; diff --git a/src/lib/yang/translator_class.cc b/src/lib/yang/translator_class.cc index 265d8e1fd6..de0ec9a8ad 100644 --- a/src/lib/yang/translator_class.cc +++ b/src/lib/yang/translator_class.cc @@ -6,6 +6,7 @@ #include #include +#include #include using namespace std; @@ -29,8 +30,8 @@ TranslatorClass::~TranslatorClass() { ElementPtr TranslatorClass::getClass(const string& xpath) { try { - if ((model_ == "kea-dhcp4-server") || - (model_ == "kea-dhcp6-server")) { + if ((model_ == KEA_DHCP4_SERVER) || + (model_ == KEA_DHCP6_SERVER)) { return (getClassKea(xpath)); } } catch (const sysrepo_exception& ex) { @@ -63,7 +64,7 @@ TranslatorClass::getClassKea(const string& xpath) { if (options && (options->size() > 0)) { result->set("option-data", options); } - if (model_ == "kea-dhcp4-server") { + if (model_ == KEA_DHCP4_SERVER) { ConstElementPtr defs = getOptionDefList(xpath +"/option-def-list"); if (defs && (defs->size() > 0)) { result->set("option-def", defs); @@ -91,8 +92,8 @@ TranslatorClass::getClassKea(const string& xpath) { void TranslatorClass::setClass(const string& xpath, ConstElementPtr elem) { try { - if ((model_ == "kea-dhcp4-server") || - (model_ == "kea-dhcp6-server")) { + if ((model_ == KEA_DHCP4_SERVER) || + (model_ == KEA_DHCP6_SERVER)) { setClassKea(xpath, elem); } else { isc_throw(NotImplemented, @@ -124,7 +125,7 @@ TranslatorClass::setClassKea(const string& xpath, ConstElementPtr elem) { setOptionDataList(xpath + "/option-data-list", options); created = true; } - if (model_ == "kea-dhcp4-server") { + if (model_ == KEA_DHCP4_SERVER) { ConstElementPtr defs = elem->get("option-def"); if (defs) { setOptionDefList(xpath + "/option-def-list", defs); @@ -175,8 +176,8 @@ TranslatorClasses::~TranslatorClasses() { ConstElementPtr TranslatorClasses::getClasses(const string& xpath) { try { - if ((model_ == "kea-dhcp4-server") || - (model_ == "kea-dhcp6-server")) { + if ((model_ == KEA_DHCP4_SERVER) || + (model_ == KEA_DHCP6_SERVER)) { return (getClassesKea(xpath)); } } catch (const sysrepo_exception& ex) { @@ -213,8 +214,8 @@ TranslatorClasses::getClassesKea(const string& xpath) { void TranslatorClasses::setClasses(const string& xpath, ConstElementPtr elem) { try { - if ((model_ == "kea-dhcp4-server") || - (model_ == "kea-dhcp6-server")) { + if ((model_ == KEA_DHCP4_SERVER) || + (model_ == KEA_DHCP6_SERVER)) { setClassesKea(xpath, elem); } else { isc_throw(NotImplemented,