]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[153-netconf-agent] Addressed more comments
authorFrancis Dupont <fdupont@isc.org>
Tue, 30 Oct 2018 10:13:02 +0000 (11:13 +0100)
committerFrancis Dupont <fdupont@isc.org>
Tue, 30 Oct 2018 11:50:38 +0000 (07:50 -0400)
src/bin/netconf/netconf.cc
src/bin/netconf/netconf.h
src/lib/yang/tests/translator_subnet_unittests.cc

index 589565fb896a68ced88de4ad89f81ebb96dc3d55..b1e5d0e5da6083a71b3652e77f6b71511bde6940 100644 (file)
@@ -109,7 +109,8 @@ NetconfAgent::~NetconfAgent() {
 
 void
 NetconfAgent::init(NetconfCfgMgrPtr cfg_mgr) {
-    if (NetconfProcess::shut_down || !cfg_mgr) {
+    // If there is no configuration manager and/or we're shutting down.
+    if (!cfg_mgr || NetconfProcess::shut_down) {
         return;
     }
     const CfgServersMapPtr& servers =
@@ -165,6 +166,7 @@ NetconfAgent::clear() {
 
 void
 NetconfAgent::keaConfig(const CfgServersMapPair& service_pair) {
+    // If the boot-update flag is not set.
     if (!service_pair.second->getBootUpdate()) {
         return;
     }
@@ -331,6 +333,8 @@ NetconfAgent::yangConfig(const CfgServersMapPair& service_pair) {
 
 void
 NetconfAgent::subscribeConfig(const CfgServersMapPair& service_pair) {
+    // If we're shutting down, or the subscribe-changes flag is not set or
+    // the model associated with it is not specified.
     if (NetconfProcess::shut_down ||
         !service_pair.second->getSubscribeChanges() ||
         service_pair.second->getModel().empty()) {
@@ -365,9 +369,13 @@ NetconfAgent::subscribeConfig(const CfgServersMapPair& service_pair) {
 
 int
 NetconfAgent::validate(S_Session sess, const CfgServersMapPair& service_pair) {
+    // If we're shutting down, or the subscribe-changes or the
+    // validate-changes flag is not set or the model associated with
+    // it is not specified.
     if (NetconfProcess::shut_down ||
         !service_pair.second->getSubscribeChanges() ||
-        !service_pair.second->getValidateChanges()) {
+        !service_pair.second->getValidateChanges() ||
+        service_pair.second->getModel().empty()) {
         return (SR_ERR_OK);
     }
     CfgControlSocketPtr ctrl_sock = service_pair.second->getCfgControlSocket();
@@ -447,7 +455,8 @@ int
 NetconfAgent::update(S_Session sess, const CfgServersMapPair& service_pair) {
     // Check if we should and can process this update.
     if (NetconfProcess::shut_down ||
-        !service_pair.second->getSubscribeChanges()) {
+        !service_pair.second->getSubscribeChanges() ||
+        service_pair.second->getModel().empty()) {
         return (SR_ERR_OK);
     }
     CfgControlSocketPtr ctrl_sock = service_pair.second->getCfgControlSocket();
index 7ea7e5edd888021cdb3dd7ffa9d59f3d3668263f..86964997b61562db62474ef1cacaf5454e8d0d9a 100644 (file)
@@ -82,7 +82,11 @@ public:
     /// @return return code for sysrepo.
     static int update(S_Session sess, const CfgServersMapPair& service_pair);
 
-    /// @brief Print changes.
+    /// @brief Log changes.
+    ///
+    /// Iterate on changes logging them. Sysrepo changes are an operation
+    /// (created, modified, deleted or moved) with old and new values
+    /// (cf sr_change_oper_e sysrepo documentation).
     ///
     /// @param sess The sysrepo running datastore session.
     /// @param model The model name.
index 233bd3b61db464be51199c1ed7d3affc0b3d41ce..de22ad9293364d9744a2597bc8c31c72b6d04d76 100644 (file)
@@ -148,10 +148,9 @@ TEST_F(TranslatorSubnetsTest, getPoolsIetf) {
     S_Val s_pool2(new Val("2001:db8::2:0/112"));
     EXPECT_NO_THROW(sess_->set_item(prefix2.c_str(), s_pool2));
 
-#if 0
-    S_Tree tree = sess_->get_subtree("/ietf-dhcpv6-server:server");
-    cerr << "tree:\n" << tree->to_string(100) << "\n";
-#endif
+    // Uncomment this for debugging.
+    // S_Tree tree = sess_->get_subtree("/ietf-dhcpv6-server:server");
+    // cerr << "tree:\n" << tree->to_string(100) << "\n";
 
     // Get the subnet.
     ConstElementPtr subnet;
@@ -206,10 +205,9 @@ TEST_F(TranslatorSubnetsTest, getPoolsKea) {
     S_Val s_pool2;
     EXPECT_NO_THROW(sess_->set_item(prefix2.c_str(), s_pool2));
 
-#if 0
-    S_Tree tree = sess_->get_subtree("/kea-dhcp6-server:config");
-    cerr << "tree:\n" << tree->to_string(100) << "\n";
-#endif
+    // Uncomment this for debugging.
+    // S_Tree tree = sess_->get_subtree("/kea-dhcp6-server:config");
+    // cerr << "tree:\n" << tree->to_string(100) << "\n";
 
     // Get the subnet.
     ConstElementPtr subnet;