]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1077] formatting changes to YANG and NETCONF
authorAndrei Pavel <andrei@isc.org>
Thu, 22 Jul 2021 19:31:52 +0000 (22:31 +0300)
committerTomek Mrugalski <tomek@isc.org>
Fri, 23 Jul 2021 10:45:36 +0000 (10:45 +0000)
src/bin/netconf/netconf.cc
src/bin/netconf/netconf.h
src/lib/yang/pretests/sysrepo_setup_tests.cc
src/lib/yang/tests/translator_unittests.cc

index ddb3a6a9611a2bb9f27e638f9597a5406e280710..fae55646000972a5bfbd392ec43a504147c68648 100644 (file)
@@ -486,19 +486,18 @@ NetconfAgent::subscribeToNotifications(const CfgServersMapPair& service_pair) {
         .arg(model);
 
     S_Subscribe subscription(std::make_shared<Subscribe>(running_sess_));
-    auto event_notif_callback =
-        [=](sysrepo::S_Session session,
-            sr_ev_notif_type_t const notification_type, char const* path,
-            sysrepo::S_Vals const vals, time_t timestamp) {
-            NetconfAgentCallback agent(service_pair);
-            return agent.event_notif(session, notification_type, path, vals,
-                                     timestamp, nullptr);
-        };
+    auto callback = [=](sysrepo::S_Session session,
+                        sr_ev_notif_type_t const notification_type,
+                        char const* path,
+                        sysrepo::S_Vals const vals,
+                        time_t timestamp) {
+        NetconfAgentCallback agent(service_pair);
+        return agent.event_notif(session, notification_type, path, vals, timestamp, nullptr);
+    };
     try {
         // The alternative event_notif_subscribe_tree() might expose more data
         // as S_Data_Node if needed.
-        subscription->event_notif_subscribe(model.c_str(),
-            event_notif_callback);
+        subscription->event_notif_subscribe(model.c_str(), callback);
     } catch (const std::exception& ex) {
         ostringstream msg;
         msg << "event notification subscription for model " << model <<
@@ -540,7 +539,7 @@ NetconfAgent::change(S_Session sess, const CfgServersMapPair& service_pair) {
             LOG_ERROR(netconf_logger, NETCONF_VALIDATE_CONFIG_FAILED)
                 .arg(service_pair.first)
                 .arg(msg.str());
-            return SR_ERR_OPERATION_FAILED;
+            return (SR_ERR_OPERATION_FAILED);
         } else {
             LOG_DEBUG(netconf_logger, NETCONF_DBG_TRACE_DETAIL_DATA,
                       NETCONF_VALIDATE_CONFIG)
index d8cfc376117af9045fb2072d95b9067a1d2a4e0f..81621163ffec9152083f769cb37e2f072d867409 100644 (file)
@@ -114,6 +114,8 @@ protected:
 
     /// @brief Retrieve names and revisions of installed modules through the
     /// sysrepo API.
+    ///
+    /// @throw Unexpected if module information cannot be retrieved from sysrepo
     void getModules();
 
     /// @brief Check module availability.
@@ -124,6 +126,9 @@ protected:
     /// @param servers the configured servers to check against YANG_REVISIONS.
     /// Is empty by default for when the caller only wants to check
     /// installed modules.
+    ///
+    /// @throw Unexpected if a module from YANG_REVISIONS is not installed or
+    /// has the wrong revision.
     void checkModules(CfgServersMapPtr const& servers = {}) const;
 
     /// @brief Retrieve Kea server configuration from the YANG startup
index 1527c063de101c50fda98536bda52ae8ba31ebdb..4ef9bd3003995c88ad9efa0d1b3f8c0ff44baf8f 100644 (file)
@@ -78,7 +78,7 @@ int main() {
     } catch (const sysrepo_exception& ex) {
         cerr << "ERROR: Can't initialize sysrepo: " << ex.what() << endl;
         cerr << "ERROR: Make sure you have the right permissions to the sysrepo repository." << endl;
-        return 1;
+        return (1);
     }
 
     S_Session sess;
@@ -87,7 +87,7 @@ int main() {
     } catch (const sysrepo_exception& ex) {
         cerr << "ERROR: Can't establish a sysrepo session: "
              << ex.what() << endl;
-        return 2;
+        return (2);
     }
 
     vector<S_Module> modules;
@@ -96,19 +96,19 @@ int main() {
         modules = context->get_module_iter();
     } catch (const sysrepo_exception& ex) {
         cerr << "ERROR: Can't retrieve available modules: " << ex.what() << endl;
-        return 3;
+        return (3);
     }
 
     std::unordered_map<std::string, std::string> installed_modules;
     for (S_Module const& module : modules) {
         if (!module->name()) {
             cerr << "ERROR: module name is mangled" << endl;
-            return 4;
+            return (4);
         }
         string const name(module->name());
         if (!module->rev() || !module->rev()->date()) {
             cerr << "ERROR: module revision is mangled" << endl;
-            return 5;
+            return (5);
         }
         string const revision(module->rev()->date());
         installed_modules.emplace(name, revision);
@@ -119,12 +119,12 @@ int main() {
         std::string const& revision(kv.second);
         if (!installed_modules.count(name)) {
             cerr << missingModuleText(name, revision);
-            return 6;
+            return (6);
         }
         string const& expected_revision(installed_modules.at(name));
         if (expected_revision != revision) {
             cerr << badRevisionModuleText(name, expected_revision, revision);
-            return 7;
+            return (7);
         }
     }
 
index 3deed28eff0959142b3b94f6147a0d5742c08ee5..f5c96293e132d8b16dfb65111398348b9400a0d7 100644 (file)
@@ -313,7 +313,8 @@ TEST(TranslatorBasicTest, getItem) {
 
     // Not found.
     xpath = "/keatest-module:main/no_such_string";
-    // sysrepo_exception: "Invalid argument" ¯\_(ツ)_/¯
+
+    // sysrepo_exception: "Invalid argument"
     EXPECT_THROW(sess->delete_item(xpath.c_str()), sysrepo_exception);
     EXPECT_THROW(elem = t_obj->getItem(xpath), SysrepoError);
     EXPECT_FALSE(elem);
@@ -595,7 +596,8 @@ TEST(TranslatorBasicTest, setItem) {
     sess->set_item_str(xpath.c_str(), "2");
     sess->set_item_str(xpath.c_str(), "3");
     sess->apply_changes();
-    // sysrepo_exception: "Invalid argument" ¯\_(ツ)_/¯
+
+    // sysrepo_exception: "Invalid argument"
     EXPECT_THROW(data_node = sess->get_subtree(xpath.c_str()),
         sysrepo_exception);
     EXPECT_FALSE(data_node);
@@ -646,7 +648,8 @@ TEST(TranslatorBasicTest, setItem) {
     EXPECT_TRUE(s_val);
     s_val.reset();
     EXPECT_NO_THROW(t_obj->delItem(xpath));
-    // sysrepo_exception: "Item not found" ¯\_(ツ)_/¯
+
+    // sysrepo_exception: "Item not found"
     EXPECT_THROW(s_val = sess->get_item(xpath.c_str()), sysrepo_exception);
     EXPECT_FALSE(s_val);
     EXPECT_NO_THROW(t_obj->delItem(xpath));