From: Francis Dupont Date: Tue, 30 Oct 2018 10:13:02 +0000 (+0100) Subject: [153-netconf-agent] Addressed more comments X-Git-Tag: 176-update-to-sysrepo-0-7-6-release_base~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02fccca94baa79c2555543d22708a06a16602786;p=thirdparty%2Fkea.git [153-netconf-agent] Addressed more comments --- diff --git a/src/bin/netconf/netconf.cc b/src/bin/netconf/netconf.cc index 589565fb89..b1e5d0e5da 100644 --- a/src/bin/netconf/netconf.cc +++ b/src/bin/netconf/netconf.cc @@ -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(); diff --git a/src/bin/netconf/netconf.h b/src/bin/netconf/netconf.h index 7ea7e5edd8..86964997b6 100644 --- a/src/bin/netconf/netconf.h +++ b/src/bin/netconf/netconf.h @@ -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. diff --git a/src/lib/yang/tests/translator_subnet_unittests.cc b/src/lib/yang/tests/translator_subnet_unittests.cc index 233bd3b61d..de22ad9293 100644 --- a/src/lib/yang/tests/translator_subnet_unittests.cc +++ b/src/lib/yang/tests/translator_subnet_unittests.cc @@ -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;