}
}
static Server* server_;
- static isc::config::ModuleCCSession* session_;
typedef boost::shared_ptr<List> ListPtr;
public:
/// \brief Initializes the class.
/// \throw isc::InvalidParameter if any of the parameters is NULL
/// \throw isc::config::ModuleCCError if the remote configuration is not
/// available for some reason.
- static void init(isc::config::ModuleCCSession* session,
- Server* server)
- {
- if (session == NULL) {
- isc_throw(isc::InvalidParameter, "The session must not be NULL");
- }
+ static void init(Server* server) {
if (server == NULL) {
isc_throw(isc::InvalidParameter, "The server must not be NULL");
}
"The configurator is already initialized");
}
server_ = server;
- session_ = session;
- session->addRemoteConfig("data_sources", reconfigureInternal, false);
}
+
/// \brief Deinitializes the class.
///
/// This detaches from the session and removes the server from internal
/// This can be called even if it is not initialized currently. You
/// can initialize it again after this.
static void cleanup() {
- if (session_ != NULL) {
- session_->removeRemoteConfig("data_sources");
- }
- session_ = NULL;
server_ = NULL;
}
+
/// \brief Reads new configuration and replaces the old one.
///
/// It instructs the server to replace the lists with new ones as needed.
}
};
-template<class Server, class List>
-isc::config::ModuleCCSession*
-DataSourceConfiguratorGeneric<Server, List>::session_(NULL);
-
template<class Server, class List>
Server* DataSourceConfiguratorGeneric<Server, List>::server_(NULL);
DataSourceConfigurator;
#endif
+
+// Local Variables:
+// mode: c++
+// End:
return (execAuthServerCommand(*auth_server, command, args));
}
+void
+datasrcConfigHandler(const std::string&,
+ isc::data::ConstElementPtr config,
+ const isc::config::ConfigData&)
+{
+ if (config->contains("classes")) {
+ DataSourceConfigurator::reconfigure(config->get("classes"));
+ }
+}
+
void
usage() {
cerr << "Usage: b10-auth [-v]"
auth_server->setTSIGKeyRing(&isc::server_common::keyring);
// Start the data source configuration
- DataSourceConfigurator::init(config_session, auth_server);
+ DataSourceConfigurator::init(auth_server);
+ config_session->addRemoteConfig("data_sources", datasrcConfigHandler,
+ false);
// HACK: The default is not passed to the handler. This one will
// get the default (or, current value). Further updates will work
// the usual way.
xfrin_session->disconnect();
}
- DataSourceConfigurator::cleanup();
+ //DataSourceConfigurator::cleanup();
+ config_session->removeRemoteConfig("data_sources");
delete xfrin_session;
delete config_session;
delete cc_session;
typedef DataSourceConfiguratorGeneric<DatasrcConfiguratorTest,
FakeList> Configurator;
+void
+datasrcConfigHandler(const std::string&,
+ isc::data::ConstElementPtr config,
+ const isc::config::ConfigData&)
+{
+ if (config->contains("classes")) {
+ Configurator::reconfigure(config->get("classes"));
+ }
+}
+
class DatasrcConfiguratorTest : public ::testing::Test {
public:
// These pretend to be the server
}
void TearDown() {
// Make sure no matter what we did, it is cleaned up.
+ mccs->removeRemoteConfig("data_sources");
Configurator::cleanup();
}
void init(const ElementPtr& config = ElementPtr()) {
session.getMessages()->
add(createAnswer(0, ElementPtr(new MapElement)));
}
- Configurator::init(mccs.get(), this);
+ Configurator::init(this);
+ mccs->addRemoteConfig("data_sources", datasrcConfigHandler, false);
}
void SetUp() {
init();
return (external);
}
void initializeINList() {
- const ElementPtr
+ const ConstElementPtr
config(buildConfig("{\"IN\": [{\"type\": \"xxx\"}]}"));
- session.addMessage(createCommand("config_update", config), "data_sources",
- "*");
+ session.addMessage(createCommand("config_update", config),
+ "data_sources", "*");
mccs->checkCommand();
// Check it called the correct things (check that there's no IN yet and
// set a new one.
EXPECT_THROW(init(), InvalidOperation);
EXPECT_TRUE(session.haveSubscription("data_sources", "*"));
// Deinitialize to make the tests reasonable
+ mccs->removeRemoteConfig("data_sources");
Configurator::cleanup();
EXPECT_FALSE(session.haveSubscription("data_sources", "*"));
// We can't reconfigure now (not even manually)
EXPECT_THROW(Configurator::reconfigure(ElementPtr(new MapElement())),
InvalidOperation);
- // If one of them is NULL, it does not work
- EXPECT_THROW(Configurator::init(NULL, this), InvalidParameter);
- EXPECT_FALSE(session.haveSubscription("data_sources", "*"));
- EXPECT_THROW(Configurator::init(mccs.get(), NULL), InvalidParameter);
+ // If the server param is NULL, it does not work
+ EXPECT_THROW(Configurator::init(NULL), InvalidParameter);
EXPECT_FALSE(session.haveSubscription("data_sources", "*"));
// But we can initialize it again now
EXPECT_NO_THROW(init());