mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[5-netconf-extend-syntax] Extended syntax
This commit is contained in:
@@ -4,6 +4,16 @@
|
||||
{
|
||||
"Netconf":
|
||||
{
|
||||
// Three flags control netconf (default values are true):
|
||||
// - "boot-update" about the YANG configuration load when
|
||||
// netconf boots.
|
||||
// - "subscribe-changes" about the subscription to notifications
|
||||
// when the running YANG module is changed.
|
||||
// - "validate-changes" alloes to validate or not changes.
|
||||
"boot-update": true,
|
||||
"subscribe-changes": true,
|
||||
"validate-changes": true,
|
||||
|
||||
// This map specifies how each server is managed:
|
||||
// the YANG model to use and the control channel.
|
||||
"managed-servers":
|
||||
@@ -16,6 +26,12 @@
|
||||
// DHCPv4 server is kea-dhcp4-server model.
|
||||
"model": "kea-dhcp4-server",
|
||||
|
||||
// The three control flags can be defined in this scope too
|
||||
// and takes precedence over global and default values.
|
||||
"boot-update": false,
|
||||
"subscribe-changes": false,
|
||||
"validate-changes": false,
|
||||
|
||||
// Currently three control channel types are supported:
|
||||
// - "stdout" which output the configuration on the standard
|
||||
// output (this is mainly for testing purposes, but you can
|
||||
|
@@ -3,6 +3,14 @@
|
||||
{
|
||||
"Netconf":
|
||||
{
|
||||
// Control flags can be defined in the global scope or
|
||||
// in a managed server scope. Precedence are:
|
||||
// - use the default value (true)
|
||||
// - use the global value
|
||||
// - use the local value.
|
||||
// So this overwrites the default value:
|
||||
"boot-update": false,
|
||||
|
||||
// This map specifies how each server is managed:
|
||||
// the YANG model to use and the control channel.
|
||||
// Currently three control channel types are supported:
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Generated 201809281126
|
||||
// Generated 201810092120
|
||||
// A Bison parser, made by GNU Bison 3.0.5.
|
||||
|
||||
// Locations for Bison parsers in C++
|
||||
|
@@ -21,12 +21,29 @@ namespace isc {
|
||||
namespace netconf {
|
||||
|
||||
NetconfConfig::NetconfConfig()
|
||||
: servers_map_(new CfgServersMap()) {
|
||||
: configured_globals_(Element::createMap()),
|
||||
servers_map_(new CfgServersMap()) {
|
||||
}
|
||||
|
||||
NetconfConfig::NetconfConfig(const NetconfConfig& orig)
|
||||
: ConfigBase(), servers_map_(orig.servers_map_),
|
||||
hooks_config_(orig.hooks_config_) {
|
||||
: ConfigBase(), configured_globals_(orig.configured_globals_),
|
||||
servers_map_(orig.servers_map_), hooks_config_(orig.hooks_config_) {
|
||||
}
|
||||
|
||||
void
|
||||
NetconfConfig::extractConfiguredGlobals(ConstElementPtr config) {
|
||||
if (config->getType() != Element::map) {
|
||||
isc_throw(BadValue,
|
||||
"extractConfiguredGlobals must be given a map element");
|
||||
}
|
||||
|
||||
const std::map<std::string, ConstElementPtr>& values = config->mapValue();
|
||||
for (auto value = values.begin(); value != values.end(); ++value) {
|
||||
if (value->second->getType() != Element::list &&
|
||||
value->second->getType() != Element::map) {
|
||||
addConfiguredGlobal(value->first, value->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetconfCfgMgr::NetconfCfgMgr()
|
||||
@@ -81,9 +98,13 @@ NetconfCfgMgr::parse(isc::data::ConstElementPtr config_set,
|
||||
|
||||
NetconfConfigPtr ctx = getNetconfConfig();
|
||||
|
||||
// Set the defaults
|
||||
// Preserve all scalar global parameters.
|
||||
ctx->extractConfiguredGlobals(config_set);
|
||||
|
||||
// Set the defaults and derive parameters.
|
||||
ElementPtr cfg = boost::const_pointer_cast<Element>(config_set);
|
||||
NetconfSimpleParser::setAllDefaults(cfg);
|
||||
NetconfSimpleParser::deriveParameters(cfg);
|
||||
|
||||
// And parse the configuration.
|
||||
ConstElementPtr answer;
|
||||
@@ -121,13 +142,13 @@ NetconfCfgMgr::parse(isc::data::ConstElementPtr config_set,
|
||||
return (answer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ElementPtr
|
||||
NetconfConfig::toElement() const {
|
||||
ElementPtr netconf = Element::createMap();
|
||||
// Set user-context
|
||||
contextToElement(netconf);
|
||||
// Add in explicitly configured globals.
|
||||
netconf->setValue(configured_globals_->mapValue());
|
||||
// Set hooks-libraries
|
||||
netconf->set("hooks-libraries", hooks_config_.toElement());
|
||||
// Set managed-servers
|
||||
|
@@ -35,6 +35,23 @@ public:
|
||||
/// @brief Default constructor
|
||||
NetconfConfig();
|
||||
|
||||
/// @brief Returns pointer to configured global parameters.
|
||||
isc::data::ConstElementPtr getConfiguredGlobals() const {
|
||||
return (isc::data::ConstElementPtr(configured_globals_));
|
||||
}
|
||||
|
||||
/// @brief Saves scalar elements from the global scope of a configuration.
|
||||
void extractConfiguredGlobals(isc::data::ConstElementPtr config);
|
||||
|
||||
/// @brief Adds a parameter to the collection configured globals.
|
||||
///
|
||||
/// @param name std::string name of the global to add.
|
||||
/// @param value ElementPtr containing the value of the global.
|
||||
void addConfiguredGlobal(const std::string& name,
|
||||
isc::data::ConstElementPtr value) {
|
||||
configured_globals_->set(name, value);
|
||||
}
|
||||
|
||||
/// @brief Returns non-const reference to the managed servers map.
|
||||
///
|
||||
/// @return non-const reference to the managed servers map.
|
||||
@@ -88,6 +105,9 @@ private:
|
||||
/// @param rhs Context to be assigned.
|
||||
NetconfConfig& operator=(const NetconfConfig& rhs);
|
||||
|
||||
/// @brief Stores the global parameters specified via configuration.
|
||||
isc::data::ElementPtr configured_globals_;
|
||||
|
||||
/// @brief CfgServers map.
|
||||
CfgServersMapPtr servers_map_;
|
||||
|
||||
|
@@ -79,7 +79,8 @@ CfgControlSocket::toElement() const {
|
||||
|
||||
// *********************** CfgServer *************************
|
||||
CfgServer::CfgServer(const string& model, CfgControlSocketPtr ctrl_sock)
|
||||
: model_(model), control_socket_(ctrl_sock) {
|
||||
: model_(model), boot_update_(true), subscribe_changes_(true),
|
||||
validate_changes_(true), control_socket_(ctrl_sock) {
|
||||
}
|
||||
|
||||
CfgServer::~CfgServer() {
|
||||
@@ -114,6 +115,12 @@ CfgServer::toElement() const {
|
||||
contextToElement(result);
|
||||
// Set model
|
||||
result->set("model", Element::create(model_));
|
||||
// Set boot-update
|
||||
result->set("boot-update", Element::create(boot_update_));
|
||||
// Set subscribe-changes
|
||||
result->set("subscribe-changes", Element::create(subscribe_changes_));
|
||||
// Set validate-changes
|
||||
result->set("validate-changes", Element::create(validate_changes_));
|
||||
// Set control-socket
|
||||
if (control_socket_) {
|
||||
result->set("control-socket", control_socket_->toElement());
|
||||
@@ -192,6 +199,11 @@ ServerConfigParser::parse(ConstElementPtr server_config) {
|
||||
<< server_config->getPosition() << ")");
|
||||
}
|
||||
|
||||
// Add flags.
|
||||
result->setBootUpdate(getBoolean(server_config, "boot-update"));
|
||||
result->setSubscribeChanges(getBoolean(server_config, "subscribe-changes"));
|
||||
result->setValidateChanges(getBoolean(server_config, "validate-changes"));
|
||||
|
||||
// Add user-context.
|
||||
if (user_context) {
|
||||
result->setContext(user_context);
|
||||
|
@@ -172,6 +172,48 @@ public:
|
||||
return (control_socket_);
|
||||
}
|
||||
|
||||
/// @brief Getter which returns the boot-update flag.
|
||||
///
|
||||
/// @return returns the boot-update flag as a bool.
|
||||
bool getBootUpdate() const {
|
||||
return (boot_update_);
|
||||
}
|
||||
|
||||
/// @brief Set the boot-update flag.
|
||||
///
|
||||
/// @param boot_update The boot-update flag.
|
||||
void setBootUpdate(bool boot_update) {
|
||||
boot_update_ = boot_update;
|
||||
}
|
||||
|
||||
/// @brief Getter which returns the subscribe-changes flag.
|
||||
///
|
||||
/// @return returns the subscribe-changes flag as a bool.
|
||||
bool getSubscribeChanges() const {
|
||||
return (subscribe_changes_);
|
||||
}
|
||||
|
||||
/// @brief Set the subscribe-changes flag.
|
||||
///
|
||||
/// @param subscribe_changes The subscribe-changes flag.
|
||||
void setSubscribeChanges(bool subscribe_changes) {
|
||||
subscribe_changes_ = subscribe_changes;
|
||||
}
|
||||
|
||||
/// @brief Getter which returns the validate-changes flag.
|
||||
///
|
||||
/// @return returns the validate-changes flag as a bool.
|
||||
bool getValidateChanges() const {
|
||||
return (validate_changes_);
|
||||
}
|
||||
|
||||
/// @brief Set the validate-changes flag.
|
||||
///
|
||||
/// @param validate_changes The validate-changes flag.
|
||||
void setValidateChanges(bool validate_changes) {
|
||||
validate_changes_ = validate_changes;
|
||||
}
|
||||
|
||||
/// @brief Returns a text representation for the server.
|
||||
std::string toText() const;
|
||||
|
||||
@@ -184,6 +226,24 @@ private:
|
||||
/// @brief The model name.
|
||||
const std::string model_;
|
||||
|
||||
/// @brief The boot-update flag.
|
||||
///
|
||||
/// If true (the defaul) Kea server configuration is updated at (netconf
|
||||
/// agent) boot time.
|
||||
bool boot_update_;
|
||||
|
||||
/// @brief The subscribe-changes flag.
|
||||
///
|
||||
/// If true (the deault) the netconf agent subscribes module changes
|
||||
/// so will be notified when the YANG running configuration is changed.
|
||||
bool subscribe_changes_;
|
||||
|
||||
/// @brief The validate-changes flag.
|
||||
///
|
||||
/// If true (the deault) the netconf agent validates module changes
|
||||
/// and can reject bad configurations.
|
||||
bool validate_changes_;
|
||||
|
||||
/// @brief The control socket.
|
||||
CfgControlSocketPtr control_socket_;
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -206,6 +206,36 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
|
||||
}
|
||||
}
|
||||
|
||||
\"boot-update\" {
|
||||
switch(driver.ctx_) {
|
||||
case ParserContext::NETCONF:
|
||||
case ParserContext::SERVER:
|
||||
return NetconfParser::make_BOOT_UPDATE(driver.loc_);
|
||||
default:
|
||||
return NetconfParser::make_STRING("boot-update", driver.loc_);
|
||||
}
|
||||
}
|
||||
|
||||
\"subscribe-changes\" {
|
||||
switch(driver.ctx_) {
|
||||
case ParserContext::NETCONF:
|
||||
case ParserContext::SERVER:
|
||||
return NetconfParser::make_SUBSCRIBE_CHANGES(driver.loc_);
|
||||
default:
|
||||
return NetconfParser::make_STRING("subscribe-changes", driver.loc_);
|
||||
}
|
||||
}
|
||||
|
||||
\"validate-changes\" {
|
||||
switch(driver.ctx_) {
|
||||
case ParserContext::NETCONF:
|
||||
case ParserContext::SERVER:
|
||||
return NetconfParser::make_VALIDATE_CHANGES(driver.loc_);
|
||||
default:
|
||||
return NetconfParser::make_STRING("validate-changes", driver.loc_);
|
||||
}
|
||||
}
|
||||
|
||||
\"managed-servers\" {
|
||||
switch(driver.ctx_) {
|
||||
case ParserContext::NETCONF:
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -352,39 +352,42 @@ namespace isc { namespace netconf {
|
||||
TOKEN_NETCONF = 265,
|
||||
TOKEN_USER_CONTEXT = 266,
|
||||
TOKEN_COMMENT = 267,
|
||||
TOKEN_MANAGED_SERVERS = 268,
|
||||
TOKEN_DHCP4_SERVER = 269,
|
||||
TOKEN_DHCP6_SERVER = 270,
|
||||
TOKEN_D2_SERVER = 271,
|
||||
TOKEN_CA_SERVER = 272,
|
||||
TOKEN_MODEL = 273,
|
||||
TOKEN_CONTROL_SOCKET = 274,
|
||||
TOKEN_SOCKET_TYPE = 275,
|
||||
TOKEN_UNIX = 276,
|
||||
TOKEN_HTTP = 277,
|
||||
TOKEN_STDOUT = 278,
|
||||
TOKEN_SOCKET_NAME = 279,
|
||||
TOKEN_SOCKET_URL = 280,
|
||||
TOKEN_HOOKS_LIBRARIES = 281,
|
||||
TOKEN_LIBRARY = 282,
|
||||
TOKEN_PARAMETERS = 283,
|
||||
TOKEN_LOGGING = 284,
|
||||
TOKEN_LOGGERS = 285,
|
||||
TOKEN_NAME = 286,
|
||||
TOKEN_OUTPUT_OPTIONS = 287,
|
||||
TOKEN_OUTPUT = 288,
|
||||
TOKEN_DEBUGLEVEL = 289,
|
||||
TOKEN_SEVERITY = 290,
|
||||
TOKEN_FLUSH = 291,
|
||||
TOKEN_MAXSIZE = 292,
|
||||
TOKEN_MAXVER = 293,
|
||||
TOKEN_START_JSON = 294,
|
||||
TOKEN_START_NETCONF = 295,
|
||||
TOKEN_START_SUB_NETCONF = 296,
|
||||
TOKEN_STRING = 297,
|
||||
TOKEN_INTEGER = 298,
|
||||
TOKEN_FLOAT = 299,
|
||||
TOKEN_BOOLEAN = 300
|
||||
TOKEN_BOOT_UPDATE = 268,
|
||||
TOKEN_SUBSCRIBE_CHANGES = 269,
|
||||
TOKEN_VALIDATE_CHANGES = 270,
|
||||
TOKEN_MANAGED_SERVERS = 271,
|
||||
TOKEN_DHCP4_SERVER = 272,
|
||||
TOKEN_DHCP6_SERVER = 273,
|
||||
TOKEN_D2_SERVER = 274,
|
||||
TOKEN_CA_SERVER = 275,
|
||||
TOKEN_MODEL = 276,
|
||||
TOKEN_CONTROL_SOCKET = 277,
|
||||
TOKEN_SOCKET_TYPE = 278,
|
||||
TOKEN_UNIX = 279,
|
||||
TOKEN_HTTP = 280,
|
||||
TOKEN_STDOUT = 281,
|
||||
TOKEN_SOCKET_NAME = 282,
|
||||
TOKEN_SOCKET_URL = 283,
|
||||
TOKEN_HOOKS_LIBRARIES = 284,
|
||||
TOKEN_LIBRARY = 285,
|
||||
TOKEN_PARAMETERS = 286,
|
||||
TOKEN_LOGGING = 287,
|
||||
TOKEN_LOGGERS = 288,
|
||||
TOKEN_NAME = 289,
|
||||
TOKEN_OUTPUT_OPTIONS = 290,
|
||||
TOKEN_OUTPUT = 291,
|
||||
TOKEN_DEBUGLEVEL = 292,
|
||||
TOKEN_SEVERITY = 293,
|
||||
TOKEN_FLUSH = 294,
|
||||
TOKEN_MAXSIZE = 295,
|
||||
TOKEN_MAXVER = 296,
|
||||
TOKEN_START_JSON = 297,
|
||||
TOKEN_START_NETCONF = 298,
|
||||
TOKEN_START_SUB_NETCONF = 299,
|
||||
TOKEN_STRING = 300,
|
||||
TOKEN_INTEGER = 301,
|
||||
TOKEN_FLOAT = 302,
|
||||
TOKEN_BOOLEAN = 303
|
||||
};
|
||||
};
|
||||
|
||||
@@ -543,6 +546,18 @@ namespace isc { namespace netconf {
|
||||
symbol_type
|
||||
make_COMMENT (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_BOOT_UPDATE (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_SUBSCRIBE_CHANGES (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_VALIDATE_CHANGES (const location_type& l);
|
||||
|
||||
static inline
|
||||
symbol_type
|
||||
make_MANAGED_SERVERS (const location_type& l);
|
||||
@@ -882,12 +897,12 @@ namespace isc { namespace netconf {
|
||||
enum
|
||||
{
|
||||
yyeof_ = 0,
|
||||
yylast_ = 221, ///< Last index in yytable_.
|
||||
yynnts_ = 100, ///< Number of nonterminal symbols.
|
||||
yylast_ = 238, ///< Last index in yytable_.
|
||||
yynnts_ = 103, ///< Number of nonterminal symbols.
|
||||
yyfinal_ = 8, ///< Termination state number.
|
||||
yyterror_ = 1,
|
||||
yyerrcode_ = 256,
|
||||
yyntokens_ = 46 ///< Number of tokens.
|
||||
yyntokens_ = 49 ///< Number of tokens.
|
||||
};
|
||||
|
||||
|
||||
@@ -934,9 +949,9 @@ namespace isc { namespace netconf {
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
|
||||
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
|
||||
45
|
||||
45, 46, 47, 48
|
||||
};
|
||||
const unsigned user_token_number_max_ = 300;
|
||||
const unsigned user_token_number_max_ = 303;
|
||||
const token_number_type undef_token_ = 2;
|
||||
|
||||
if (static_cast<int> (t) <= yyeof_)
|
||||
@@ -967,25 +982,25 @@ namespace isc { namespace netconf {
|
||||
{
|
||||
switch (other.type_get ())
|
||||
{
|
||||
case 54: // value
|
||||
case 57: // map_value
|
||||
case 113: // socket_type_value
|
||||
case 57: // value
|
||||
case 60: // map_value
|
||||
case 119: // socket_type_value
|
||||
value.copy< ElementPtr > (other.value);
|
||||
break;
|
||||
|
||||
case 45: // "boolean"
|
||||
case 48: // "boolean"
|
||||
value.copy< bool > (other.value);
|
||||
break;
|
||||
|
||||
case 44: // "floating point"
|
||||
case 47: // "floating point"
|
||||
value.copy< double > (other.value);
|
||||
break;
|
||||
|
||||
case 43: // "integer"
|
||||
case 46: // "integer"
|
||||
value.copy< int64_t > (other.value);
|
||||
break;
|
||||
|
||||
case 42: // "constant string"
|
||||
case 45: // "constant string"
|
||||
value.copy< std::string > (other.value);
|
||||
break;
|
||||
|
||||
@@ -1004,25 +1019,25 @@ namespace isc { namespace netconf {
|
||||
(void) v;
|
||||
switch (this->type_get ())
|
||||
{
|
||||
case 54: // value
|
||||
case 57: // map_value
|
||||
case 113: // socket_type_value
|
||||
case 57: // value
|
||||
case 60: // map_value
|
||||
case 119: // socket_type_value
|
||||
value.copy< ElementPtr > (v);
|
||||
break;
|
||||
|
||||
case 45: // "boolean"
|
||||
case 48: // "boolean"
|
||||
value.copy< bool > (v);
|
||||
break;
|
||||
|
||||
case 44: // "floating point"
|
||||
case 47: // "floating point"
|
||||
value.copy< double > (v);
|
||||
break;
|
||||
|
||||
case 43: // "integer"
|
||||
case 46: // "integer"
|
||||
value.copy< int64_t > (v);
|
||||
break;
|
||||
|
||||
case 42: // "constant string"
|
||||
case 45: // "constant string"
|
||||
value.copy< std::string > (v);
|
||||
break;
|
||||
|
||||
@@ -1100,25 +1115,25 @@ namespace isc { namespace netconf {
|
||||
// Type destructor.
|
||||
switch (yytype)
|
||||
{
|
||||
case 54: // value
|
||||
case 57: // map_value
|
||||
case 113: // socket_type_value
|
||||
case 57: // value
|
||||
case 60: // map_value
|
||||
case 119: // socket_type_value
|
||||
value.template destroy< ElementPtr > ();
|
||||
break;
|
||||
|
||||
case 45: // "boolean"
|
||||
case 48: // "boolean"
|
||||
value.template destroy< bool > ();
|
||||
break;
|
||||
|
||||
case 44: // "floating point"
|
||||
case 47: // "floating point"
|
||||
value.template destroy< double > ();
|
||||
break;
|
||||
|
||||
case 43: // "integer"
|
||||
case 46: // "integer"
|
||||
value.template destroy< int64_t > ();
|
||||
break;
|
||||
|
||||
case 42: // "constant string"
|
||||
case 45: // "constant string"
|
||||
value.template destroy< std::string > ();
|
||||
break;
|
||||
|
||||
@@ -1143,25 +1158,25 @@ namespace isc { namespace netconf {
|
||||
super_type::move (s);
|
||||
switch (this->type_get ())
|
||||
{
|
||||
case 54: // value
|
||||
case 57: // map_value
|
||||
case 113: // socket_type_value
|
||||
case 57: // value
|
||||
case 60: // map_value
|
||||
case 119: // socket_type_value
|
||||
value.move< ElementPtr > (s.value);
|
||||
break;
|
||||
|
||||
case 45: // "boolean"
|
||||
case 48: // "boolean"
|
||||
value.move< bool > (s.value);
|
||||
break;
|
||||
|
||||
case 44: // "floating point"
|
||||
case 47: // "floating point"
|
||||
value.move< double > (s.value);
|
||||
break;
|
||||
|
||||
case 43: // "integer"
|
||||
case 46: // "integer"
|
||||
value.move< int64_t > (s.value);
|
||||
break;
|
||||
|
||||
case 42: // "constant string"
|
||||
case 45: // "constant string"
|
||||
value.move< std::string > (s.value);
|
||||
break;
|
||||
|
||||
@@ -1224,7 +1239,7 @@ namespace isc { namespace netconf {
|
||||
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
|
||||
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
|
||||
285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
|
||||
295, 296, 297, 298, 299, 300
|
||||
295, 296, 297, 298, 299, 300, 301, 302, 303
|
||||
};
|
||||
return static_cast<token_type> (yytoken_number_[type]);
|
||||
}
|
||||
@@ -1295,6 +1310,24 @@ namespace isc { namespace netconf {
|
||||
return symbol_type (token::TOKEN_COMMENT, l);
|
||||
}
|
||||
|
||||
NetconfParser::symbol_type
|
||||
NetconfParser::make_BOOT_UPDATE (const location_type& l)
|
||||
{
|
||||
return symbol_type (token::TOKEN_BOOT_UPDATE, l);
|
||||
}
|
||||
|
||||
NetconfParser::symbol_type
|
||||
NetconfParser::make_SUBSCRIBE_CHANGES (const location_type& l)
|
||||
{
|
||||
return symbol_type (token::TOKEN_SUBSCRIBE_CHANGES, l);
|
||||
}
|
||||
|
||||
NetconfParser::symbol_type
|
||||
NetconfParser::make_VALIDATE_CHANGES (const location_type& l)
|
||||
{
|
||||
return symbol_type (token::TOKEN_VALIDATE_CHANGES, l);
|
||||
}
|
||||
|
||||
NetconfParser::symbol_type
|
||||
NetconfParser::make_MANAGED_SERVERS (const location_type& l)
|
||||
{
|
||||
@@ -1496,7 +1529,7 @@ namespace isc { namespace netconf {
|
||||
|
||||
#line 14 "netconf_parser.yy" // lalr1.cc:379
|
||||
} } // isc::netconf
|
||||
#line 1500 "netconf_parser.h" // lalr1.cc:379
|
||||
#line 1533 "netconf_parser.h" // lalr1.cc:379
|
||||
|
||||
|
||||
|
||||
|
@@ -53,6 +53,10 @@ using namespace std;
|
||||
USER_CONTEXT "user-context"
|
||||
COMMENT "comment"
|
||||
|
||||
BOOT_UPDATE "boot-update"
|
||||
SUBSCRIBE_CHANGES "subscribe-changes"
|
||||
VALIDATE_CHANGES "validate-changes"
|
||||
|
||||
MANAGED_SERVERS "managed-servers"
|
||||
DHCP4_SERVER "dhcp4"
|
||||
DHCP6_SERVER "dhcp6"
|
||||
@@ -268,13 +272,31 @@ not_empty_global_params: global_param
|
||||
|
||||
// These are the parameters that are allowed in the top-level for
|
||||
// Netconf.
|
||||
global_param: managed_servers
|
||||
global_param: boot_update
|
||||
| subscribe_changes
|
||||
| validate_changes
|
||||
| managed_servers
|
||||
| hooks_libraries
|
||||
| user_context
|
||||
| comment
|
||||
| unknown_map_entry
|
||||
;
|
||||
|
||||
boot_update: BOOT_UPDATE COLON BOOLEAN {
|
||||
ElementPtr flag(new BoolElement($3, ctx.loc2pos(@3)));
|
||||
ctx.stack_.back()->set("boot-update", flag);
|
||||
};
|
||||
|
||||
subscribe_changes: SUBSCRIBE_CHANGES COLON BOOLEAN {
|
||||
ElementPtr flag(new BoolElement($3, ctx.loc2pos(@3)));
|
||||
ctx.stack_.back()->set("subscribe-changes", flag);
|
||||
};
|
||||
|
||||
validate_changes: VALIDATE_CHANGES COLON BOOLEAN {
|
||||
ElementPtr flag(new BoolElement($3, ctx.loc2pos(@3)));
|
||||
ctx.stack_.back()->set("validate-changes", flag);
|
||||
};
|
||||
|
||||
user_context: USER_CONTEXT {
|
||||
ctx.enter(ctx.NO_KEYWORDS);
|
||||
} COLON map_value {
|
||||
@@ -460,6 +482,9 @@ managed_server_params: managed_server_param
|
||||
|
||||
// We currently support two server parameters: model and control-socket.
|
||||
managed_server_param: model
|
||||
| boot_update
|
||||
| subscribe_changes
|
||||
| validate_changes
|
||||
| control_socket
|
||||
| user_context
|
||||
| comment
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Generated 201809281126
|
||||
// Generated 201810092120
|
||||
// A Bison parser, made by GNU Bison 3.0.5.
|
||||
|
||||
// Positions for Bison parsers in C++
|
||||
|
@@ -36,6 +36,9 @@ namespace netconf {
|
||||
///
|
||||
/// These are global Netconf parameters.
|
||||
const SimpleDefaults NetconfSimpleParser::NETCONF_DEFAULTS = {
|
||||
{ "boot-update", Element::boolean, "true" },
|
||||
{ "subscribe-changes", Element::boolean, "true" },
|
||||
{ "validate-changes", Element::boolean, "true" }
|
||||
};
|
||||
|
||||
/// Supplies defaults for control-socket elements
|
||||
@@ -65,6 +68,18 @@ const SimpleDefaults NetconfSimpleParser::CA_DEFAULTS = {
|
||||
{ "model", Element::string, "kea-ctrl-agent" }
|
||||
};
|
||||
|
||||
/// @brief List of parameters that can be inherited to managed-servers scope.
|
||||
///
|
||||
/// Some parameters may be defined on both global (directly in Netconf) and
|
||||
/// servers (Netconf/managed-servers/...) scope. If not defined in the
|
||||
/// managed-servers scope, the value is being inherited (derived) from
|
||||
/// the global scope. This array lists all of such parameters.
|
||||
const ParamsList NetconfSimpleParser::INHERIT_TO_SERVERS = {
|
||||
"boot-update",
|
||||
"subscribe-changes",
|
||||
"validate-changes"
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
||||
/// ---------------------------------------------------------------------------
|
||||
@@ -87,6 +102,24 @@ size_t NetconfSimpleParser::setAllDefaults(const ElementPtr& global) {
|
||||
return (cnt);
|
||||
}
|
||||
|
||||
size_t NetconfSimpleParser::deriveParameters(ConstElementPtr global) {
|
||||
size_t cnt = 0;
|
||||
|
||||
// Now derive global parameters into managed-servers.
|
||||
ConstElementPtr servers = global->get("managed-servers");
|
||||
if (servers) {
|
||||
for (auto it : servers->mapValue()) {
|
||||
ElementPtr mutable_server =
|
||||
boost::const_pointer_cast<Element>(it.second);
|
||||
cnt += SimpleParser::deriveParams(global,
|
||||
mutable_server,
|
||||
INHERIT_TO_SERVERS);
|
||||
}
|
||||
}
|
||||
|
||||
return (cnt);
|
||||
}
|
||||
|
||||
size_t
|
||||
NetconfSimpleParser::setServerDefaults(const std::string name,
|
||||
ConstElementPtr server) {
|
||||
|
@@ -30,6 +30,14 @@ public:
|
||||
/// @return number of default values added
|
||||
static size_t setAllDefaults(const isc::data::ElementPtr& global);
|
||||
|
||||
/// @brief Derives (inherits) all parameters from global to more specific scopes.
|
||||
///
|
||||
/// This method currently does the following:
|
||||
/// - derives global parameters to managed servers (flags for now)
|
||||
/// @param global scope to be modified if needed
|
||||
/// @return number of default values derived
|
||||
static size_t deriveParameters(isc::data::ConstElementPtr global);
|
||||
|
||||
/// @brief Adds default values to a Managed server entry.
|
||||
///
|
||||
/// Adds server specific defaults, e.g. the default model.
|
||||
@@ -58,6 +66,7 @@ public:
|
||||
static const isc::data::SimpleDefaults DHCP6_DEFAULTS;
|
||||
static const isc::data::SimpleDefaults D2_DEFAULTS;
|
||||
static const isc::data::SimpleDefaults CA_DEFAULTS;
|
||||
static const isc::data::ParamsList INHERIT_TO_SERVERS;
|
||||
};
|
||||
|
||||
};
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Generated 201809281126
|
||||
// Generated 201810092120
|
||||
// A Bison parser, made by GNU Bison 3.0.5.
|
||||
|
||||
// Stack handling for Bison parsers in C++
|
||||
|
@@ -12,11 +12,13 @@
|
||||
#include <process/testutils/d_test_stubs.h>
|
||||
#include <process/d_cfg_mgr.h>
|
||||
#include <yang/yang_models.h>
|
||||
#include <testutils/test_to_element.h>
|
||||
#include <netconf/tests/test_libraries.h>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace isc;
|
||||
using namespace isc::netconf;
|
||||
using namespace isc::config;
|
||||
using namespace isc::data;
|
||||
@@ -135,6 +137,59 @@ TEST(NetconfCfgMgr, contextHookParams) {
|
||||
EXPECT_EQ(libs.get(), stored_libs.get());
|
||||
}
|
||||
|
||||
// Tests if the context can store and retrieve globals.
|
||||
TEST(NetconfCfgMgr, contextGlobals) {
|
||||
NetconfConfig ctx;
|
||||
|
||||
// By default there should be no globals.
|
||||
ConstElementPtr globals = ctx.getConfiguredGlobals();
|
||||
ASSERT_TRUE(globals);
|
||||
ASSERT_EQ(Element::map, globals->getType());
|
||||
EXPECT_EQ(0, globals->mapValue().size());
|
||||
|
||||
// Attempting to extract globals from a non-map should throw.
|
||||
ASSERT_THROW(ctx.extractConfiguredGlobals(Element::create(777)), BadValue);
|
||||
|
||||
// Now let's create a configuration from which to extract global scalars.
|
||||
// Extraction (currently) has no business logic, so the elements we use
|
||||
// can be arbitrary.
|
||||
ConstElementPtr global_cfg;
|
||||
string global_cfg_str =
|
||||
"{\n"
|
||||
" \"astring\": \"okay\",\n"
|
||||
" \"amap\": { \"not-this\":777, \"not-that\": \"poo\" },\n"
|
||||
" \"anint\": 444,\n"
|
||||
" \"alist\": [ 1, 2, 3 ],\n"
|
||||
" \"abool\": true\n"
|
||||
"}\n";
|
||||
ASSERT_NO_THROW(global_cfg = Element::fromJSON(global_cfg_str));
|
||||
|
||||
// Extract globals from the config.
|
||||
ASSERT_NO_THROW(ctx.extractConfiguredGlobals(global_cfg));
|
||||
|
||||
// Now see if the extract was correct.
|
||||
globals = ctx.getConfiguredGlobals();
|
||||
ASSERT_TRUE(globals);
|
||||
ASSERT_EQ(Element::map, globals->getType());
|
||||
EXPECT_NE(0, globals->mapValue().size());
|
||||
|
||||
// Maps and lists should be excluded.
|
||||
for (auto it : globals->mapValue()) {
|
||||
if (it.first == "astring") {
|
||||
ASSERT_EQ(Element::string, it.second->getType());
|
||||
EXPECT_EQ("okay", it.second->stringValue());
|
||||
} else if (it.first == "anint") {
|
||||
ASSERT_EQ(Element::integer, it.second->getType());
|
||||
EXPECT_EQ(444, it.second->intValue());
|
||||
} else if (it.first == "abool") {
|
||||
ASSERT_EQ(Element::boolean, it.second->getType());
|
||||
EXPECT_TRUE(it.second->boolValue());
|
||||
} else {
|
||||
ADD_FAILURE() << "unexpected element found:" << it.first;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Netconf configurations used in tests.
|
||||
const char* NETCONF_CONFIGS[] = {
|
||||
|
||||
@@ -143,12 +198,17 @@ const char* NETCONF_CONFIGS[] = {
|
||||
|
||||
// Configuration 1: global parameters only (no server, not hooks)
|
||||
"{\n"
|
||||
" \"boot-update\": false,\n"
|
||||
" \"subscribe-changes\": false,\n"
|
||||
" \"validate-changes\": false\n"
|
||||
"}",
|
||||
|
||||
// Configuration 2: 1 server
|
||||
"{\n"
|
||||
" \"boot-update\": false,\n"
|
||||
" \"managed-servers\": {\n"
|
||||
" \"dhcp4\": {\n"
|
||||
" \"boot-update\": true,\n"
|
||||
" \"control-socket\": {\n"
|
||||
" \"socket-name\": \"/tmp/socket-v4\"\n"
|
||||
" }\n"
|
||||
@@ -158,8 +218,10 @@ const char* NETCONF_CONFIGS[] = {
|
||||
|
||||
// Configuration 3: all 4 servers
|
||||
"{\n"
|
||||
" \"boot-update\": false,\n"
|
||||
" \"managed-servers\": {\n"
|
||||
" \"dhcp4\": {\n"
|
||||
" \"boot-update\": true,\n"
|
||||
" \"control-socket\": {\n"
|
||||
" \"socket-name\": \"/tmp/socket-v4\"\n"
|
||||
" }\n"
|
||||
@@ -170,6 +232,7 @@ const char* NETCONF_CONFIGS[] = {
|
||||
" }\n"
|
||||
" },\n"
|
||||
" \"d2\": {\n"
|
||||
" \"subscribe-changes\": false,\n"
|
||||
" \"control-socket\": {\n"
|
||||
" \"socket-name\": \"/tmp/socket-d2\"\n"
|
||||
" }\n"
|
||||
@@ -207,6 +270,7 @@ const char* NETCONF_CONFIGS[] = {
|
||||
"{\n"
|
||||
" \"managed-servers\": {\n"
|
||||
" \"d2\": {\n"
|
||||
" \"subscribe-changes\": false,\n"
|
||||
" \"control-socket\": {\n"
|
||||
" \"socket-name\": \"/tmp/socket-d2\"\n"
|
||||
" }\n"
|
||||
@@ -255,6 +319,9 @@ const char* NETCONF_CONFIGS[] = {
|
||||
|
||||
// Configuration 9: empty control socket
|
||||
"{\n"
|
||||
" \"boot-update\": false,\n"
|
||||
" \"subscribe-changes\": false,\n"
|
||||
" \"validate-changes\": false,\n"
|
||||
" \"managed-servers\": {\n"
|
||||
" \"dhcp4\": {\n"
|
||||
" \"control-socket\": {\n"
|
||||
@@ -354,6 +421,13 @@ TEST_F(NetconfParserTest, configParseGlobalOnly) {
|
||||
ASSERT_TRUE(ctx);
|
||||
ASSERT_TRUE(ctx->getCfgServersMap());
|
||||
EXPECT_EQ(0, ctx->getCfgServersMap()->size());
|
||||
ConstElementPtr globals = ctx->getConfiguredGlobals();
|
||||
ASSERT_TRUE(globals);
|
||||
string expected = "{ "
|
||||
"\"boot-update\": false, "
|
||||
"\"subscribe-changes\": false, "
|
||||
"\"validate-changes\": false }";
|
||||
EXPECT_EQ(expected, globals->str());
|
||||
}
|
||||
|
||||
// Tests if an empty (i.e. without a control socket) can be configured.
|
||||
@@ -369,6 +443,10 @@ TEST_F(NetconfParserTest, configParseEmptyCfgServer) {
|
||||
CfgServerPtr server = ctx->getCfgServersMap()->at("dhcp4");
|
||||
ASSERT_TRUE(server);
|
||||
EXPECT_EQ(KEA_DHCP4_SERVER, server->getModel());
|
||||
// Defaults.
|
||||
EXPECT_TRUE(server->getBootUpdate());
|
||||
EXPECT_TRUE(server->getSubscribeChanges());
|
||||
EXPECT_TRUE(server->getValidateChanges());
|
||||
CfgControlSocketPtr socket = server->getCfgControlSocket();
|
||||
EXPECT_FALSE(socket);
|
||||
}
|
||||
@@ -386,6 +464,10 @@ TEST_F(NetconfParserTest, configParseDefaults) {
|
||||
CfgServerPtr server = ctx->getCfgServersMap()->at("dhcp4");
|
||||
ASSERT_TRUE(server);
|
||||
EXPECT_EQ(KEA_DHCP4_SERVER, server->getModel());
|
||||
// Globals overwrite defaults.
|
||||
EXPECT_FALSE(server->getBootUpdate());
|
||||
EXPECT_FALSE(server->getSubscribeChanges());
|
||||
EXPECT_FALSE(server->getValidateChanges());
|
||||
CfgControlSocketPtr socket = server->getCfgControlSocket();
|
||||
ASSERT_TRUE(socket);
|
||||
|
||||
@@ -407,6 +489,10 @@ TEST_F(NetconfParserTest, configParseServerDhcp4) {
|
||||
CfgServerPtr server = ctx->getCfgServersMap()->at("dhcp4");
|
||||
ASSERT_TRUE(server);
|
||||
EXPECT_EQ(KEA_DHCP4_SERVER, server->getModel());
|
||||
// Locals overwrite globals.
|
||||
EXPECT_TRUE(server->getBootUpdate());
|
||||
EXPECT_TRUE(server->getSubscribeChanges());
|
||||
EXPECT_TRUE(server->getValidateChanges());
|
||||
CfgControlSocketPtr socket = server->getCfgControlSocket();
|
||||
ASSERT_TRUE(socket);
|
||||
EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
|
||||
@@ -426,6 +512,9 @@ TEST_F(NetconfParserTest, configParseServerD2) {
|
||||
CfgServerPtr server = ctx->getCfgServersMap()->at("d2");
|
||||
ASSERT_TRUE(server);
|
||||
EXPECT_EQ(KEA_DHCP_DDNS, server->getModel());
|
||||
EXPECT_TRUE(server->getBootUpdate());
|
||||
EXPECT_FALSE(server->getSubscribeChanges());
|
||||
EXPECT_TRUE(server->getValidateChanges());
|
||||
CfgControlSocketPtr socket = server->getCfgControlSocket();
|
||||
ASSERT_TRUE(socket);
|
||||
EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
|
||||
@@ -466,6 +555,9 @@ TEST_F(NetconfParserTest, configParse4Servers) {
|
||||
CfgServerPtr server = ctx->getCfgServersMap()->at("dhcp4");
|
||||
ASSERT_TRUE(server);
|
||||
EXPECT_EQ(KEA_DHCP4_SERVER, server->getModel());
|
||||
EXPECT_TRUE(server->getBootUpdate());
|
||||
EXPECT_TRUE(server->getSubscribeChanges());
|
||||
EXPECT_TRUE(server->getValidateChanges());
|
||||
CfgControlSocketPtr socket = server->getCfgControlSocket();
|
||||
ASSERT_TRUE(socket);
|
||||
EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
|
||||
@@ -477,6 +569,9 @@ TEST_F(NetconfParserTest, configParse4Servers) {
|
||||
ASSERT_TRUE(server);
|
||||
EXPECT_EQ(KEA_DHCP6_SERVER, server->getModel());
|
||||
socket = server->getCfgControlSocket();
|
||||
EXPECT_FALSE(server->getBootUpdate());
|
||||
EXPECT_TRUE(server->getSubscribeChanges());
|
||||
EXPECT_TRUE(server->getValidateChanges());
|
||||
ASSERT_TRUE(socket);
|
||||
EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
|
||||
EXPECT_EQ("/tmp/socket-v6", socket->getName());
|
||||
@@ -486,6 +581,9 @@ TEST_F(NetconfParserTest, configParse4Servers) {
|
||||
server = ctx->getCfgServersMap()->at("d2");
|
||||
ASSERT_TRUE(server);
|
||||
EXPECT_EQ(KEA_DHCP_DDNS, server->getModel());
|
||||
EXPECT_FALSE(server->getBootUpdate());
|
||||
EXPECT_FALSE(server->getSubscribeChanges());
|
||||
EXPECT_TRUE(server->getValidateChanges());
|
||||
socket = server->getCfgControlSocket();
|
||||
ASSERT_TRUE(socket);
|
||||
EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
|
||||
@@ -496,11 +594,69 @@ TEST_F(NetconfParserTest, configParse4Servers) {
|
||||
server = ctx->getCfgServersMap()->at("ca");
|
||||
ASSERT_TRUE(server);
|
||||
EXPECT_EQ(KEA_CTRL_AGENT, server->getModel());
|
||||
EXPECT_FALSE(server->getBootUpdate());
|
||||
EXPECT_TRUE(server->getSubscribeChanges());
|
||||
EXPECT_TRUE(server->getValidateChanges());
|
||||
socket = server->getCfgControlSocket();
|
||||
ASSERT_TRUE(socket);
|
||||
EXPECT_EQ(CfgControlSocket::Type::STDOUT, socket->getType());
|
||||
EXPECT_EQ("/tmp/socket-ca", socket->getName());
|
||||
EXPECT_EQ("http://127.0.0.1:8000/", socket->getUrl().toText());
|
||||
|
||||
// Check unparsing.
|
||||
string expected = "{\n"
|
||||
" \"Netconf\": {\n"
|
||||
" \"boot-update\": false,\n"
|
||||
" \"managed-servers\": {\n"
|
||||
" \"dhcp4\": {\n"
|
||||
" \"model\": \"kea-dhcp4-server\",\n"
|
||||
" \"boot-update\": true,\n"
|
||||
" \"subscribe-changes\": true,\n"
|
||||
" \"validate-changes\": true,\n"
|
||||
" \"control-socket\": {\n"
|
||||
" \"socket-type\": \"stdout\",\n"
|
||||
" \"socket-name\": \"/tmp/socket-v4\",\n"
|
||||
" \"socket-url\": \"http://127.0.0.1:8000/\"\n"
|
||||
" }\n"
|
||||
" },\n"
|
||||
" \"dhcp6\": {\n"
|
||||
" \"model\": \"kea-dhcp6-server\",\n"
|
||||
" \"boot-update\": false,\n"
|
||||
" \"subscribe-changes\": true,\n"
|
||||
" \"validate-changes\": true,\n"
|
||||
" \"control-socket\": {\n"
|
||||
" \"socket-type\": \"stdout\",\n"
|
||||
" \"socket-name\": \"/tmp/socket-v6\",\n"
|
||||
" \"socket-url\": \"http://127.0.0.1:8000/\"\n"
|
||||
" }\n"
|
||||
" },\n"
|
||||
" \"d2\": {\n"
|
||||
" \"model\": \"kea-dhcp-ddns\",\n"
|
||||
" \"boot-update\": false,\n"
|
||||
" \"subscribe-changes\": false,\n"
|
||||
" \"validate-changes\": true,\n"
|
||||
" \"control-socket\": {\n"
|
||||
" \"socket-type\": \"stdout\",\n"
|
||||
" \"socket-name\": \"/tmp/socket-d2\",\n"
|
||||
" \"socket-url\": \"http://127.0.0.1:8000/\"\n"
|
||||
" }\n"
|
||||
" },\n"
|
||||
" \"ca\": {\n"
|
||||
" \"model\": \"kea-ctrl-agent\",\n"
|
||||
" \"boot-update\": false,\n"
|
||||
" \"subscribe-changes\": true,\n"
|
||||
" \"validate-changes\": true,\n"
|
||||
" \"control-socket\": {\n"
|
||||
" \"socket-type\": \"stdout\",\n"
|
||||
" \"socket-name\": \"/tmp/socket-ca\",\n"
|
||||
" \"socket-url\": \"http://127.0.0.1:8000/\"\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" },\n"
|
||||
" \"hooks-libraries\": [ ]\n"
|
||||
" }\n"
|
||||
"}";
|
||||
isc::test::runToElementTest<NetconfConfig>(expected, *ctx);
|
||||
}
|
||||
|
||||
// Tests the handling of invalid socket URL.
|
||||
|
@@ -24,6 +24,8 @@ namespace {
|
||||
/// @brief Valid Netconf Config used in tests.
|
||||
const char* valid_netconf_config =
|
||||
"{"
|
||||
" \"boot-update\": false,"
|
||||
" \"subscribe-changes\": false,"
|
||||
" \"managed-servers\": {"
|
||||
" \"dhcp4\": {"
|
||||
" \"control-socket\": {"
|
||||
|
@@ -124,9 +124,15 @@ TEST(ParserTest, keywordJSON) {
|
||||
// be parsed with syntactic checking (and as pure JSON).
|
||||
TEST(ParserTest, keywordNetconf) {
|
||||
string txt = "{ \"Netconf\": {\n"
|
||||
" \"boot-update\": true,"
|
||||
" \"subscribe-changes\": true,"
|
||||
" \"validate-changes\": true,"
|
||||
" \"managed-servers\": {"
|
||||
" \"dhcp4\": {"
|
||||
" \"model\": \"kea-dhcp4-server\","
|
||||
" \"boot-update\": false,"
|
||||
" \"subscribe-changes\": false,"
|
||||
" \"validate-changes\": false,"
|
||||
" \"control-socket\": {"
|
||||
" \"socket-type\": \"unix\","
|
||||
" \"socket-name\": \"/path/to/the/unix/socket-v4\""
|
||||
@@ -134,6 +140,9 @@ TEST(ParserTest, keywordNetconf) {
|
||||
" },"
|
||||
" \"dhcp6\": {"
|
||||
" \"model\": \"kea-dhcp6-server\","
|
||||
" \"boot-update\": false,"
|
||||
" \"subscribe-changes\": false,"
|
||||
" \"validate-changes\": false,"
|
||||
" \"control-socket\": {"
|
||||
" \"socket-type\": \"http\","
|
||||
" \"socket-url\": \"http://127.0.0.1:12345/\""
|
||||
@@ -141,12 +150,18 @@ TEST(ParserTest, keywordNetconf) {
|
||||
" },"
|
||||
" \"d2\": {"
|
||||
" \"model\": \"kea-dhcp-ddns\","
|
||||
" \"boot-update\": false,"
|
||||
" \"subscribe-changes\": false,"
|
||||
" \"validate-changes\": false,"
|
||||
" \"control-socket\": {"
|
||||
" \"socket-type\": \"stdout\""
|
||||
" }"
|
||||
" },"
|
||||
" \"ca\": {"
|
||||
" \"model\": \"kea-ctrl-agent\","
|
||||
" \"boot-update\": false,"
|
||||
" \"subscribe-changes\": false,"
|
||||
" \"validate-changes\": false,"
|
||||
" \"control-socket\": {"
|
||||
" \"socket-type\": \"http\","
|
||||
" \"user-context\": { \"use default\": true }"
|
||||
@@ -174,9 +189,15 @@ TEST(ParserTest, keywordSubNetconf) {
|
||||
// This is similar to previous test, but note the lack of outer
|
||||
// map and Netconf.
|
||||
string txt = "{\n"
|
||||
" \"boot-update\": true,"
|
||||
" \"subscribe-changes\": true,"
|
||||
" \"validate-changes\": true,"
|
||||
" \"managed-servers\": {"
|
||||
" \"dhcp4\": {"
|
||||
" \"model\": \"kea-dhcp4-server\","
|
||||
" \"boot-update\": false,"
|
||||
" \"subscribe-changes\": false,"
|
||||
" \"validate-changes\": false,"
|
||||
" \"control-socket\": {"
|
||||
" \"socket-type\": \"unix\","
|
||||
" \"socket-name\": \"/path/to/the/unix/socket-v4\""
|
||||
@@ -184,6 +205,9 @@ TEST(ParserTest, keywordSubNetconf) {
|
||||
" },"
|
||||
" \"dhcp6\": {"
|
||||
" \"model\": \"kea-dhcp6-server\","
|
||||
" \"boot-update\": false,"
|
||||
" \"subscribe-changes\": false,"
|
||||
" \"validate-changes\": false,"
|
||||
" \"control-socket\": {"
|
||||
" \"socket-type\": \"http\","
|
||||
" \"socket-url\": \"http://127.0.0.1:12345/\""
|
||||
@@ -191,13 +215,18 @@ TEST(ParserTest, keywordSubNetconf) {
|
||||
" },"
|
||||
" \"d2\": {"
|
||||
" \"model\": \"kea-dhcp-ddns\","
|
||||
" \"boot-update\": false,"
|
||||
" \"subscribe-changes\": false,"
|
||||
" \"validate-changes\": false,"
|
||||
" \"control-socket\": {"
|
||||
" \"socket-type\": \"stdout\""
|
||||
" }"
|
||||
" },"
|
||||
" \"ca\": {"
|
||||
" \"model\": \"kea-ctrl-agent\","
|
||||
" \"model\": \"kea-dhcp6-server\","
|
||||
" \"boot-update\": false,"
|
||||
" \"subscribe-changes\": false,"
|
||||
" \"validate-changes\": false,"
|
||||
" \"control-socket\": {"
|
||||
" \"socket-type\": \"http\","
|
||||
" \"user-context\": { \"use default\": true }"
|
||||
|
21
src/bin/netconf/tests/testdata/get_config.json
vendored
21
src/bin/netconf/tests/testdata/get_config.json
vendored
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"Netconf": {
|
||||
"boot-update": false,
|
||||
"hooks-libraries": [
|
||||
{
|
||||
"library": "/tmp/ky/src/bin/netconf/tests/.libs/libbasic.so",
|
||||
@@ -10,14 +11,18 @@
|
||||
],
|
||||
"managed-servers": {
|
||||
"ca": {
|
||||
"boot-update": false,
|
||||
"control-socket": {
|
||||
"socket-name": "",
|
||||
"socket-type": "http",
|
||||
"socket-url": "http://127.0.0.1:8000/"
|
||||
},
|
||||
"model": "kea-ctrl-agent"
|
||||
"model": "kea-ctrl-agent",
|
||||
"subscribe-changes": true,
|
||||
"validate-changes": true
|
||||
},
|
||||
"d2": {
|
||||
"boot-update": false,
|
||||
"control-socket": {
|
||||
"socket-name": "",
|
||||
"socket-type": "stdout",
|
||||
@@ -26,24 +31,32 @@
|
||||
"in-use": false
|
||||
}
|
||||
},
|
||||
"model": "kea-dhcp-ddns"
|
||||
"model": "kea-dhcp-ddns",
|
||||
"subscribe-changes": true,
|
||||
"validate-changes": true
|
||||
},
|
||||
"dhcp4": {
|
||||
"comment": "DHCP4 server",
|
||||
"boot-update": false,
|
||||
"control-socket": {
|
||||
"socket-name": "/path/to/the/unix/socket-v4",
|
||||
"socket-type": "unix",
|
||||
"socket-url": "http://127.0.0.1:8000/"
|
||||
},
|
||||
"model": "kea-dhcp4-server"
|
||||
"model": "kea-dhcp4-server",
|
||||
"subscribe-changes": true,
|
||||
"validate-changes": true
|
||||
},
|
||||
"dhcp6": {
|
||||
"boot-update": false,
|
||||
"control-socket": {
|
||||
"socket-name": "/path/to/the/unix/socket-v6",
|
||||
"socket-type": "unix",
|
||||
"socket-url": "http://127.0.0.1:8000/"
|
||||
},
|
||||
"model": "kea-dhcp6-server"
|
||||
"model": "kea-dhcp6-server",
|
||||
"subscribe-changes": true,
|
||||
"validate-changes": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user