]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[204-move-models-] Addressing comments (checkpoint)
authorFrancis Dupont <fdupont@isc.org>
Mon, 10 Dec 2018 12:38:29 +0000 (13:38 +0100)
committerFrancis Dupont <fdupont@isc.org>
Mon, 10 Dec 2018 12:38:29 +0000 (13:38 +0100)
doc/guide/netconf.xml
src/bin/netconf/netconf.cc
src/bin/netconf/netconf_messages.mes
src/bin/netconf/tests/netconf_unittests.cc
src/lib/yang/yang.dox

index f6036fc7e8de671d27204e7e96208dc86e4e093f..0e34ee86453a1c45e1ddfba8faa6af2c49739bf5 100644 (file)
@@ -114,27 +114,35 @@ ietf-ip                    | 2014-06-16 | Installed   |                     |
     </para>
 
     <para>
-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 <filename>src/share/yang/modules</filename> in sources
+and <filename>share/kea/yang/modules</filename> after installation.
+    </para>
+
+    <para>
+To install modules from sources, do the following:
 
 <screen>
 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
+...
 </screen>
 
 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.
+    </para>
 
+    <para>
 The installation should look similar to the following:
 <screen>
 $ 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.
           </simpara>
         </listitem>
 
index c0c92dd436759978e08c22d1f095a21b2330be31..ef279793225a8893dcc9fc9cad53345f41697aa2 100644 (file)
@@ -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);
index c2f6e84d6f7004a6430017f486b329ed7dc3a85c..07144de82397266f554ee20ba4708eb4d7162f51 100644 (file)
@@ -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.
index 25f86641f35e46f2c9503a41de8ec071c90057d0..d1f24a58b5aab9d2e5b40f22f72ae9f8cc837d9e 100644 (file)
@@ -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());
index a36c64eac2943cf2907f2a3a85795e6c9ab51771..ecc14c4fc774ade77ee6e00e91306c4e94ea39ab 100644 (file)
@@ -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