Browse Source

[master] Merge branch 'trac3744'

Marcin Siodelski 10 years ago
parent
commit
ed3ee8e8d4
2 changed files with 33 additions and 6 deletions
  1. 16 3
      src/bin/dhcp4/json_config_parser.cc
  2. 17 3
      src/bin/dhcp6/json_config_parser.cc

+ 16 - 3
src/bin/dhcp4/json_config_parser.cc

@@ -414,12 +414,14 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
     // depend on the global values. Also, option values configuration
     // depend on the global values. Also, option values configuration
     // must be performed after the option definitions configurations.
     // must be performed after the option definitions configurations.
     // Thus we group parsers and will fire them in the right order:
     // Thus we group parsers and will fire them in the right order:
-    // all parsers other than subnet4 and option-data parser,
-    // option-data parser, subnet4 parser.
+    // all parsers other than: lease-database, subnet4 and option-data parser,
+    // then: option-data parser, subnet4 parser, lease-database parser.
+    // Please do not change this order!
     ParserCollection independent_parsers;
     ParserCollection independent_parsers;
     ParserPtr subnet_parser;
     ParserPtr subnet_parser;
     ParserPtr option_parser;
     ParserPtr option_parser;
     ParserPtr iface_parser;
     ParserPtr iface_parser;
+    ParserPtr leases_parser;
 
 
     // Some of the parsers alter the state of the system in a way that can't
     // Some of the parsers alter the state of the system in a way that can't
     // easily be undone. (Or alter it in a way such that undoing the change has
     // easily be undone. (Or alter it in a way such that undoing the change has
@@ -455,6 +457,8 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
                       .arg(config_pair.first);
                       .arg(config_pair.first);
             if (config_pair.first == "subnet4") {
             if (config_pair.first == "subnet4") {
                 subnet_parser = parser;
                 subnet_parser = parser;
+            } else if (config_pair.first == "lease-database") {
+                leases_parser = parser;
             } else if (config_pair.first == "option-data") {
             } else if (config_pair.first == "option-data") {
                 option_parser = parser;
                 option_parser = parser;
             } else if (config_pair.first == "interfaces-config") {
             } else if (config_pair.first == "interfaces-config") {
@@ -489,7 +493,7 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
             option_parser->commit();
             option_parser->commit();
         }
         }
 
 
-        // The subnet parser is the last one to be run.
+        // The subnet parser is the next one to be run.
         std::map<std::string, ConstElementPtr>::const_iterator subnet_config =
         std::map<std::string, ConstElementPtr>::const_iterator subnet_config =
             values_map.find("subnet4");
             values_map.find("subnet4");
         if (subnet_config != values_map.end()) {
         if (subnet_config != values_map.end()) {
@@ -497,6 +501,15 @@ configureDhcp4Server(Dhcpv4Srv&, isc::data::ConstElementPtr config_set) {
             subnet_parser->build(subnet_config->second);
             subnet_parser->build(subnet_config->second);
         }
         }
 
 
+        // the leases database parser is the last to be run.
+        std::map<std::string, ConstElementPtr>::const_iterator leases_config =
+            values_map.find("lease-database");
+        if (leases_config != values_map.end()) {
+            config_pair.first = "lease-database";
+            leases_parser->build(leases_config->second);
+            leases_parser->commit();
+        }
+
     } catch (const isc::Exception& ex) {
     } catch (const isc::Exception& ex) {
         LOG_ERROR(dhcp4_logger, DHCP4_PARSER_FAIL)
         LOG_ERROR(dhcp4_logger, DHCP4_PARSER_FAIL)
                   .arg(config_pair.first).arg(ex.what());
                   .arg(config_pair.first).arg(ex.what());

+ 17 - 3
src/bin/dhcp6/json_config_parser.cc

@@ -626,12 +626,15 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
     // depend on the global values. Also, option values configuration
     // depend on the global values. Also, option values configuration
     // must be performed after the option definitions configurations.
     // must be performed after the option definitions configurations.
     // Thus we group parsers and will fire them in the right order:
     // Thus we group parsers and will fire them in the right order:
-    // all parsers other than subnet6 and option-data parser,
-    // option-data parser, subnet6 parser.
+    // all parsers other than lease-database, subnet6 and
+    // option-data parser, then option-data parser, subnet6 parser,
+    // lease-database parser.
+    // Please do not change this order!
     ParserCollection independent_parsers;
     ParserCollection independent_parsers;
     ParserPtr subnet_parser;
     ParserPtr subnet_parser;
     ParserPtr option_parser;
     ParserPtr option_parser;
     ParserPtr iface_parser;
     ParserPtr iface_parser;
+    ParserPtr leases_parser;
 
 
     // Some of the parsers alter state of the system that can't easily
     // Some of the parsers alter state of the system that can't easily
     // be undone. (Or alter it in a way such that undoing the change
     // be undone. (Or alter it in a way such that undoing the change
@@ -668,6 +671,8 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
                       .arg(config_pair.first);
                       .arg(config_pair.first);
             if (config_pair.first == "subnet6") {
             if (config_pair.first == "subnet6") {
                 subnet_parser = parser;
                 subnet_parser = parser;
+            } else if (config_pair.first == "lease-database") {
+                leases_parser = parser;
             } else if (config_pair.first == "option-data") {
             } else if (config_pair.first == "option-data") {
                 option_parser = parser;
                 option_parser = parser;
             } else if (config_pair.first == "hooks-libraries") {
             } else if (config_pair.first == "hooks-libraries") {
@@ -703,7 +708,7 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
             option_parser->commit();
             option_parser->commit();
         }
         }
 
 
-        // The subnet parser is the last one to be run.
+        // The subnet parser is the next one to be run.
         std::map<std::string, ConstElementPtr>::const_iterator subnet_config =
         std::map<std::string, ConstElementPtr>::const_iterator subnet_config =
             values_map.find("subnet6");
             values_map.find("subnet6");
         if (subnet_config != values_map.end()) {
         if (subnet_config != values_map.end()) {
@@ -711,6 +716,15 @@ configureDhcp6Server(Dhcpv6Srv&, isc::data::ConstElementPtr config_set) {
             subnet_parser->build(subnet_config->second);
             subnet_parser->build(subnet_config->second);
         }
         }
 
 
+        // The lease database parser is the last to be run.
+        std::map<std::string, ConstElementPtr>::const_iterator leases_config =
+            values_map.find("lease-database");
+        if (leases_config != values_map.end()) {
+            config_pair.first = "lease-database";
+            leases_parser->build(leases_config->second);
+            leases_parser->commit();
+        }
+
     } catch (const isc::Exception& ex) {
     } catch (const isc::Exception& ex) {
         LOG_ERROR(dhcp6_logger, DHCP6_PARSER_FAIL)
         LOG_ERROR(dhcp6_logger, DHCP6_PARSER_FAIL)
                   .arg(config_pair.first).arg(ex.what());
                   .arg(config_pair.first).arg(ex.what());