From: Francis Dupont Date: Mon, 10 Dec 2018 12:38:29 +0000 (+0100) Subject: [204-move-models-] Addressing comments (checkpoint) X-Git-Tag: 339-doxygen-errors_base~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3f4584a8b76646b4f71dea89718639dcf5ed12c;p=thirdparty%2Fkea.git [204-move-models-] Addressing comments (checkpoint) --- diff --git a/doc/guide/netconf.xml b/doc/guide/netconf.xml index f6036fc7e8..0e34ee8645 100644 --- a/doc/guide/netconf.xml +++ b/doc/guide/netconf.xml @@ -114,27 +114,35 @@ ietf-ip | 2014-06-16 | Installed | | -Installing Kea YANG modules. There are two major modules that Kea is able to -support: kea-dhcp4-server and kea-dhcp6-server. Note that while there is an -active effort at DHC working group at IETF to develop an DHCPv6 YANG model, -similar initiative for DHCPv4 died long time ago. As such, Kea uses its own -dedicated models for DHCPv4 and DHCPv6 but partially supports the IETF model -for DHCPv6. Those three models have extra -models as dependencies. The dependency models are also provided in -src/lib/libyang/models. To install models from sources, do the following: +Installing Kea YANG modules. There are two major modules that Kea is +able to support: kea-dhcp4-server and kea-dhcp6-server. Note that +while there is an active effort at DHC working group at IETF to +develop an DHCPv6 YANG model, similar initiative for DHCPv4 died long +time ago. As such, Kea uses its own dedicated models for DHCPv4 and +DHCPv6 but partially supports the IETF model for DHCPv6. Those three +models have extra modules as dependencies. The dependency modules are +also provided in src/share/yang/modules in sources +and share/kea/yang/modules after installation. + + + +To install modules from sources, do the following: cd src/share/yang/modules sudo sysrepoctl -i -s /home/thomson/devel/sysrepo-0.7.6/build/repository/yang -s . -g ietf-dhcpv6-server*.yang sudo sysrepoctl -i -s /home/thomson/devel/sysrepo-0.7.6/build/repository/yang -s . -g kea-dhcp4-server*.yang sudo sysrepoctl -i -s /home/thomson/devel/sysrepo-0.7.6/build/repository/yang -s . -g kea-dhcp6-server*.yang +... Note the first -s parameter specifies the location of your YANG schema repository. You can check it with sysrepoctl -l. This is a parameter that is configured during sysrepo compilation and is detected by Kea configure under the SYSREPO_REPO name. + + The installation should look similar to the following: $ sudo sysrepoctl -i -s /home/thomson/devel/sysrepo-0.7.6/build/repository/yang -s . -g ietf-dhcpv6-server*.yang @@ -242,6 +250,9 @@ done in dependency order and reverse dependency order accordingly. Check that used (not essential) and required (essential) modules are installed in the sysrepo repository at the right revision. + If an essential module, i.e. a module where the configuration + schema for a managed server is defined, is not installed + then a fatal error is raised. diff --git a/src/bin/netconf/netconf.cc b/src/bin/netconf/netconf.cc index c0c92dd436..ef27979322 100644 --- a/src/bin/netconf/netconf.cc +++ b/src/bin/netconf/netconf.cc @@ -103,20 +103,20 @@ public: /// This callback is called by sysrepo when a module is (un)installed. /// /// @param module_name The module name. - /// @param revision The module revision. + /// @param revision The module revision (NULL for uninstallation). /// @param state The new state of the module (ignored). /// @param private_ctx The private context. void module_install(const char* module_name, const char* revision, sr_module_state_t /*state*/, void* /*private_ctx*/) { - if (!module_name || !revision) { + if (!module_name) { // Not for us... return; } LOG_WARN(netconf_logger, NETCONF_MODULE_INSTALL) .arg(module_name) - .arg(revision); + .arg(revision ? revision : "unknown"); } }; @@ -170,7 +170,7 @@ NetconfAgent::init(NetconfCfgMgrPtr cfg_mgr) { } } if (!can_start) { - cerr << "An essential YNAG module / revision is missing." + cerr << "An essential YANG module / revision is missing." << endl << "The environment is not suitable for running kea-netconf." << endl; @@ -327,13 +327,16 @@ NetconfAgent::initSysrepo() { return; } + // Subscribe to the module (un)installation callback. + // When a module is (un)installed the callback is called. + // Note this requires a system test (vs. unit test). try { S_Subscribe subs(new Subscribe(startup_sess_)); S_Callback cb(new NetconfAgentInstallCallback()); subs->module_install_subscribe(cb); subscriptions_.insert(make_pair("__install__", subs)); } catch (const sysrepo_exception& ex) { - isc_throw(Unexpected, "Can't subscribe moduel install: " + isc_throw(Unexpected, "Can't subscribe module install: " << ex.what()); } } @@ -345,17 +348,19 @@ NetconfAgent::checkModule(const string& module_name) const { } auto module = modules_.find(module_name); if (module == modules_.end()) { - LOG_ERROR(netconf_logger, METCONF_MODULE_MISSING_ERR) + LOG_ERROR(netconf_logger, NETCONF_MODULE_MISSING_ERR) .arg(module_name); return (false); } auto modrev = YANG_REVISIONS.find(module_name); if (modrev == YANG_REVISIONS.end()) { // Can't check revision?! + // It can happen only with a module which is not in + // YANG_REVISIONS but installed so likely on purpose. return (true); } if (modrev->second != module->second) { - LOG_ERROR(netconf_logger, METCONF_MODULE_REVISION_ERR) + LOG_ERROR(netconf_logger, NETCONF_MODULE_REVISION_ERR) .arg(module_name) .arg(modrev->second) .arg(module->second); @@ -372,12 +377,12 @@ NetconfAgent::checkModules() const { } auto module = modules_.find(modrev.first); if (module == modules_.end()) { - LOG_WARN(netconf_logger, METCONF_MODULE_MISSING_WARN) + LOG_WARN(netconf_logger, NETCONF_MODULE_MISSING_WARN) .arg(modrev.first); continue; } if (modrev.second != module->second) { - LOG_WARN(netconf_logger, METCONF_MODULE_REVISION_WARN) + LOG_WARN(netconf_logger, NETCONF_MODULE_REVISION_WARN) .arg(modrev.first) .arg(modrev.second) .arg(module->second); diff --git a/src/bin/netconf/netconf_messages.mes b/src/bin/netconf/netconf_messages.mes index c2f6e84d6f..07144de823 100644 --- a/src/bin/netconf/netconf_messages.mes +++ b/src/bin/netconf/netconf_messages.mes @@ -57,21 +57,21 @@ This warning message indicates that sysrepo reports the installation or uninstallation of a module used by Kea. The name and revision of the module are printed. -% METCONF_MODULE_MISSING_ERR Missing essential module %1 in sysrepo +% NETCONF_MODULE_MISSING_ERR Missing essential module %1 in sysrepo This fatal error message indicates that a module required by Netconf configuration is not available in the sysrepo repository. The name of the module is printed. -% METCONF_MODULE_MISSING_WARN Missing module %1 in sysrepo +% NETCONF_MODULE_MISSING_WARN Missing module %1 in sysrepo This warning message indicates that a module used by Kea is not available in the sysrepo repository. The name of the module is printed. -% METCONF_MODULE_REVISION_ERR Essential module %1 does have the right revision: expected %2, got %3 +% NETCONF_MODULE_REVISION_ERR Essential module %1 does have the right revision: expected %2, got %3 This fatal error message indicates that a module required by Netconf configuration is not at the right revision in the sysrepo repository. The name, expected and available revisions of the module are printed. -% METCONF_MODULE_REVISION_WARN Module %1 does have the right revision: expected %2, got %3 +% NETCONF_MODULE_REVISION_WARN Module %1 does have the right revision: expected %2, got %3 This warning message indicates that a module used by Kea is not at the right revision in the sysrepo repository. The name, expected and available revisions of the module are printed. diff --git a/src/bin/netconf/tests/netconf_unittests.cc b/src/bin/netconf/tests/netconf_unittests.cc index 25f86641f3..d1f24a58b5 100644 --- a/src/bin/netconf/tests/netconf_unittests.cc +++ b/src/bin/netconf/tests/netconf_unittests.cc @@ -323,7 +323,7 @@ TEST_F(NetconfAgentTest, initSysrepo) { EXPECT_TRUE(agent_->running_sess_); EXPECT_EQ(1, agent_->subscriptions_.size()); EXPECT_LE(16, agent_->modules_.size()); - // No way to check the module_install callback (BTW is ther + // No way to check the module_install callback (BTW is there // an API to install modules? If none only system tests can // do something)... } @@ -346,7 +346,7 @@ TEST_F(NetconfAgentLogTest, checkModule) { // Unknown module should emit a missing error. EXPECT_EQ(0, agent_->modules_.count("does-not-exist")); EXPECT_FALSE(agent_->checkModule("does-not-exist")); - addString("METCONF_MODULE_MISSING_ERR Missing essential module " + addString("NETCONF_MODULE_MISSING_ERR Missing essential module " "does-not-exist in sysrepo"); // Patch the found revision to get a revision error. @@ -360,7 +360,7 @@ TEST_F(NetconfAgentLogTest, checkModule) { agent_->modules_.insert(make_pair(module, bad_revision)); EXPECT_FALSE(agent_->checkModule(module)); ostringstream msg; - msg << "METCONF_MODULE_REVISION_ERR Essential module " << module + msg << "NETCONF_MODULE_REVISION_ERR Essential module " << module << " does have the right revision: expected " << YANG_REVISIONS.at(module) << ", got " << bad_revision; addString(msg.str()); @@ -393,7 +393,7 @@ TEST_F(NetconfAgentLogTest, checkModules) { } ASSERT_NO_THROW(agent_->checkModules()); ostringstream mmsg; - mmsg << "METCONF_MODULE_MISSING_WARN Missing module " << module + mmsg << "NETCONF_MODULE_MISSING_WARN Missing module " << module << " in sysrepo"; addString(mmsg.str()); @@ -402,7 +402,7 @@ TEST_F(NetconfAgentLogTest, checkModules) { agent_->modules_.insert(make_pair(module, bad_revision)); ASSERT_NO_THROW(agent_->checkModules()); ostringstream rmsg; - rmsg << "METCONF_MODULE_REVISION_WARN Module " << module + rmsg << "NETCONF_MODULE_REVISION_WARN Module " << module << " does have the right revision: expected " << YANG_REVISIONS.at(module) << ", got " << bad_revision; addString(rmsg.str()); diff --git a/src/lib/yang/yang.dox b/src/lib/yang/yang.dox index a36c64eac2..ecc14c4fc7 100644 --- a/src/lib/yang/yang.dox +++ b/src/lib/yang/yang.dox @@ -151,7 +151,7 @@ Those models depend on the following modules: - kea-logging - kea-dhcp-types -Those models are extracted from the IETF DHCPv6 YNAG draft too: +Those modules are extracted from the IETF DHCPv6 YANG draft too: - ietf-dhcpv6-client - ietf-dhcpv6-relay