Commit a0164fae authored by Marcin Siodelski's avatar Marcin Siodelski

[3588] Return pointer to the RW option definition configs, not a reference.

parent 31a9ba39
...@@ -1807,7 +1807,7 @@ Dhcpv4Srv::unpackOptions(const OptionBuffer& buf, ...@@ -1807,7 +1807,7 @@ Dhcpv4Srv::unpackOptions(const OptionBuffer& buf,
option_defs = LibDHCP::getOptionDefs(Option::V4); option_defs = LibDHCP::getOptionDefs(Option::V4);
} else if (!option_space.empty()) { } else if (!option_space.empty()) {
OptionDefContainerPtr option_defs_ptr = CfgMgr::instance() OptionDefContainerPtr option_defs_ptr = CfgMgr::instance()
.getCurrentCfg()->getCfgOptionDef().getAll(option_space); .getCurrentCfg()->getCfgOptionDef()->getAll(option_space);
if (option_defs_ptr != NULL) { if (option_defs_ptr != NULL) {
option_defs = *option_defs_ptr; option_defs = *option_defs_ptr;
} }
......
...@@ -80,6 +80,7 @@ public: ...@@ -80,6 +80,7 @@ public:
srv_.reset(new Dhcpv4Srv(0)); srv_.reset(new Dhcpv4Srv(0));
// Create fresh context. // Create fresh context.
globalContext()->copyContext(ParserContext(Option::V4)); globalContext()->copyContext(ParserContext(Option::V4));
resetConfiguration();
} }
// Check that no hooks libraries are loaded. This is a pre-condition for // Check that no hooks libraries are loaded. This is a pre-condition for
...@@ -444,8 +445,6 @@ public: ...@@ -444,8 +445,6 @@ public:
void resetConfiguration() { void resetConfiguration() {
string config = "{ \"interfaces\": [ \"*\" ]," string config = "{ \"interfaces\": [ \"*\" ],"
"\"hooks-libraries\": [ ], " "\"hooks-libraries\": [ ], "
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"valid-lifetime\": 4000, " "\"valid-lifetime\": 4000, "
"\"subnet4\": [ ], " "\"subnet4\": [ ], "
"\"dhcp-ddns\": { \"enable-updates\" : false }, " "\"dhcp-ddns\": { \"enable-updates\" : false }, "
...@@ -453,6 +452,7 @@ public: ...@@ -453,6 +452,7 @@ public:
"\"option-data\": [ ] }"; "\"option-data\": [ ] }";
static_cast<void>(executeConfiguration(config, static_cast<void>(executeConfiguration(config,
"reset configuration database")); "reset configuration database"));
CfgMgr::instance().clear();
} }
...@@ -1231,8 +1231,8 @@ TEST_F(Dhcp4ParserTest, optionDefIpv4Address) { ...@@ -1231,8 +1231,8 @@ TEST_F(Dhcp4ParserTest, optionDefIpv4Address) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the particular option definition does not exist. // Make sure that the particular option definition does not exist.
OptionDefinitionPtr def = CfgMgr::instance().getCurrentCfg() OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
->getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_FALSE(def); ASSERT_FALSE(def);
// Use the configuration string to create new option definition. // Use the configuration string to create new option definition.
...@@ -1242,7 +1242,7 @@ TEST_F(Dhcp4ParserTest, optionDefIpv4Address) { ...@@ -1242,7 +1242,7 @@ TEST_F(Dhcp4ParserTest, optionDefIpv4Address) {
checkResult(status, 0); checkResult(status, 0);
// The option definition should now be available in the CfgMgr. // The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getCurrentCfg()->getCfgOptionDef().get("isc", 100); def = CfgMgr::instance().getStagingCfg()->getCfgOptionDef()->get("isc", 100);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Verify that the option definition data is valid. // Verify that the option definition data is valid.
...@@ -1273,8 +1273,8 @@ TEST_F(Dhcp4ParserTest, optionDefRecord) { ...@@ -1273,8 +1273,8 @@ TEST_F(Dhcp4ParserTest, optionDefRecord) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the particular option definition does not exist. // Make sure that the particular option definition does not exist.
OptionDefinitionPtr def = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_FALSE(def); ASSERT_FALSE(def);
// Use the configuration string to create new option definition. // Use the configuration string to create new option definition.
...@@ -1284,7 +1284,7 @@ TEST_F(Dhcp4ParserTest, optionDefRecord) { ...@@ -1284,7 +1284,7 @@ TEST_F(Dhcp4ParserTest, optionDefRecord) {
checkResult(status, 0); checkResult(status, 0);
// The option definition should now be available in the CfgMgr. // The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getCurrentCfg()->getCfgOptionDef().get("isc", 100); def = CfgMgr::instance().getStagingCfg()->getCfgOptionDef()->get("isc", 100);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Check the option data. // Check the option data.
...@@ -1332,10 +1332,10 @@ TEST_F(Dhcp4ParserTest, optionDefMultiple) { ...@@ -1332,10 +1332,10 @@ TEST_F(Dhcp4ParserTest, optionDefMultiple) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the option definitions do not exist yet. // Make sure that the option definitions do not exist yet.
ASSERT_FALSE(CfgMgr::instance().getCurrentCfg()-> ASSERT_FALSE(CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100)); getCfgOptionDef()->get("isc", 100));
ASSERT_FALSE(CfgMgr::instance().getCurrentCfg()-> ASSERT_FALSE(CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 101)); getCfgOptionDef()->get("isc", 101));
// Use the configuration string to create new option definitions. // Use the configuration string to create new option definitions.
ConstElementPtr status; ConstElementPtr status;
...@@ -1344,8 +1344,8 @@ TEST_F(Dhcp4ParserTest, optionDefMultiple) { ...@@ -1344,8 +1344,8 @@ TEST_F(Dhcp4ParserTest, optionDefMultiple) {
checkResult(status, 0); checkResult(status, 0);
// Check the first definition we have created. // Check the first definition we have created.
OptionDefinitionPtr def1 = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def1 = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_TRUE(def1); ASSERT_TRUE(def1);
// Check the option data. // Check the option data.
...@@ -1356,8 +1356,8 @@ TEST_F(Dhcp4ParserTest, optionDefMultiple) { ...@@ -1356,8 +1356,8 @@ TEST_F(Dhcp4ParserTest, optionDefMultiple) {
EXPECT_TRUE(def1->getEncapsulatedSpace().empty()); EXPECT_TRUE(def1->getEncapsulatedSpace().empty());
// Check the second option definition we have created. // Check the second option definition we have created.
OptionDefinitionPtr def2 = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def2 = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 101); getCfgOptionDef()->get("isc", 101);
ASSERT_TRUE(def2); ASSERT_TRUE(def2);
// Check the option data. // Check the option data.
...@@ -1398,8 +1398,8 @@ TEST_F(Dhcp4ParserTest, optionDefDuplicate) { ...@@ -1398,8 +1398,8 @@ TEST_F(Dhcp4ParserTest, optionDefDuplicate) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the option definition does not exist yet. // Make sure that the option definition does not exist yet.
ASSERT_FALSE(CfgMgr::instance().getCurrentCfg()-> ASSERT_FALSE(CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100)); getCfgOptionDef()->get("isc", 100));
// Use the configuration string to create new option definitions. // Use the configuration string to create new option definitions.
ConstElementPtr status; ConstElementPtr status;
...@@ -1429,8 +1429,8 @@ TEST_F(Dhcp4ParserTest, optionDefArray) { ...@@ -1429,8 +1429,8 @@ TEST_F(Dhcp4ParserTest, optionDefArray) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the particular option definition does not exist. // Make sure that the particular option definition does not exist.
OptionDefinitionPtr def = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_FALSE(def); ASSERT_FALSE(def);
// Use the configuration string to create new option definition. // Use the configuration string to create new option definition.
...@@ -1440,8 +1440,8 @@ TEST_F(Dhcp4ParserTest, optionDefArray) { ...@@ -1440,8 +1440,8 @@ TEST_F(Dhcp4ParserTest, optionDefArray) {
checkResult(status, 0); checkResult(status, 0);
// The option definition should now be available in the CfgMgr. // The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getCurrentCfg()-> def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Check the option data. // Check the option data.
...@@ -1472,8 +1472,8 @@ TEST_F(Dhcp4ParserTest, optionDefEncapsulate) { ...@@ -1472,8 +1472,8 @@ TEST_F(Dhcp4ParserTest, optionDefEncapsulate) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the particular option definition does not exist. // Make sure that the particular option definition does not exist.
OptionDefinitionPtr def = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_FALSE(def); ASSERT_FALSE(def);
// Use the configuration string to create new option definition. // Use the configuration string to create new option definition.
...@@ -1483,8 +1483,8 @@ TEST_F(Dhcp4ParserTest, optionDefEncapsulate) { ...@@ -1483,8 +1483,8 @@ TEST_F(Dhcp4ParserTest, optionDefEncapsulate) {
checkResult(status, 0); checkResult(status, 0);
// The option definition should now be available in the CfgMgr. // The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getCurrentCfg()-> def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Check the option data. // Check the option data.
...@@ -1681,8 +1681,8 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) { ...@@ -1681,8 +1681,8 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
"}"; "}";
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
OptionDefinitionPtr def = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("dhcp4", 109); getCfgOptionDef()->get("dhcp4", 109);
ASSERT_FALSE(def); ASSERT_FALSE(def);
// Use the configuration string to create new option definition. // Use the configuration string to create new option definition.
...@@ -1692,8 +1692,8 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) { ...@@ -1692,8 +1692,8 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
checkResult(status, 0); checkResult(status, 0);
// The option definition should now be available in the CfgMgr. // The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getCurrentCfg()-> def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("dhcp4", 109); getCfgOptionDef()->get("dhcp4", 109);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Check the option data. // Check the option data.
...@@ -1749,8 +1749,8 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) { ...@@ -1749,8 +1749,8 @@ TEST_F(Dhcp4ParserTest, optionStandardDefOverride) {
// Expecting success. // Expecting success.
checkResult(status, 0); checkResult(status, 0);
def = CfgMgr::instance().getCurrentCfg()-> def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("dhcp4", 65); getCfgOptionDef()->get("dhcp4", 65);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Check the option data. // Check the option data.
...@@ -1964,6 +1964,8 @@ TEST_F(Dhcp4ParserTest, optionDataEncapsulate) { ...@@ -1964,6 +1964,8 @@ TEST_F(Dhcp4ParserTest, optionDataEncapsulate) {
ASSERT_TRUE(status); ASSERT_TRUE(status);
checkResult(status, 0); checkResult(status, 0);
CfgMgr::instance().clear();
// Stage 2. Configure base option and a subnet. Please note that // Stage 2. Configure base option and a subnet. Please note that
// the configuration from the stage 2 is repeated because BIND // the configuration from the stage 2 is repeated because BIND
// configuration manager sends whole configuration for the lists // configuration manager sends whole configuration for the lists
...@@ -2538,6 +2540,8 @@ TEST_F(Dhcp4ParserTest, stdOptionDataEncapsulate) { ...@@ -2538,6 +2540,8 @@ TEST_F(Dhcp4ParserTest, stdOptionDataEncapsulate) {
ASSERT_TRUE(status); ASSERT_TRUE(status);
checkResult(status, 0); checkResult(status, 0);
CfgMgr::instance().clear();
// Once the definitions have been added we can configure the // Once the definitions have been added we can configure the
// standard option #17. This option comprises an enterprise // standard option #17. This option comprises an enterprise
// number and sub options. By convention (introduced in // number and sub options. By convention (introduced in
...@@ -2893,6 +2897,10 @@ TEST_F(Dhcp4ParserTest, LibrariesSpecified) { ...@@ -2893,6 +2897,10 @@ TEST_F(Dhcp4ParserTest, LibrariesSpecified) {
EXPECT_TRUE(checkMarkerFile(LOAD_MARKER_FILE, "12")); EXPECT_TRUE(checkMarkerFile(LOAD_MARKER_FILE, "12"));
EXPECT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE)); EXPECT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
// Commit the changes so as we get the fresh configuration for the
// second part of this test.
CfgMgr::instance().commit();
// Unload the libraries. The load file should not have changed, but // Unload the libraries. The load file should not have changed, but
// the unload one should indicate the unload() functions have been run. // the unload one should indicate the unload() functions have been run.
config = buildHooksLibrariesConfig(); config = buildHooksLibrariesConfig();
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <dhcp/dhcp4.h> #include <dhcp/dhcp4.h>
#include <dhcp4/ctrl_dhcp4_srv.h> #include <dhcp4/ctrl_dhcp4_srv.h>
#include <dhcpsrv/cfgmgr.h> #include <dhcpsrv/cfgmgr.h>
#include <log/logger_unittest_support.h>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -57,6 +58,7 @@ public: ...@@ -57,6 +58,7 @@ public:
} }
~JSONFileBackendTest() { ~JSONFileBackendTest() {
isc::log::resetUnitTestRootLogger();
static_cast<void>(unlink(TEST_FILE)); static_cast<void>(unlink(TEST_FILE));
}; };
......
...@@ -2444,8 +2444,8 @@ Dhcpv6Srv::unpackOptions(const OptionBuffer& buf, ...@@ -2444,8 +2444,8 @@ Dhcpv6Srv::unpackOptions(const OptionBuffer& buf,
option_defs = LibDHCP::getOptionDefs(Option::V6); option_defs = LibDHCP::getOptionDefs(Option::V6);
} else if (!option_space.empty()) { } else if (!option_space.empty()) {
OptionDefContainerPtr option_defs_ptr = OptionDefContainerPtr option_defs_ptr =
CfgMgr::instance().getCurrentCfg()->getCfgOptionDef() CfgMgr::instance().getCurrentCfg()->getCfgOptionDef()->
.getAll(option_space); getAll(option_space);
if (option_defs_ptr != NULL) { if (option_defs_ptr != NULL) {
option_defs = *option_defs_ptr; option_defs = *option_defs_ptr;
} }
......
...@@ -302,6 +302,7 @@ public: ...@@ -302,6 +302,7 @@ public:
try { try {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
status = configureDhcp6Server(srv_, json); status = configureDhcp6Server(srv_, json);
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
ADD_FAILURE() << "Unable to " << operation << ". " ADD_FAILURE() << "Unable to " << operation << ". "
<< "The following configuration was used: " << std::endl << "The following configuration was used: " << std::endl
...@@ -382,6 +383,7 @@ public: ...@@ -382,6 +383,7 @@ public:
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json)); EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
checkResult(x, 1); checkResult(x, 1);
EXPECT_TRUE(errorContainsPosition(x, "<string>")); EXPECT_TRUE(errorContainsPosition(x, "<string>"));
CfgMgr::instance().clear();
} }
/// @brief Test invalid option paramater value. /// @brief Test invalid option paramater value.
...@@ -399,6 +401,7 @@ public: ...@@ -399,6 +401,7 @@ public:
EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json)); EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
checkResult(x, 1); checkResult(x, 1);
EXPECT_TRUE(errorContainsPosition(x, "<string>")); EXPECT_TRUE(errorContainsPosition(x, "<string>"));
CfgMgr::instance().clear();
} }
/// @brief Test option against given code and data. /// @brief Test option against given code and data.
...@@ -468,11 +471,13 @@ public: ...@@ -468,11 +471,13 @@ public:
const size_t expected_data_len) { const size_t expected_data_len) {
std::string config = createConfigWithOption(params); std::string config = createConfigWithOption(params);
ASSERT_TRUE(executeConfiguration(config, "parse option configuration")); ASSERT_TRUE(executeConfiguration(config, "parse option configuration"));
// The subnet should now hold one option with the specified code. // The subnet should now hold one option with the specified code.
Subnet::OptionDescriptor desc = Subnet::OptionDescriptor desc =
getOptionFromSubnet(IOAddress("2001:db8:1::5"), option_code); getOptionFromSubnet(IOAddress("2001:db8:1::5"), option_code);
ASSERT_TRUE(desc.option); ASSERT_TRUE(desc.option);
testOption(desc, option_code, expected_data, expected_data_len); testOption(desc, option_code, expected_data, expected_data_len);
CfgMgr::instance().clear();
} }
int rcode_; ///< Return code (see @ref isc::config::parseAnswer) int rcode_; ///< Return code (see @ref isc::config::parseAnswer)
...@@ -1466,8 +1471,8 @@ TEST_F(Dhcp6ParserTest, optionDefIpv6Address) { ...@@ -1466,8 +1471,8 @@ TEST_F(Dhcp6ParserTest, optionDefIpv6Address) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the particular option definition does not exist. // Make sure that the particular option definition does not exist.
OptionDefinitionPtr def = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_FALSE(def); ASSERT_FALSE(def);
// Use the configuration string to create new option definition. // Use the configuration string to create new option definition.
...@@ -1476,7 +1481,7 @@ TEST_F(Dhcp6ParserTest, optionDefIpv6Address) { ...@@ -1476,7 +1481,7 @@ TEST_F(Dhcp6ParserTest, optionDefIpv6Address) {
ASSERT_TRUE(status); ASSERT_TRUE(status);
// The option definition should now be available in the CfgMgr. // The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getCurrentCfg()->getCfgOptionDef().get("isc", 100); def = CfgMgr::instance().getStagingCfg()->getCfgOptionDef()->get("isc", 100);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Verify that the option definition data is valid. // Verify that the option definition data is valid.
...@@ -1506,8 +1511,8 @@ TEST_F(Dhcp6ParserTest, optionDefRecord) { ...@@ -1506,8 +1511,8 @@ TEST_F(Dhcp6ParserTest, optionDefRecord) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the particular option definition does not exist. // Make sure that the particular option definition does not exist.
OptionDefinitionPtr def = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_FALSE(def); ASSERT_FALSE(def);
// Use the configuration string to create new option definition. // Use the configuration string to create new option definition.
...@@ -1517,7 +1522,7 @@ TEST_F(Dhcp6ParserTest, optionDefRecord) { ...@@ -1517,7 +1522,7 @@ TEST_F(Dhcp6ParserTest, optionDefRecord) {
checkResult(status, 0); checkResult(status, 0);
// The option definition should now be available in the CfgMgr. // The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getCurrentCfg()->getCfgOptionDef().get("isc", 100); def = CfgMgr::instance().getStagingCfg()->getCfgOptionDef()->get("isc", 100);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Check the option data. // Check the option data.
...@@ -1564,10 +1569,10 @@ TEST_F(Dhcp6ParserTest, optionDefMultiple) { ...@@ -1564,10 +1569,10 @@ TEST_F(Dhcp6ParserTest, optionDefMultiple) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the option definitions do not exist yet. // Make sure that the option definitions do not exist yet.
ASSERT_FALSE(CfgMgr::instance().getCurrentCfg()-> ASSERT_FALSE(CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100)); getCfgOptionDef()->get("isc", 100));
ASSERT_FALSE(CfgMgr::instance().getCurrentCfg()-> ASSERT_FALSE(CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 101)); getCfgOptionDef()->get("isc", 101));
// Use the configuration string to create new option definitions. // Use the configuration string to create new option definitions.
ConstElementPtr status; ConstElementPtr status;
...@@ -1576,8 +1581,8 @@ TEST_F(Dhcp6ParserTest, optionDefMultiple) { ...@@ -1576,8 +1581,8 @@ TEST_F(Dhcp6ParserTest, optionDefMultiple) {
checkResult(status, 0); checkResult(status, 0);
// Check the first definition we have created. // Check the first definition we have created.
OptionDefinitionPtr def1 = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def1 = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_TRUE(def1); ASSERT_TRUE(def1);
// Check the option data. // Check the option data.
...@@ -1587,8 +1592,8 @@ TEST_F(Dhcp6ParserTest, optionDefMultiple) { ...@@ -1587,8 +1592,8 @@ TEST_F(Dhcp6ParserTest, optionDefMultiple) {
EXPECT_FALSE(def1->getArrayType()); EXPECT_FALSE(def1->getArrayType());
// Check the second option definition we have created. // Check the second option definition we have created.
OptionDefinitionPtr def2 = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def2 = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 101); getCfgOptionDef()->get("isc", 101);
ASSERT_TRUE(def2); ASSERT_TRUE(def2);
// Check the option data. // Check the option data.
...@@ -1628,8 +1633,8 @@ TEST_F(Dhcp6ParserTest, optionDefDuplicate) { ...@@ -1628,8 +1633,8 @@ TEST_F(Dhcp6ParserTest, optionDefDuplicate) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the option definition does not exist yet. // Make sure that the option definition does not exist yet.
ASSERT_FALSE(CfgMgr::instance().getCurrentCfg()-> ASSERT_FALSE(CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100)); getCfgOptionDef()->get("isc", 100));
// Use the configuration string to create new option definitions. // Use the configuration string to create new option definitions.
ConstElementPtr status; ConstElementPtr status;
...@@ -1659,8 +1664,8 @@ TEST_F(Dhcp6ParserTest, optionDefArray) { ...@@ -1659,8 +1664,8 @@ TEST_F(Dhcp6ParserTest, optionDefArray) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the particular option definition does not exist. // Make sure that the particular option definition does not exist.
OptionDefinitionPtr def = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_FALSE(def); ASSERT_FALSE(def);
// Use the configuration string to create new option definition. // Use the configuration string to create new option definition.
...@@ -1670,7 +1675,7 @@ TEST_F(Dhcp6ParserTest, optionDefArray) { ...@@ -1670,7 +1675,7 @@ TEST_F(Dhcp6ParserTest, optionDefArray) {
checkResult(status, 0); checkResult(status, 0);
// The option definition should now be available in the CfgMgr. // The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getCurrentCfg()->getCfgOptionDef().get("isc", 100); def = CfgMgr::instance().getStagingCfg()->getCfgOptionDef()->get("isc", 100);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Check the option data. // Check the option data.
...@@ -1700,8 +1705,8 @@ TEST_F(Dhcp6ParserTest, optionDefEncapsulate) { ...@@ -1700,8 +1705,8 @@ TEST_F(Dhcp6ParserTest, optionDefEncapsulate) {
ElementPtr json = Element::fromJSON(config); ElementPtr json = Element::fromJSON(config);
// Make sure that the particular option definition does not exist. // Make sure that the particular option definition does not exist.
OptionDefinitionPtr def = CfgMgr::instance().getCurrentCfg()-> OptionDefinitionPtr def = CfgMgr::instance().getStagingCfg()->
getCfgOptionDef().get("isc", 100); getCfgOptionDef()->get("isc", 100);
ASSERT_FALSE(def); ASSERT_FALSE(def);
// Use the configuration string to create new option definition. // Use the configuration string to create new option definition.
...@@ -1711,7 +1716,7 @@ TEST_F(Dhcp6ParserTest, optionDefEncapsulate) { ...@@ -1711,7 +1716,7 @@ TEST_F(Dhcp6ParserTest, optionDefEncapsulate) {
checkResult(status, 0); checkResult(status, 0);
// The option definition should now be available in the CfgMgr. // The option definition should now be available in the CfgMgr.
def = CfgMgr::instance().getCurrentCfg()->getCfgOptionDef().get("isc", 100); def = CfgMgr::instance().getStagingCfg()->getCfgOptionDef()->get("isc", 100);
ASSERT_TRUE(def); ASSERT_TRUE(def);
// Check the option data. // Check the option data.
...@@ -1909,8 +1914,8 @@ TEST_F(Dhcp6ParserTest, optionStandardDefOverride) { ...@@ -1909,8 +1914,8 @@ TEST_F(Dhcp6ParserTest, optionStandardDefOverride) {