]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] Finishing merge of trac5096 (migrate database config)
authorFrancis Dupont <fdupont@isc.org>
Wed, 25 Jan 2017 14:00:15 +0000 (15:00 +0100)
committerFrancis Dupont <fdupont@isc.org>
Wed, 25 Jan 2017 14:00:15 +0000 (15:00 +0100)
1  2 
src/bin/dhcp4/dhcp4_lexer.ll
src/bin/dhcp4/dhcp4_parser.yy
src/bin/dhcp4/json_config_parser.cc
src/bin/dhcp4/parser_context.cc
src/bin/dhcp4/parser_context.h
src/bin/dhcp6/dhcp6_lexer.ll
src/bin/dhcp6/dhcp6_parser.yy
src/bin/dhcp6/json_config_parser.cc
src/bin/dhcp6/parser_context.cc
src/bin/dhcp6/parser_context.h

Simple merge
index b00bc7f579b8c8bf5792caaed082fe56c783c09a,e94e63d7b91b1a556c9c501519304a0817ebea30..3d620234234fd9ba714f4d57c26e4f94ad2365f6
@@@ -122,19 -125,7 +127,13 @@@ using namespace std
    PARAMETERS "parameters"
  
    EXPIRED_LEASES_PROCESSING "expired-leases-processing"
 +  RECLAIM_TIMER_WAIT_TIME "reclaim-timer-wait-time"
 +  FLUSH_RECLAIMED_TIMER_WAIT_TIME "flush-reclaimed-timer-wait-time"
 +  HOLD_RECLAIMED_TIME "hold-reclaimed-time"
 +  MAX_RECLAIM_LEASES "max-reclaim-leases"
 +  MAX_RECLAIM_TIME "max-reclaim-time"
 +  UNWARNED_RECLAIM_CYCLES "unwarned-reclaim-cycles"
  
-   SERVER_ID "server-id"
-   IDENTIFIER "identifier"
-   HTYPE "htype"
-   TIME "time"
-   ENTERPRISE_ID "enterprise-id"
    DHCP4O6_PORT "dhcp4o6-port"
  
    CONTROL_SOCKET "control-socket"
  %token <bool> BOOLEAN "boolean"
  
  %type <ElementPtr> value
 +%type <ElementPtr> socket_type
+ %type <ElementPtr> db_type
 +%type <ElementPtr> ncr_protocol_value
 +%type <ElementPtr> replace_client_name_value
  
  %printer { yyoutput << $$; } <*>;
  
