diff options
22 files changed, 67 insertions, 83 deletions
diff --git a/src/bin/netconf/control_socket.h b/src/bin/netconf/control_socket.h index 05cfe74975..10bcafcc40 100644 --- a/src/bin/netconf/control_socket.h +++ b/src/bin/netconf/control_socket.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -19,8 +19,9 @@ namespace netconf { /// @brief Exception thrown when the error during communication. class ControlSocketError : public isc::Exception { public: - ControlSocketError(const char* file, size_t line, const char* what) : - isc::Exception(file, line, what) { } + ControlSocketError(const char* file, size_t line, const char* what) + : isc::Exception(file, line, what) { + } }; // ControlSocketError /// @brief Base class for control socket communication. @@ -38,7 +39,7 @@ public: ControlSocketBase(CfgControlSocketPtr ctrl_sock) : socket_cfg_(ctrl_sock) { if (!ctrl_sock) { isc_throw(ControlSocketError, "ControlSocket constructor called " - "with a null configuration"); + "with a null configuration"); } } diff --git a/src/bin/netconf/http_control_socket.cc b/src/bin/netconf/http_control_socket.cc index 12b240232f..f630383312 100644 --- a/src/bin/netconf/http_control_socket.cc +++ b/src/bin/netconf/http_control_socket.cc @@ -130,4 +130,3 @@ HttpControlSocket::sendCommand(ConstElementPtr command) { } // namespace netconf } // namespace isc - diff --git a/src/bin/netconf/netconf.cc b/src/bin/netconf/netconf.cc index d66c3139a2..561cda9e50 100644 --- a/src/bin/netconf/netconf.cc +++ b/src/bin/netconf/netconf.cc @@ -142,7 +142,7 @@ public: } }; // NetconfAgentCallback -} //anonymous namespace +} // anonymous namespace namespace isc { namespace netconf { @@ -254,15 +254,15 @@ NetconfAgent::initSysrepo() { startup_sess_ = Connection{}.sessionStart(); startup_sess_->switchDatastore(Datastore::Startup); } catch (exception const& ex) { - isc_throw(Unexpected, "Can't establish a sysrepo session: " - << ex.what()); + isc_throw(Unexpected, "Can't establish a sysrepo session: " << ex.what()); } // Retrieve names and revisions of installed modules from sysrepo. getModules(); } -void NetconfAgent::getModules() { +void +NetconfAgent::getModules() { vector<Module> modules; try { Context context(running_sess_->getContext()); @@ -274,8 +274,7 @@ void NetconfAgent::getModules() { for (Module const& module : modules) { string const name(module.name()); if (!module.revision()) { - isc_throw(Unexpected, - "could not retrieve module revision for module " << name); + isc_throw(Unexpected, "could not retrieve module revision for module " << name); } string const revision(*module.revision()); modules_.emplace(name, revision); @@ -464,8 +463,7 @@ NetconfAgent::subscribeToDataChanges(const CfgServersMapPair& service_pair) { } catch (exception const& ex) { ostringstream msg; msg << "module change subscribe failed with " << ex.what(); - msg << "change subscription for model " << model << - " failed with: " << ex.what(); + msg << "change subscription for model " << model << " failed with: " << ex.what(); LOG_ERROR(netconf_logger, NETCONF_SUBSCRIBE_CONFIG_FAILED) .arg(server) .arg(configuration->getModel()) @@ -754,7 +752,8 @@ NetconfAgent::announceShutdown() const { } } -bool NetconfAgent::shouldShutdown() const { +bool +NetconfAgent::shouldShutdown() const { return boost::dynamic_pointer_cast<NetconfController>(NetconfController::instance()) ->getNetconfProcess() ->shouldShutdown(); diff --git a/src/bin/netconf/netconf.h b/src/bin/netconf/netconf.h index bb37ea5308..e5b363e928 100644 --- a/src/bin/netconf/netconf.h +++ b/src/bin/netconf/netconf.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -15,10 +15,10 @@ #include <netconf/stdout_control_socket.h> #include <netconf/unix_control_socket.h> -#include <sysrepo-cpp/Session.hpp> - #include <map> +#include <sysrepo-cpp/Session.hpp> + namespace isc { namespace netconf { @@ -69,8 +69,7 @@ public: /// @param sess The sysrepo running datastore session. /// @param service_pair The service name and configuration pair. /// @return return code for sysrepo. - static sysrepo::ErrorCode - change(sysrepo::Session sess, const CfgServersMapPair& service_pair); + static sysrepo::ErrorCode change(sysrepo::Session sess, const CfgServersMapPair& service_pair); /// @brief Event::Done callback. /// @@ -80,8 +79,7 @@ public: /// @param sess The sysrepo running datastore session. /// @param service_pair The service name and configuration pair. /// @return return code for sysrepo. - static sysrepo::ErrorCode - done(sysrepo::Session sess, const CfgServersMapPair& service_pair); + static sysrepo::ErrorCode done(sysrepo::Session sess, const CfgServersMapPair& service_pair); /// @brief Log changes. /// diff --git a/src/bin/netconf/netconf_cfg_mgr.cc b/src/bin/netconf/netconf_cfg_mgr.cc index da7b97cd29..14c5b082dc 100644 --- a/src/bin/netconf/netconf_cfg_mgr.cc +++ b/src/bin/netconf/netconf_cfg_mgr.cc @@ -135,11 +135,9 @@ NetconfCfgMgr::parse(isc::data::ConstElementPtr config_set, } if (check_only) { - answer = createAnswer(CONTROL_RESULT_SUCCESS, - "Configuration check successful"); + answer = createAnswer(CONTROL_RESULT_SUCCESS, "Configuration check successful"); } else { - answer = createAnswer(CONTROL_RESULT_SUCCESS, - "Configuration applied successfully."); + answer = createAnswer(CONTROL_RESULT_SUCCESS, "Configuration applied successfully."); } return (answer); diff --git a/src/bin/netconf/netconf_cfg_mgr.h b/src/bin/netconf/netconf_cfg_mgr.h index d8c8b889c5..fd07bcac82 100644 --- a/src/bin/netconf/netconf_cfg_mgr.h +++ b/src/bin/netconf/netconf_cfg_mgr.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -30,7 +30,6 @@ using NetconfConfigPtr = boost::shared_ptr<NetconfConfig>; /// It is derived from the context base class, ConfigBase. class NetconfConfig : public process::ConfigBase { public: - /// @brief Default constructor NetconfConfig(); @@ -93,7 +92,6 @@ public: isc::data::ElementPtr toElement() const override final; private: - /// @brief Private copy constructor /// /// It is private to forbid anyone outside of this class to make copies. diff --git a/src/bin/netconf/netconf_config.cc b/src/bin/netconf/netconf_config.cc index eac9ce5cb0..d03b8129b3 100644 --- a/src/bin/netconf/netconf_config.cc +++ b/src/bin/netconf/netconf_config.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -7,9 +7,9 @@ #include <config.h> #include <asiolink/io_error.h> +#include <exceptions/exceptions.h> #include <netconf/netconf_cfg_mgr.h> #include <netconf/netconf_log.h> -#include <exceptions/exceptions.h> #include <sstream> #include <string> @@ -89,7 +89,7 @@ CfgServer::toText() const { s << "UNIX:'" << control_socket_->getName() << "'"; break; case CfgControlSocket::Type::HTTP: - s << "HTTP:'" << control_socket_->getUrl().toText() << "'"; + s << "HTTP:'" << control_socket_->getUrl().toText() << "'"; break; case CfgControlSocket::Type::STDOUT: s << "STDOUT"; diff --git a/src/bin/netconf/netconf_config.h b/src/bin/netconf/netconf_config.h index b4f6339c88..d80dce2cc0 100644 --- a/src/bin/netconf/netconf_config.h +++ b/src/bin/netconf/netconf_config.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -14,8 +14,7 @@ #include <exceptions/exceptions.h> #include <http/url.h> -#include <stdint.h> - +#include <cstdint> #include <string> #include <unordered_map> diff --git a/src/bin/netconf/netconf_controller.h b/src/bin/netconf/netconf_controller.h index ca1f72510b..0d5224de57 100644 --- a/src/bin/netconf/netconf_controller.h +++ b/src/bin/netconf/netconf_controller.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -20,7 +20,6 @@ namespace netconf { /// NetconfProcess. class NetconfController : public process::DControllerBase { public: - /// @brief Static singleton instance method. /// /// This method returns the base class singleton instance member. @@ -59,7 +58,6 @@ public: void processSignal(int signum) override final; private: - /// @brief Creates an instance of the Netconf application process. /// /// This method is invoked during the process initialization step of diff --git a/src/bin/netconf/netconf_log.cc b/src/bin/netconf/netconf_log.cc index 97079ea2e4..01e5db25f5 100644 --- a/src/bin/netconf/netconf_log.cc +++ b/src/bin/netconf/netconf_log.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -16,8 +16,7 @@ namespace netconf { extern const int NETCONF_DBG_TRACE = isc::log::DBGLVL_TRACE_BASIC; extern const int NETCONF_DBG_RESULTS = isc::log::DBGLVL_TRACE_BASIC_DATA; -extern const int NETCONF_DBG_TRACE_DETAIL_DATA = - isc::log::DBGLVL_TRACE_DETAIL_DATA; +extern const int NETCONF_DBG_TRACE_DETAIL_DATA = isc::log::DBGLVL_TRACE_DETAIL_DATA; const char* NETCONF_LOGGER_NAME = "netconf"; diff --git a/src/bin/netconf/netconf_process.cc b/src/bin/netconf/netconf_process.cc index c78f16e188..89a3f8e2a4 100644 --- a/src/bin/netconf/netconf_process.cc +++ b/src/bin/netconf/netconf_process.cc @@ -57,8 +57,7 @@ NetconfProcess::run() { } catch (...) { // Ignore double errors } - isc_throw(DProcessBaseError, - "Process run method failed: " << ex.what()); + isc_throw(DProcessBaseError, "Process run method failed: " << ex.what()); } LOG_DEBUG(netconf_logger, isc::log::DBGLVL_START_SHUT, NETCONF_RUN_EXIT); @@ -95,8 +94,7 @@ NetconfProcess::configure(isc::data::ConstElementPtr config_set, IOServiceMgr::instance().pollIOServices(); } catch (const std::exception& ex) { std::ostringstream err; - err << "Error initializing hooks: " - << ex.what(); + err << "Error initializing hooks: " << ex.what(); return (isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str())); } diff --git a/src/bin/netconf/netconf_process.h b/src/bin/netconf/netconf_process.h index 0c8b6ce702..dbf491a773 100644 --- a/src/bin/netconf/netconf_process.h +++ b/src/bin/netconf/netconf_process.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -79,14 +79,12 @@ public: /// of an integer status value (0 means successful, non-zero means failure), /// and a string explanation of the outcome. isc::data::ConstElementPtr - configure(isc::data::ConstElementPtr config_set, - bool check_only = false) override final; + configure(isc::data::ConstElementPtr config_set, bool check_only = false) override final; /// @brief Returns a pointer to the configuration manager. NetconfCfgMgrPtr getNetconfCfgMgr(); private: - /// @brief Polls all ready handlers and then runs one handler if none /// handlers have been executed as a result of polling. /// diff --git a/src/bin/netconf/parser_context_decl.h b/src/bin/netconf/parser_context_decl.h index 43cb515c4a..f91833a7fd 100644 --- a/src/bin/netconf/parser_context_decl.h +++ b/src/bin/netconf/parser_context_decl.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -14,7 +14,7 @@ namespace netconf { class ParserContext; -} // namespace dhcp +} // namespace netconf } // namespace isc #endif diff --git a/src/bin/netconf/stdout_control_socket.h b/src/bin/netconf/stdout_control_socket.h index cd03cbea16..ab43bce5fe 100644 --- a/src/bin/netconf/stdout_control_socket.h +++ b/src/bin/netconf/stdout_control_socket.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,6 +11,7 @@ #define STDOUT_CONTROL_SOCKET_H #include <netconf/control_socket.h> + #include <iostream> namespace isc { diff --git a/src/bin/netconf/tests/control_socket_unittests.cc b/src/bin/netconf/tests/control_socket_unittests.cc index 5f211cf8e5..d66dce3f8a 100644 --- a/src/bin/netconf/tests/control_socket_unittests.cc +++ b/src/bin/netconf/tests/control_socket_unittests.cc @@ -6,8 +6,6 @@ #include <config.h> -#include <gtest/gtest.h> - #include <asiolink/asio_wrapper.h> #include <asiolink/interval_timer.h> #include <asiolink/io_service.h> @@ -29,6 +27,8 @@ #include <sstream> #include <thread> +#include <gtest/gtest.h> + using namespace std; using namespace isc; using namespace isc::netconf; diff --git a/src/bin/netconf/tests/get_config_unittest.cc b/src/bin/netconf/tests/get_config_unittest.cc index 2eaa7b1d65..98dc57a524 100644 --- a/src/bin/netconf/tests/get_config_unittest.cc +++ b/src/bin/netconf/tests/get_config_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -6,8 +6,6 @@ #include <config.h> -#include <gtest/gtest.h> - #include <cc/command_interpreter.h> #include <cc/data.h> #include <netconf/netconf_cfg_mgr.h> @@ -20,6 +18,8 @@ #include <iostream> #include <string> +#include <gtest/gtest.h> + #include "test_data_files_config.h" #include "test_libraries.h" diff --git a/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc b/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc index 2ca62dfbf4..20fdd9fb2a 100644 --- a/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc +++ b/src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc @@ -6,8 +6,6 @@ #include <config.h> -#include <gtest/gtest.h> - #include <cc/command_interpreter.h> #include <exceptions/exceptions.h> #include <netconf/netconf_cfg_mgr.h> @@ -19,6 +17,8 @@ #include <testutils/test_to_element.h> #include <yang/yang_models.h> +#include <gtest/gtest.h> + using namespace std; using namespace isc; using namespace isc::netconf; @@ -29,7 +29,7 @@ using namespace isc::http; using namespace isc::process; using namespace isc::yang; -namespace { +namespace { /// @brief Almost regular netconf CfgMgr with internal parse method exposed. class NakedNetconfCfgMgr : public NetconfCfgMgr { @@ -64,7 +64,6 @@ TEST(NetconfCfgMgr, getContext) { // Tests if context can store and retrieve managed server information. TEST(NetconfCfgMgr, contextServer) { - NetconfConfig ctx; // Check managed server parameters. @@ -377,7 +376,6 @@ TEST(NetconfParser, badSocketType) { /// @brief Class used for testing CfgMgr class NetconfParserTest : public isc::process::ConfigParseTest { public: - /// @brief Tries to load input text as a configuration /// /// @param config text containing input configuration diff --git a/src/bin/netconf/tests/netconf_controller_unittests.cc b/src/bin/netconf/tests/netconf_controller_unittests.cc index 774ee30506..457dc8b6ba 100644 --- a/src/bin/netconf/tests/netconf_controller_unittests.cc +++ b/src/bin/netconf/tests/netconf_controller_unittests.cc @@ -6,8 +6,6 @@ #include <config.h> -#include <gtest/gtest.h> - #include <asiolink/testutils/timed_signal.h> #include <cc/data.h> #include <netconf/netconf_controller.h> @@ -15,6 +13,8 @@ #include <process/testutils/d_test_stubs.h> #include <testutils/gtest_utils.h> +#include <gtest/gtest.h> + using namespace isc::asiolink::test; using namespace isc::netconf; using namespace isc::data; @@ -186,4 +186,4 @@ TEST_F(NetconfControllerTest, sigtermShutdown) { EXPECT_TRUE(elapsed_time.total_milliseconds() < 300); } -} +} // namespace diff --git a/src/bin/netconf/tests/netconf_process_unittests.cc b/src/bin/netconf/tests/netconf_process_unittests.cc index 7746806e8f..b6d8e391ba 100644 --- a/src/bin/netconf/tests/netconf_process_unittests.cc +++ b/src/bin/netconf/tests/netconf_process_unittests.cc @@ -6,8 +6,6 @@ #include <config.h> -#include <gtest/gtest.h> - #include <asiolink/interval_timer.h> #include <asiolink/io_service.h> #include <netconf/netconf_cfg_mgr.h> @@ -17,6 +15,8 @@ #include <functional> +#include <gtest/gtest.h> + using namespace isc; using namespace isc::netconf; using namespace isc::asiolink; @@ -84,4 +84,4 @@ TEST_F(NetconfProcessTest, shutdown) { getIOService()->stopAndPoll(); } -} +} // namespace diff --git a/src/bin/netconf/tests/netconf_unittests.cc b/src/bin/netconf/tests/netconf_unittests.cc index 448453cd63..23da4c91b7 100644 --- a/src/bin/netconf/tests/netconf_unittests.cc +++ b/src/bin/netconf/tests/netconf_unittests.cc @@ -6,8 +6,6 @@ #include <config.h> -#include <gtest/gtest.h> - #include <asiolink/asio_wrapper.h> #include <asiolink/interval_timer.h> #include <asiolink/io_service.h> @@ -26,14 +24,16 @@ #include <yang/yang_models.h> #include <yang/yang_revisions.h> -#include <sysrepo-cpp/utils/exception.hpp> - #include <chrono> #include <iostream> #include <sstream> #include <thread> #include <vector> +#include <gtest/gtest.h> + +#include <sysrepo-cpp/utils/exception.hpp> + using namespace std; using namespace isc; using namespace isc::netconf; @@ -61,16 +61,16 @@ using ThreadPtr = shared_ptr<thread>; class NakedNetconfAgent : public NetconfAgent { public: /// Export protected methods and fields. - using NetconfAgent::keaConfig; - using NetconfAgent::initSysrepo; using NetconfAgent::checkModule; using NetconfAgent::checkModules; - using NetconfAgent::yangConfig; - using NetconfAgent::subscribeToDataChanges; - using NetconfAgent::startup_sess_; - using NetconfAgent::running_sess_; + using NetconfAgent::initSysrepo; + using NetconfAgent::keaConfig; using NetconfAgent::modules_; + using NetconfAgent::running_sess_; + using NetconfAgent::startup_sess_; + using NetconfAgent::subscribeToDataChanges; using NetconfAgent::subscriptions_; + using NetconfAgent::yangConfig; }; // NakedNetconfAgent /// @brief Type definition for the pointer to NakedNetconfAgent objects. diff --git a/src/bin/netconf/tests/parser_unittests.cc b/src/bin/netconf/tests/parser_unittests.cc index 77fbcad113..6f8b90cf6f 100644 --- a/src/bin/netconf/tests/parser_unittests.cc +++ b/src/bin/netconf/tests/parser_unittests.cc @@ -6,8 +6,6 @@ #include <config.h> -#include <gtest/gtest.h> - #include <cc/data.h> #include <cc/dhcp_config_error.h> #include <netconf/parser_context.h> @@ -17,12 +15,14 @@ #include <testutils/test_to_element.h> #include <testutils/user_context_utils.h> -#include <iostream> #include <fstream> +#include <iostream> #include <vector> #include <boost/algorithm/string.hpp> +#include <gtest/gtest.h> + using namespace isc::data; using namespace isc::test; using namespace std; diff --git a/src/bin/netconf/tests/run_unittests.cc b/src/bin/netconf/tests/run_unittests.cc index 15391d2f7d..5ec7e6a50f 100644 --- a/src/bin/netconf/tests/run_unittests.cc +++ b/src/bin/netconf/tests/run_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2024 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -6,11 +6,11 @@ #include <config.h> -#include <gtest/gtest.h> - #include <log/logger_support.h> #include <util/unittests/run_all.h> +#include <gtest/gtest.h> + int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); |