mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 05:27:55 +00:00
[#2601] address review comments
* make all-keys.json loadable by Kea again * formatting * EXPECT_NO_THROW -> EXPECT_NO_THROW_LOG * add missing YANG tests for i64 and ui64 * memmove -> memcpy * fix doxygen comments * make checking of empty containers consistent when retrieving YANG data * remove unnecessary setting of v6 YANG nodes for v4 modules * fix hash of keatest-module.yang
This commit is contained in:
parent
dd2dbd5be0
commit
d67f8aca89
@ -83,7 +83,6 @@
|
||||
// class when the given expression evaluates to true.
|
||||
"test": "member('HA_server2')"
|
||||
},
|
||||
|
||||
{
|
||||
// Third class name.
|
||||
"name": "late",
|
||||
@ -96,10 +95,15 @@
|
||||
"only-if-required": true,
|
||||
|
||||
// Class selection expression.
|
||||
"test": "member('ALL')",
|
||||
"test": "member('ALL')"
|
||||
},
|
||||
{
|
||||
// Fourth class name.
|
||||
"name": "my-template-class",
|
||||
|
||||
// Template class flag.
|
||||
"template-test": ""
|
||||
// Template class flag that holds the expression used to generate the names for all
|
||||
// the spawned subclasses. In this case, the classes are named after the client ID.
|
||||
"template-test": "substring(option[1].hex, 0, all)"
|
||||
}
|
||||
],
|
||||
|
||||
|
@ -83,7 +83,6 @@
|
||||
// class when the given expression evaluates to true.
|
||||
"test": "member('HA_server2')"
|
||||
},
|
||||
|
||||
{
|
||||
// Third class name.
|
||||
"name": "late",
|
||||
@ -96,10 +95,15 @@
|
||||
"only-if-required": true,
|
||||
|
||||
// Class selection expression.
|
||||
"test": "member('ALL')",
|
||||
"test": "member('ALL')"
|
||||
},
|
||||
{
|
||||
// Fourth class name.
|
||||
"name": "my-template-class",
|
||||
|
||||
// Template class flag.
|
||||
"template-test": ""
|
||||
// Template class flag that holds the expression used to generate the names for all
|
||||
// the spawned subclasses. In this case, the classes are named after the client ID.
|
||||
"template-test": "substring(option[61].hex, 0, all)"
|
||||
}
|
||||
],
|
||||
|
||||
|
@ -65,10 +65,15 @@
|
||||
"only-if-required": true,
|
||||
|
||||
// Class selection expression.
|
||||
"test": "member('ALL')",
|
||||
"test": "member('ALL')"
|
||||
},
|
||||
{
|
||||
// Fourth class name.
|
||||
"name": "my-template-class",
|
||||
|
||||
// Template class flag.
|
||||
"template-test": ""
|
||||
// Template class flag that holds the expression used to generate the names for all
|
||||
// the spawned subclasses. In this case, the classes are named after the client ID.
|
||||
"template-test": "substring(option[1].hex, 0, all)"
|
||||
}
|
||||
],
|
||||
|
||||
|
@ -65,10 +65,15 @@
|
||||
"only-if-required": true,
|
||||
|
||||
// Class selection expression.
|
||||
"test": "member('ALL')",
|
||||
"test": "member('ALL')"
|
||||
},
|
||||
{
|
||||
// Fourth class name.
|
||||
"name": "my-template-class",
|
||||
|
||||
// Template class flag.
|
||||
"template-test": ""
|
||||
// Template class flag that holds the expression used to generate the names for all
|
||||
// the spawned subclasses. In this case, the classes are named after the client ID.
|
||||
"template-test": "substring(option[1].hex, 0, all)"
|
||||
}
|
||||
],
|
||||
|
||||
|
@ -2907,6 +2907,7 @@ Dhcpv4SrvTest::checkConfigFiles() {
|
||||
vector<string> examples = {
|
||||
"advanced.json",
|
||||
#if defined (HAVE_MYSQL) && defined (HAVE_PGSQL)
|
||||
"all-keys.json",
|
||||
"all-keys-netconf.json",
|
||||
"all-options.json",
|
||||
#endif
|
||||
|
@ -292,6 +292,7 @@ Dhcpv6SrvTest::checkConfigFiles() {
|
||||
vector<string> examples = {
|
||||
"advanced.json",
|
||||
#if defined (HAVE_MYSQL) && defined (HAVE_PGSQL)
|
||||
"all-keys.json",
|
||||
"all-keys-netconf.json",
|
||||
"all-options.json",
|
||||
#endif
|
||||
|
@ -71,7 +71,6 @@ kea_netconf_LDADD += $(LIBYANGCPP_LIBS)
|
||||
kea_netconf_LDADD += $(SYSREPO_LIBS)
|
||||
kea_netconf_LDADD += $(SYSREPOCPP_LIBS)
|
||||
|
||||
|
||||
kea_netconfdir = $(pkgdatadir)
|
||||
|
||||
# If we want to get rid of all generated messages files, we need to use
|
||||
|
@ -463,7 +463,6 @@ NetconfAgent::subscribeToDataChanges(const CfgServersMapPair& service_pair) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
NetconfAgent::subscribeToNotifications(const CfgServersMapPair& service_pair) {
|
||||
string const& server(service_pair.first);
|
||||
|
@ -147,7 +147,6 @@ public:
|
||||
: ThreadedTest(), io_service_() {
|
||||
}
|
||||
|
||||
|
||||
void SetUp() override {
|
||||
SysrepoSetup::cleanSharedMemory();
|
||||
removeUnixSocketFile();
|
||||
@ -428,7 +427,7 @@ public:
|
||||
/// @brief Create a new request.
|
||||
///
|
||||
/// @return Pointer to the new instance of the HttpRequest.
|
||||
HttpRequestPtr createNewHttpRequest() const override final {
|
||||
HttpRequestPtr createNewHttpRequest() const override final {
|
||||
return (HttpRequestPtr(new PostHttpRequestJson()));
|
||||
}
|
||||
|
||||
|
@ -221,9 +221,9 @@ public:
|
||||
EXPECT_TRUE(executeConfiguration(config, "reset config"));
|
||||
}
|
||||
|
||||
unique_ptr<NakedNetconfCfgMgr> srv_; ///< Netconf server under test
|
||||
int rcode_; ///< Return code from element parsing
|
||||
ConstElementPtr comment_; ///< Reason for parse fail
|
||||
unique_ptr<NakedNetconfCfgMgr> srv_; ///< Netconf server under test
|
||||
int rcode_; ///< Return code from element parsing
|
||||
ConstElementPtr comment_; ///< Reason for parse fail
|
||||
}; // NetconfGetCfgTest
|
||||
|
||||
// Test a simple configuration.
|
||||
|
@ -363,7 +363,7 @@ TEST(NetconfParser, badSocketType) {
|
||||
ElementPtr json;
|
||||
ParserContext parser;
|
||||
EXPECT_NO_THROW_LOG(json = parser.parseString(NETCONF_CONFIGS[10],
|
||||
ParserContext::PARSER_JSON));
|
||||
ParserContext::PARSER_JSON));
|
||||
ConstElementPtr answer;
|
||||
NakedNetconfCfgMgr cfg_mgr;
|
||||
EXPECT_NO_THROW_LOG(answer = cfg_mgr.parse(json, false));
|
||||
|
@ -104,7 +104,6 @@ TEST_F(NetconfControllerTest, basicInstanceTesting) {
|
||||
EXPECT_FALSE(checkProcess());
|
||||
}
|
||||
|
||||
|
||||
// Tests basic command line processing.
|
||||
// Verifies that:
|
||||
// 1. Standard command line options are supported.
|
||||
|
@ -87,7 +87,6 @@ void clearYang(NakedNetconfAgentPtr agent) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Empirically the requested subnets have sometimes returned in decreasing
|
||||
// order of subnet ID. To avoid flaky test failures, sort them before
|
||||
// comparing.
|
||||
|
@ -280,7 +280,7 @@ protected:
|
||||
const std::string& space);
|
||||
}; // AdaptorConfig
|
||||
|
||||
} //namespace yang
|
||||
} // namespace yang
|
||||
} // namespace isc
|
||||
|
||||
#endif // ISC_ADAPTOR_CONFIG_H
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
static void quoteIdentifier(isc::data::ElementPtr host);
|
||||
}; // AdaptorHost
|
||||
|
||||
} //namespace yang
|
||||
} // namespace yang
|
||||
} // namespace isc
|
||||
|
||||
#endif // ISC_ADAPTOR_HOST_H
|
||||
|
@ -96,7 +96,7 @@ protected:
|
||||
size_t params_size);
|
||||
}; // AdaptorOption
|
||||
|
||||
} //namespace yang
|
||||
} // namespace yang
|
||||
} // namespace isc
|
||||
|
||||
#endif // ISC_ADAPTOR_OPTION_H
|
||||
|
@ -79,5 +79,5 @@ AdaptorPool::toSubnetIetf6(ElementPtr subnet, ConstElementPtr pools) {
|
||||
Adaptor::toParent("rebind-timer", subnet, pools);
|
||||
}
|
||||
|
||||
} //namespace yang
|
||||
} // namespace yang
|
||||
} // namespace isc
|
||||
|
@ -1,7 +1,3 @@
|
||||
|
||||
|
||||
|
||||
|
||||
CLEANFILES = *.gcno *.gcda
|
||||
|
||||
TESTS = sysrepo_setup_tests
|
||||
|
@ -23,7 +23,6 @@ using namespace isc::yang;
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
/// @brief Fixture class that helps testing AdaptorConfig
|
||||
class AdaptorConfigTest : public ::testing::Test {
|
||||
public:
|
||||
|
@ -188,7 +188,7 @@ struct ConfigTestKeaV4 : ConfigTest {
|
||||
ConfigTestKeaV4() {
|
||||
model_ = KEA_DHCP4_SERVER;
|
||||
}
|
||||
}; // ConfigTestKeav4
|
||||
}; // ConfigTestKeaV4
|
||||
struct ConfigTestKeaV6 : ConfigTest {
|
||||
ConfigTestKeaV6() {
|
||||
model_ = KEA_DHCP6_SERVER;
|
||||
|
@ -354,7 +354,7 @@ TEST_F(TranslatorTest, getItem) {
|
||||
EXPECT_FALSE(element);
|
||||
}
|
||||
|
||||
|
||||
// Check the Translator::deleteItem function.
|
||||
TEST_F(TranslatorTest, deleteItem) {
|
||||
ElementPtr got;
|
||||
string xpath;
|
||||
@ -363,31 +363,31 @@ TEST_F(TranslatorTest, deleteItem) {
|
||||
Translator translator(Connection{}.sessionStart(), "keatest-module");
|
||||
|
||||
// Missing schema node
|
||||
EXPECT_NO_THROW(translator.deleteItem("/keatest-module:main/no_such_node"));
|
||||
EXPECT_NO_THROW_LOG(translator.deleteItem("/keatest-module:main/no_such_node"));
|
||||
|
||||
// Existing schema node, but no data
|
||||
xpath = "/keatest-module:main/string";
|
||||
EXPECT_NO_THROW(translator.deleteItem(xpath));
|
||||
EXPECT_NO_THROW_LOG(translator.deleteItem(xpath));
|
||||
EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
|
||||
EXPECT_FALSE(got);
|
||||
got.reset();
|
||||
|
||||
// Existing schema node, existing data
|
||||
translator.setItem(xpath, Element::create("value"), LeafBaseType::String);
|
||||
EXPECT_NO_THROW(translator.deleteItem(xpath));
|
||||
EXPECT_NO_THROW_LOG(translator.deleteItem(xpath));
|
||||
EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
|
||||
EXPECT_FALSE(got);
|
||||
got.reset();
|
||||
|
||||
// Container schema node, no data
|
||||
EXPECT_NO_THROW(translator.deleteItem("/keatest-module:main"));
|
||||
EXPECT_NO_THROW_LOG(translator.deleteItem("/keatest-module:main"));
|
||||
EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
|
||||
EXPECT_FALSE(got);
|
||||
got.reset();
|
||||
|
||||
// Container schema node, existing data
|
||||
translator.setItem(xpath, Element::create("value"), LeafBaseType::String);
|
||||
EXPECT_NO_THROW(translator.deleteItem("/keatest-module:main"));
|
||||
EXPECT_NO_THROW_LOG(translator.deleteItem("/keatest-module:main"));
|
||||
EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
|
||||
EXPECT_FALSE(got);
|
||||
got.reset();
|
||||
@ -466,7 +466,7 @@ TEST_F(TranslatorTest, valueTo) {
|
||||
EXPECT_EQ(element->str(), value);
|
||||
element.reset();
|
||||
|
||||
// Signed 32 bit integer.
|
||||
// Signed 64 bit integer.
|
||||
element = Element::create(int64_t(-1234567890123456));
|
||||
EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Int64));
|
||||
EXPECT_EQ("-1234567890123456", value);
|
||||
@ -822,8 +822,7 @@ TEST_F(TranslatorTest, container) {
|
||||
Translator translator(Connection{}.sessionStart(), "keatest-module");
|
||||
|
||||
// Container with no data apparently throws.
|
||||
EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container"),
|
||||
NotImplemented,
|
||||
EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), NotImplemented,
|
||||
"getting node of type 1 not supported, xpath is '/keatest-module:container'");
|
||||
EXPECT_FALSE(element);
|
||||
element.reset();
|
||||
@ -839,13 +838,12 @@ TEST_F(TranslatorTest, container) {
|
||||
element, LeafBaseType::String));
|
||||
element.reset();
|
||||
EXPECT_THROW_MSG(
|
||||
element = translator.getItemFromAbsoluteXpath("/keatest-module:container"),
|
||||
NotImplemented,
|
||||
element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), NotImplemented,
|
||||
"getting node of type 1 not supported, xpath is '/keatest-module:container'");
|
||||
EXPECT_FALSE(element);
|
||||
element.reset();
|
||||
EXPECT_NO_THROW_LOG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container[key1="
|
||||
"'key1'][key2='key2']"));
|
||||
EXPECT_NO_THROW_LOG(
|
||||
element = translator.getItemFromAbsoluteXpath("/keatest-module:container[key1='key1'][key2='key2']"));
|
||||
EXPECT_FALSE(element);
|
||||
}
|
||||
|
||||
@ -869,14 +867,12 @@ TEST_F(TranslatorTest, list) {
|
||||
LeafBaseType::String));
|
||||
element.reset();
|
||||
EXPECT_THROW_MSG(
|
||||
element = translator.getItemFromAbsoluteXpath("/keatest-module:container/list"),
|
||||
NotImplemented,
|
||||
element = translator.getItemFromAbsoluteXpath("/keatest-module:container/list"), NotImplemented,
|
||||
"getting node of type 16 not supported, xpath is '/keatest-module:container/list'");
|
||||
EXPECT_FALSE(element);
|
||||
element.reset();
|
||||
EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath(
|
||||
"/keatest-module:container/list[key1='key1'][key2='key2']"),
|
||||
NotImplemented,
|
||||
"/keatest-module:container/list[key1='key1'][key2='key2']"), NotImplemented,
|
||||
"getting node of type 16 not supported, xpath is "
|
||||
"'/keatest-module:container/list[key1='key1'][key2='key2']'");
|
||||
EXPECT_FALSE(element);
|
||||
|
@ -112,6 +112,12 @@ TEST(YangReprTest, getTest) {
|
||||
EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
|
||||
EXPECT_NO_THROW_LOG(sess.applyChanges());
|
||||
|
||||
xpath = "/keatest-module:main/ui64";
|
||||
uint32_t u64(64);
|
||||
value = to_string(u64);
|
||||
EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
|
||||
EXPECT_NO_THROW_LOG(sess.applyChanges());
|
||||
|
||||
xpath = "/keatest-module:main/i8";
|
||||
int8_t s8(8);
|
||||
value = to_string(s8);
|
||||
@ -130,6 +136,12 @@ TEST(YangReprTest, getTest) {
|
||||
EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
|
||||
EXPECT_NO_THROW_LOG(sess.applyChanges());
|
||||
|
||||
xpath = "/keatest-module:main/i64";
|
||||
int32_t s64(64);
|
||||
value = to_string(s64);
|
||||
EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
|
||||
EXPECT_NO_THROW_LOG(sess.applyChanges());
|
||||
|
||||
xpath = "/keatest-module:main/id_ref";
|
||||
value = "keatest-module:id_1";
|
||||
EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
|
||||
|
@ -33,12 +33,16 @@ const YRTree testTree = YangRepr::buildTreeFromVector({
|
||||
"16", libyang::LeafBaseType::Uint16, true },
|
||||
{ "/keatest-module:main/ui32",
|
||||
"32", libyang::LeafBaseType::Uint32, true },
|
||||
{ "/keatest-module:main/ui64",
|
||||
"64", libyang::LeafBaseType::Uint64, true },
|
||||
{ "/keatest-module:main/i8",
|
||||
"8", libyang::LeafBaseType::Int8, true },
|
||||
{ "/keatest-module:main/i16",
|
||||
"16", libyang::LeafBaseType::Int16, true },
|
||||
{ "/keatest-module:main/i32",
|
||||
"32", libyang::LeafBaseType::Int32, true },
|
||||
{ "/keatest-module:main/i64",
|
||||
"64", libyang::LeafBaseType::Int64, true },
|
||||
{ "/keatest-module:main/id_ref",
|
||||
"keatest-module:id_1", libyang::LeafBaseType::IdentityRef, true },
|
||||
{ "/keatest-module:main/enum",
|
||||
|
@ -99,12 +99,10 @@ YangRepr::YangReprItem::get(const string& xpath, Session session) {
|
||||
// Get the underlying type.
|
||||
type = data_node->schema().asLeaf().valueType().asLeafRef().resolvedType().base();
|
||||
}
|
||||
value = Translator::translateToYang(Translator::translateFromYang(data_node),
|
||||
type);
|
||||
value = Translator::translateToYang(Translator::translateFromYang(data_node), type);
|
||||
val_xpath = string(data_node->path());
|
||||
} catch (Error const& ex) {
|
||||
isc_throw(NetconfError,
|
||||
"in YangReprItem: " << ex.what());
|
||||
isc_throw(NetconfError, "in YangReprItem: " << ex.what());
|
||||
}
|
||||
return (YangReprItem(val_xpath, value, type, settable));
|
||||
}
|
||||
|
@ -59,17 +59,6 @@ Translator::checkAndGetAndJsonifyLeaf(ElementPtr& storage,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Translator::checkAndStringifyAndSetLeaf(ConstElementPtr const& from,
|
||||
string const& xpath,
|
||||
string const& name) {
|
||||
ConstElementPtr const& x(from->get(name));
|
||||
if (x) {
|
||||
ElementPtr const& json(Element::create(x->str()));
|
||||
setItem(xpath + "/" + name, json, LeafBaseType::String);
|
||||
}
|
||||
}
|
||||
|
||||
void Translator::checkAndSetLeaf(ConstElementPtr const& from,
|
||||
string const& xpath,
|
||||
string const& name,
|
||||
@ -113,8 +102,18 @@ void Translator::checkAndSetUserContext(ConstElementPtr const& from,
|
||||
}
|
||||
|
||||
void
|
||||
Translator::deleteItem(string const& xpath) {
|
||||
Translator::checkAndStringifyAndSetLeaf(ConstElementPtr const& from,
|
||||
string const& xpath,
|
||||
string const& name) {
|
||||
ConstElementPtr const& x(from->get(name));
|
||||
if (x) {
|
||||
ElementPtr const& json(Element::create(x->str()));
|
||||
setItem(xpath + "/" + name, json, LeafBaseType::String);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Translator::deleteItem(string const& xpath) {
|
||||
try {
|
||||
if (session_.getData(xpath)) {
|
||||
session_.deleteItem(xpath);
|
||||
@ -201,7 +200,6 @@ Translator::getMandatoryLeaf(ElementPtr& storage,
|
||||
storage->set(name, x);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Translator::getMandatoryDivergingLeaf(ElementPtr& storage,
|
||||
DataNode const& data_node,
|
||||
@ -310,7 +308,7 @@ Translator::decode64(string const& input) {
|
||||
decodeBase64(input, binary);
|
||||
string result;
|
||||
result.resize(binary.size());
|
||||
memmove(&result[0], &binary[0], result.size());
|
||||
memcpy(&result[0], &binary[0], result.size());
|
||||
return (result);
|
||||
}
|
||||
|
||||
@ -318,7 +316,7 @@ string
|
||||
Translator::encode64(string const& input) {
|
||||
vector<uint8_t> binary;
|
||||
binary.resize(input.size());
|
||||
memmove(&binary[0], input.c_str(), binary.size());
|
||||
memcpy(&binary[0], input.c_str(), binary.size());
|
||||
return (encodeBase64(binary));
|
||||
}
|
||||
|
||||
|
@ -119,19 +119,8 @@ public:
|
||||
///
|
||||
/// @param from the parent configuration node from which to take the value
|
||||
/// @param xpath the xpath to the YANG node without the last node
|
||||
/// @param name the name of the YANG node which should also match the map
|
||||
/// key in the JSON configuration
|
||||
void checkAndStringifyAndSetLeaf(isc::data::ConstElementPtr const& from,
|
||||
std::string const& xpath,
|
||||
std::string const& name);
|
||||
|
||||
/// @brief Get an element from given ElementPtr node and set it in sysrepo
|
||||
/// at given xpath.
|
||||
///
|
||||
/// @param from the parent configuration node from which to take the value
|
||||
/// @param xpath the xpath to the YANG node without the last node
|
||||
/// @param name the name of the YANG node which should also match the map
|
||||
/// key in the JSON configuration
|
||||
/// @param name the name of the YANG node which should also match the key
|
||||
/// under which data is set in the MapElement {from}
|
||||
/// @param type the YANG node type
|
||||
void checkAndSetLeaf(isc::data::ConstElementPtr const& from,
|
||||
std::string const& xpath,
|
||||
@ -146,8 +135,8 @@ public:
|
||||
///
|
||||
/// @param from the parent configuration node from which to take the value
|
||||
/// @param xpath the xpath to the YANG node without the last node
|
||||
/// @param name the name of the parameter to be set in storage
|
||||
/// @param yang_name the name by which to find the parameter in the YANG data node
|
||||
/// @param name the key under which data is set in the MapElement {from}
|
||||
/// @param yang_name the name of the YANG node
|
||||
/// @param type the YANG node type
|
||||
void checkAndSetDivergingLeaf(isc::data::ConstElementPtr const& from,
|
||||
std::string const& xpath,
|
||||
@ -160,7 +149,8 @@ public:
|
||||
///
|
||||
/// @param from the parent configuration node from which to take the values
|
||||
/// @param xpath the xpath to the YANG node without the last node
|
||||
/// @param name the name of the parameter to be set in storage
|
||||
/// @param name the name of the YANG node which should also match the key
|
||||
/// under which data is set in the MapElement {from}
|
||||
/// @param type the YANG node type of the underlying leaf-list nodes
|
||||
void checkAndSetLeafList(isc::data::ConstElementPtr const& from,
|
||||
std::string const& xpath,
|
||||
@ -175,6 +165,17 @@ public:
|
||||
void checkAndSetUserContext(isc::data::ConstElementPtr const& from,
|
||||
std::string const& xpath);
|
||||
|
||||
/// @brief Get an element from given ElementPtr node and set it in sysrepo
|
||||
/// at given xpath.
|
||||
///
|
||||
/// @param from the parent configuration node from which to take the value
|
||||
/// @param xpath the xpath to the YANG node without the last node
|
||||
/// @param name the name of the YANG node which should also match the key
|
||||
/// under which data is set in the MapElement {from}
|
||||
void checkAndStringifyAndSetLeaf(isc::data::ConstElementPtr const& from,
|
||||
std::string const& xpath,
|
||||
std::string const& name);
|
||||
|
||||
/// @brief Delete basic value from YANG.
|
||||
///
|
||||
/// @param xpath The xpath of the basic value.
|
||||
|
@ -47,7 +47,7 @@ ElementPtr
|
||||
TranslatorClass::getClassFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getClass(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
@ -170,7 +170,7 @@ ElementPtr
|
||||
TranslatorClasses::getClassesFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getClasses(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ TranslatorConfig::getConfigIetf6() {
|
||||
optional<DataNode> config;
|
||||
try {
|
||||
config = findXPath(xpath);
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ TranslatorConfig::getInterfacesKea(DataNode const& config) {
|
||||
|
||||
checkAndGetAndJsonifyLeaf(result, interfaces_config, "user-context");
|
||||
}
|
||||
return result;
|
||||
return (result->empty() ? ElementPtr() : result);
|
||||
}
|
||||
|
||||
ElementPtr
|
||||
@ -289,22 +289,22 @@ TranslatorConfig::getServerKeaDhcpCommon(DataNode const& data_node) {
|
||||
});
|
||||
|
||||
ConstElementPtr options = getOptionDataList(data_node);
|
||||
if (options && !options->empty()) {
|
||||
if (options) {
|
||||
result->set("option-data", options);
|
||||
}
|
||||
|
||||
ConstElementPtr defs = getOptionDefList(data_node);
|
||||
if (defs && !defs->empty()) {
|
||||
if (defs) {
|
||||
result->set("option-def", defs);
|
||||
}
|
||||
|
||||
ConstElementPtr hosts = getHosts(data_node);
|
||||
if (hosts && !hosts->empty()) {
|
||||
if (hosts) {
|
||||
result->set("reservations", hosts);
|
||||
}
|
||||
|
||||
ConstElementPtr networks = getSharedNetworks(data_node);
|
||||
if (networks && !networks->empty()) {
|
||||
if (networks) {
|
||||
result->set("shared-networks", networks);
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ TranslatorConfig::getServerKeaDhcp4() {
|
||||
optional<DataNode> config_optional;
|
||||
try {
|
||||
config_optional = findXPath(xpath);
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
DataNode const config(*config_optional);
|
||||
@ -341,13 +341,13 @@ TranslatorConfig::getServerKeaDhcp4() {
|
||||
|
||||
// Handle interfaces.
|
||||
ElementPtr interfaces_config(getInterfacesKea(config));
|
||||
if (interfaces_config && !interfaces_config->empty()) {
|
||||
if (interfaces_config) {
|
||||
result->set("interfaces-config", interfaces_config);
|
||||
}
|
||||
|
||||
// Handle subnets.
|
||||
ConstElementPtr subnets = getSubnets(config);
|
||||
if (subnets && !subnets->empty()) {
|
||||
if (subnets) {
|
||||
result->set("subnet4", subnets);
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ TranslatorConfig::getServerKeaDhcp6() {
|
||||
optional<DataNode> config_optional;
|
||||
try {
|
||||
config_optional = findXPath(xpath);
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
DataNode const config(*config_optional);
|
||||
@ -376,7 +376,7 @@ TranslatorConfig::getServerKeaDhcp6() {
|
||||
|
||||
// Handle interfaces.
|
||||
ElementPtr interfaces_config(getInterfacesKea(config));
|
||||
if (interfaces_config && !interfaces_config->empty()) {
|
||||
if (interfaces_config) {
|
||||
result->set("interfaces-config", interfaces_config);
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ TranslatorConfig::getServerKeaDhcp6() {
|
||||
|
||||
// Handle subnets.
|
||||
ConstElementPtr subnets = getSubnets(config);
|
||||
if (subnets && !subnets->empty()) {
|
||||
if (subnets) {
|
||||
result->set("subnet6", subnets);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ ElementPtr
|
||||
TranslatorControlSocket::getControlSocketFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getControlSocket(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ ElementPtr
|
||||
TranslatorDatabase::getDatabaseFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getDatabase(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
@ -155,7 +155,7 @@ ElementPtr
|
||||
TranslatorDatabases::getDatabasesFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getDatabases(findXPath(xpath), xpath);
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <yang/translator.h>
|
||||
|
||||
|
||||
namespace isc {
|
||||
namespace yang {
|
||||
|
||||
|
@ -45,7 +45,7 @@ ElementPtr
|
||||
TranslatorHost::getHostFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getHost(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
@ -144,7 +144,7 @@ ElementPtr
|
||||
TranslatorHosts::getHostsFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getHosts(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ ConstElementPtr
|
||||
TranslatorLoggers::getLoggersFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getLoggers(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ ElementPtr
|
||||
TranslatorOptionData::getOptionDataFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getOptionData(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
@ -124,7 +124,7 @@ ConstElementPtr
|
||||
TranslatorOptionDataList::getOptionDataListFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getOptionDataList(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ ElementPtr
|
||||
TranslatorOptionDef::getOptionDefFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getOptionDef(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ ConstElementPtr
|
||||
TranslatorOptionDefList::getOptionDefListFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getOptionDefList(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include <yang/translator.h>
|
||||
|
||||
|
||||
namespace isc {
|
||||
namespace yang {
|
||||
|
||||
|
@ -48,7 +48,7 @@ ElementPtr
|
||||
TranslatorPdPool::getPdPoolFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getPdPool(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
@ -260,7 +260,7 @@ ElementPtr
|
||||
TranslatorPdPools::getPdPoolsFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getPdPools(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ ElementPtr
|
||||
TranslatorPool::getPoolFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getPool(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
@ -253,7 +253,7 @@ ElementPtr
|
||||
TranslatorPools::getPoolsFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getPools(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ ElementPtr
|
||||
TranslatorSharedNetwork::getSharedNetworkFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getSharedNetwork(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
@ -254,7 +254,7 @@ ElementPtr
|
||||
TranslatorSharedNetworks::getSharedNetworksFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getSharedNetworks(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ ElementPtr
|
||||
TranslatorSubnet::getSubnetFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getSubnet(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
@ -310,11 +310,7 @@ TranslatorSubnet::setSubnetKea(string const& xpath, ConstElementPtr elem) {
|
||||
checkAndSetLeaf(elem, xpath, "authoritative", LeafBaseType::Bool);
|
||||
checkAndSetLeaf(elem, xpath, "boot-file-name", LeafBaseType::String);
|
||||
checkAndSetLeaf(elem, xpath, "match-client-id", LeafBaseType::Bool);
|
||||
checkAndSetLeaf(elem, xpath, "max-preferred-lifetime", LeafBaseType::Uint32);
|
||||
checkAndSetLeaf(elem, xpath, "min-preferred-lifetime", LeafBaseType::Uint32);
|
||||
checkAndSetLeaf(elem, xpath, "next-server", LeafBaseType::String);
|
||||
checkAndSetLeaf(elem, xpath, "preferred-lifetime", LeafBaseType::Uint32);
|
||||
checkAndSetLeaf(elem, xpath, "rapid-commit", LeafBaseType::Bool);
|
||||
checkAndSetLeaf(elem, xpath, "server-hostname", LeafBaseType::String);
|
||||
|
||||
checkAndSetDivergingLeaf(elem, xpath, "4o6-interface", "subnet-4o6-interface", LeafBaseType::String);
|
||||
@ -360,7 +356,7 @@ ElementPtr
|
||||
TranslatorSubnets::getSubnetsFromAbsoluteXpath(string const& xpath) {
|
||||
try {
|
||||
return getSubnets(findXPath(xpath));
|
||||
} catch(NetconfError const&) {
|
||||
} catch (NetconfError const&) {
|
||||
return ElementPtr();
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ the basic / base class and recursively from translators for embedded parts.
|
||||
- @c isc::yang::Translator::getItem() retrieves and translates a leaf
|
||||
from YANG to Element.
|
||||
|
||||
- @c isc::yang::Translator::getList() retrieves a list from Sysrepo and
|
||||
- @c isc::yang::Translator::getList() retrieves a list from sysrepo and
|
||||
translates it form YANG to Element.
|
||||
|
||||
- @c isc::yang::Translator::getMandatoryLeaf() fetches a leaf that is expected
|
||||
@ -96,7 +96,7 @@ the basic / base class and recursively from translators for embedded parts.
|
||||
substitute logic that had been previously removed.
|
||||
|
||||
- @c isc::yang::Translator::setItem() translates a leaf from Element to
|
||||
YANG and sets it in Sysrepo.
|
||||
YANG and sets it in sysrepo.
|
||||
|
||||
- @c isc::yang::Translator::setMandatoryLeaf() sets a leaf that is expected
|
||||
to be present in the Element node, most of the time a YANG key.
|
||||
@ -270,7 +270,7 @@ them.
|
||||
@section yangMTConsiderations Multi-Threading Consideration for YANG Utilities
|
||||
|
||||
The YANG utilities are not thread-safe. Note as they are used only in a
|
||||
configuration context it is not a problem, and the YANG / Sysrepo libraries
|
||||
configuration context it is not a problem, and the libyang and sysrepo libraries
|
||||
are multi-threaded so their APIs are thread-safe.
|
||||
|
||||
*/
|
||||
|
@ -1 +1 @@
|
||||
154760167c8e5986b3e3dfa52dbde018ffd23de2399da76ce30583feb10071f9
|
||||
a4c5fd6a22da33a8973b9a83a10bde57fd93123d1072276e190ddb0482299374
|
||||
|
Loading…
x
Reference in New Issue
Block a user