]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[128-netconf-use-libprocess] Addressed last comments
authorFrancis Dupont <fdupont@isc.org>
Wed, 3 Oct 2018 22:22:46 +0000 (00:22 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 3 Oct 2018 22:22:46 +0000 (00:22 +0200)
14 files changed:
src/bin/agent/ca_cfg_mgr.cc
src/bin/agent/tests/ca_unittests.cc
src/bin/d2/d2_cfg_mgr.cc
src/bin/d2/tests/d2_controller_unittests.cc
src/bin/d2/tests/d2_process_unittests.cc
src/bin/netconf/netconf_cfg_mgr.cc
src/bin/netconf/netconf_cfg_mgr.h
src/bin/netconf/simple_parser.cc
src/bin/netconf/simple_parser.h
src/bin/netconf/tests/netconf_cfg_mgr_unittests.cc
src/bin/netconf/tests/netconf_controller_unittests.cc
src/bin/netconf/tests/netconf_process_unittests.cc
src/bin/netconf/tests/run_unittests.cc
src/bin/shell/tests/shell_process_tests.sh.in

index 9086457e028d71d5d2308fb72adb1b858c9170d6..20c193bd10f531a722ea4ea0e5219d9241310dfe 100644 (file)
@@ -12,6 +12,7 @@
 #include <cc/command_interpreter.h>
 #include <exceptions/exceptions.h>
 
+using namespace isc::config;
 using namespace isc::dhcp;
 using namespace isc::process;
 using namespace isc::data;
@@ -86,10 +87,10 @@ CtrlAgentCfgMgr::parse(isc::data::ConstElementPtr config_set, bool check_only) {
         parser.parse(ctx, cfg, check_only);
     } catch (const isc::Exception& ex) {
         excuse = ex.what();
-        answer = isc::config::createAnswer(2, excuse);
+        answer = createAnswer(CONTROL_RESULT_ERROR, excuse);
     } catch (...) {
         excuse = "undefined configuration parsing error";
-        answer = isc::config::createAnswer(2, excuse);
+        answer = createAnswer(CONTROL_RESULT_ERROR, excuse);
     }
 
     // At this stage the answer was created only in case of exception.
@@ -103,9 +104,11 @@ CtrlAgentCfgMgr::parse(isc::data::ConstElementPtr config_set, bool check_only) {
     }
 
     if (check_only) {
-        answer = isc::config::createAnswer(0, "Configuration check successful");
+        answer = createAnswer(CONTROL_RESULT_SUCCESS,
+                              "Configuration check successful");
     } else {
-        answer = isc::config::createAnswer(0, "Configuration applied successfully.");
+        answer = createAnswer(CONTROL_RESULT_SUCCESS,
+                              "Configuration applied successfully.");
     }
 
     return (answer);
index ab55fe8f349360cd6cb44d92f07f08c9a15f5acf..85b494c08222bc0a3e7f631af1e424d36be8d6fa 100644 (file)
@@ -15,7 +15,7 @@ main(int argc, char* argv[]) {
     ::testing::InitGoogleTest(&argc, argv);
 
     // See the documentation of the KEA_* environment variables in
-    // src/lib/log/README for info on how to tweak logging
+    // the developer's guide for info on how to tweak logging
     isc::log::initLogger();
 
     // Override --localstatedir value for PID files
index 9c172ce098752f246aeaeef0b250905be347b74f..cb163d1fbc38f556cef19308509613e89767dceb 100644 (file)
@@ -15,6 +15,7 @@
 #include <boost/foreach.hpp>
 
 using namespace isc::asiolink;
+using namespace isc::config;
 using namespace isc::data;
 using namespace isc::process;
 
@@ -269,10 +270,10 @@ D2CfgMgr::parse(isc::data::ConstElementPtr config_set, bool check_only) {
         parser.parse(ctx, cfg, check_only);
     } catch (const isc::Exception& ex) {
         excuse = ex.what();
-        answer = isc::config::createAnswer(2, excuse);
+        answer = createAnswer(CONTROL_RESULT_ERROR, excuse);
     } catch (...) {
         excuse = "undefined configuration parsing error";
-        answer = isc::config::createAnswer(2, excuse);
+        answer = createAnswer(CONTROL_RESULT_ERROR, excuse);
     }
 
     // At this stage the answer was created only in case of exception.
@@ -286,9 +287,11 @@ D2CfgMgr::parse(isc::data::ConstElementPtr config_set, bool check_only) {
     }
 
     if (check_only) {
-        answer = isc::config::createAnswer(0, "Configuration check successful");
+        answer = createAnswer(CONTROL_RESULT_SUCCESS,
+                              "Configuration check successful");
     } else {
-        answer = isc::config::createAnswer(0, "Configuration applied successfully.");
+        answer = createAnswer(CONTROL_RESULT_SUCCESS,
+                              "Configuration applied successfully.");
     }
 
     return (answer);
index 4ed618813d34d4099c6292c3c9dd5dd5a8e493a0..5ee602cab78bb427d032eb1b29c6e56c16754156 100644 (file)
@@ -188,12 +188,12 @@ TEST_F(D2ControllerTest, configUpdateTests) {
     config_set = isc::data::Element::fromJSON(config);
     answer = updateConfig(config_set);
     isc::config::parseAnswer(rcode, answer);
-    EXPECT_EQ(2, rcode);
+    EXPECT_EQ(1, rcode);
 
     // Use an invalid configuration to verify checking error return.
     answer = checkConfig(config_set);
     isc::config::parseAnswer(rcode, answer);
-    EXPECT_EQ(2, rcode);
+    EXPECT_EQ(1, rcode);
 }
 
 // Tests that the original configuration is retained after a SIGHUP triggered
index 35be2b0d97f791f280f13633d0155d29358acd11..f5eae674a726a99ba4bf29e93ae591b48d7fd863 100644 (file)
@@ -213,7 +213,7 @@ TEST_F(D2ProcessTest, configure) {
     //  Create an invalid configuration set from text config.
     ASSERT_TRUE(fromJSON("{ \"ip-address\": \"950 Charter St.\" } "));
     answer = configure(config_set_, false);
-    ASSERT_TRUE(checkAnswer(answer, 2));
+    ASSERT_TRUE(checkAnswer(answer, 1));
     EXPECT_FALSE(getReconfQueueFlag());
     EXPECT_EQ(D2QueueMgr::RUNNING, queue_mgr->getMgrState());
 }
index cfee2a759fc6df4f6db6f31a285e4ca180026eff..7b61123336339bf55ab92e6468360c7c3853d749 100644 (file)
@@ -12,6 +12,7 @@
 #include <cc/command_interpreter.h>
 #include <exceptions/exceptions.h>
 
+using namespace isc::config;
 using namespace isc::dhcp;
 using namespace isc::process;
 using namespace isc::data;
@@ -19,15 +20,15 @@ using namespace isc::data;
 namespace isc {
 namespace netconf {
 
-NetconfCfgContext::NetconfCfgContext() {
+NetconfConfig::NetconfConfig() {
 }
 
-NetconfCfgContext::NetconfCfgContext(const NetconfCfgContext& orig)
+NetconfConfig::NetconfConfig(const NetconfConfig& orig)
     : ConfigBase(), hooks_config_(orig.hooks_config_) {
 }
 
 NetconfCfgMgr::NetconfCfgMgr()
-    : DCfgMgrBase(ConfigPtr(new NetconfCfgContext())) {
+    : DCfgMgrBase(ConfigPtr(new NetconfConfig())) {
 }
 
 NetconfCfgMgr::~NetconfCfgMgr() {
@@ -36,7 +37,7 @@ NetconfCfgMgr::~NetconfCfgMgr() {
 std::string
 NetconfCfgMgr::getConfigSummary(const uint32_t /*selection*/) {
 
-    NetconfCfgContextPtr ctx = getNetconfCfgContext();
+    NetconfConfigPtr ctx = getNetconfConfig();
 
     std::ostringstream s;
 
@@ -52,7 +53,7 @@ NetconfCfgMgr::getConfigSummary(const uint32_t /*selection*/) {
 
 ConfigPtr
 NetconfCfgMgr::createNewContext() {
-    return (ConfigPtr(new NetconfCfgContext()));
+    return (ConfigPtr(new NetconfConfig()));
 }
 
 isc::data::ConstElementPtr
@@ -63,7 +64,7 @@ NetconfCfgMgr::parse(isc::data::ConstElementPtr config_set,
         isc_throw(DhcpConfigError, "Mandatory config parameter not provided");
     }
 
-    NetconfCfgContextPtr ctx = getNetconfCfgContext();
+    NetconfConfigPtr ctx = getNetconfConfig();
 
     // Set the defaults
     ElementPtr cfg = boost::const_pointer_cast<Element>(config_set);
@@ -78,10 +79,10 @@ NetconfCfgMgr::parse(isc::data::ConstElementPtr config_set,
         parser.parse(ctx, cfg, check_only);
     } catch (const isc::Exception& ex) {
         excuse = ex.what();
-        answer = isc::config::createAnswer(2, excuse);
+        answer = createAnswer(CONTROL_RESULT_ERROR, excuse);
     } catch (...) {
         excuse = "undefined configuration parsing error";
-        answer = isc::config::createAnswer(2, excuse);
+        answer = createAnswer(CONTROL_RESULT_ERROR, excuse);
     }
 
     // At this stage the answer was created only in case of exception.
@@ -95,16 +96,18 @@ NetconfCfgMgr::parse(isc::data::ConstElementPtr config_set,
     }
 
     if (check_only) {
-        answer = isc::config::createAnswer(0, "Configuration check successful");
+        answer = createAnswer(CONTROL_RESULT_SUCCESS,
+                              "Configuration check successful");
     } else {
-        answer = isc::config::createAnswer(0, "Configuration applied successfully.");
+        answer = createAnswer(CONTROL_RESULT_SUCCESS,
+                              "Configuration applied successfully.");
     }
 
     return (answer);
 }
 
 ElementPtr
-NetconfCfgContext::toElement() const {
+NetconfConfig::toElement() const {
     ElementPtr netconf = Element::createMap();
     // Set user-context
     contextToElement(netconf);
index ca3e4d0cac6a32f43348575846452d28d0200fba..0a56d0c820bca86991f5f74d4ae5660524514c89 100644 (file)
@@ -17,9 +17,9 @@
 namespace isc {
 namespace netconf {
 
-class NetconfCfgContext;
+class NetconfConfig;
 /// @brief Pointer to a configuration context.
-typedef boost::shared_ptr<NetconfCfgContext> NetconfCfgContextPtr;
+typedef boost::shared_ptr<NetconfConfig> NetconfConfigPtr;
 
 /// @brief Netconf Configuration Context.
 ///
@@ -28,11 +28,11 @@ typedef boost::shared_ptr<NetconfCfgContext> NetconfCfgContextPtr;
 /// and any other Netconf specific information that needs to be accessible
 /// during configuration parsing as well as to the application as a whole.
 /// It is derived from the context base class, ConfigBase.
-class NetconfCfgContext : public process::ConfigBase {
+class NetconfConfig : public process::ConfigBase {
 public:
 
     /// @brief Default constructor
-    NetconfCfgContext();
+    NetconfConfig();
 
     /// @brief Returns non-const reference to configured hooks libraries.
     ///
@@ -66,12 +66,12 @@ private:
     /// It is private to forbid anyone outside of this class to make copies.
     ///
     /// @param orig the original context to copy from
-    NetconfCfgContext(const NetconfCfgContext& orig);
+    NetconfConfig(const NetconfConfig& orig);
 
     /// @brief Private assignment operator to avoid potential for slicing.
     ///
     /// @param rhs Context to be assigned.
-    NetconfCfgContext& operator=(const NetconfCfgContext& rhs);
+    NetconfConfig& operator=(const NetconfConfig& rhs);
 
     /// @brief Configured hooks libraries.
     isc::hooks::HooksConfig hooks_config_;
@@ -94,8 +94,8 @@ public:
     /// context.
     ///
     /// @return returns a pointer to the configuration context.
-    NetconfCfgContextPtr getNetconfCfgContext() {
-        return (boost::dynamic_pointer_cast<NetconfCfgContext>(getContext()));
+    NetconfConfigPtr getNetconfConfig() {
+        return (boost::dynamic_pointer_cast<NetconfConfig>(getContext()));
     }
 
     /// @brief Returns configuration summary in the textual format.
@@ -117,11 +117,11 @@ protected:
     virtual isc::data::ConstElementPtr
     parse(isc::data::ConstElementPtr config, bool check_only);
 
-    /// @brief Creates a new, blank NetconfCfgContext context.
+    /// @brief Creates a new, blank NetconfConfig context.
     ///
     ///
     /// This method is used at the beginning of configuration process to
-    /// create a fresh, empty copy of a NetconfCfgContext. This new context
+    /// create a fresh, empty copy of a NetconfConfig. This new context
     /// will be populated during the configuration process and will replace the
     /// existing context provided the configuration process completes without
     /// error.
index d3a3ffd64a8b8f53fcf1600c30d40a79dabb7620..bee5dd8b1ab05fcfc91b128f57553149253ea5d6 100644 (file)
@@ -53,7 +53,7 @@ size_t NetconfSimpleParser::setAllDefaults(const isc::data::ElementPtr& global)
 }
 
 void
-NetconfSimpleParser::parse(const NetconfCfgContextPtr& ctx,
+NetconfSimpleParser::parse(const NetconfConfigPtr& ctx,
                            const isc::data::ConstElementPtr& config,
                            bool check_only) {
 
index f2422e6528bab2f14a0a59b92c589562284eec26..a0216fea7d5a3dedbbc825f251e4d6d99195fc08 100644 (file)
@@ -37,7 +37,7 @@ public:
     /// @param check_only - if true the configuration is verified only, not applied
     ///
     /// @throw ConfigError if any issues are encountered.
-    void parse(const NetconfCfgContextPtr& ctx,
+    void parse(const NetconfConfigPtr& ctx,
                const isc::data::ConstElementPtr& config,
                bool check_only);
 
index 8a38c924bf8159512c3d55dba9f86089c2e5cbc0..038ae2f61b5f5ca6aadb70fea27f809fceac2d76 100644 (file)
@@ -35,8 +35,8 @@ TEST(NetconfCfgMgr, construction) {
     ASSERT_NO_THROW(cfg_mgr.reset(new NetconfCfgMgr()));
 
     // Verify that the context can be retrieved and is not null.
-    NetconfCfgContextPtr context;
-    ASSERT_NO_THROW(context = cfg_mgr->getNetconfCfgContext());
+    NetconfConfigPtr context;
+    ASSERT_NO_THROW(context = cfg_mgr->getNetconfConfig());
     EXPECT_TRUE(context);
 
     // Verify that the manager can be destructed without error.
@@ -47,14 +47,14 @@ TEST(NetconfCfgMgr, construction) {
 TEST(NetconfCfgMgr, getContext) {
     NetconfCfgMgr cfg_mgr;
 
-    NetconfCfgContextPtr ctx;
-    ASSERT_NO_THROW(ctx = cfg_mgr.getNetconfCfgContext());
+    NetconfConfigPtr ctx;
+    ASSERT_NO_THROW(ctx = cfg_mgr.getNetconfConfig());
     ASSERT_TRUE(ctx);
 }
 
 // Tests if the context can store and retrieve hook libs information.
 TEST(NetconfCfgMgr, contextHookParams) {
-    NetconfCfgContext ctx;
+    NetconfConfig ctx;
 
     // By default there should be no hooks.
     HooksConfig& libs = ctx.getHooksConfig();
index 2ba3563627e7bc2a5268e19747eeb70c651feeb9..d984b8f3fc42aa4994ca5de04e7491b14deb2180 100644 (file)
@@ -49,10 +49,10 @@ public:
     }
 
     /// @brief Returns a pointer to the configuration context.
-    NetconfCfgContextPtr getNetconfCfgContext() {
-        NetconfCfgContextPtr p;
+    NetconfConfigPtr getNetconfConfig() {
+        NetconfConfigPtr p;
         if (getNetconfCfgMgr()) {
-            p = getNetconfCfgMgr()->getNetconfCfgContext();
+            p = getNetconfCfgMgr()->getNetconfConfig();
         }
         return (p);
     }
index 0fc73cec79eec98634a5add9a5065e44386e8c4e..e75b38323fbae7d9c921ed2de448dd9dc85e0989 100644 (file)
@@ -29,7 +29,7 @@ public:
     NetconfProcessTest() :
         NetconfProcess("netconf-test",
                       IOServicePtr(new isc::asiolink::IOService())) {
-        NetconfCfgContextPtr ctx = getNetconfCfgMgr()->getNetconfCfgContext();
+        NetconfConfigPtr ctx = getNetconfCfgMgr()->getNetconfConfig();
     }
 
     /// @brief Destructor
index 77dbb04902eb235003d8a8e81768e0473e4b5ad0..3d8595f0e58faa03d94ee4b367b59ac965e76ad7 100644 (file)
@@ -15,7 +15,7 @@ main(int argc, char* argv[]) {
     ::testing::InitGoogleTest(&argc, argv);
 
     // See the documentation of the KEA_* environment variables in
-    // src/lib/log/README for info on how to tweak logging
+    // the developer guide for info on how to tweak logging
     isc::log::initLogger();
 
     // Override --localstatedir value for PID files
index 5171ec0cdbe6b4bd64422075bf6895db0a22f8eb..8e33c7f0cdcec9167190894ddaa55175961e60ea 100644 (file)
@@ -190,5 +190,5 @@ shell_command_test "shell.no-map-config-test" "config-test" \
     "[ { \"result\": 1, \"text\": \"'Control-agent' parameter expected to be a map.\" } ]" \
     "\"Control-agent\": [ ]"
 shell_command_test "shell.bad-value-config-test" "config-test" \
-    "[ { \"result\": 2, \"text\": \"out of range value (80000) specified for parameter 'http-port' (<string>:1:76) You did not include \\\"service\\\" parameter in the command, which indicates that Kea Control Agent should process this command rather than forward it to one or more DHCP servers. If you aimed to send this command to one of the DHCP servers you should include the \\\"service\\\" parameter in your request, e.g. \\\"service\\\": [ \\\"dhcp4\\\" ] to forward the command to the DHCPv4 server, or \\\"service\\\": [ \\\"dhcp4\\\", \\\"dhcp6\\\" ] to forward it to both DHCPv4 and DHCPv6 servers etc.\" } ]" \
+    "[ { \"result\": 1, \"text\": \"out of range value (80000) specified for parameter 'http-port' (<string>:1:76)\" } ]" \
     "\"Control-agent\": { \"http-port\": 80000 }"