Browse Source

[master] Merge branch 'trac5030'

Marcin Siodelski 8 years ago
parent
commit
b55841b6a4

+ 9 - 5
src/bin/dhcp4/json_config_parser.cc

@@ -152,9 +152,8 @@ public:
         // Parse Host Reservations for this subnet if any.
         ConstElementPtr reservations = subnet->get("reservations");
         if (reservations) {
-            ParserPtr parser(new HostReservationsListParser<
-                             HostReservationParser4>(subnet_->getID()));
-            parser->build(reservations);
+            HostReservationsListParser<HostReservationParser4> parser;
+            parser.parse(subnet_->getID(), reservations);
         }
     }
 
@@ -444,8 +443,7 @@ DhcpConfigParser* createGlobalDhcp4ConfigParser(const std::string& config_id,
         parser = new ExpirationConfigParser();
     } else if (config_id.compare("client-classes") == 0) {
         parser = new ClientClassDefListParser(config_id, globalContext());
-    } else if (config_id.compare("host-reservation-identifiers") == 0) {
-        parser = new HostReservationIdsParser4();
+    // host-reservation-identifiers have been converted to SimpleParser already.
     } else {
         isc_throw(DhcpConfigError,
                 "unsupported global configuration parameter: "
@@ -642,6 +640,12 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
                 continue;
             }
 
+            if (config_pair.first == "host-reservation-identifiers") {
+                HostReservationIdsParser4 parser;
+                parser.parse(config_pair.second);
+                continue;
+            }
+
             ParserPtr parser(createGlobalDhcp4ConfigParser(config_pair.first,
                                                            config_pair.second));
             LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_PARSER_CREATED)

+ 9 - 5
src/bin/dhcp6/json_config_parser.cc

@@ -385,9 +385,8 @@ public:
             // Parse Host Reservations for this subnet if any.
             ConstElementPtr reservations = subnet->get("reservations");
             if (reservations) {
-                ParserPtr parser(new HostReservationsListParser<
-                                 HostReservationParser6>(subnet_->getID()));
-                parser->build(reservations);
+                HostReservationsListParser<HostReservationParser6> parser;
+                parser.parse(subnet_->getID(), reservations);
             }
         }
     }
@@ -727,8 +726,7 @@ DhcpConfigParser* createGlobal6DhcpConfigParser(const std::string& config_id,
         parser = new ClientClassDefListParser(config_id, globalContext());
     } else if (config_id.compare("server-id") == 0) {
         parser = new DUIDConfigParser();
-    } else if (config_id.compare("host-reservation-identifiers") == 0) {
-        parser = new HostReservationIdsParser6();
+    // host-reservation-identifiers have been converted to SimpleParser already.
     } else {
         isc_throw(DhcpConfigError,
                 "unsupported global configuration parameter: "
@@ -921,6 +919,12 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
                 continue;
             }
 
+            if (config_pair.first == "host-reservation-identifiers") {
+                HostReservationIdsParser6 parser;
+                parser.parse(config_pair.second);
+                continue;
+            }
+
             ParserPtr parser(createGlobal6DhcpConfigParser(config_pair.first,
                                                            config_pair.second));
             LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL, DHCP6_PARSER_CREATED)

