-# Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2012-2019 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
no interfaces that server should listen on, or specified interfaces are not
configured to receive the traffic.
+% DHCP6_OPEN_CONFIG_DB Opening configuration database: %1
+This message is printed when the DHCPv6 server is attempting to open a
+configuration database. The database access string with password redacted
+is logged.
+
% DHCP6_OPEN_SOCKET opening service sockets on port %1
A debug message issued during startup, this indicates that the IPv6 DHCP
server is about to open sockets on the specified port.
-// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2019 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
#include <dhcp/iface_mgr.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/cfgmgr.h>
+#include <dhcpsrv/config_backend_dhcp6_mgr.h>
#include <dhcpsrv/db_type.h>
#include <dhcpsrv/pool.h>
#include <dhcpsrv/subnet.h>
using namespace isc::dhcp;
using namespace isc::asiolink;
using namespace isc::hooks;
+using namespace isc::process;
namespace {
}
if (config_pair.first == "config-control") {
- process::ConfigControlParser parser;
- process::ConfigControlInfoPtr config_ctl_info = parser.parse(config_pair.second);
+ ConfigControlParser parser;
+ ConfigControlInfoPtr config_ctl_info = parser.parse(config_pair.second);
CfgMgr::instance().getStagingCfg()->setConfigControlInfo(config_ctl_info);
continue;
}
const HooksConfig& libraries =
CfgMgr::instance().getStagingCfg()->getHooksConfig();
libraries.loadLibraries();
+
+#ifdef CONFIG_BACKEND // Disabled until we restart CB work
+ // If there are config backends, fetch and merge into staging config
+ databaseConfigFetch(srv_cfg, mutable_cfg);
+#endif
}
catch (const isc::Exception& ex) {
LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(ex.what());
return (answer);
}
+bool databaseConfigConnect(const SrvConfigPtr& srv_cfg) {
+ // We need to get rid of any existing backends. These would be any
+ // opened by previous configuration cycle.
+ ConfigBackendDHCPv6Mgr& mgr = ConfigBackendDHCPv6Mgr::instance();
+ mgr.delAllBackends();
+
+ // Fetch the config-control info.
+ ConstConfigControlInfoPtr config_ctl = srv_cfg->getConfigControlInfo();
+ if (!config_ctl || config_ctl->getConfigDatabases().empty()) {
+ // No config dbs, nothing to do.
+ return (false);
+ }
+
+ // Iterate over the configured DBs and instantiate them.
+ for (auto db : config_ctl->getConfigDatabases()) {
+ LOG_INFO(dhcp6_logger, DHCP6_OPEN_CONFIG_DB)
+ .arg(db.redactedAccessString());
+ mgr.addBackend(db.getAccessString());
+ }
+
+ // Let the caller know we have opened DBs.
+ return (true);
+}
+
+void databaseConfigFetch(const SrvConfigPtr& srv_cfg, ElementPtr /* mutable_cfg */) {
+
+ // Close any existing CB databasess, then open all in srv_cfg (if any)
+ if (!databaseConfigConnect(srv_cfg)) {
+ // There are no CB databases so we're done
+ return;
+ }
+
+ // @todo Fetching and merging the configuration falls under #99
+ // ConfigBackendDHCPv6Mgr& mgr = ConfigBackendDHCPv6Mgr::instance();
+ // Next we have to fetch the pieces we care about it and merge them
+ // probably in this order?
+ // globals
+ // option defs
+ // options
+ // shared networks
+ // subnets
+}
+
}; // end of isc::dhcp namespace
}; // end of isc namespace
-// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2019 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
configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
bool check_only = false);
+/// @brief Attempts to connect to configured CB databases
+///
+/// First, this function will close all existing CB backends. It
+/// will then attempt to connect to all of the CB backends defined
+/// in the given SrvConfig (if any).
+///
+/// It will return true if there are configured CB databases,
+/// and false otherwise. Any errors encountered along the way
+/// should generate throws.
+///
+/// @param srv_cfg Server configuration from which to get
+/// the config-control information to use.
+///
+/// @return True if there are configured CB databases, false if not.
+bool
+databaseConfigConnect(const SrvConfigPtr& srv_cfg);
+
+/// @brief Fetch configuration from CB databases and merge it into the given configuration
+///
+/// It will call @c databaseConfigConnect, passing in the given server configuration. If
+/// that call results in open CB databases, the function will then proceed to fetch
+/// configuration components from said databases and merge them into the given server
+/// configuration.
+///
+/// @param srv_cfg Server configuration into which database configuration should be merged
+/// @param mutable_cfg parsed configuration from the configuration file plus default values (ignored)
+void
+databaseConfigFetch(const SrvConfigPtr& srv_cfg, isc::data::ElementPtr mutable_cfg);
+
}; // end of isc::dhcp namespace
}; // end of isc namespace
-// Copyright (C) 2012-2018 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2019 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
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/subnet_selector.h>
#include <dhcpsrv/testutils/config_result_check.h>
+#include <dhcpsrv/testutils/test_config_backend_dhcp6.h>
#include <hooks/hooks_manager.h>
#include <process/config_ctl_info.h>
EXPECT_EQ(11, static_cast<int>(opt_prf->getValue()));
}
+// Rather than disable these tests they are compiled out. This avoids them
+// reporting as disbabled and thereby drawing attention to them.
+#ifdef CONFIG_BACKEND
+// This test verifies that configuration control with unsupported type fails
+TEST_F(Dhcp6ParserTest, configControlInfoNoFactory) {
+ string config = PARSER_CONFIGS[6];
+ extractConfig(config);
+
+ // Should fail because "type=mysql" has no factories.
+ configure(config, CONTROL_RESULT_ERROR,
+ "The type of the configuration backend: 'mysql' is not supported");
+#endif // CONFIG_BACKEND}
+
// This test verifies that configuration control info gets populated.
TEST_F(Dhcp6ParserTest, configControlInfo) {
string config = PARSER_CONFIGS[8];