mgmt: revert router name configuration options
This reverts commit ee7c8441c8.
That implementation introduces a global static variable which conflicts with ndnSIM.
refs #3026
Change-Id: I803e2ab497f71ec259d96d7b094ba0d04718c344
This commit is contained in:
1 parent
faa5c0cd3c
commit
0e092aee5c
4 files changed
-278
No files matched your search
@@ -35,67 +35,6 @@ namespace general {
|
||||
|
||||
NFD_LOG_INIT("GeneralConfigSection");
|
||||
|
||||
const ndn::Name
|
||||
RouterName::getName() const
|
||||
{
|
||||
ndn::Name routerName;
|
||||
|
||||
if (network.empty() || site.empty() || router.empty())
|
||||
{
|
||||
return routerName;
|
||||
}
|
||||
|
||||
routerName = network;
|
||||
routerName.append(site);
|
||||
routerName.append(ROUTER_MARKER);
|
||||
routerName.append(router);
|
||||
|
||||
return routerName;
|
||||
}
|
||||
|
||||
const ndn::PartialName RouterName::ROUTER_MARKER("%C1.Router");
|
||||
|
||||
static RouterName&
|
||||
getRouterNameInstance()
|
||||
{
|
||||
static RouterName routerName;
|
||||
return routerName;
|
||||
}
|
||||
|
||||
ndn::PartialName
|
||||
loadPartialNameFromSection(const ConfigSection& section, const std::string& key)
|
||||
{
|
||||
ndn::PartialName value;
|
||||
|
||||
try
|
||||
{
|
||||
value = section.get<ndn::PartialName>(key);
|
||||
|
||||
if (value.empty())
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"router_name." + key + "\""
|
||||
" in \"general\" section"));
|
||||
}
|
||||
}
|
||||
catch (const boost::property_tree::ptree_error& error)
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(ConfigFile::Error("Invalid value for \"router_name." + key + "\""
|
||||
" in \"general\" section"));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void
|
||||
processSectionRouterName(const ConfigSection& section, bool isDryRun)
|
||||
{
|
||||
RouterName& routerName = getRouterNameInstance();
|
||||
|
||||
routerName.network = loadPartialNameFromSection(section, "network");
|
||||
routerName.site = loadPartialNameFromSection(section, "site");
|
||||
routerName.router = loadPartialNameFromSection(section, "router");
|
||||
}
|
||||
|
||||
static void
|
||||
onConfig(const ConfigSection& configSection,
|
||||
bool isDryRun,
|
||||
@@ -105,13 +44,6 @@ onConfig(const ConfigSection& configSection,
|
||||
// {
|
||||
// ; user "ndn-user"
|
||||
// ; group "ndn-user"
|
||||
//
|
||||
// ; router_name
|
||||
// ; {
|
||||
// ; network ndn
|
||||
// ; site edu/site
|
||||
// ; router router/name
|
||||
// ; }
|
||||
// }
|
||||
|
||||
std::string user;
|
||||
@@ -161,14 +93,6 @@ onConfig(const ConfigSection& configSection,
|
||||
NFD_LOG_TRACE("using user \"" << user << "\" group \"" << group << "\"");
|
||||
|
||||
PrivilegeHelper::initialize(user, group);
|
||||
|
||||
boost::optional<const ConfigSection&> routerNameSection =
|
||||
configSection.get_child_optional("router_name");
|
||||
|
||||
if (routerNameSection)
|
||||
{
|
||||
processSectionRouterName(*routerNameSection, isDryRun);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -177,12 +101,6 @@ setConfigFile(ConfigFile& configFile)
|
||||
configFile.addSectionHandler("general", &onConfig);
|
||||
}
|
||||
|
||||
const RouterName&
|
||||
getRouterName()
|
||||
{
|
||||
return getRouterNameInstance();
|
||||
}
|
||||
|
||||
} // namespace general
|
||||
|
||||
} // namespace nfd
|
||||
@@ -25,8 +25,6 @@
|
||||
#ifndef NFD_MGMT_GENERAL_CONFIG_SECTION_HPP
|
||||
#define NFD_MGMT_GENERAL_CONFIG_SECTION_HPP
|
||||
|
||||
#include <ndn-cxx/name.hpp>
|
||||
|
||||
namespace nfd {
|
||||
|
||||
class ConfigFile;
|
||||
@@ -36,33 +34,6 @@ namespace general {
|
||||
void
|
||||
setConfigFile(ConfigFile& configFile);
|
||||
|
||||
class RouterName
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Return the router name constructed from the network, site, and
|
||||
* router variables.
|
||||
*
|
||||
* The router name is constructed in the following manner:
|
||||
* /<network>/<site>/<ROUTER_MARKER>/<router>
|
||||
*
|
||||
* \return The constructed router name if the network, site, and router
|
||||
* configuration options are non-empty; otherwise, an empty ndn::Name.
|
||||
*/
|
||||
const ndn::Name
|
||||
getName() const;
|
||||
|
||||
public:
|
||||
ndn::PartialName network;
|
||||
ndn::PartialName site;
|
||||
ndn::PartialName router;
|
||||
|
||||
static const ndn::PartialName ROUTER_MARKER;
|
||||
};
|
||||
|
||||
const RouterName&
|
||||
getRouterName();
|
||||
|
||||
} // namespace general
|
||||
|
||||
} // namespace nfd
|
||||
|
||||
@@ -7,18 +7,6 @@ general
|
||||
|
||||
; user ndn-user
|
||||
; group ndn-user
|
||||
|
||||
; The router_name section specifies the name components used
|
||||
; to build this router's name. The router name is constructed
|
||||
; using the configuration options in the following manner:
|
||||
; /<network>/<site>/<%C1.Router>/<router>
|
||||
|
||||
; router_name
|
||||
; {
|
||||
; network ndn ; the network to which this router belongs
|
||||
; site edu/site ; the site to which this router belongs
|
||||
; router router/name ; name used to uniquely identify this router under the site
|
||||
; }
|
||||
}
|
||||
|
||||
log
|
||||
|
||||
@@ -60,8 +60,6 @@ BOOST_AUTO_TEST_CASE(DefaultConfig)
|
||||
|
||||
general::setConfigFile(configFile);
|
||||
BOOST_CHECK_NO_THROW(configFile.parse(CONFIG, true, "test-general-config-section"));
|
||||
|
||||
BOOST_CHECK(getRouterName().getName().empty());
|
||||
}
|
||||
|
||||
#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
|
||||
@@ -151,159 +149,6 @@ BOOST_AUTO_TEST_CASE(InvalidGroupConfig)
|
||||
bind(&checkExceptionMessage, _1, expected));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(RouterNameConfig)
|
||||
{
|
||||
const std::string CONFIG =
|
||||
"general\n"
|
||||
"{\n"
|
||||
" router_name\n"
|
||||
" {\n"
|
||||
" network ndn\n"
|
||||
" site edu/site\n"
|
||||
" router router/name\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
ConfigFile configFile;
|
||||
general::setConfigFile(configFile);
|
||||
|
||||
BOOST_CHECK_NO_THROW(configFile.parse(CONFIG, true, "test-general-config-section"));
|
||||
|
||||
BOOST_CHECK_EQUAL(getRouterName().network, ndn::PartialName("ndn"));
|
||||
BOOST_CHECK_EQUAL(getRouterName().site, ndn::PartialName("edu/site"));
|
||||
BOOST_CHECK_EQUAL(getRouterName().router, ndn::PartialName("router/name"));
|
||||
BOOST_CHECK_EQUAL(getRouterName().getName(), ndn::Name("/ndn/edu/site/%C1.Router/router/name"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NoNetworkConfig)
|
||||
{
|
||||
const std::string CONFIG =
|
||||
"general\n"
|
||||
"{\n"
|
||||
" router_name\n"
|
||||
" {\n"
|
||||
" site edu/site\n"
|
||||
" router router/name\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
ConfigFile configFile;
|
||||
general::setConfigFile(configFile);
|
||||
|
||||
const std::string expected = "Invalid value for \"router_name.network\" in \"general\" section";
|
||||
BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"),
|
||||
ConfigFile::Error,
|
||||
bind(&checkExceptionMessage, _1, expected));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NoSiteConfig)
|
||||
{
|
||||
const std::string CONFIG =
|
||||
"general\n"
|
||||
"{\n"
|
||||
" router_name\n"
|
||||
" {\n"
|
||||
" network ndn\n"
|
||||
" router router/name\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
ConfigFile configFile;
|
||||
general::setConfigFile(configFile);
|
||||
|
||||
const std::string expected = "Invalid value for \"router_name.site\" in \"general\" section";
|
||||
BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"),
|
||||
ConfigFile::Error,
|
||||
bind(&checkExceptionMessage, _1, expected));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(NoRouterConfig)
|
||||
{
|
||||
const std::string CONFIG =
|
||||
"general\n"
|
||||
"{\n"
|
||||
" router_name\n"
|
||||
" {\n"
|
||||
" network ndn\n"
|
||||
" site edu/site\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
ConfigFile configFile;
|
||||
general::setConfigFile(configFile);
|
||||
|
||||
const std::string expected = "Invalid value for \"router_name.router\" in \"general\" section";
|
||||
BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"),
|
||||
ConfigFile::Error,
|
||||
bind(&checkExceptionMessage, _1, expected));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(InvalidNetworkConfig)
|
||||
{
|
||||
const std::string CONFIG =
|
||||
"general\n"
|
||||
"{\n"
|
||||
" router_name\n"
|
||||
" {\n"
|
||||
" network\n"
|
||||
" site edu/site\n"
|
||||
" router router/name\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
ConfigFile configFile;
|
||||
general::setConfigFile(configFile);
|
||||
|
||||
const std::string expected = "Invalid value for \"router_name.network\" in \"general\" section";
|
||||
BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"),
|
||||
ConfigFile::Error,
|
||||
bind(&checkExceptionMessage, _1, expected));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(InvalidSiteConfig)
|
||||
{
|
||||
const std::string CONFIG =
|
||||
"general\n"
|
||||
"{\n"
|
||||
" router_name\n"
|
||||
" {\n"
|
||||
" network ndn\n"
|
||||
" site\n"
|
||||
" router router/name\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
ConfigFile configFile;
|
||||
general::setConfigFile(configFile);
|
||||
|
||||
const std::string expected = "Invalid value for \"router_name.site\" in \"general\" section";
|
||||
BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"),
|
||||
ConfigFile::Error,
|
||||
bind(&checkExceptionMessage, _1, expected));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(InvalidRouterConfig)
|
||||
{
|
||||
const std::string CONFIG =
|
||||
"general\n"
|
||||
"{\n"
|
||||
" router_name\n"
|
||||
" {\n"
|
||||
" network ndn\n"
|
||||
" site edu/site\n"
|
||||
" router\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
ConfigFile configFile;
|
||||
general::setConfigFile(configFile);
|
||||
|
||||
const std::string expected = "Invalid value for \"router_name.router\" in \"general\" section";
|
||||
BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"),
|
||||
ConfigFile::Error,
|
||||
bind(&checkExceptionMessage, _1, expected));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
} // namespace tests
|
||||
|
||||
Reference in new issue
Block a user