"subnet4": [],
// Global valid lifetime value.
- "valid-lifetime": 6000
+ "valid-lifetime": 6000,
+
+ // Configuration control.
+ "config-control":
+ {
+ // Only configuration databases entry is defined.
+ "config-databases": [
+ {
+ // Name of the database to connect to.
+ "name": "config",
+
+ // Type of the database, e.g. "mysql", "pgsql", "cql".
+ "type": "mysql"
+ }
+ ]
+ },
+
+ // Server tag.
+ "server-tag": "my DHCPv4 server",
+
+ // DHCP queue control parameters.
+ "dhcp-queue-control":
+ {
+ // Queue type is mandatory.
+ "queue-type": "kea-ring4"
+ }
},
// Logging configuration begins here.
"subnet6": [],
// Global valid lifetime value.
- "valid-lifetime": 6000
+ "valid-lifetime": 6000,
+
+ // Configuration control.
+ "config-control":
+ {
+ // Only configuration databases entry is defined.
+ "config-databases": [
+ {
+ // Name of the database to connect to.
+ "name": "config",
+
+ // Type of the database, e.g. "mysql", "pgsql", "cql".
+ "type": "mysql"
+ }
+ ]
+ },
+
+ // Server tag.
+ "server-tag": "my DHCPv6 server",
+
+ // DHCP queue control parameters.
+ "dhcp-queue-control":
+ {
+ // Queue type is mandatory.
+ "queue-type": "kea-ring6"
+ }
},
// Logging configuration begins here.
}
import kea-logging {
prefix logging;
- revision-date 2018-11-11;
+ revision-date 2018-11-16;
}
organization "Internet Systems Consortium";
description "This model defines a YANG data model that can be
used to configure and manage a Kea control agent.";
- revision 2018-11-11 {
+ revision 2018-11-16 {
description "Initial revision";
reference "";
}
}
import kea-logging {
prefix logging;
- revision-date 2018-11-11;
+ revision-date 2018-11-16;
}
organization "Internet Systems Consortium";
description "This model defines a YANG data model that can be
used to configure and manage a Kea DHCP-DDNS server.";
- revision 2018-11-11 {
+ revision 2018-11-16 {
description "Initial revision";
reference "";
}
description "Lease database.";
uses database;
}
- container hosts-databases {
- description "Hosts databases.";
- list hosts-database {
- key database-type;
- description "List of databases.";
- uses database;
- }
+ list hosts-database {
+ key database-type;
+ description "List of databases.";
+ uses database;
}
}
description "Config control grouping.";
container config-control {
description "Config control.";
- list config-databases {
+ list config-database {
key database-type;
description "List of databases.";
uses database;
}
import kea-logging {
prefix logging;
- revision-date 2018-11-11;
+ revision-date 2018-11-16;
}
organization "Internet Systems Consortium";
description "This model defines a YANG data model that can be
used to configure and manage a Kea DHCPv4 server.";
- revision 2018-11-14 {
+ revision 2018-11-16 {
description "Initial revision";
reference "";
}
grouping reservations {
description "Host reservations grouping.";
- container reservations {
- description "Host reservations container.";
- list host {
- key "identifier-type identifier";
- description "Host reservation entry.";
- uses host;
- }
+ list host {
+ key "identifier-type identifier";
+ description "Host reservation list.";
+ uses host;
}
}
uses dhcp:renew-timer;
uses dhcp:rebind-timer;
uses option-data-list;
- container pools {
- description "List of pools.";
- list pool {
- key "start-address end-address";
- ordered-by user;
- description "Pool entry.";
- leaf prefix {
- type inet:ipv4-prefix;
- description "Defines a pool of dynamic IPv4 addresses to be managed
- by the server.";
- }
- leaf start-address {
- type inet:ipv4-address;
- mandatory true;
- description "First IPv4 address in a pool.";
- }
- leaf end-address {
- type inet:ipv4-address;
- mandatory true;
- description "Last IPv4 address in a pool.";
- }
- uses option-data-list;
- uses dhcp:pool-client-class;
- uses dhcp:pool-require-client-classes;
- uses dhcp:pool-user-context;
+ list pool {
+ key "start-address end-address";
+ ordered-by user;
+ description "Pool list.";
+ leaf prefix {
+ type inet:ipv4-prefix;
+ description "Defines a pool of dynamic IPv4 addresses to be managed
+ by the server.";
+ }
+ leaf start-address {
+ type inet:ipv4-address;
+ mandatory true;
+ description "First IPv4 address in a pool.";
}
+ leaf end-address {
+ type inet:ipv4-address;
+ mandatory true;
+ description "Last IPv4 address in a pool.";
+ }
+ uses option-data-list;
+ uses dhcp:pool-client-class;
+ uses dhcp:pool-require-client-classes;
+ uses dhcp:pool-user-context;
}
leaf subnet {
type inet:ipv4-prefix;
uses dhcp:subnet-client-class;
uses dhcp:subnet-require-client-classes;
uses reservations {
- refine reservations {
- description "Subnet host reservations.";
+ refine host {
+ description "Subnet host reservations list.";
}
}
uses dhcp:subnet-reservation-mode;
}
}
- grouping client-class {
+ grouping client-classes {
description "Client class grouping.";
- uses dhcp:class-name;
- uses dhcp:class-test;
- uses dhcp:class-only-if-required;
- uses option-def-list;
- uses option-data-list;
- uses next-server;
- uses server-hostname;
- uses boot-file-name;
- uses dhcp:class-user-context;
+ list client-class {
+ key name;
+ ordered-by user;
+ description "List of client classes.";
+ uses dhcp:class-name;
+ uses dhcp:class-test;
+ uses dhcp:class-only-if-required;
+ uses option-def-list;
+ uses option-data-list;
+ uses next-server;
+ uses server-hostname;
+ uses boot-file-name;
+ uses dhcp:class-user-context;
+ }
}
grouping option-def-list {
description "Option definition list grouping.";
- container option-def-list {
- description "List with custom option definitions.";
- list option-def {
- key "code space";
- description "Option definition entry.";
- leaf code {
- type uint8;
- mandatory true;
- description "Option code to be used by the new option definition.";
- }
- leaf space {
- type string;
- mandatory true;
- description "Option space for the new option (typically dhcp4).";
- }
- uses dhcp:option-def-name;
- uses dhcp:option-def-type;
- uses dhcp:option-def-record-types;
- uses dhcp:option-def-encapsulate;
- uses dhcp:option-def-array;
- uses dhcp:option-def-user-context;
+ list option-def {
+ key "code space";
+ description "Option definition entry.";
+ leaf code {
+ type uint8;
+ mandatory true;
+ description "Option code to be used by the new option definition.";
}
- }
+ leaf space {
+ type string;
+ mandatory true;
+ description "Option space for the new option (typically dhcp4).";
+ }
+ uses dhcp:option-def-name;
+ uses dhcp:option-def-type;
+ uses dhcp:option-def-record-types;
+ uses dhcp:option-def-encapsulate;
+ uses dhcp:option-def-array;
+ uses dhcp:option-def-user-context;
+ }
}
grouping option-data-list {
uses dhcp:renew-timer;
uses dhcp:rebind-timer;
uses dhcp:decline-probation-period;
+ uses subnet4-list;
- container subnet4 {
- description "Global list of IPv4 subnets.";
+ list shared-network {
+ key name;
+ description "List of IPv4 shared networks.";
+ uses dhcp:network-name;
uses subnet4-list;
- }
-
- container shared-networks {
- description "Defines a list of IPv4 shared networks.";
- list shared-network {
- key name;
- description "List of IPv4 shared networks.";
- uses dhcp:network-name;
- container subnet4 {
- description "List of IPv4 subnets that belong to this shared
- network.";
- uses subnet4-list;
- }
- uses dhcp:network-interface;
- uses dhcp:renew-timer;
- uses dhcp:rebind-timer;
- uses option-data-list;
- uses match-client-id;
- uses next-server;
- uses server-hostname;
- uses boot-file-name;
- container relay {
- description "Optional information about relay agent.";
- uses relay;
- }
- uses authoritative;
- uses dhcp:network-reservation-mode;
- uses dhcp:network-client-class;
- uses dhcp:network-require-client-classes;
- uses dhcp:valid-lifetime;
- uses dhcp:network-user-context;
+ uses dhcp:network-interface;
+ uses dhcp:renew-timer;
+ uses dhcp:rebind-timer;
+ uses option-data-list;
+ uses match-client-id;
+ uses next-server;
+ uses server-hostname;
+ uses boot-file-name;
+ container relay {
+ description "Optional information about relay agent.";
+ uses relay;
}
+ uses authoritative;
+ uses dhcp:network-reservation-mode;
+ uses dhcp:network-client-class;
+ uses dhcp:network-require-client-classes;
+ uses dhcp:valid-lifetime;
+ uses dhcp:network-user-context;
}
container interfaces-config {
description "Host reservation identifiers.";
}
- container client-classes {
- description "Client classes.";
- list client-class {
- key name;
- ordered-by user;
- description "List of client classes.";
- uses client-class;
- }
- }
-
+ uses client-classes;
uses option-def-list;
uses option-data-list;
uses kea:hooks-libraries;
}
uses dhcp:sanity-checks;
uses reservations {
- refine reservations {
- description "Global host reservations.";
+ refine host {
+ description "Global host reservations list.";
}
}
uses dhcp:config-control;
}
import kea-logging {
prefix logging;
- revision-date 2018-11-11;
+ revision-date 2018-11-16;
}
organization "Internet Systems Consortium";
description "This model defines a YANG data model that can be
used to configure and manage a Kea DHCPv6 server.";
- revision 2018-11-14 {
+ revision 2018-11-16 {
description "Initial revision";
reference "";
}
grouping reservations {
description "Host reservations grouping.";
- container reservations {
- description "Host reservations container.";
- list host {
- key "identifier-type identifier";
- description "Host reservation entry.";
- uses host;
- }
+ list host {
+ key "identifier-type identifier";
+ description "Host reservation list.";
+ uses host;
}
}
uses dhcp:renew-timer;
uses dhcp:rebind-timer;
uses option-data-list;
- container pools {
- description "List of pools.";
- list pool {
- key "start-address end-address";
- ordered-by user;
- description "Pool entry.";
- leaf prefix {
- type inet:ipv6-prefix;
- description "Pool prefix.";
- }
- leaf start-address {
- type inet:ipv6-address;
- mandatory true;
- description "First IPv6 address in a pool.";
- }
- leaf end-address {
- type inet:ipv6-address;
- mandatory true;
- description "Last IPv6 address in a pool.";
- }
- uses option-data-list;
- uses dhcp:pool-client-class;
- uses dhcp:pool-require-client-classes;
- uses dhcp:pool-user-context;
+ list pool {
+ key "start-address end-address";
+ ordered-by user;
+ description "Pool list.";
+ leaf prefix {
+ type inet:ipv6-prefix;
+ description "Pool prefix.";
}
+ leaf start-address {
+ type inet:ipv6-address;
+ mandatory true;
+ description "First IPv6 address in a pool.";
+ }
+ leaf end-address {
+ type inet:ipv6-address;
+ mandatory true;
+ description "Last IPv6 address in a pool.";
+ }
+ uses option-data-list;
+ uses dhcp:pool-client-class;
+ uses dhcp:pool-require-client-classes;
+ uses dhcp:pool-user-context;
}
- container pd-pools {
- description "List of prefix delegation pools.";
- list pd-pool {
- key prefix;
- ordered-by user;
- description "Prefix delegation pool entry.";
- leaf prefix {
- type inet:ipv6-prefix;
- mandatory true;
- description "IPv6 pool prefix.";
- }
- leaf delegated-len {
- type uint8;
- description "Prefix pool delegated length.";
- }
- uses option-data-list;
- uses dhcp:client-class {
- refine client-class {
- description "Prefix pool client class guard. (only
- clients belonging to this class will be
- allowed in this pool).";
- }
- }
- uses dhcp:require-client-classes {
- refine require-client-classes {
- description "Prefix pool require client classes.";
- }
+ list pd-pool {
+ key prefix;
+ ordered-by user;
+ description "Prefix delegation pool list.";
+ leaf prefix {
+ type inet:ipv6-prefix;
+ mandatory true;
+ description "IPv6 pool prefix.";
+ }
+ leaf delegated-len {
+ type uint8;
+ description "Prefix pool delegated length.";
+ }
+ uses option-data-list;
+ uses dhcp:client-class {
+ refine client-class {
+ description "Prefix pool client class guard. (only
+ clients belonging to this class will be
+ allowed in this pool).";
}
- leaf excluded-prefix {
- type inet:ipv6-prefix;
- description "Prefix pool excluded prefix.";
+ }
+ uses dhcp:require-client-classes {
+ refine require-client-classes {
+ description "Prefix pool require client classes.";
}
- uses kea:user-context {
- refine user-context {
- description "Prefix pool user context. Arbitrary JSON data
- can be stored here.";
- }
+ }
+ leaf excluded-prefix {
+ type inet:ipv6-prefix;
+ description "Prefix pool excluded prefix.";
+ }
+ uses kea:user-context {
+ refine user-context {
+ description "Prefix pool user context. Arbitrary JSON data
+ can be stored here.";
}
}
}
uses dhcp:subnet-client-class;
uses dhcp:require-client-classes;
uses reservations {
- refine reservations {
- description "Subnet host reservations.";
+ refine host {
+ description "Subnet host reservations list.";
}
}
uses dhcp:subnet-reservation-mode;
}
}
- grouping client-class {
- description "Client class grouping.";
- uses dhcp:class-name;
- uses dhcp:class-test;
- uses dhcp:class-only-if-required;
- uses option-data-list;
- uses dhcp:class-user-context;
+ grouping client-classes {
+ description "Client classes grouping.";
+ list client-class {
+ key name;
+ ordered-by user;
+ description "List of client classes.";
+ uses dhcp:class-name;
+ uses dhcp:class-test;
+ uses dhcp:class-only-if-required;
+ uses option-data-list;
+ uses dhcp:class-user-context;
+ }
}
grouping option-def-list {
description "Option definition list grouping.";
- container option-def-list {
- description "Option definition list.";
- list option-def {
- key "code space";
- description "Option definition entry.";
- leaf code {
- type uint16;
- mandatory true;
- description "Option code to be used by the new option definition.";
- }
- leaf space {
- type string;
- mandatory true;
- description "Option space for the new option (typically dhcp6).";
- }
- uses dhcp:option-def-name;
- uses dhcp:option-def-type;
- uses dhcp:option-def-record-types;
- uses dhcp:option-def-encapsulate;
- uses dhcp:option-def-array;
- uses dhcp:option-def-user-context;
+ list option-def {
+ key "code space";
+ description "Option definition entry.";
+ leaf code {
+ type uint16;
+ mandatory true;
+ description "Option code to be used by the new option definition.";
+ }
+ leaf space {
+ type string;
+ mandatory true;
+ description "Option space for the new option (typically dhcp6).";
}
+ uses dhcp:option-def-name;
+ uses dhcp:option-def-type;
+ uses dhcp:option-def-record-types;
+ uses dhcp:option-def-encapsulate;
+ uses dhcp:option-def-array;
+ uses dhcp:option-def-user-context;
}
}
uses dhcp:renew-timer;
uses dhcp:rebind-timer;
uses dhcp:decline-probation-period;
+ uses subnet6-list;
- container subnet6 {
- description "Global subnet6 list.";
+ list shared-network {
+ key name;
+ uses dhcp:network-name;
+ description "List of IPv4 shared networks.";
uses subnet6-list;
- }
-
- container shared-networks {
- description "Defines a list of IPv6 shared networks.";
- list shared-network {
- key name;
- uses dhcp:network-name;
- description "List of IPv4 shared networks.";
- container subnet6 {
- description "List of IPv6 subnets that belong to this shared
- network.";
- uses subnet6-list;
- }
- uses dhcp:network-interface;
- uses interface-id {
- refine interface-id {
- description "Shared network interface-id option.";
- }
+ uses dhcp:network-interface;
+ uses interface-id {
+ refine interface-id {
+ description "Shared network interface-id option.";
}
- uses dhcp:renew-timer;
- uses dhcp:rebind-timer;
- uses option-data-list;
- container relay {
- description "Optional information about relay agent.";
- uses relay;
- }
- uses dhcp:network-reservation-mode;
- uses dhcp:network-client-class;
- uses dhcp:require-client-classes;
- uses preferred-lifetime;
- uses rapid-commit {
- refine rapid-commit {
- description "Shared network rapid commit flag.";
- }
+ }
+ uses dhcp:renew-timer;
+ uses dhcp:rebind-timer;
+ uses option-data-list;
+ container relay {
+ description "Optional information about relay agent.";
+ uses relay;
+ }
+ uses dhcp:network-reservation-mode;
+ uses dhcp:network-client-class;
+ uses dhcp:require-client-classes;
+ uses preferred-lifetime;
+ uses rapid-commit {
+ refine rapid-commit {
+ description "Shared network rapid commit flag.";
}
- uses dhcp:valid-lifetime;
- uses dhcp:network-user-context;
}
+ uses dhcp:valid-lifetime;
+ uses dhcp:network-user-context;
}
container interfaces-config {
description "Host reservation identifiers.";
}
- container client-classes {
- description "Client classes.";
- list client-class {
- key name;
- ordered-by user;
- description "List of client classes.";
- uses client-class;
- }
- }
-
+ uses client-classes;
uses option-def-list;
uses option-data-list;
uses kea:hooks-libraries;
}
uses dhcp:sanity-checks;
uses reservations {
- refine reservations {
- description "Global host reservations.";
+ refine host {
+ description "Global host reservations list.";
}
}
uses dhcp:config-control;
description "This model defines a YANG data model that can be
used to configure and manage logging of a Kea server.";
- revision 2018-11-11 {
+ revision 2018-11-16 {
description "Initial revision";
reference "";
}
* Groupings
*/
- grouping configuration {
- description "Contains parameters for logging configuration.";
-
- container loggers {
- description "Loggers.";
- list logger {
- key name;
- description "List of loggers.";
- leaf name {
+ grouping loggers {
+ description "Loggers.";
+ list logger {
+ key name;
+ description "List of loggers.";
+ leaf name {
+ type string;
+ mandatory true;
+ description "Name of the logger.";
+ }
+ list output-option {
+ key output;
+ description "List of output options.";
+ leaf output {
type string;
- mandatory true;
- description "Name of the logger.";
+ description "Type of output. Special values are stdout (standard
+ output), stderr (standard error), syslog (syslog using default
+ name), syslog:name (syslog using specified name). Any other
+ value is interpreted as a filename.";
}
- container output-options {
- description "Output options.";
- list option {
- key output;
- description "List of output options.";
- leaf output {
- type string;
- description "Type of output. Special values are stdout (standard
- output), stderr (standard error), syslog (syslog using default
- name), syslog:name (syslog using specified name). Any other
- value is interpreted as a filename.";
- }
- leaf flush {
- type boolean;
- description "When true flush buffers after each message.";
- }
- leaf maxsize {
- type uint32;
- description "Maximum size of output file before rotation.
- Values below 204800 including 0 disable rotation.";
- }
- leaf maxver {
- type uint32 {
- range 1..max;
- }
- description "Maximum version to keep a rotated output file.";
- }
- }
+ leaf flush {
+ type boolean;
+ description "When true flush buffers after each message.";
}
- leaf debuglevel {
- type uint8 {
- range 0..99;
- }
- description "What level of debug messages should be printed.";
+ leaf maxsize {
+ type uint32;
+ description "Maximum size of output file before rotation.
+ Values below 204800 including 0 disable rotation.";
}
- leaf severity {
- type enumeration {
- enum "FATAL" {
- description "Condition is so serious that the server cannot
- continue executing";
- }
- enum "ERROR" {
- description "Error condition. The server will continue
- executing, but the results may not be as expected.";
- }
- enum "WARN" {
- description "Out of the ordinary condition. However, the server
- will continue executing normally.";
- }
- enum "INFO" {
- description "Information message marking some event.";
- }
- enum "DEBUG" {
- description "For debugging purposes.";
- }
- enum "NONE" {
- description "All messages are inhibited.";
- }
+ leaf maxver {
+ type uint32 {
+ range 1..max;
}
- description "Category of messages logged.";
+ description "Maximum version to keep a rotated output file.";
+ }
+ }
+ leaf debuglevel {
+ type uint8 {
+ range 0..99;
}
- leaf user-context {
- type kea:user-context;
- description "Logger user context.";
+ description "What level of debug messages should be printed.";
+ }
+ leaf severity {
+ type enumeration {
+ enum "FATAL" {
+ description "Condition is so serious that the server cannot
+ continue executing";
+ }
+ enum "ERROR" {
+ description "Error condition. The server will continue
+ executing, but the results may not be as expected.";
+ }
+ enum "WARN" {
+ description "Out of the ordinary condition. However, the server
+ will continue executing normally.";
+ }
+ enum "INFO" {
+ description "Information message marking some event.";
+ }
+ enum "DEBUG" {
+ description "For debugging purposes.";
+ }
+ enum "NONE" {
+ description "All messages are inhibited.";
+ }
}
+ description "Category of messages logged.";
+ }
+ leaf user-context {
+ type kea:user-context;
+ description "Logger user context.";
}
}
}
+
+ grouping configuration {
+ description "Contains parameters for logging configuration.";
+ uses loggers;
+ }
}
grouping hooks-libraries {
description "Hooks libraries grouping.";
- container hooks-libraries {
- description "Hook libraries.";
- list hook-library {
- key library;
- description "List of hook library.";
- leaf library {
- type string;
- mandatory true;
- description "Path to the DSO.";
- }
- leaf parameters {
- type string;
- description "Parameters (JSON value).";
- }
+ list hook-library {
+ key library;
+ description "List of hook library.";
+ leaf library {
+ type string;
+ mandatory true;
+ description "Path to the DSO.";
+ }
+ leaf parameters {
+ type string;
+ description "Parameters (JSON value).";
}
}
}
useModel(KEA_DHCP4_SERVER);
// Get the client class list and check if it is empty.
- const string& xpath = "/kea-dhcp4-server:config/client-classes";
+ const string& xpath = "/kea-dhcp4-server:config";
ConstElementPtr classes;
EXPECT_NO_THROW(classes = t_obj_->getClasses(xpath));
EXPECT_FALSE(classes);
useModel(KEA_DHCP6_SERVER);
// Create the client class.
- const string& xpath = "/kea-dhcp6-server:config/client-classes";
+ const string& xpath = "/kea-dhcp6-server:config";
const string& xclass = xpath + "/client-class[name='foo']";
const string& xtest = xclass + "/test";
S_Val v_test(new Val("not member('ALL')", SR_STRING_T));
useModel(KEA_DHCP4_SERVER);
// Set empty list.
- const string& xpath = "/kea-dhcp4-server:config/client-classes";
+ const string& xpath = "/kea-dhcp4-server:config";
ConstElementPtr classes = Element::createList();
EXPECT_NO_THROW(t_obj_->setClasses(xpath, classes));
useModel(KEA_DHCP6_SERVER);
// Set one client class.
- const string& xpath = "/kea-dhcp6-server:config/client-classes";
+ const string& xpath = "/kea-dhcp6-server:config";
ElementPtr classes = Element::createList();
ElementPtr cclass = Element::createMap();
cclass->set("name", Element::create(string("foo")));
string expected =
"kea-dhcp6-server:config (container)\n"
" |\n"
- " -- client-classes (container)\n"
+ " -- client-class (list instance)\n"
" |\n"
- " -- client-class (list instance)\n"
- " |\n"
- " -- name = foo\n"
- " |\n"
- " -- test = ''==''\n"
- " |\n"
- " -- only-if-required = false\n";
+ " -- name = foo\n"
+ " |\n"
+ " -- test = ''==''\n"
+ " |\n"
+ " -- only-if-required = false\n";
EXPECT_EQ(expected, tree->to_string(100));
// Check it validates.
useModel(KEA_DHCP6_SERVER);
// Get empty.
- const string& xpath = "/kea-dhcp6-server:config/hosts-databases";
+ const string& xpath = "/kea-dhcp6-server:config/hosts-database";
ConstElementPtr databases;
EXPECT_NO_THROW(databases = t_obj_->getDatabases(xpath));
EXPECT_FALSE(databases);
useModel(KEA_DHCP4_SERVER);
// Set a value.
- const string& xpath = "/kea-dhcp4-server:config/hosts-databases";
- const string& xdatabase =
- xpath + "/hosts-database[database-type='mysql']";
+ const string& xpath = "/kea-dhcp4-server:config/hosts-database";
+ const string& xdatabase = xpath + "[database-type='mysql']";
const string& xname = xdatabase + "/name";
const string& xuser = xdatabase + "/user";
const string& xpassword = xdatabase + "/password";
useModel(KEA_DHCP6_SERVER);
// Set a value.
- const string& xpath = "/kea-dhcp6-server:config/hosts-databases";
+ const string& xpath = "/kea-dhcp6-server:config/hosts-database";
ElementPtr database = Element::createMap();
database->set("type", Element::create(string("memfile")));
database->set("lfc-interval", Element::create(3600));
useModel(KEA_DHCP4_SERVER);
// Set a value.
- const string& xpath = "/kea-dhcp4-server:config/hosts-databases";
- const string& xdatabase =
- xpath + "/hosts-database[database-type='mysql']";
+ const string& xpath = "/kea-dhcp4-server:config/hosts-database";
+ const string& xdatabase = xpath + "[database-type='mysql']";
const string& xname = xdatabase + "/name";
const string& xuser = xdatabase + "/user";
const string& xpassword = xdatabase + "/password";
useModel(KEA_DHCP4_SERVER);
// Set a value.
- const string& xpath = "/kea-dhcp4-server:config/hosts-databases";
- const string& xdatabase =
- xpath + "/hosts-database[database-type='mysql']";
+ const string& xpath = "/kea-dhcp4-server:config/hosts-database";
+ const string& xdatabase = xpath + "[database-type='mysql']";
const string& xname = xdatabase + "/name";
const string& xuser = xdatabase + "/user";
const string& xpassword = xdatabase + "/password";
// Get the host reservation list and check if it is empty.
const string& xpath =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/reservations";
+ "/kea-dhcp6-server:config/subnet6[id='111']";
ConstElementPtr hosts;
EXPECT_NO_THROW(hosts = t_obj_->getHosts(xpath));
ASSERT_TRUE(hosts);
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& subnet =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']";
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
- const string& xsubnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Create the host reservation for 2001:db8::1.
- const string& xpath = subnet + "/reservations";
ostringstream shost;
shost << xpath + "/host[identifier-type='hw-address']"
<< "[identifier='00:01:02:03:04:05']";
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& subnet =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']";
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
- const string& xsubnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Set empty list.
- const string& xpath = subnet + "/reservations";
ConstElementPtr hosts = Element::createList();
EXPECT_NO_THROW(t_obj_->setHosts(xpath, hosts));
useModel(KEA_DHCP4_SERVER);
// Create the subnet 10.0.0.0/14 #111.
- const string& subnet =
- "/kea-dhcp4-server:config/subnet4/subnet4[id='111']";
+ const string& xpath =
+ "/kea-dhcp4-server:config/subnet4[id='111']";
S_Val v_subnet(new Val("10.0.0.0/24", SR_STRING_T));
- const string& xsubnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Set one host.
- const string& xpath = subnet + "/reservations";
ElementPtr hosts = Element::createList();
ElementPtr host = Element::createMap();
host->set("flex-id", Element::create(string("00:ff")));
string expected =
"kea-dhcp4-server:config (container)\n"
" |\n"
- " -- subnet4 (container)\n"
+ " -- subnet4 (list instance)\n"
+ " |\n"
+ " -- id = 111\n"
" |\n"
- " -- subnet4 (list instance)\n"
+ " -- subnet = 10.0.0.0/24\n"
+ " |\n"
+ " -- host (list instance)\n"
+ " |\n"
+ " -- identifier-type = flex-id\n"
" |\n"
- " -- id = 111\n"
+ " -- identifier = 00:ff\n"
" |\n"
- " -- subnet = 10.0.0.0/24\n"
+ " -- hostname = foo\n"
" |\n"
- " -- reservations (container)\n"
- " |\n"
- " -- host (list instance)\n"
- " |\n"
- " -- identifier-type = flex-id\n"
- " |\n"
- " -- identifier = 00:ff\n"
- " |\n"
- " -- hostname = foo\n"
- " |\n"
- " -- ip-address = 10.0.0.1\n";
+ " -- ip-address = 10.0.0.1\n";
EXPECT_EQ(expected, tree->to_string(100));
// Check it validates.
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& subnet =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']";
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
- const string& xsubnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Create the host reservation for 2001:db8::1.
- const string& xpath = subnet + "/reservations";
ostringstream shost;
shost << xpath + "/host[identifier-type='hw-address']"
<< "[identifier='00:01:02:03:04:05']";
EXPECT_NO_THROW(sess_->set_item(xaddr.c_str(), s_addr));
// Create another reservation for 2001:db8::2
- const string xpath2 = subnet + "/reservations";
ostringstream shost2;
shost2 << xpath + "/host[identifier-type='hw-address']"
<< "[identifier='00:01:0a:0b:0c:0d']";
// Get the host.
ConstElementPtr hosts;
- string hosts_path = subnet + "/reservations";
- EXPECT_NO_THROW(hosts = t_obj_->getHosts(hosts_path));
+ EXPECT_NO_THROW(hosts = t_obj_->getHosts(xpath));
ASSERT_TRUE(hosts);
EXPECT_EQ(hosts->str(),
useModel(KEA_DHCP4_SERVER);
// Get empty.
- const string& xpath = "/kea-dhcp4-server:logging/loggers";
+ const string& xpath = "/kea-dhcp4-server:logging";
ConstElementPtr loggers;
EXPECT_NO_THROW(loggers = t_obj_->getLoggers(xpath));
ASSERT_TRUE(loggers);
useModel(KEA_DHCP6_SERVER);
// Set a value.
- const string& xpath = "/kea-dhcp6-server:logging/loggers";
+ const string& xpath = "/kea-dhcp6-server:logging";
const string& xlogger = xpath + "/logger[name='foo']";
const string& xseverity = xlogger + "/severity";
- const string& xoption = xlogger + "/output-options/option[output='/bar']";
+ const string& xoption = xlogger + "/output-option[output='/bar']";
const string& xmaxver = xoption + "/maxver";
S_Val s_severity(new Val("WARN", SR_ENUM_T));
EXPECT_NO_THROW(sess_->set_item(xseverity.c_str(), s_severity));
useModel(KEA_DHCP4_SERVER);
// Set a value.
- const string& xpath = "/kea-dhcp4-server:logging/loggers";
+ const string& xpath = "/kea-dhcp4-server:logging";
ElementPtr option = Element::createMap();
option->set("output", Element::create(string("/bar")));
option->set("maxver", Element::create(10));
string expected =
"kea-dhcp4-server:logging (container)\n"
" |\n"
- " -- loggers (container)\n"
+ " -- logger (list instance)\n"
" |\n"
- " -- logger (list instance)\n"
- " |\n"
- " -- name = foo\n"
- " |\n"
- " -- output-options (container)\n"
- " | |\n"
- " | -- option (list instance)\n"
- " | |\n"
- " | -- output = /bar\n"
- " | |\n"
- " | -- maxver = 10\n"
- " |\n"
- " -- severity = WARN\n";
+ " -- name = foo\n"
+ " |\n"
+ " -- output-option (list instance)\n"
+ " | |\n"
+ " | -- output = /bar\n"
+ " | |\n"
+ " | -- maxver = 10\n"
+ " |\n"
+ " -- severity = WARN\n";
EXPECT_EQ(expected, tree->to_string(100));
// Check it validates.
useModel(KEA_DHCP4_SERVER);
// Get the option definition list and check if it is empty.
- const string& xpath = "/kea-dhcp4-server:config/option-def-list";
+ const string& xpath = "/kea-dhcp4-server:config";
ConstElementPtr options;
EXPECT_NO_THROW(options = t_obj_->getOptionDefList(xpath));
ASSERT_TRUE(options);
useModel(KEA_DHCP6_SERVER);
// Create the option code 100.
- const string& xpath = "/kea-dhcp6-server:config/option-def-list";
+ const string& xpath = "/kea-dhcp6-server:config";
const string& xdef = xpath + "/option-def[code='100'][space='isc']";
const string& xname = xdef + "/name";
const string& xtype = xdef + "/type";
useModel(KEA_DHCP4_SERVER);
// Set empty list.
- const string& xpath = "/kea-dhcp4-server:config/option-def-list";
+ const string& xpath = "/kea-dhcp4-server:config";
ConstElementPtr defs = Element::createList();
EXPECT_NO_THROW(t_obj_->setOptionDefList(xpath, defs));
useModel(KEA_DHCP6_SERVER);
// Set one option def.
- const string& xpath = "/kea-dhcp6-server:config/option-def-list";
+ const string& xpath = "/kea-dhcp6-server:config";
ElementPtr defs = Element::createList();
ElementPtr def = Element::createMap();
def->set("code", Element::create(100));
string expected =
"kea-dhcp6-server:config (container)\n"
" |\n"
- " -- option-def-list (container)\n"
+ " -- option-def (list instance)\n"
" |\n"
- " -- option-def (list instance)\n"
- " |\n"
- " -- code = 100\n"
- " |\n"
- " -- space = isc\n"
- " |\n"
- " -- name = foo\n"
- " |\n"
- " -- type = string\n"
- " |\n"
- " -- array = false\n";
+ " -- code = 100\n"
+ " |\n"
+ " -- space = isc\n"
+ " |\n"
+ " -- name = foo\n"
+ " |\n"
+ " -- type = string\n"
+ " |\n"
+ " -- array = false\n";
EXPECT_EQ(expected, tree->to_string(100));
// Check it validates.
// Get the pd-pool list and check if it is empty.
const string& xpath =
"/ietf-dhcpv6-server:server/server-config/network-ranges"
- "/network-range[network-range-id='111']/pd-pools";
+ "/network-range[network-range-id='111']/pd-pools/pd-pool";
ConstElementPtr pools;
EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath));
ASSERT_TRUE(pools);
// Get the pd-pool list and check if it is empty.
const string& xpath =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pd-pools";
+ "/kea-dhcp6-server:config/subnet6[id='111']/pd-pool";
ConstElementPtr pools;
EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath));
ASSERT_TRUE(pools);
// Get the pd-pool list and check if the pd-pool is in it.
ConstElementPtr pools;
- EXPECT_NO_THROW(pools = t_obj_->getPdPools(subnet + "/pd-pools"));
+ EXPECT_NO_THROW(pools = t_obj_->getPdPools(subnet + "/pd-pools/pd-pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
ASSERT_EQ(1, pools->size());
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& subnet =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']";
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
- const string& subnet_subnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Create the pd-pool 2001:db8:0:1000::/64.
- const string& xpath = subnet + "/pd-pools";
const string& prefix = "2001:db8:0:1000::/56";
ostringstream spool;
spool << xpath + "/pd-pool[prefix='" << prefix << "']";
// Get the pd-pool list and check if the pd-pool is in it.
ConstElementPtr pools;
- EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath + "/pd-pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
ASSERT_EQ(1, pools->size());
// Get it back.
pools.reset();
- EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath + "/pd-pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
EXPECT_EQ(0, pools->size());
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& subnet =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']";
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
- const string& subnet_subnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Set empty list.
- const string& xpath = subnet + "/pd-pools";
ConstElementPtr pools = Element::createList();
EXPECT_NO_THROW(t_obj_->setPdPools(xpath, pools));
// Get it back.
pools.reset();
- EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath + "/pd-pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
EXPECT_EQ(0, pools->size());
// Get it back.
pools.reset();
- EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath + "/pd-pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
ASSERT_EQ(1, pools->size());
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& subnet =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']";
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
- const string& subnet_subnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Set one pool.
- const string& xpath = subnet + "/pd-pools";
ElementPtr pools = Element::createList();
ElementPtr pool = Element::createMap();
pool->set("prefix", Element::create(string("2001:db8:0:1000::")));
// Get it back.
pools.reset();
- EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath + "/pd-pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
ASSERT_EQ(1, pools->size());
string expected =
"kea-dhcp6-server:config (container)\n"
" |\n"
- " -- subnet6 (container)\n"
+ " -- subnet6 (list instance)\n"
" |\n"
- " -- subnet6 (list instance)\n"
- " |\n"
- " -- id = 111\n"
+ " -- id = 111\n"
+ " |\n"
+ " -- subnet = 2001:db8::/48\n"
+ " |\n"
+ " -- pd-pool (list instance)\n"
" |\n"
- " -- subnet = 2001:db8::/48\n"
+ " -- prefix = 2001:db8:0:1000::/56\n"
" |\n"
- " -- pd-pools (container)\n"
- " |\n"
- " -- pd-pool (list instance)\n"
- " |\n"
- " -- prefix = 2001:db8:0:1000::/56\n"
- " |\n"
- " -- delegated-len = 64\n";
+ " -- delegated-len = 64\n";
EXPECT_EQ(expected, tree->to_string(100));
// Check it validates.
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& subnet =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']";
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
- const string& subnet_subnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Create the first pd-pool 2001:db8:0:1000::/56.
- const string& xpath = subnet + "/pd-pools";
const string& prefix = "2001:db8:0:1000::/56";
ostringstream spool;
spool << xpath + "/pd-pool[prefix='" << prefix << "']";
EXPECT_NO_THROW(sess_->set_item(x_delegated.c_str(), s_delegated));
// Create the second pd-pool 2001:db8:0:2000::/56
- const string& xpath2 = subnet + "/pd-pools";
const string& prefix2 = "2001:db8:0:2000::/56";
ostringstream spool2;
- spool2 << xpath2 + "/pd-pool[prefix='" << prefix2 << "']";
+ spool2 << xpath + "/pd-pool[prefix='" << prefix2 << "']";
const string& x_delegated2 = spool2.str() + "/delegated-len";
uint8_t dl2 = 60;
S_Val s_delegated2(new Val(dl2, SR_UINT8_T));
// Get the pools list.
ConstElementPtr pools;
- EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath2));
+ EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath + "/pd-pool"));
ASSERT_TRUE(pools);
// Check that both of them are returned properly.
// Get the pool list and check if it is empty.
const string& xpath = "/ietf-dhcpv6-server:server/server-config/"
- "network-ranges/network-range[network-range-id='111']/address-pools";
+ "network-ranges/network-range[network-range-id='111']/"
+ "address-pools/address-pool";
ConstElementPtr pools;
EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
ASSERT_TRUE(pools);
// Get the pool list and check if it is empty.
const string& xpath =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools";
+ "/kea-dhcp6-server:config/subnet6[id='111']/pool";
ConstElementPtr pools;
EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
ASSERT_TRUE(pools);
// Get the pool list and check if the pool is in it.
ConstElementPtr pools;
- EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPools(xpath + "/address-pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
ASSERT_EQ(1, pools->size());
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& subnet =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']";
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
- const string& subnet_subnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Create the pool 2001:db8::1:0/112.
- const string& xpath = subnet + "/pools";
const string& prefix = "2001:db8::1:0/112";
string start_addr;
string end_addr;
// Get the pool list and check if the pool is in it.
ConstElementPtr pools;
- EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPools(xpath + "/pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
ASSERT_EQ(1, pools->size());
// Get it back.
pools.reset();
- EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPools(xpath + "/address-pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
EXPECT_EQ(0, pools->size());
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& subnet =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']";
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
- const string& subnet_subnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Set empty list.
- const string& xpath = subnet + "/pools";
ConstElementPtr pools = Element::createList();
EXPECT_NO_THROW(t_obj_->setPools(xpath, pools));
// Get it back.
pools.reset();
- EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPools(xpath + "/pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
EXPECT_EQ(0, pools->size());
// Get it back.
pools.reset();
- EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPools(xpath + "/address-pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
ASSERT_EQ(1, pools->size());
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& subnet =
- "/kea-dhcp6-server:config/subnet6/subnet6[id='111']";
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
- const string& subnet_subnet = subnet + "/subnet";
- EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet));
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet));
// Set one pool.
- const string& xpath = subnet + "/pools";
ElementPtr pools = Element::createList();
ElementPtr pool = Element::createMap();
pool->set("pool",
// Get it back.
pools.reset();
- EXPECT_NO_THROW(pools = t_obj_->getPools(xpath));
+ EXPECT_NO_THROW(pools = t_obj_->getPools(xpath + "/pool"));
ASSERT_TRUE(pools);
ASSERT_EQ(Element::list, pools->getType());
ASSERT_EQ(1, pools->size());
string expected =
"kea-dhcp6-server:config (container)\n"
" |\n"
- " -- subnet6 (container)\n"
+ " -- subnet6 (list instance)\n"
" |\n"
- " -- subnet6 (list instance)\n"
- " |\n"
- " -- id = 111\n"
+ " -- id = 111\n"
+ " |\n"
+ " -- subnet = 2001:db8::/48\n"
+ " |\n"
+ " -- pool (list instance)\n"
" |\n"
- " -- subnet = 2001:db8::/48\n"
+ " -- start-address = 2001:db8::1\n"
" |\n"
- " -- pools (container)\n"
- " |\n"
- " -- pool (list instance)\n"
- " |\n"
- " -- start-address = 2001:db8::1\n"
- " |\n"
- " -- end-address = 2001:db8::100\n";
+ " -- end-address = 2001:db8::100\n";
EXPECT_EQ(expected, tree->to_string(100));
// Check it validates.
useModel(KEA_DHCP4_SERVER);
// Get the shared network list and check if it is empty.
- const string& xpath = "/kea-dhcp4-server:config/shared-networks";
+ const string& xpath = "/kea-dhcp4-server:config";
ConstElementPtr networks;
EXPECT_NO_THROW(networks = t_obj_->getSharedNetworks(xpath));
ASSERT_TRUE(networks);
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111 in shared network foo.
- const string& xpath = "/kea-dhcp6-server:config/shared-networks";
+ const string& xpath = "/kea-dhcp6-server:config";
const string& xnetwork = xpath + "/shared-network[name='foo']";
- const string& xsubnet = xnetwork + "/subnet6/subnet6[id='111']/subnet";
+ const string& xsubnet = xnetwork + "/subnet6[id='111']/subnet";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet));
useModel(KEA_DHCP4_SERVER);
// Set empty list.
- const string& xpath = "/kea-dhcp4-server:config/shared-networks";
+ const string& xpath = "/kea-dhcp4-server:config";
ConstElementPtr networks = Element::createList();
EXPECT_NO_THROW(t_obj_->setSharedNetworks(xpath, networks));
useModel(KEA_DHCP6_SERVER);
// Set one shared network.
- const string& xpath = "/kea-dhcp6-server:config/shared-networks";
+ const string& xpath = "/kea-dhcp6-server:config";
ElementPtr networks = Element::createList();
ElementPtr share = Element::createMap();
ElementPtr subnets = Element::createList();
string expected =
"kea-dhcp6-server:config (container)\n"
" |\n"
- " -- shared-networks (container)\n"
+ " -- shared-network (list instance)\n"
" |\n"
- " -- shared-network (list instance)\n"
+ " -- name = foo\n"
+ " |\n"
+ " -- subnet6 (list instance)\n"
" |\n"
- " -- name = foo\n"
+ " -- id = 123\n"
" |\n"
- " -- subnet6 (container)\n"
- " |\n"
- " -- subnet6 (list instance)\n"
- " |\n"
- " -- id = 123\n"
- " |\n"
- " -- subnet = 2001:db8::/48\n";
+ " -- subnet = 2001:db8::/48\n";
EXPECT_EQ(expected, tree->to_string(100));
// Check it validates.
TEST_F(TranslatorSharedNetworksTest, getList) {
useModel(KEA_DHCP6_SERVER);
- const string& xpath = "/kea-dhcp6-server:config/shared-networks";
+ const string& xpath = "/kea-dhcp6-server:config";
// Those two networks will be added.
const string& xnetwork1 = xpath + "/shared-network[name='foo']";
"[ " + exp_net1 + ", " + exp_net2 + " ]";
// Create the subnet1: 2001:db8:1::/48 #1 in shared network foo.
- const string& xsubnet1 = xnetwork1 + "/subnet6/subnet6[id='1']/subnet";
+ const string& xsubnet1 = xnetwork1 + "/subnet6[id='1']/subnet";
S_Val v_subnet1(new Val("2001:db8:1::/48", SR_STRING_T));
EXPECT_NO_THROW(sess_->set_item(xsubnet1.c_str(), v_subnet1));
// Create the subnet2: 2001:db8:2::/48 #2 in shared network foo.
- const string& xsubnet2 = xnetwork1 + "/subnet6/subnet6[id='2']/subnet";
+ const string& xsubnet2 = xnetwork1 + "/subnet6[id='2']/subnet";
S_Val v_subnet2(new Val("2001:db8:2::/48", SR_STRING_T));
EXPECT_NO_THROW(sess_->set_item(xsubnet2.c_str(), v_subnet2));
// Create the subnet1: 2001:db8:101::/48 #101 in shared network foo.
- const string& xsubnet3 = xnetwork2 + "/subnet6/subnet6[id='101']/subnet";
+ const string& xsubnet3 = xnetwork2 + "/subnet6[id='101']/subnet";
S_Val v_subnet(new Val("2001:db8:101::/48", SR_STRING_T));
EXPECT_NO_THROW(sess_->set_item(xsubnet3.c_str(), v_subnet));
// Create the subnet2: 2001:db8:2::/48 #2 in shared network foo.
- const string& xsubnet4 = xnetwork2 + "/subnet6/subnet6[id='102']/subnet";
+ const string& xsubnet4 = xnetwork2 + "/subnet6[id='102']/subnet";
S_Val v_subnet4(new Val("2001:db8:102::/48", SR_STRING_T));
EXPECT_NO_THROW(sess_->set_item(xsubnet4.c_str(), v_subnet4));
// Get the subnet list and check if it is empty.
const string& xpath =
- "/ietf-dhcpv6-server:server/server-config/network-ranges";
+ "/ietf-dhcpv6-server:server/server-config/"
+ "network-ranges/network-range";
ConstElementPtr subnets;
EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
ASSERT_TRUE(subnets);
// Get the subnet list and check if the subnet is in it.
ConstElementPtr subnets;
- EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
+ EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath + "/network-range"));
ASSERT_TRUE(subnets);
ASSERT_EQ(Element::list, subnets->getType());
ASSERT_EQ(1, subnets->size());
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& xpath = "/kea-dhcp6-server:config/subnet6";
+ const string& xpath = "/kea-dhcp6-server:config";
const string& xsub = xpath + "/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
const string& xsubnet = xsub + "/subnet";
// Get the subnet list and check if the subnet is in it.
ConstElementPtr subnets;
- EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
+ EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath + "/subnet6"));
ASSERT_TRUE(subnets);
ASSERT_EQ(Element::list, subnets->getType());
ASSERT_EQ(1, subnets->size());
// Get the subnet list and check if the subnet is in it.
ConstElementPtr subnets;
- EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
+ EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath + "/network-range"));
ASSERT_TRUE(subnets);
ASSERT_EQ(Element::list, subnets->getType());
ASSERT_EQ(1, subnets->size());
useModel(KEA_DHCP6_SERVER);
// Create the subnet 2001:db8::/48 #111.
- const string& xpath = "/kea-dhcp6-server:config/subnet6";
+ const string& xpath = "/kea-dhcp6-server:config";
const string& xsub = xpath + "/subnet6[id='111']";
S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T));
const string& xsubnet = xsub + "/subnet";
EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet));
// Create the pool 2001:db8::1:0/112.
- const string& xpool = xsub + "/pools";
- const string& prefix1 = xpool + "/pool[start-address='2001:db8::1:0']" +
+ const string& prefix1 = xsub + "/pool[start-address='2001:db8::1:0']" +
"[end-address='2001:db8::1:ffff']/prefix";
S_Val s_pool1(new Val("2001:db8::1:0/112", SR_STRING_T));
EXPECT_NO_THROW(sess_->set_item(prefix1.c_str(), s_pool1));
// Create the pool 2001:db8::2:0/112.
- const string& prefix2 = xpool + "/pool[start-address='2001:db8::2:0']" +
+ const string& prefix2 = xsub + "/pool[start-address='2001:db8::2:0']" +
"[end-address='2001:db8::2:ffff']";
S_Val s_pool2;
EXPECT_NO_THROW(sess_->set_item(prefix2.c_str(), s_pool2));
// Get the subnet list and check if the subnet is in it.
ConstElementPtr subnets;
- EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
+ EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath + "/subnet6"));
ASSERT_TRUE(subnets);
ASSERT_EQ(Element::list, subnets->getType());
ASSERT_EQ(1, subnets->size());
// Get it back.
subnets.reset();
- EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
+ EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath + "/network-range"));
ASSERT_TRUE(subnets);
ASSERT_EQ(Element::list, subnets->getType());
EXPECT_EQ(0, subnets->size());
// Get it back.
subnets.reset();
- EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
+ EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath + "/network-range"));
ASSERT_TRUE(subnets);
ASSERT_EQ(Element::list, subnets->getType());
ASSERT_EQ(1, subnets->size());
// Get it back.
subnets.reset();
- EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath));
+ EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath + "/network-range"));
ASSERT_TRUE(subnets);
ASSERT_EQ(Element::list, subnets->getType());
ASSERT_EQ(1, subnets->size());
string expected =
"kea-dhcp4-server:config (container)\n"
" |\n"
- " -- subnet4 (container)\n"
+ " -- subnet4 (list instance)\n"
" |\n"
- " -- subnet4 (list instance)\n"
- " |\n"
- " -- id = 123\n"
- " |\n"
- " -- pools (container)\n"
- " | |\n"
- " | -- pool (list instance)\n"
- " | | |\n"
- " | | -- start-address = 10.0.1.0\n"
- " | | |\n"
- " | | -- end-address = 10.0.1.15\n"
- " | | |\n"
- " | | -- prefix = 10.0.1.0/28\n"
- " | |\n"
- " | -- pool (list instance)\n"
- " | |\n"
- " | -- start-address = 10.0.1.200\n"
- " | |\n"
- " | -- end-address = 10.0.1.222\n"
- " |\n"
- " -- subnet = 10.0.1.0/24\n";
+ " -- id = 123\n"
+ " |\n"
+ " -- pool (list instance)\n"
+ " | |\n"
+ " | -- start-address = 10.0.1.0\n"
+ " | |\n"
+ " | -- end-address = 10.0.1.15\n"
+ " | |\n"
+ " | -- prefix = 10.0.1.0/28\n"
+ " |\n"
+ " -- pool (list instance)\n"
+ " | |\n"
+ " | -- start-address = 10.0.1.200\n"
+ " | |\n"
+ " | -- end-address = 10.0.1.222\n"
+ " |\n"
+ " -- subnet = 10.0.1.0/24\n";
EXPECT_EQ(expected, tree->to_string(100));
// Check it validates.
const std::string subnetOptionsModelKeaDhcp4 = KEA_DHCP4_SERVER;
const YRTree subnetOptionsTreeKeaDhcp4 = {
{ "/kea-dhcp4-server:config", "", SR_CONTAINER_T, false },
- { "/kea-dhcp4-server:config/subnet4", "", SR_CONTAINER_T, false },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']", "",
+ { "/kea-dhcp4-server:config/subnet4[id='111']", "",
SR_LIST_T, true },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/id",
+ { "/kea-dhcp4-server:config/subnet4[id='111']/id",
"111", SR_UINT32_T, false },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/"
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
"option-data[code='100'][space='dns']", "", SR_LIST_T, true },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/"
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
"option-data[code='100'][space='dns']/code",
"100", SR_UINT8_T, false },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/"
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
"option-data[code='100'][space='dns']/space",
"dns", SR_STRING_T, false },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/"
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
"option-data[code='100'][space='dns']/data",
"12121212", SR_STRING_T, true },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/"
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
"option-data[code='100'][space='dns']/csv-format",
"false", SR_BOOL_T, true },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/"
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
"option-data[code='100'][space='dns']/always-send",
"false", SR_BOOL_T, true },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/pools",
- "", SR_CONTAINER_T, false },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/pools/"
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
"pool[start-address='10.0.1.0'][end-address='10.0.1.255']",
"", SR_LIST_T, true },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/pools/"
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
"pool[start-address='10.0.1.0'][end-address='10.0.1.255']/start-address",
"10.0.1.0", SR_STRING_T, false },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/pools/"
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
"pool[start-address='10.0.1.0'][end-address='10.0.1.255']/end-address",
"10.0.1.255", SR_STRING_T, false },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/pools/"
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
"pool[start-address='10.0.1.0'][end-address='10.0.1.255']/prefix",
"10.0.1.0/24", SR_STRING_T, true },
- { "/kea-dhcp4-server:config/subnet4/subnet4[id='111']/subnet",
+ { "/kea-dhcp4-server:config/subnet4[id='111']/subnet",
"10.0.0.0/8", SR_STRING_T, true }
};
const std::string subnetOptionsModelKeaDhcp6 = KEA_DHCP6_SERVER;
const YRTree subnetOptionsTreeKeaDhcp6 = {
{ "/kea-dhcp6-server:config", "", SR_CONTAINER_T, false },
- { "/kea-dhcp6-server:config/subnet6", "", SR_CONTAINER_T, false },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']", "",
+ { "/kea-dhcp6-server:config/subnet6[id='111']", "",
SR_LIST_T, true },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/id",
+ { "/kea-dhcp6-server:config/subnet6[id='111']/id",
"111", SR_UINT32_T, false },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools",
- "", SR_CONTAINER_T, false },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/"
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
"pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']",
"", SR_LIST_T, true },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/"
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
"pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
"start-address", "2001:db8::1:0", SR_STRING_T, false },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/"
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
"pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
"end-address", "2001:db8::1:ffff", SR_STRING_T, false },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/"
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
"pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
"prefix", "2001:db8::1:0/112", SR_STRING_T, true },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/"
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
"pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
"option-data[code='100'][space='dns']",
"", SR_LIST_T, true },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/"
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
"pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
"option-data[code='100'][space='dns']/code",
"100", SR_UINT16_T, false },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/"
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
"pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
"option-data[code='100'][space='dns']/space",
"dns", SR_STRING_T, false },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/"
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
"pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
"option-data[code='100'][space='dns']/data",
"12121212", SR_STRING_T, true },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/"
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
"pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
"option-data[code='100'][space='dns']/csv-format",
"false", SR_BOOL_T, true },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/"
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
"pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
"option-data[code='100'][space='dns']/always-send",
"false", SR_BOOL_T, true },
- { "/kea-dhcp6-server:config/subnet6/subnet6[id='111']/subnet",
+ { "/kea-dhcp6-server:config/subnet6[id='111']/subnet",
"2001:db8::/48", SR_STRING_T, true }
};
result->set("option-data", options);
}
if (model_ == KEA_DHCP4_SERVER) {
- ConstElementPtr defs = getOptionDefList(xpath +"/option-def-list");
+ ConstElementPtr defs = getOptionDefList(xpath);
if (defs && (defs->size() > 0)) {
result->set("option-def", defs);
}
if (model_ == KEA_DHCP4_SERVER) {
ConstElementPtr defs = elem->get("option-def");
if (defs) {
- setOptionDefList(xpath + "/option-def-list", defs);
+ setOptionDefList(xpath, defs);
created = true;
}
ConstElementPtr next = elem->get("next-server");
ElementPtr
TranslatorClasses::getClassesKea(const string& xpath) {
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath + "/client-class");
if (!iter) {
// Can't happen.
isc_throw(Unexpected, "getClassesKea: can't get iterator: " << xpath);
/// +--rw test? string
/// +--rw only-if-required? boolean
/// +--rw option-data*
-/// +--rw option-def-list option-def*
+/// +--rw option-def*
/// +--rw next-server? inet:ipv4-address
/// +--rw server-hostname? string
/// +--rw boot-file-name? string
/// @endcode
/// @code
/// /kea-dhcp6-server:config (container)
-/// /kea-dhcp6-server:config/client-classes (container)
-/// /kea-dhcp6-server:config/client-classes/
-/// client-class[name='foo'] (list instance)
-/// /kea-dhcp6-server:config/client-classes/
-/// client-class[name='foo']/name = foo
-/// /kea-dhcp6-server:config/client-classes/
-/// client-class[name='foo']/test = ''==''
-/// /kea-dhcp6-server:config/client-classes/
-/// client-class[name='foo']/ only-if-required = false
+/// /kea-dhcp6-server:config/client-class[name='foo'] (list instance)
+/// /kea-dhcp6-server:config/client-class[name='foo']/name = foo
+/// /kea-dhcp6-server:config/client-class[name='foo']/test = ''==''
+/// /kea-dhcp6-server:config/client-class[name='foo']/only-if-required = false
/// @endcode
/// @brief A translator class for converting a client class between
ElementPtr dhcp6 = Element::createMap();
result->set("Dhcp6", dhcp6);
string xpath = "/" + model_ + ":server/server-config";
- ConstElementPtr ranges = getSubnets(xpath + "/network-ranges");
+ ConstElementPtr ranges =
+ getSubnets(xpath + "/network-ranges/network-range");
if (ranges && !ranges->empty()) {
dhcp6->set("subnet6", ranges);
}
ElementPtr
TranslatorConfig::getHooksKea(const std::string& xpath) {
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath + "/hook-library");
if (iter) {
ElementPtr hook_libs = Element::createList();
for (;;) {
ElementPtr
TranslatorConfig::getConfigControlKea(const string& xpath) {
ElementPtr config_ctrl = Element::createMap();
- ConstElementPtr databases = getDatabases(xpath + "/config-databases");
+ ConstElementPtr databases = getDatabases(xpath + "/config-database");
if (databases && !databases->empty()) {
config_ctrl->set("config-databases", databases);
}
getParam(result, xpath, "rebind-timer");
getParam(result, xpath, "decline-probation-period");
- ConstElementPtr networks = getSharedNetworks(xpath + "/shared-networks");
+ ConstElementPtr networks = getSharedNetworks(xpath);
if (networks && !networks->empty()) {
result->set("shared-networks", networks);
}
- ConstElementPtr classes = getClasses(xpath + "/client-classes");
+ ConstElementPtr classes = getClasses(xpath);
if (classes && !classes->empty()) {
result->set("client-classes", classes);
}
if (database) {
result->set("lease-database", database);
}
- ConstElementPtr databases = getDatabases(xpath + "/hosts-databases");
+ ConstElementPtr databases = getDatabases(xpath + "/hosts-database");
if (databases && !databases->empty()) {
result->set("hosts-databases", databases);
}
if (host_ids) {
result->set("host-reservation-identifiers", host_ids);
}
- ConstElementPtr defs = getOptionDefList(xpath + "/option-def-list");
+ ConstElementPtr defs = getOptionDefList(xpath);
if (defs && !defs->empty()) {
result->set("option-def", defs);
}
if (options && !options->empty()) {
result->set("option-data", options);
}
- ConstElementPtr hooks = getHooksKea(xpath + "/hooks-libraries");
+ ConstElementPtr hooks = getHooksKea(xpath);
if (hooks && !hooks->empty()) {
result->set("hooks-libraries", hooks);
}
sanity->set("lease-checks", checks);
result->set("sanity-checks", sanity);
}
- ConstElementPtr hosts = getHosts(xpath + "/reservations");
+ ConstElementPtr hosts = getHosts(xpath);
if (hosts && !hosts->empty()) {
result->set("reservations", hosts);
}
TranslatorConfig::getServerKeaLogging() {
string xpath = "/" + model_ + ":logging";
ElementPtr result = Element::createMap();
- ConstElementPtr loggers = getLoggers(xpath + "/loggers");
+ ConstElementPtr loggers = getLoggers(xpath);
if (loggers && !loggers->empty()) {
result->set("loggers", loggers);
}
}
ConstElementPtr networks = elem->get("shared-networks");
if (networks) {
- setSharedNetworks(xpath + "/shared-networks", networks);
+ setSharedNetworks(xpath, networks);
}
ConstElementPtr classes = elem->get("client-classes");
if (classes && !classes->empty()) {
- setClasses(xpath + "/client-classes", classes);
+ setClasses(xpath, classes);
}
ConstElementPtr database = elem->get("lease-database");
if (database) {
}
ConstElementPtr databases = elem->get("hosts-databases");
if (databases && !databases->empty()) {
- setDatabases(xpath + "/hosts-databases", databases);
+ setDatabases(xpath + "/hosts-database", databases);
} else {
// Reuse of database from lease-database.
database = elem->get("hosts-database");
if (database) {
ElementPtr list = Element::createList();
list->add(copy(database));
- setDatabases(xpath + "/hosts-databases", list);
+ setDatabases(xpath + "/hosts-database", list);
}
}
ConstElementPtr host_ids = elem->get("host-reservation-identifiers");
}
ConstElementPtr defs = elem->get("option-def");
if (defs && !defs->empty()) {
- setOptionDefList(xpath + "/option-def-list", defs);
+ setOptionDefList(xpath, defs);
}
ConstElementPtr options = elem->get("option-data");
if (options && !options->empty()) {
continue;
}
ostringstream hook_lib;
- hook_lib << xpath << "/hooks-libraries/hook-library[library='"
+ hook_lib << xpath << "/hook-library[library='"
<< name->stringValue() << "']";
ConstElementPtr params = lib->get("parameters");
if (params) {
}
ConstElementPtr hosts = elem->get("reservations");
if (hosts && !hosts->empty()) {
- setHosts(xpath + "/reservations", hosts);
+ setHosts(xpath, hosts);
}
ConstElementPtr config_ctrl = elem->get("config-control");
if (config_ctrl && !config_ctrl->empty()) {
databases = config_ctrl->get("config-databases");
if (databases && !databases->empty()) {
- setDatabases(xpath + "/config-control/config-databases",
- databases);
+ setDatabases(xpath + "/config-control/config-database", databases);
}
}
ConstElementPtr server_tag = elem->get("server-tag");
string xpath = "/" + model_ + ":logging";
ConstElementPtr loggers = elem->get("loggers");
if (loggers) {
- setLoggers(xpath + "/loggers", loggers);
+ setLoggers(xpath, loggers);
}
}
/// +--rw renew-timer? uint32
/// +--rw rebind-timer? uint32
/// +--rw decline-probation-period? uint32
-/// +--rw subnet4 subnet4*
-/// +--rw shared-networks shared-network*
+/// +--rw subnet4*
+/// +--rw shared-network*
/// +--rw interfaces-config
/// +--rw interfaces* string
/// +--rw dhcp-socket-type? enumeration
/// +--rw re-detect? boolean
/// +--rw user-context? string
/// +--rw lease-database! <database>
-/// +--rw hosts-databases hosts-database*
+/// +--rw hosts-database*
/// +--rw host-reservation-identifiers* enumeration
-/// +--rw client-classes client-class*
-/// +--rw option-def-list option-def*
+/// +--rw client-class*
+/// +--rw option-def*
/// +--rw option-data*
/// +--rw hook-library*
/// +--rw library string
/// +--rw user-context? string
/// +--rw sanity-checks
/// +--rw lease-checks? enumeration
+/// +--rw host*
/// +--rw config-control
-/// +--rw config-databases config-databases*
+/// +--rw config-database*
/// +--rw server-tag string
/// +--rw dhcp-queue-control string
/// @endcode
/// @code
/// <config xmlns="urn:ietf:params:xml:ns:yang:kea-dhcp4-server">
/// <subnet4>
-/// <subnet4>
-/// <id>1</id>
-/// <pools>
-/// <pool>
-/// <start-address>10.0.35.64</start-address>
-/// <end-address>10.0.35.95</end-address>
-/// <prefix>10.0.35.64/27</prefix>
-/// </pool>
-/// </pools>
-/// <subnet>10.0.35.0/24</subnet>
-/// </subnet4>
+/// <id>1</id>
+/// <pool>
+/// <start-address>10.0.35.64</start-address>
+/// <end-address>10.0.35.95</end-address>
+/// <prefix>10.0.35.64/27</prefix>
+/// </pool>
+/// <subnet>10.0.35.0/24</subnet>
/// </subnet4>
/// <interfaces-config>
/// <interfaces>eth1</interfaces>
/// +--rw renew-timer? uint32
/// +--rw rebind-timer? uint32
/// +--rw decline-probation-period? uint32
-/// +--rw subnet6 subnet6*
-/// +--rw shared-networks shared-network*
+/// +--rw subnet6*
+/// +--rw shared-network*
/// +--rw interfaces-config
/// +--rw interfaces* string
/// +--rw re-detect? boolean
/// +--rw user-context? string
/// +--rw lease-database! <database>
-/// +--rw hosts-databases hosts-database*
+/// +--rw hosts-database*
/// +--rw relay-supplied-options* string
/// +--rw mac-sources* string
/// +--rw host-reservation-identifiers* enumeration
-/// +--rw client-classes client-class*
-/// +--rw option-def-list option-def*
-/// +--rw option-data-list option-data*
+/// +--rw client-class*
+/// +--rw option-def*
+/// +--rw option-data*
/// +--rw hook-library*
/// +--rw library string
/// +--rw parameters? string
/// +--rw user-context? string
/// +--rw sanity-checks
/// +--rw lease-checks? enumeration
+/// +--rw host*
/// +--rw config-control
-/// +--rw config-databases config-databases*
+/// +--rw config-database*
/// +--rw server-tag string
/// +--rw dhcp-queue-control string
/// @endcode
/// @code
/// <config xmlns="urn:ietf:params:xml:ns:yang:kea-dhcp6-server">
/// <subnet6>
-/// <subnet6>
-/// <id>1</id>
-/// <pools>
-/// <pool>
-/// <start-address>2001:db8::1:0</start-address>
-/// <end-address>2001:db8::1:ffff</end-address>
-/// <prefix>2001:db8::1:0/112</prefix>
-/// </pool>
-/// </pools>
-/// <subnet>2001:db8::/64</subnet>
-/// </subnet6>
+/// <id>1</id>
+/// <pool>
+/// <start-address>2001:db8::1:0</start-address>
+/// <end-address>2001:db8::1:ffff</end-address>
+/// <prefix>2001:db8::1:0/112</prefix>
+/// </pool>
+/// <subnet>2001:db8::/64</subnet>
/// </subnet6>
/// <interfaces-config>
/// <interfaces>eth1</interfaces>
/// YANG syntax for kea-*:logging is:
/// @code
/// +--rw logging
-/// +--rw loggers
+/// +--rw logger*
/// @endcode
///
/// Example of Logging simple configuration:
/// with a kea server model and exported to XML format:
/// @code
/// <logging xmlns="urn:ietf:params:xml:ns:yang:kea-dhcp4-server">
-/// <loggers>
-/// <logger>
-/// <name>kea-dhcp6</name>
-/// <output-options>
-/// <option>
-/// <output>stderr</output>
-/// </option>
-/// </output-options>
-/// <debuglevel>99</debuglevel>
-/// <severity>DEBUG</severity>
-/// </logger>
-/// </loggers>
+/// <logger>
+/// <name>kea-dhcp6</name>
+/// <output-options>
+/// <option>
+/// <output>stderr</output>
+/// </option>
+/// </output-options>
+/// <debuglevel>99</debuglevel>
+/// <severity>DEBUG</severity>
+/// </logger>
/// </logging>
/// @endcode
///
ElementPtr
TranslatorDatabases::getDatabasesKea(const string& xpath) {
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath);
if (!iter) {
// Can't happen.
isc_throw(Unexpected, "getDatabasesKea can't get iterator: " << xpath);
TranslatorDatabases::setDatabasesKea(const string& xpath,
ConstElementPtr elem) {
if (!elem) {
- delItem(xpath + "/hosts-database");
delItem(xpath);
return;
}
}
string type = database->get("type")->stringValue();
ostringstream key;
- key << xpath << "/hosts-database[database-type='" << type << "']";
+ key << xpath << "[database-type='" << type << "']";
setDatabase(key.str(), database, true);
}
}
/// @endcode
/// @code
/// /kea-dhcp6-server:config (container)
-/// /kea-dhcp6-server:config/hosts-databases (container)
-/// /kea-dhcp6-server:config/hosts-databases/
+/// /kea-dhcp6-server:config/
/// hosts-database[database-type='mysql'] (list instance)
-/// /kea-dhcp6-server:config/hosts-databases/
+/// /kea-dhcp6-server:config/
/// hosts-database[database-type='mysql']/type = mysql
-/// /kea-dhcp6-server:config/hosts-databases/
+/// /kea-dhcp6-server:config/
/// hosts-database[database-type='mysql']/name = kea
-/// /kea-dhcp6-server:config/hosts-databases/
+/// /kea-dhcp6-server:config/
/// hosts-database[database-type='mysql']/user = kea
-/// /kea-dhcp6-server:config/hosts-databases/
+/// /kea-dhcp6-server:config/
/// hosts-database[database-type='mysql']/password = kea
-/// /kea-dhcp6-server:config/hosts-databases/
+/// /kea-dhcp6-server:config/
/// hosts-database[database-type='mysql']/host = localhost
-/// /kea-dhcp6-server:config/hosts-databases/
+/// /kea-dhcp6-server:config/
/// hosts-database[database-type='mysql']/port = 3306
/// @endcode
TranslatorHosts::getHosts(const string& xpath) {
try {
ElementPtr result = Element::createList();
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath + "/host");
if (!iter) {
// Can't happen.
isc_throw(Unexpected, "getHosts can't get iterator: " << xpath);
/// @endcode
/// @code
/// /kea-dhcp4-server:config (container)
-/// /kea-dhcp4-server:config/subnet4 (container)
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='111'] (list instance)
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='111']/id = 111
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='111']/subnet = 10.0.0.0/24
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='111']/
-/// reservations (container)
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='111']/reservations/
+/// /kea-dhcp4-server:config/subnet4[id='111'] (list instance)
+/// /kea-dhcp4-server:config/subnet4[id='111']/id = 111
+/// /kea-dhcp4-server:config/subnet4[id='111']/subnet = 10.0.0.0/24
+/// /kea-dhcp4-server:config/subnet4[id='111']/
/// host[identifier-type='flex-id'][identifier='00:ff'] (list instance)
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='111']/reservations/
+/// /kea-dhcp4-server:config/subnet4[id='111']/
/// host[identifier-type='flex-id'][identifier='00:ff']/
/// identifier-type = flex-id
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='111']/reservations/
+/// /kea-dhcp4-server:config/subnet4[id='111']/
/// host[identifier-type='flex-id'][identifier='00:ff']/
/// identifier = 00:ff
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='111']/reservations/
+/// /kea-dhcp4-server:config/subnet4[id='111']/
/// host[identifier-type='flex-id'][identifier='00:ff']/
/// hostname = foo
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='111']/reservations/
+/// /kea-dhcp4-server:config/subnet4[id='111']/
/// host[identifier-type='flex-id'][identifier='00:ff']/
/// ip-address = 10.0.0.1
/// @endcode
}
ElementPtr result = Element::createMap();
result->set("name", name);
- ConstElementPtr options = getOutputOptions(xpath + "/output-options");
+ ConstElementPtr options = getOutputOptions(xpath);
if (options && (options->size() > 0)) {
result->set("output_options", options);
}
ElementPtr
TranslatorLogger::getOutputOptions(const string& xpath) {
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath + "/output-option");
if (!iter) {
// Can't happen.
isc_throw(Unexpected, "getOutputOptions: can't get iterator: "
// Skip name as it is the key.
ConstElementPtr options = elem->get("output_options");
if (options && (options->size() > 0)) {
- setOutputOptions(xpath + "/output-options", options);
+ setOutputOptions(xpath, options);
}
ConstElementPtr debuglevel = elem->get("debuglevel");
if (debuglevel) {
}
string output = option->get("output")->stringValue();
ostringstream key;
- key << xpath << "/option[output='" << output << "']";
+ key << xpath << "/output-option[output='" << output << "']";
setOutputOption(key.str(), option);
}
}
ElementPtr
TranslatorLoggers::getLoggersKea(const string& xpath) {
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath + "/logger");
if (!iter) {
// Can't happen.
isc_throw(Unexpected, "getLoggersKea: can't get iterator: " << xpath);
/// YANG syntax for kea-logging is with name as the logger list key and
/// output as the output option list key.
/// @code
-/// +--rw logger container
+/// +--rw logger (list)
/// |
/// +--rw name? string
-/// +--rw output-options container
-/// | +--rw option* [output]
+/// +--rw output-option*
/// | +--rw output string
/// | +--rw maxver? uint32
/// | +--rw maxsize? uint32
/// @endcode
/// @code
/// /kea-dhcp4-server:logging (container)
-/// /kea-dhcp4-server:logging/loggers (container)
-/// /kea-dhcp4-server:logging/loggers/logger[name='foo'] (list instance)
-/// /kea-dhcp4-server:logging/loggers/logger[name='foo']/name = foo
-/// /kea-dhcp4-server:logging/loggers/logger[name='foo']/
-/// output-options (container)
-/// /kea-dhcp4-server:logging/loggers/logger[name='foo']/output-options/
+/// /kea-dhcp4-server:logging/logger[name='foo'] (list instance)
+/// /kea-dhcp4-server:logging/logger[name='foo']/name = foo
+/// /kea-dhcp4-server:logging/logger[name='foo']/
/// option[output='/bar'] (list instance)
-/// /kea-dhcp4-server:logging/loggers/logger[name='foo']/output-options/
+/// /kea-dhcp4-server:logging/logger[name='foo']/
/// option[output='/bar']/option = /bar
-/// /kea-dhcp4-server:logging/loggers/logger[name='foo']/output-options/
+/// /kea-dhcp4-server:logging/logger[name='foo']/
/// option[output='/bar']/maxver = 10
-/// /kea-dhcp4-server:logging/loggers/logger[name='foo']/severity = WARN
+/// /kea-dhcp4-server:logging/logger[name='foo']/severity = WARN
/// @endcode
/// @brief A translator class for converting a logger between
ConstElementPtr
TranslatorOptionDefList::getOptionDefListKea(const string& xpath) {
ElementPtr result = Element::createList();
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath + "/option-def");
if (!iter) {
// Can't happen.
isc_throw(Unexpected, "getOptionDefListKea: can't get iterator: "
/// @endcode
/// @code
/// /kea-dhcp6-server:config (container)
-/// /kea-dhcp6-server:config/option-def-list (container)
-/// /kea-dhcp6-server:config/option-def-list/
+/// /kea-dhcp6-server:config/
/// option-def[code='100'][space='isc'] (list instance)
-/// /kea-dhcp6-server:config/option-def-list/
+/// /kea-dhcp6-server:config/
/// option-def[code='100'][space='isc']/code = 100
-/// /kea-dhcp6-server:config/option-def-list/
+/// /kea-dhcp6-server:config/
/// option-def[code='100'][space='isc']/space = isc
-/// /kea-dhcp6-server:config/option-def-list/
+/// /kea-dhcp6-server:config/
/// option-def[code='100'][space='isc']/name = foo
-/// /kea-dhcp6-server:config/option-def-list/
+/// /kea-dhcp6-server:config/
/// option-def[code='100'][space='isc']/type = string
-/// /kea-dhcp6-server:config/option-def-list/
+/// /kea-dhcp6-server:config/
/// option-def[code='100'][space='isc']/array = false
/// @endcode
TranslatorPdPools::getPdPools(const string& xpath) {
try {
ElementPtr result = Element::createList();
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath);
if (!iter) {
// Can't happen.
isc_throw(Unexpected, "getPdPools: can't get iterator: " << xpath);
/// @endcode
/// @code
/// /kea-dhcp6-server:config (container)
-/// /kea-dhcp6-server:config/subnet6 (container)
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111'] (list instance)
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/id = 111
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/subnet = 2001:db8::/48
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/pd-pools (container)
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/pd-pools/
+/// /kea-dhcp6-server:config/subnet6[id='111'] (list instance)
+/// /kea-dhcp6-server:config/subnet6[id='111']/id = 111
+/// /kea-dhcp6-server:config/subnet6[id='111']/subnet = 2001:db8::/48
+/// /kea-dhcp6-server:config/subnet6[id='111']/
/// pd-pool[prefix='2001:db8:0:1000::/56' (list instance)
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/pd-pools/
+/// /kea-dhcp6-server:config/subnet6[id='111']/
/// pd-pool[prefix='2001:db8:0:1000::/56'/prefix = 2001:db8:0:1000::/56
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/pd-pools/
+/// /kea-dhcp6-server:config/subnet6[id='111']/
/// pd-pool[prefix='2001:db8:0:1000::/56'/delegated-len = 64
/// @endcode
TranslatorPools::getPools(const string& xpath) {
try {
ElementPtr result = Element::createList();
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath);
if (!iter) {
// Can't happen.
isc_throw(Unexpected, "getPools can't get iterator: " << xpath);
/// @endcode
/// @code
/// /kea-dhcp6-server:config (container)
-/// /kea-dhcp6-server:config/subnet6 (container)
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111'] (list instance)
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/id = 111
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/subnet = 2001:db8::/48
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools (container)
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/
+/// /kea-dhcp6-server:config/subnet6[id='111'] (list instance)
+/// /kea-dhcp6-server:config/subnet6[id='111']/id = 111
+/// /kea-dhcp6-server:config/subnet6[id='111']/subnet = 2001:db8::/48
+/// /kea-dhcp6-server:config/subnet6[id='111']/
/// pool[start-address='2001:db8::1'][end-address='2001:db8::100']
/// (list instance)
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/
+/// /kea-dhcp6-server:config/subnet6[id='111']/
/// pool[start-address='2001:db8::1'][end-address='2001:db8::100']/
/// start-address = 2001:db8::1
-/// /kea-dhcp6-server:config/subnet6/subnet6[id='111']/pools/
+/// /kea-dhcp6-server:config/subnet6[id='111']/
/// pool[start-address='2001:db8::1'][end-address='2001:db8::100']/
/// end-address = 2001:db8::100
/// @endcode
TranslatorSharedNetworks::getSharedNetworks(const string& xpath) {
try {
ElementPtr result = Element::createList();
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath + "/shared-network");
if (!iter) {
// Can't happen.
isc_throw(Unexpected, "getSharedNetworks: can't get iterator: "
/// +--rw relay ip-addresses*
/// +--rw user-context? string
/// (DHCPv4 only)
-/// +--rw subnet4 subnet4*
+/// +--rw subnet4*
/// +--rw match-client-id? boolean
/// +--rw next-server? inet:ipv4-address
/// +--rw server-hostname? string
/// +--rw boot-file-name? string
/// +--rw authoritative? boolean
/// (DHCPv6 only)
-/// +--rw subnet6 subnet6*
+/// +--rw subnet6*
/// +--rw preferred-lifetime? uint32
/// +--rw interface-id? string
/// +--rw rapid-commit? boolean
/// @endcode
/// @code
/// /kea-dhcp6-server:config (container)
-/// /kea-dhcp6-server:config/shared-networks (container)
-/// /kea-dhcp6-server:config/shared-networks/
-/// shared-network[name='foo'] (list instance)
-/// /kea-dhcp6-server:config/shared-networks/shared-network[name='foo']/
-/// name = foo
-/// /kea-dhcp6-server:config/shared-networks/shared-network[name='foo']/
-/// subnet6 (container)
-/// /kea-dhcp6-server:config/shared-networks/shared-network[name='foo']/
-/// subnet6/subnet6[id='123'] (list instance)
-/// /kea-dhcp6-server:config/shared-networks/shared-network[name='foo']/
-/// subnet6/subnet6[id='123']/id = 123
-/// /kea-dhcp6-server:config/shared-networks/shared-network[name='foo']/
-/// subnet6/subnet6[id='123']/subnet = 2001:db8::/48
+/// /kea-dhcp6-server:config/shared-network[name='foo'] (list instance)
+/// /kea-dhcp6-server:config/shared-network[name='foo']/name = foo
+/// /kea-dhcp6-server:config/shared-network[name='foo']/
+/// subnet6[id='123'] (list instance)
+/// /kea-dhcp6-server:config/shared-network[name='foo']/
+/// subnet6[id='123']/id = 123
+/// /kea-dhcp6-server:config/shared-network[name='foo']/
+/// subnet6[id='123']/subnet = 2001:db8::/48
/// @endcode
/// @brief A translator class for converting a shared network between
ElementPtr result = Element::createMap();
/// @todo timers
/// @todo: option-data
- ConstElementPtr pools = getPools(xpath + "/address-pools");
+ ConstElementPtr pools = getPools(xpath + "/address-pools/address-pool");
if (pools) {
/// Set empty list too.
result->set("pools", pools);
}
- pools = getPdPools(xpath + "/pd-pools");
+ pools = getPdPools(xpath + "/pd-pools/pd-pool");
if (pools && (pools->size() > 0)) {
result->set("pd-pools", pools);
}
if (options && (options->size() > 0)) {
result->set("option-data", options);
}
- ConstElementPtr pools = getPools(xpath + "/pools");
+ ConstElementPtr pools = getPools(xpath + "/pool");
if (pools && (pools->size() > 0)) {
result->set("pools", pools);
}
if (model_ == KEA_DHCP6_SERVER) {
- pools = getPdPools(xpath + "/pd-pools");
+ pools = getPdPools(xpath + "/pd-pool");
if (pools && (pools->size() > 0)) {
result->set("pd-pools", pools);
}
if (required && (required->size() > 0)) {
result->set("require-client-classes", required);
}
- ConstElementPtr hosts = getHosts(xpath + "/reservations");
+ ConstElementPtr hosts = getHosts(xpath);
if (hosts && (hosts->size() > 0)) {
result->set("reservations", hosts);
}
}
ConstElementPtr pools = elem->get("pools");
if (pools && (pools->size() > 0)) {
- setPools(xpath + "/pools", pools);
+ setPools(xpath, pools);
}
if (model_ == KEA_DHCP6_SERVER) {
pools = elem->get("pd-pools");
if (pools && (pools->size() > 0)) {
- setPdPools(xpath + "/pd-pools", pools);
+ setPdPools(xpath, pools);
}
}
ConstElementPtr subnet = elem->get("subnet");
}
ConstElementPtr hosts = elem->get("reservations");
if (hosts && (hosts->size() > 0)) {
- setHosts(xpath + "/reservations", hosts);
+ setHosts(xpath, hosts);
}
ConstElementPtr mode = elem->get("reservation-mode");
if (mode) {
TranslatorSubnets::getSubnets(const string& xpath) {
try {
ElementPtr result = Element::createList();
- S_Iter_Value iter = getIter(xpath + "/*");
+ S_Iter_Value iter = getIter(xpath);
if (!iter) {
/// Can't happen.
isc_throw(Unexpected, "getSubnets: can't get iterator: " << xpath);
try {
if (model_ == IETF_DHCPV6_SERVER) {
setSubnetsIetf6(xpath, elem);
- } else if (model_ == KEA_DHCP4_SERVER) {
- setSubnetsKea(xpath, elem, "subnet4");
- } else if (model_ == KEA_DHCP6_SERVER) {
- setSubnetsKea(xpath, elem, "subnet6");
+ } else if ((model_ == KEA_DHCP4_SERVER) ||
+ (model_ == KEA_DHCP6_SERVER)) {
+ setSubnetsKea(xpath, elem);
} else {
isc_throw(NotImplemented,
"setSubnets not implemented for the model: " << model_);
}
void
-TranslatorSubnets::setSubnetsKea(const string& xpath, ConstElementPtr elem,
- const std::string& subsel) {
+TranslatorSubnets::setSubnetsKea(const string& xpath, ConstElementPtr elem) {
for (size_t i = 0; i < elem->size(); ++i) {
ConstElementPtr subnet = elem->get(i);
if (!subnet->contains("id")) {
isc_throw(BadValue, "subnet without id: " << subnet->str());
}
ostringstream prefix;
- prefix << xpath << "/" << subsel << "[id='"
- << subnet->get("id")->intValue() << "']";
+ prefix << xpath << "[id='" << subnet->get("id")->intValue() << "']";
setSubnet(prefix.str(), subnet);
}
}
/// +--rw network-prefix inet:ipv4-prefix
/// +--rw option-set-id?
/// /server/server-config/option-sets/option-set/option-set-id
-/// +--rw address-pools address-pool* [pool-id]
-/// +--rw pd-pools pd-pool* [pool-id]
+/// +--rw address-pool* [pool-id]
+/// +--rw pd-pool* [pool-id]
/// +--rw host-reservations host-reservation* [cli-id]
/// @endcode
///
/// +--rw renew-timer? uint32
/// +--rw rebind-timer? uint32
/// +--rw option-data*
-/// +--rw pools pool*
+/// +--rw pool*
/// +--rw subnet inet:ip-prefix
/// +--rw interface? string
/// +--rw id uint32
/// +--rw client-class? string
/// +--rw require-client-classes* string
-/// +--rw reservations host*
+/// +--rw host*
/// +--rw reservation-mode? enumeration
/// +--rw relay ip-addresses*
/// +--rw user-context? string
/// +--rw authoritative? boolean
/// (DHCPv6 only)
/// +--rw preferred-lifetime? uint32
-/// +--rw pd-pools pd-pool*
+/// +--rw pd-pool*
/// +--rw interface-id? string
/// +--rw rapid-commit? boolean
/// @endcode
/// @endcode
/// @code
/// /kea-dhcp4-server:config (container)
-/// /kea-dhcp4-server:config/subnet4 (container)
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123'] (list instance)
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123']/id = 123
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123']/pools (container)
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123']/pools/
+/// /kea-dhcp4-server:config/subnet4[id='123'] (list instance)
+/// /kea-dhcp4-server:config/subnet4[id='123']/id = 123
+/// /kea-dhcp4-server:config/subnet4[id='123']/
/// pool[start-address='10.0.1.0'][end-address='10.0.1.15'] (list instance)
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123']/pools/
+/// /kea-dhcp4-server:config/subnet4[id='123']/
/// pool[start-address='10.0.1.0'][end-address='10.0.1.15']/
/// start-address = 10.0.1.0
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123']/pools/
+/// /kea-dhcp4-server:config/subnet4[id='123']/
/// pool[start-address='10.0.1.0'][end-address='10.0.1.15']/
/// end-address = 10.0.1.15
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123']/pools/
+/// /kea-dhcp4-server:config/subnet4[id='123']/
/// pool[start-address='10.0.1.0'][end-address='10.0.1.15']/
/// prefix = 10.0.1.0/28
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123']/pools/
+/// /kea-dhcp4-server:config/subnet4[id='123']/
/// pool[start-address='10.0.1.200'][end-address='10.0.1.222']
/// (list instance)
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123']/pools/
+/// /kea-dhcp4-server:config/subnet4[id='123']/
/// pool[start-address='10.0.1.200'][end-address='10.0.1.222']/
/// start-address = 10.0.1.200
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123']/pools/
+/// /kea-dhcp4-server:config/subnet4[id='123']/
/// pool[start-address='10.0.1.200'][end-address='10.0.1.222']/
/// end-address = 10.0.1.222
-/// /kea-dhcp4-server:config/subnet4/subnet4[id='123']/subnet = 10.0.1.0/24
+/// /kea-dhcp4-server:config/subnet4[id='123']/subnet = 10.0.1.0/24
/// @endcode
/// @brief A translator class for converting a subnet between YANG and JSON.
///
/// @param xpath The xpath of the subnet list.
/// @param elem The JSON element.
- /// @param subsel The subnet list name.
void setSubnetsKea(const std::string& xpath,
- isc::data::ConstElementPtr elem,
- const std::string& subsel);
+ isc::data::ConstElementPtr elem);
};
}; // end of namespace isc::yang