index 814df9aa4d3528cc336d13661971e60d7b00744f,cd8c1767d66ee920ba0a04801df7a71916869462..c9178fc79f904a2804a1ef87036ccdd6fa22a860
@@@ -425,14 -426,13 +425,11 @@@ DhcpConfigParser* createGlobalDhcp4Conf
      } else if ((config_id.compare("next-server") == 0)) {
          parser  = new StringParser(config_id,
                                      globalContext()->string_values_);
-     } else if (config_id.compare("lease-database") == 0) {
-         parser = new DbAccessParser(config_id, DbAccessParser::LEASE_DB);
-     } else if (config_id.compare("hosts-database") == 0) {
-         parser = new DbAccessParser(config_id, DbAccessParser::HOSTS_DB);
-         // hooks-libraries are now migrated to SimpleParser.
 -   // lease-database and hosts-database have been converted to SimpleParser already.
 -    } else if (config_id.compare("hooks-libraries") == 0) {
 -        parser = new HooksLibrariesParser(config_id);
--    } else if (config_id.compare("echo-client-id") == 0) {
++    // hooks-libraries are now migrated to SimpleParser.
++    // lease-database and hosts-database have been converted to SimpleParser already.
++     } else if (config_id.compare("echo-client-id") == 0) {
          parser = new BooleanParser(config_id, globalContext()->boolean_values_);
 -    } else if (config_id.compare("dhcp-ddns") == 0) {
 -        parser = new D2ClientConfigParser(config_id);
 +    // dhcp-ddns has been converted to SimpleParser.
      } else if (config_id.compare("match-client-id") == 0) {
          parser = new BooleanParser(config_id, globalContext()->boolean_values_);
      // control-socket has been converted to SimpleParser already.
@@@ -566,7 -568,8 +563,6 @@@ configureDhcp4Server(Dhcpv4Srv&, isc::d
      // Please do not change this order!
      ParserCollection independent_parsers;
      ParserPtr subnet_parser;
-     ParserPtr leases_parser;
 -    ParserPtr iface_parser;
 -    ParserPtr client_classes_parser;
  
      // 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
      ConfigPair config_pair;
      try {
  
++        SrvConfigPtr srv_cfg = CfgMgr::instance().getStagingCfg();
++
          // This is a way to convert ConstElementPtr to ElementPtr.
          // We need a config that can be edited, because we will insert
          // default values and will insert derived values as well.
          ConstElementPtr option_defs = mutable_cfg->get("option-def");
          if (option_defs) {
              OptionDefListParser parser;
--            CfgOptionDefPtr cfg_option_def = CfgMgr::instance().getStagingCfg()->getCfgOptionDef();
++            CfgOptionDefPtr cfg_option_def = srv_cfg->getCfgOptionDef();
              parser.parse(cfg_option_def, option_defs);
          }
  
          const std::map<std::string, ConstElementPtr>& values_map =
                                                          mutable_cfg->mapValue();
          BOOST_FOREACH(config_pair, values_map) {
 -            SrvConfigPtr srv_cfg = CfgMgr::instance().getStagingCfg();
 -
 +            // In principle we could have the following code structured as a series
 +            // of long if else if clauses. That would give a marginal performance
 +            // boost, but would make the code less readable. We had serious issues
 +            // with the parser code debugability, so I decided to keep it as a
 +            // series of independent ifs.
              if (config_pair.first == "option-def") {
                  // This is converted to SimpleParser and is handled already above.
                  continue;
                  continue;
              }
  
-                 CfgIfacePtr cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
 +            if (config_pair.first == "interfaces-config") {
 +                IfacesConfigParser parser(AF_INET);
-                 CfgMgr::instance().getStagingCfg()->setD2ClientConfig(cfg);
++                CfgIfacePtr cfg_iface = srv_cfg->getCfgIface();
 +                parser.parse(cfg_iface, config_pair.second);
 +                continue;
 +            }
 +
 +            if (config_pair.first == "expired-leases-processing") {
 +                ExpirationConfigParser parser;
 +                parser.parse(config_pair.second);
 +                continue;
 +            }
 +
 +            if (config_pair.first == "hooks-libraries") {
 +                hooks_parser.parse(config_pair.second);
 +                hooks_parser.verifyLibraries();
 +                continue;
 +            }
 +            
 +            // Legacy DhcpConfigParser stuff below
 +            if (config_pair.first == "dhcp-ddns") {
 +                // Apply defaults if not in short cut
 +                if (!D2ClientConfigParser::isShortCutDisabled(config_pair.second)) {
 +                    D2ClientConfigParser::setAllDefaults(config_pair.second);
 +                }
 +                D2ClientConfigParser parser;
 +                D2ClientConfigPtr cfg = parser.parse(config_pair.second);
-                 CfgMgr::instance().getStagingCfg()->setClientClassDictionary(dictionary);
++                srv_cfg->setD2ClientConfig(cfg);
 +                continue;
 +            }
 +
 +            if (config_pair.first == "client-classes") {
 +                ClientClassDefListParser parser;
 +                ClientClassDictionaryPtr dictionary =
 +                    parser.parse(config_pair.second, AF_INET);
++                srv_cfg->setClientClassDictionary(dictionary);
++                continue;
++            }
++
+             // Please move at the end when migration will be finished.
+             if (config_pair.first == "lease-database") {
+                 DbAccessParser parser(DbAccessParser::LEASE_DB);
+                 CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
+                 parser.parse(cfg_db_access, config_pair.second);
+                 continue;
+             }
+             if (config_pair.first == "host-database") {
+                 DbAccessParser parser(DbAccessParser::HOSTS_DB);
+                 CfgDbAccessPtr cfg_db_access = srv_cfg->getCfgDbAccess();
+                 parser.parse(cfg_db_access, config_pair.second);
                  continue;
              }
  
                        .arg(config_pair.first);
              if (config_pair.first == "subnet4") {
                  subnet_parser = parser;
-             } else if (config_pair.first == "lease-database") {
-                 leases_parser = parser;
 -            } else if (config_pair.first == "interfaces-config") {
 -                // The interface parser is independent from any other
 -                // parser and can be run here before any other parsers.
 -                iface_parser = parser;
 -                parser->build(config_pair.second);
 -            } else if (config_pair.first == "hooks-libraries") {
 -                // Executing commit will alter currently-loaded hooks
 -                // libraries.  Check if the supplied libraries are valid,
 -                // but defer the commit until everything else has committed.
 -                hooks_parser = parser;
 -                parser->build(config_pair.second);
 -            } else if (config_pair.first == "client-classes") {
 -                client_classes_parser = parser;
              } else {
                  // Those parsers should be started before other
                  // parsers so we can call build straight away.
Simple merge
Simple merge
Simple merge
index 98ee268ddafcb0408f14081a2eb73162142542a5,4536e41e93858b6ee57be3cc4c88a1277340f4ee..fa13b1c60c66dcf2b1b4e22806fd6f92fd70f555
@@@ -197,9 -193,8 +202,10 @@@ using namespace std
  %token <bool> BOOLEAN "boolean"
  
  %type <ElementPtr> value
+ %type <ElementPtr> db_type
  %type <ElementPtr> duid_type
 +%type <ElementPtr> ncr_protocol_value
 +%type <ElementPtr> replace_client_name_value
  
  %printer { yyoutput << $$; } <*>;
  
index f3ed466e701c0eb4410b318a8fec8cd8c5e913eb,2a8994bc39135051da60da559a1fc8a47ed02cab..87a7ec35b67fb19c17fd7b671ee5b9c8db5d5b77
@@@ -702,16 -702,18 +702,13 @@@ DhcpConfigParser* createGlobal6DhcpConf
      } else if (config_id.compare("subnet6") == 0) {
          parser = new Subnets6ListConfigParser(config_id);
      // option-data and option-def are no longer needed here. They're now
 -    //  converted to SimpleParser and are handled in configureDhcp6Server
 -    }  else if (config_id.compare("version") == 0) {
 -        parser  = new StringParser(config_id,
 -                                   globalContext()->string_values_);
 +    // converted to SimpleParser and are handled in configureDhcp6Server.
 +    // interfaces-config has been converted to SimpleParser.
 +    // version was removed - it was a leftover from bindctrl.
-     } else if (config_id.compare("lease-database") == 0) {
-         parser = new DbAccessParser(config_id, DbAccessParser::LEASE_DB);
-     } else if (config_id.compare("hosts-database") == 0) {
-         parser = new DbAccessParser(config_id, DbAccessParser::HOSTS_DB);
 +    // hooks-libraries is now converted to SimpleParser.
+     // lease-database and hosts-database have been converted to SimpleParser already.
 -    } else if (config_id.compare("hooks-libraries") == 0) {
 -        parser = new HooksLibrariesParser(config_id);
 -    } else if (config_id.compare("dhcp-ddns") == 0) {
 -        parser = new D2ClientConfigParser(config_id);
      // mac-source has been converted to SimpleParser.
 +    // dhcp-ddns has been converted to SimpleParser
      } else if (config_id.compare("relay-supplied-options") == 0) {
          parser = new RSOOListConfigParser(config_id);
      // control-socket has been converted to SimpleParser.
@@@ -835,7 -839,8 +832,6 @@@ configureDhcp6Server(Dhcpv6Srv&, isc::d
      // Please do not change this order!
      ParserCollection independent_parsers;
      ParserPtr subnet_parser;
-     ParserPtr leases_parser;
 -    ParserPtr iface_parser;
 -    ParserPtr client_classes_parser;
  
      // 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
      ConfigPair config_pair;
      try {
  
++        SrvConfigPtr srv_config = CfgMgr::instance().getStagingCfg();
++
          // This is a way to convert ConstElementPtr to ElementPtr.
          // We need a config that can be edited, because we will insert
          // default values and will insert derived values as well.
          ConstElementPtr option_defs = mutable_cfg->get("option-def");
          if (option_defs) {
              OptionDefListParser parser;
--            CfgOptionDefPtr cfg_option_def = CfgMgr::instance().getStagingCfg()->getCfgOptionDef();
++            CfgOptionDefPtr cfg_option_def = srv_config->getCfgOptionDef();
              parser.parse(cfg_option_def, option_defs);
          }
  
                  continue;
              }
  
-                 CfgIfacePtr cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
 +            if (config_pair.first == "interfaces-config") {
 +                IfacesConfigParser parser(AF_INET6);
-                 CfgMgr::instance().getStagingCfg()->setD2ClientConfig(cfg);
++                CfgIfacePtr cfg_iface = srv_config->getCfgIface();
 +                parser.parse(cfg_iface, config_pair.second);
 +                continue;
 +            }
 +
 +            if (config_pair.first == "expired-leases-processing") {
 +                ExpirationConfigParser parser;
 +                parser.parse(config_pair.second);
 +                continue;
 +            }
 +
 +            if (config_pair.first == "hooks-libraries") {
 +                hooks_parser.parse(config_pair.second);
 +                hooks_parser.verifyLibraries();
 +                continue;
 +            }
 +
 +            if (config_pair.first == "dhcp-ddns") {
 +                // Apply defaults if not in short cut
 +                if (!D2ClientConfigParser::isShortCutDisabled(config_pair.second)) {
 +                    D2ClientConfigParser::setAllDefaults(config_pair.second);
 +                }
 +                D2ClientConfigParser parser;
 +                D2ClientConfigPtr cfg = parser.parse(config_pair.second);
-                 CfgMgr::instance().getStagingCfg()->setClientClassDictionary(dictionary);
++                srv_config->setD2ClientConfig(cfg);
 +                continue;
 +            }
 +
 +            if (config_pair.first =="client-classes") {
 +                ClientClassDefListParser parser;
 +                ClientClassDictionaryPtr dictionary =
 +                    parser.parse(config_pair.second, AF_INET6);
++                srv_config->setClientClassDictionary(dictionary);
++                continue;
++            }
++
+             // Please move at the end when migration will be finished.
+             if (config_pair.first == "lease-database") {
+                 DbAccessParser parser(DbAccessParser::LEASE_DB);
+                 CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
+                 parser.parse(cfg_db_access, config_pair.second);
+                 continue;
+             }
+             if (config_pair.first == "host-database") {
+                 DbAccessParser parser(DbAccessParser::HOSTS_DB);
+                 CfgDbAccessPtr cfg_db_access = srv_config->getCfgDbAccess();
+                 parser.parse(cfg_db_access, config_pair.second);
                  continue;
              }
  
                        .arg(config_pair.first);
              if (config_pair.first == "subnet6") {
                  subnet_parser = parser;
-             } else if (config_pair.first == "lease-database") {
-                 leases_parser = parser;
 -            } else if (config_pair.first == "hooks-libraries") {
 -                // Executing the commit will alter currently loaded hooks
 -                // libraries. Check if the supplied libraries are valid,
 -                // but defer the commit until after everything else has
 -                // committed.
 -                hooks_parser = parser;
 -                hooks_parser->build(config_pair.second);
 -            } else if (config_pair.first == "interfaces-config") {
 -                // The interface parser is independent from any other parser and
 -                // can be run here before other parsers.
 -                parser->build(config_pair.second);
 -                iface_parser = parser;
 -            } else if (config_pair.first == "client-classes") {
 -                client_classes_parser = parser;
              } else {
                  // Those parsers should be started before other
                  // parsers so we can call build straight away.
Simple merge
Simple merge