+ 21 - 19
src/lib/dhcpsrv/parsers/host_reservation_parser.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2017 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
@@ -94,12 +94,15 @@ getSupportedParams6(const bool identifiers_only = false) {
 namespace isc {
 namespace dhcp {
 
-HostReservationParser::HostReservationParser(const SubnetID& subnet_id)
-    : DhcpConfigParser(), subnet_id_(subnet_id) {
+void
+HostReservationParser::parse(const SubnetID& subnet_id,
+                             isc::data::ConstElementPtr reservation_data) {
+    parseInternal(subnet_id, reservation_data);
 }
 
 void
-HostReservationParser::build(isc::data::ConstElementPtr reservation_data) {
+HostReservationParser::parseInternal(const SubnetID& subnet_id,
+                                     isc::data::ConstElementPtr reservation_data) {
     std::string identifier;
     std::string identifier_name;
     std::string hostname;
@@ -180,15 +183,12 @@ HostReservationParser::isSupportedParameter(const std::string& param_name) const
     return (getSupportedParameters(false).count(param_name) > 0);
 }
 
-HostReservationParser4::HostReservationParser4(const SubnetID& subnet_id)
-    : HostReservationParser(subnet_id) {
-}
-
 void
-HostReservationParser4::build(isc::data::ConstElementPtr reservation_data) {
-    HostReservationParser::build(reservation_data);
+HostReservationParser4::parseInternal(const SubnetID& subnet_id,
+                                      isc::data::ConstElementPtr reservation_data) {
+    HostReservationParser::parseInternal(subnet_id, reservation_data);
 
-    host_->setIPv4SubnetID(subnet_id_);
+    host_->setIPv4SubnetID(subnet_id);
 
     BOOST_FOREACH(ConfigPair element, reservation_data->mapValue()) {
         // For 'option-data' element we will use another parser which
@@ -242,15 +242,12 @@ HostReservationParser4::getSupportedParameters(const bool identifiers_only) cons
     return (getSupportedParams4(identifiers_only));
 }
 
-HostReservationParser6::HostReservationParser6(const SubnetID& subnet_id)
-    : HostReservationParser(subnet_id) {
-}
-
 void
-HostReservationParser6::build(isc::data::ConstElementPtr reservation_data) {
-    HostReservationParser::build(reservation_data);
+HostReservationParser6::parseInternal(const SubnetID& subnet_id,
+                                      isc::data::ConstElementPtr reservation_data) {
+    HostReservationParser::parseInternal(subnet_id, reservation_data);
 
-    host_->setIPv6SubnetID(subnet_id_);
+    host_->setIPv6SubnetID(subnet_id);
 
     BOOST_FOREACH(ConfigPair element, reservation_data->mapValue()) {
         // Parse option values. Note that the configuration option parser
@@ -359,7 +356,12 @@ HostReservationIdsParser::HostReservationIdsParser()
 }
 
 void
-HostReservationIdsParser::build(isc::data::ConstElementPtr ids_list) {
+HostReservationIdsParser::parse(isc::data::ConstElementPtr ids_list) {
+    parseInternal(ids_list);
+}
+
+void
+HostReservationIdsParser::parseInternal(isc::data::ConstElementPtr ids_list) {
     // Remove existing identifier types.
     staging_cfg_->clearIdentifierTypes();
 

+ 46 - 38
src/lib/dhcpsrv/parsers/host_reservation_parser.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2017 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
@@ -8,34 +8,45 @@
 #define HOST_RESERVATION_PARSER_H
 
 #include <cc/data.h>
+#include <cc/simple_parser.h>
 #include <dhcpsrv/host.h>
-#include <dhcpsrv/parsers/dhcp_config_parser.h>
 
 namespace isc {
 namespace dhcp {
 
 /// @brief Parser for a single host reservation entry.
-class HostReservationParser : public DhcpConfigParser {
+class HostReservationParser : public isc::data::SimpleParser {
 public:
 
-    /// @brief Constructor.
+    /// @brief Destructor.
+    virtual ~HostReservationParser() { }
+
+    /// @brief Parses a single entry for host reservation.
     ///
     /// @param subnet_id Identifier of the subnet that the host is
     /// connected to.
-    HostReservationParser(const SubnetID& subnet_id);
+    /// @param reservation_data Data element holding map with a host
+    /// reservation configuration.
+    ///
+    /// @throw DhcpConfigError If the configuration is invalid.
+    void parse(const SubnetID& subnet_id,
+               isc::data::ConstElementPtr reservation_data);
+
+protected:
 
     /// @brief Parses a single entry for host reservation.
     ///
+    /// This method is called by @ref parse and it can be overriden in the
+    /// derived classes to provide class specific parsing logic.
+    ///
+    /// @param subnet_id Identifier of the subnet that the host is
+    /// connected to.
     /// @param reservation_data Data element holding map with a host
     /// reservation configuration.
     ///
     /// @throw DhcpConfigError If the configuration is invalid.
-    virtual void build(isc::data::ConstElementPtr reservation_data);
-
-    /// @brief Commit, unused.
-    virtual void commit() { }
-
-protected:
+    virtual void parseInternal(const SubnetID& subnet_id,
+                               isc::data::ConstElementPtr reservation_data);
 
     /// @brief Inserts @c host_ object to the staging configuration.
     ///
@@ -73,9 +84,6 @@ protected:
     virtual const std::set<std::string>&
     getSupportedParameters(const bool identifiers_only) const = 0;
 
-    /// @brief Identifier of the subnet that the host is connected to.
-    SubnetID subnet_id_;
-
     /// @brief Holds a pointer to @c Host object representing a parsed
     /// host reservation configuration.
     HostPtr host_;
@@ -84,23 +92,18 @@ protected:
 
 /// @brief Parser for a single host reservation for DHCPv4.
 class HostReservationParser4 : public HostReservationParser {
-public:
+protected:
 
-    /// @brief Constructor.
+    /// @brief Parses a single host reservation for DHCPv4.
     ///
     /// @param subnet_id Identifier of the subnet that the host is
     /// connected to.
-    HostReservationParser4(const SubnetID& subnet_id);
-
-    /// @brief Parses a single host reservation for DHCPv4.
-    ///
     /// @param reservation_data Data element holding map with a host
     /// reservation configuration.
     ///
     /// @throw DhcpConfigError If the configuration is invalid.
-    virtual void build(isc::data::ConstElementPtr reservation_data);
-
-protected:
+    virtual void parseInternal(const SubnetID& subnet_id,
+                               isc::data::ConstElementPtr reservation_data);
 
     /// @brief Returns set of the supported parameters for DHCPv4.
     ///
@@ -111,28 +114,22 @@ protected:
     /// @return Set of supported parameter names.
     virtual const std::set<std::string>&
     getSupportedParameters(const bool identifiers_only) const;
-
 };
 
 /// @brief Parser for a single host reservation for DHCPv6.
 class HostReservationParser6 : public HostReservationParser {
-public:
+protected:
 
-    /// @brief Constructor.
+    /// @brief Parses a single host reservation for DHCPv6.
     ///
     /// @param subnet_id Identifier of the subnet that the host is
     /// connected to.
-    HostReservationParser6(const SubnetID& subnet_id);
-
-    /// @brief Parses a single host reservation for DHCPv6.
-    ///
     /// @param reservation_data Data element holding map with a host
     /// reservation configuration.
     ///
     /// @throw DhcpConfigError If the configuration is invalid.
-    virtual void build(isc::data::ConstElementPtr reservation_data);
-
-protected:
+    virtual void parseInternal(const SubnetID& subnet_id,
+                               isc::data::ConstElementPtr reservation_data);
 
     /// @brief Returns set of the supported parameters for DHCPv6.
     ///
@@ -151,25 +148,36 @@ protected:
 /// This is a parent parser class for parsing "host-reservation-identifiers"
 /// global configuration parmeter. The DHCPv4 and DHCPv6 specific parsers
 /// derive from this class.
-class HostReservationIdsParser : public DhcpConfigParser {
+class HostReservationIdsParser : public isc::data::SimpleParser {
 public:
 
     /// @brief Constructor.
     HostReservationIdsParser();
 
+    /// @brief Destructor.
+    virtual ~HostReservationIdsParser() { }
+
     /// @brief Parses a list of host identifiers.
     ///
     /// @param ids_list Data element pointing to an ordered list of host
     /// identifier names.
     ///
     /// @throw DhcpConfigError If specified configuration is invalid.
-    virtual void build(isc::data::ConstElementPtr ids_list);
-
-    /// @brief Commit, unused.
-    virtual void commit() { }
+    void parse(isc::data::ConstElementPtr ids_list);
 
 protected:
 
+    /// @brief Parses a list of host identifiers.
+    ///
+    /// This method is called by @ref parse and it can be overriden in the
+    /// derived classes to provide class specific parsing logic.
+    ///
+    /// @param ids_list Data element pointing to an ordered list of host
+    /// identifier names.
+    ///
+    /// @throw DhcpConfigError If specified configuration is invalid.
+    virtual void parseInternal(isc::data::ConstElementPtr ids_list);
+
     /// @brief Checks if specified identifier name is supported in the
     /// context of the parser.
     ///

+ 7 - 22
src/lib/dhcpsrv/parsers/host_reservations_list_parser.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2017 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
@@ -8,8 +8,8 @@
 #define HOST_RESERVATIONS_LIST_PARSER_H
 
 #include <cc/data.h>
+#include <cc/simple_parser.h>
 #include <dhcpsrv/subnet_id.h>
-#include <dhcpsrv/parsers/dhcp_config_parser.h>
 #include <boost/foreach.hpp>
 
 namespace isc {
@@ -21,39 +21,24 @@ namespace dhcp {
 /// parse individual reservations: @c HostReservationParser4 or
 /// @c HostReservationParser6.
 template<typename HostReservationParserType>
-class HostReservationsListParser : public DhcpConfigParser {
+class HostReservationsListParser : public isc::data::SimpleParser {
 public:
 
-    /// @brief Constructor.
+    /// @brief Parses a list of host reservation entries for a subnet.
     ///
     /// @param subnet_id Identifier of the subnet to which the reservations
     /// belong.
-    HostReservationsListParser(const SubnetID& subnet_id)
-        : subnet_id_(subnet_id) {
-    }
-
-    /// @brief Parses a list of host reservation entries for a subnet.
-    ///
     /// @param hr_list Data element holding a list of host reservations.
     /// Each host reservation is described by a map object.
     ///
     /// @throw DhcpConfigError If the configuration if any of the reservations
     /// is invalid.
-    virtual void build(isc::data::ConstElementPtr hr_list) {
+    void parse(const SubnetID& subnet_id, isc::data::ConstElementPtr hr_list) {
         BOOST_FOREACH(data::ConstElementPtr reservation, hr_list->listValue()) {
-            ParserPtr parser(new HostReservationParserType(subnet_id_));
-            parser->build(reservation);
+            HostReservationParserType parser;
+            parser.parse(subnet_id, reservation);
         }
     }
-
-    /// @brief Commit, unused.
-    virtual void commit() { }
-
-private:
-
-    /// @brief Identifier of the subnet to whic the reservations belong.
-    SubnetID subnet_id_;
-
 };
 
 }

+ 33 - 32
src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2017 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,6 +15,7 @@
 #include <dhcp/option6_addrlst.h>
 #include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/host.h>
+#include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <dhcpsrv/parsers/host_reservation_parser.h>
 #include <dhcpsrv/testutils/config_result_check.h>
 #include <boost/pointer_cast.hpp>
@@ -115,8 +116,8 @@ protected:
 
         ElementPtr config_element = Element::fromJSON(config);
 
-        ParserType parser(SubnetID(10));
-        ASSERT_NO_THROW(parser.build(config_element));
+        ParserType parser;
+        ASSERT_NO_THROW(parser.parse(SubnetID(10), config_element));
 
         // Retrieve a host.
         HostCollection hosts;
@@ -146,8 +147,8 @@ protected:
 
         ElementPtr config_element = Element::fromJSON(config.str());
 
-        HostReservationParser4 parser(SubnetID(10));
-        ASSERT_NO_THROW(parser.build(config_element));
+        HostReservationParser4 parser;
+        ASSERT_NO_THROW(parser.parse(SubnetID(10), config_element));
 
         CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
         HostCollection hosts;
@@ -171,8 +172,8 @@ protected:
     template<typename ParserType>
     void testInvalidConfig(const std::string& config) const {
         ElementPtr config_element = Element::fromJSON(config);
-        ParserType parser(SubnetID(10));
-        EXPECT_THROW(parser.build(config_element), DhcpConfigError);
+        ParserType parser;
+        EXPECT_THROW(parser.parse(SubnetID(10), config_element), DhcpConfigError);
     }
 
     /// @brief HW Address object used by tests.
@@ -285,8 +286,8 @@ TEST_F(HostReservationParserTest, dhcp4NoHostname) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationParser4 parser(SubnetID(10));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationParser4 parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(10), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -308,8 +309,8 @@ TEST_F(HostReservationParserTest, dhcp4ClientClasses) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationParser4 parser(SubnetID(10));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationParser4 parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(10), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -334,8 +335,8 @@ TEST_F(HostReservationParserTest, dhcp4MessageFields) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationParser4 parser(SubnetID(10));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationParser4 parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(10), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -421,8 +422,8 @@ TEST_F(HostReservationParserTest, noIPAddress) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationParser4 parser(SubnetID(10));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationParser4 parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(10), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -516,8 +517,8 @@ TEST_F(HostReservationParserTest, dhcp6HWaddr) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationParser6 parser(SubnetID(10));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationParser6 parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(10), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -563,8 +564,8 @@ TEST_F(HostReservationParserTest, dhcp6DUID) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationParser6 parser(SubnetID(12));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationParser6 parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(12), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -622,8 +623,8 @@ TEST_F(HostReservationParserTest, dhcp6NoHostname) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationParser6 parser(SubnetID(12));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationParser6 parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(12), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -658,8 +659,8 @@ TEST_F(HostReservationParserTest, dhcp6ClientClasses) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationParser6 parser(SubnetID(10));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationParser6 parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(10), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -769,8 +770,8 @@ TEST_F(HostReservationParserTest, options4) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationParser4 parser(SubnetID(10));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationParser4 parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(10), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -826,8 +827,8 @@ TEST_F(HostReservationParserTest, options6) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationParser6 parser(SubnetID(10));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationParser6 parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(10), config_element));
 
     // One host should have been added to the configuration.
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
@@ -981,7 +982,7 @@ public:
     void testInvalidConfig(const std::string& config) const {
         ElementPtr config_element = Element::fromJSON(config);
         ParserType parser;
-        EXPECT_THROW(parser.build(config_element), DhcpConfigError);
+        EXPECT_THROW(parser.parse(config_element), DhcpConfigError);
     }
 
 };
@@ -995,7 +996,7 @@ TEST_F(HostReservationIdsParserTest, dhcp4Identifiers) {
     ElementPtr config_element = Element::fromJSON(config);
 
     HostReservationIdsParser4 parser;
-    ASSERT_NO_THROW(parser.build(config_element));
+    ASSERT_NO_THROW(parser.parse(config_element));
 
     ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getStagingCfg()->
         getCfgHostOperations4();
@@ -1017,7 +1018,7 @@ TEST_F(HostReservationIdsParserTest, dhcp6Identifiers) {
     ElementPtr config_element = Element::fromJSON(config);
 
     HostReservationIdsParser6 parser;
-    ASSERT_NO_THROW(parser.build(config_element));
+    ASSERT_NO_THROW(parser.parse(config_element));
 
     ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getStagingCfg()->
         getCfgHostOperations6();
@@ -1051,7 +1052,7 @@ TEST_F(HostReservationIdsParserTest, dhcp4AutoIdentifiers) {
     ElementPtr config_element = Element::fromJSON(config);
 
     HostReservationIdsParser4 parser;
-    ASSERT_NO_THROW(parser.build(config_element));
+    ASSERT_NO_THROW(parser.parse(config_element));
 
     ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getStagingCfg()->
         getCfgHostOperations4();
@@ -1094,7 +1095,7 @@ TEST_F(HostReservationIdsParserTest, dhcp6AutoIdentifiers) {
     ElementPtr config_element = Element::fromJSON(config);
 
     HostReservationIdsParser6 parser;
-    ASSERT_NO_THROW(parser.build(config_element));
+    ASSERT_NO_THROW(parser.parse(config_element));
 
     ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getStagingCfg()->
         getCfgHostOperations6();

+ 10 - 9
src/lib/dhcpsrv/tests/host_reservations_list_parser_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2017 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
@@ -13,6 +13,7 @@
 #include <dhcpsrv/cfg_hosts.h>
 #include <dhcpsrv/host.h>
 #include <dhcpsrv/subnet_id.h>
+#include <dhcpsrv/parsers/dhcp_parsers.h>
 #include <dhcpsrv/parsers/host_reservation_parser.h>
 #include <dhcpsrv/parsers/host_reservations_list_parser.h>
 #include <gtest/gtest.h>
@@ -85,8 +86,8 @@ TEST_F(HostReservationsListParserTest, ipv4Reservations) {
 
     ElementPtr config_element = Element::fromJSON(config);
 
-    HostReservationsListParser<HostReservationParser4> parser(SubnetID(1));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationsListParser<HostReservationParser4> parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(1), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -138,8 +139,8 @@ TEST_F(HostReservationsListParserTest, duplicatedIdentifierValue4) {
 
         ElementPtr config_element = Element::fromJSON(config.str());
 
-        HostReservationsListParser<HostReservationParser4> parser(SubnetID(1));
-        EXPECT_THROW(parser.build(config_element), DhcpConfigError);
+        HostReservationsListParser<HostReservationParser4> parser;
+        EXPECT_THROW(parser.parse(SubnetID(1), config_element), DhcpConfigError);
     }
 }
 
@@ -163,8 +164,8 @@ TEST_F(HostReservationsListParserTest, ipv6Reservations) {
     ElementPtr config_element = Element::fromJSON(config);
 
     // Parse configuration.
-    HostReservationsListParser<HostReservationParser6> parser(SubnetID(2));
-    ASSERT_NO_THROW(parser.build(config_element));
+    HostReservationsListParser<HostReservationParser6> parser;
+    ASSERT_NO_THROW(parser.parse(SubnetID(2), config_element));
 
     CfgHostsPtr cfg_hosts = CfgMgr::instance().getStagingCfg()->getCfgHosts();
     HostCollection hosts;
@@ -230,8 +231,8 @@ TEST_F(HostReservationsListParserTest, duplicatedIdentifierValue6) {
 
         ElementPtr config_element = Element::fromJSON(config.str());
 
-        HostReservationsListParser<HostReservationParser6> parser(SubnetID(1));
-        EXPECT_THROW(parser.build(config_element), DhcpConfigError);
+        HostReservationsListParser<HostReservationParser6> parser;
+        EXPECT_THROW(parser.parse(SubnetID(1), config_element), DhcpConfigError);
     }
 }