Commit d12b6f4a authored by Francis Dupont's avatar Francis Dupont

[master] Finished merge of trac5061 (database port and Cassandra fixes)

parents 9d3c7922 e7fcce77
1219. [func] marcin
1220. [func] parisioa, fdupont, tomek
DHCPv4 and DHCPv6 parsers have updated to accept database port
parameter. The parameter for Cassandra is now called
"contact-points" (was "contact_points" previously).
(Trac #5061, git xxx)
1219. [func] marcin
Control Agent uses libkea-http to process commands over
the RESTful interface.
(Trac #5107, git 88ce715926a46b6b3832630116fc7782adc46c7b)
......
......@@ -13,6 +13,7 @@ nobase_dist_doc_DATA += examples/ddns/sample1.json
nobase_dist_doc_DATA += examples/ddns/template.json
nobase_dist_doc_DATA += examples/kea4/advanced.json
nobase_dist_doc_DATA += examples/kea4/backends.json
nobase_dist_doc_DATA += examples/kea4/cassandra.json
nobase_dist_doc_DATA += examples/kea4/classify.json
nobase_dist_doc_DATA += examples/kea4/dhcpv4-over-dhcpv6.json
nobase_dist_doc_DATA += examples/kea4/hooks.json
......@@ -26,6 +27,7 @@ nobase_dist_doc_DATA += examples/kea4/single-subnet.json
nobase_dist_doc_DATA += examples/kea4/with-ddns.json
nobase_dist_doc_DATA += examples/kea6/advanced.json
nobase_dist_doc_DATA += examples/kea6/backends.json
nobase_dist_doc_DATA += examples/kea6/cassandra.json
nobase_dist_doc_DATA += examples/kea6/classify.json
nobase_dist_doc_DATA += examples/kea6/dhcpv4-over-dhcpv6.json
nobase_dist_doc_DATA += examples/kea6/duid.json
......
......@@ -22,6 +22,7 @@
# dependencies or services running.
# "lease-database": {
# "type": "memfile",
# "persist": true,
# "lfc-interval": 3600
# },
......@@ -36,6 +37,7 @@
# "type": "mysql",
# "name": "keatest",
# "host": "localhost",
# "port": 3306,
# "user": "keatest",
# "password": "secret1",
# "connect-timeout": 3
......@@ -52,21 +54,24 @@
# "type": "pgsql",
# "name": "keatest",
# "host": "localhost",
# "port": 5432,
# "user": "keatest",
# "password": "secret1"
# "password": "secret1",
# "connect-timeout": 3
# },
# 4. CQL (Cassandra) backend. Leases will be stored in Cassandra database. Make
# sure it is up, running and properly initialized. See kea-admin documentation
# for details on how to initialize the database. The only strictly required
# parameters are type, keyspace and contact_points. At least one contact point
# parameters are type, keyspace and contact-points. At least one contact point
# must be specified, but more than one is required for redundancy. Make sure
# you specify the contact points without spaces. Kea must be compiled with
# --with-cql option to use this backend.
# "lease-database": {
# "type": "cql",
# "keyspace": "keatest",
# "contact_points": "192.0.2.1,192.0.2.2,192.0.2.3"
# "contact-points": "192.0.2.1,192.0.2.2,192.0.2.3",
# "port": 9042
# },
# Addresses will be assigned with a lifetime of 4000 seconds.
......
// This is an example configuration file for the DHCPv4 server in Kea.
// It is a basic scenario with one IPv4 subnet configured. It demonstrates
// how to configure Kea to use CQL (Cassandra) backend
{ "Dhcp4":
{
// Kea is told to listen on ethX interface only.
"interfaces-config": {
"interfaces": [ "ethX" ]
},
// 4. CQL (Cassandra) backend. Leases will be stored in Cassandra database. Make
// sure it is up, running and properly initialized. See kea-admin documentation
// for details on how to initialize the database. The only strictly required
// parameters are type, keyspace and contact-points. At least one contact point
// must be specified, but more than one is required for redundancy. Make sure
// you specify the contact points without spaces. Kea must be compiled with
// --with-cql option to use this backend.
"lease-database": {
"type": "cql",
"keyspace": "keatest",
"contact-points": "192.0.2.1,192.0.2.2,192.0.2.3",
"port": 9042
},
// Addresses will be assigned with a lifetime of 4000 seconds.
"valid-lifetime": 4000,
// Renew and rebind timers are commented out. This implies that options
// 58 and 59 will not be sent to the client. In this case it is up to
// the client to pick the timer values according to RFC2131. Uncomment the
// timers to send these options to the client.
// "renew-timer": 1000,
// "rebind-timer": 2000,
// The following list defines subnets. We have only one subnet
// here. We tell Kea that it is directly available over local interface.
"subnet4": [
{
"pools": [ { "pool": "192.0.2.1 - 192.0.2.200" } ],
"subnet": "192.0.2.0/24",
"interface": "ethX"
}
]
},
// The following configures logging. It assumes that messages with at least
// informational level (info, warn, error and fatal) should be logged to stdout.
"Logging": {
"loggers": [
{
"name": "kea-dhcp4",
"output_options": [
{
"output": "stdout"
}
],
"severity": "INFO"
}
]
}
}
......@@ -58,7 +58,8 @@
"name": "kea",
"user": "kea",
"password": "kea",
"host": "localhost"
"host": "localhost",
"port": 3306
},
# Define a subnet with a single pool of dynamic addresses. Addresses from
......
......@@ -21,7 +21,9 @@
# This is the easiest backend to use as it does not require any extra
# dependencies or services running.
"lease-database": {
"type": "memfile"
"type": "memfile",
"persist": true,
"lfc-interval": 3600
},
# 2. MySQL backend. Leases will be stored in MySQL database. Make sure it
......@@ -35,6 +37,7 @@
# "type": "mysql",
# "name": "keatest",
# "host": "localhost",
# "port": 3306,
# "user": "keatest",
# "password": "secret1",
# "connect-timeout": 3
......@@ -51,21 +54,24 @@
# "type": "pgsql",
# "name": "keatest",
# "host": "localhost",
# "port": 5432,
# "user": "keatest",
# "password": "secret1"
# "password": "secret1",
# "connect-timeout": 3
# },
# 4. CQL (Cassandra) backend. Leases will be stored in Cassandra database. Make
# sure it is up, running and properly initialized. See kea-admin documentation
# for details on how to initialize the database. The only strictly required
# parameters are type, keyspace and contact_points. At least one contact point
# parameters are type, keyspace and contact-points. At least one contact point
# must be specified, but more than one is required for redundancy. Make sure
# you specify the contact points without spaces. Kea must be compiled with
# --with-cql option to use this backend.
# "lease-database": {
# "type": "cql",
# "keyspace": "keatest",
# "contact_points": "192.0.2.1,192.0.2.2,192.0.2.3"
# "contact-points": "192.0.2.1,192.0.2.2,192.0.2.3",
# "port": 9042
# },
# Addresses will be assigned with preferred and valid lifetimes
......
// This is an example configuration file for the DHCPv6 server in Kea.
// It is a basic scenario with one IPv6 subnet configured. It demonstrates
// how to configure Kea to use CQL (Cassandra) backend.
{ "Dhcp6":
{
// Kea is told to listen on ethX interface only.
"interfaces-config": {
"interfaces": [ "ethX" ]
},
// CQL (Cassandra) backend. Leases will be stored in Cassandra database. Make
// sure it is up, running and properly initialized. See kea-admin documentation
// for details on how to initialize the database. The only strictly required
// parameters are type, keyspace and contact-points. At least one contact point
// must be specified, but more than one is required for redundancy. Make sure
// you specify the contact points without spaces. Kea must be compiled with
// --with-cql option to use this backend.
"lease-database": {
"type": "cql",
"keyspace": "keatest",
"contact-points": "192.0.2.1,192.0.2.2,192.0.2.3",
"port": 9042
},
// Addresses will be assigned with preferred and valid lifetimes
// being 3000 and 4000, respectively. Client is told to start
// renewing after 1000 seconds. If the server does not respond
// after 2000 seconds since the lease was granted, client is supposed
// to start REBIND procedure (emergency renewal that allows switching
// to a different server).
"preferred-lifetime": 3000,
"valid-lifetime": 4000,
"renew-timer": 1000,
"rebind-timer": 2000,
// The following list defines subnets. Each subnet consists of at
// least subnet and pool entries.
"subnet6": [
{
"pools": [ { "pool": "2001:db8:1::/80" } ],
"subnet": "2001:db8:1::/64",
"interface": "ethX"
}
]
},
// The following configures logging. It assumes that messages with at least
// informational level (info, warn, error and fatal) should be logged to stdout.
"Logging": {
"loggers": [
{
"name": "kea-dhcp6",
"output_options": [
{
"output": "stdout"
}
],
"debuglevel": 0,
"severity": "INFO"
}
]
}
}
......@@ -47,6 +47,7 @@
"user": "kea",
"password": "kea",
"host": "localhost",
"port": 3306,
"readonly": true
},
......
......@@ -459,6 +459,11 @@ be followed by a comma and another object definition.</para>
the DHCPv4 server. In this case, set the value to the empty string:
<screen>
"Dhcp4": { "lease-database": { <userinput>"host" : ""</userinput>, ... }, ... }
</screen>
Should the database use a port different than default, it may be
specified as well:
<screen>
"Dhcp4": { "lease-database": { <userinput>"port" : 12345</userinput>, ... }, ... }
</screen>
Should the database be located on a different system, you may need to specify a longer interval
for the connection timeout:
......@@ -468,6 +473,17 @@ be followed by a comma and another object definition.</para>
The default value of five seconds should be more than adequate for local connections.
If a timeout is given though, it should be an integer greater than zero.
</para>
<para>
Note that host parameter is used by MySQL and PostgreSQL
backends. Cassandra has a concept of contact points that could be
used to contact the cluster, instead of a single IP or
hostname. It takes a list of comma separated IP addresses. This may be specified as:
<screen>
"Dhcp4": { "lease-database": { <userinput>"contact-points" : "192.0.2.1,192.0.2.2"</userinput>, ... }, ... }
</screen>
</para>
<para>Finally, the credentials of the account under which the server will
access the database should be set:
<screen>
......@@ -527,6 +543,12 @@ If a timeout is given though, it should be an integer greater than zero.
<screen>
"Dhcp4": { "hosts-database": { <userinput>"host" : ""</userinput>, ... }, ... }
</screen>
Should the database use a port different than default, it may be
specified as well:
<screen>
"Dhcp4": { "hosts-database": { <userinput>"port" : 12345</userinput>, ... }, ... }
</screen>
</para>
<para>Finally, the credentials of the account under which the server will
access the database should be set:
......
......@@ -454,6 +454,11 @@ be followed by a comma and another object definition.</para>
the DHCPv6 server. In this case, set the value to the empty string:
<screen>
"Dhcp6": { "lease-database": { <userinput>"host" : ""</userinput>, ... }, ... }
</screen>
Should the database use a port different than default, it may be
specified as well:
<screen>
"Dhcp4": { "lease-database": { <userinput>"port" : 12345</userinput>, ... }, ... }
</screen>
Should the database be located on a different system, you may need to specify a longer interval
for the connection timeout:
......@@ -463,6 +468,17 @@ be followed by a comma and another object definition.</para>
The default value of five seconds should be more than adequate for local connections.
If a timeout is given though, it should be an integer greater than zero.
</para>
<para>
Note that host parameter is used by MySQL and PostgreSQL
backends. Cassandra has a concept of contact points that could be
used to contact the cluster, instead of a single IP or
hostname. It takes a list of comma separated IP addresses. This may be specified as:
<screen>
"Dhcp4": { "lease-database": { <userinput>"contact-points" : "192.0.2.1,192.0.2.2"</userinput>, ... }, ... }
</screen>
</para>
<para>Finally, the credentials of the account under which the server will
access the database should be set:
<screen>
......@@ -521,6 +537,9 @@ If a timeout is given though, it should be an integer greater than zero.
the DHCPv6 server. In this case, set the value to the empty string:
<screen>
"Dhcp6": { "hosts-database": { <userinput>"host" : ""</userinput>, ... }, ... }
</screen>
<screen>
"Dhcp4": { "hosts-database": { <userinput>"port" : 12345</userinput>, ... }, ... }
</screen>
</para>
<para>Finally, the credentials of the account under which the server will
......
This diff is collapsed.
......@@ -330,6 +330,16 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"port\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE:
case isc::dhcp::Parser4Context::HOSTS_DATABASE:
return isc::dhcp::Dhcp4Parser::make_PORT(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("port", driver.loc_);
}
}
\"persist\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE:
......@@ -360,6 +370,26 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence}
}
}
\"keyspace\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE:
case isc::dhcp::Parser4Context::HOSTS_DATABASE:
return isc::dhcp::Dhcp4Parser::make_KEYSPACE(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("keyspace", driver.loc_);
}
}
\"contact-points\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE:
case isc::dhcp::Parser4Context::HOSTS_DATABASE:
return isc::dhcp::Dhcp4Parser::make_CONTACT_POINTS(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("contact-points", driver.loc_);
}
}
\"valid-lifetime\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::DHCP4:
......
This diff is collapsed.
......@@ -374,108 +374,111 @@ namespace isc { namespace dhcp {
TOKEN_USER = 283,
TOKEN_PASSWORD = 284,
TOKEN_HOST = 285,
TOKEN_PERSIST = 286,
TOKEN_LFC_INTERVAL = 287,
TOKEN_READONLY = 288,
TOKEN_CONNECT_TIMEOUT = 289,
TOKEN_VALID_LIFETIME = 290,
TOKEN_RENEW_TIMER = 291,
TOKEN_REBIND_TIMER = 292,
TOKEN_DECLINE_PROBATION_PERIOD = 293,
TOKEN_SUBNET4 = 294,
TOKEN_SUBNET_4O6_INTERFACE = 295,
TOKEN_SUBNET_4O6_INTERFACE_ID = 296,
TOKEN_SUBNET_4O6_SUBNET = 297,
TOKEN_OPTION_DEF = 298,
TOKEN_OPTION_DATA = 299,
TOKEN_NAME = 300,
TOKEN_DATA = 301,
TOKEN_CODE = 302,
TOKEN_SPACE = 303,
TOKEN_CSV_FORMAT = 304,
TOKEN_RECORD_TYPES = 305,
TOKEN_ENCAPSULATE = 306,
TOKEN_ARRAY = 307,
TOKEN_POOLS = 308,
TOKEN_POOL = 309,
TOKEN_USER_CONTEXT = 310,
TOKEN_SUBNET = 311,
TOKEN_INTERFACE = 312,
TOKEN_INTERFACE_ID = 313,
TOKEN_ID = 314,
TOKEN_RAPID_COMMIT = 315,
TOKEN_RESERVATION_MODE = 316,
TOKEN_HOST_RESERVATION_IDENTIFIERS = 317,
TOKEN_CLIENT_CLASSES = 318,
TOKEN_TEST = 319,
TOKEN_CLIENT_CLASS = 320,
TOKEN_RESERVATIONS = 321,
TOKEN_DUID = 322,
TOKEN_HW_ADDRESS = 323,
TOKEN_CIRCUIT_ID = 324,
TOKEN_CLIENT_ID = 325,
TOKEN_HOSTNAME = 326,
TOKEN_RELAY = 327,
TOKEN_IP_ADDRESS = 328,
TOKEN_HOOKS_LIBRARIES = 329,
TOKEN_LIBRARY = 330,
TOKEN_PARAMETERS = 331,
TOKEN_EXPIRED_LEASES_PROCESSING = 332,
TOKEN_RECLAIM_TIMER_WAIT_TIME = 333,
TOKEN_FLUSH_RECLAIMED_TIMER_WAIT_TIME = 334,
TOKEN_HOLD_RECLAIMED_TIME = 335,
TOKEN_MAX_RECLAIM_LEASES = 336,
TOKEN_MAX_RECLAIM_TIME = 337,
TOKEN_UNWARNED_RECLAIM_CYCLES = 338,
TOKEN_DHCP4O6_PORT = 339,
TOKEN_CONTROL_SOCKET = 340,
TOKEN_SOCKET_TYPE = 341,
TOKEN_SOCKET_NAME = 342,
TOKEN_DHCP_DDNS = 343,
TOKEN_ENABLE_UPDATES = 344,
TOKEN_QUALIFYING_SUFFIX = 345,
TOKEN_SERVER_IP = 346,
TOKEN_SERVER_PORT = 347,
TOKEN_SENDER_IP = 348,
TOKEN_SENDER_PORT = 349,
TOKEN_MAX_QUEUE_SIZE = 350,
TOKEN_NCR_PROTOCOL = 351,
TOKEN_NCR_FORMAT = 352,
TOKEN_ALWAYS_INCLUDE_FQDN = 353,
TOKEN_ALLOW_CLIENT_UPDATE = 354,
TOKEN_OVERRIDE_NO_UPDATE = 355,
TOKEN_OVERRIDE_CLIENT_UPDATE = 356,
TOKEN_REPLACE_CLIENT_NAME = 357,
TOKEN_GENERATED_PREFIX = 358,
TOKEN_TCP = 359,
TOKEN_JSON = 360,
TOKEN_WHEN_PRESENT = 361,
TOKEN_NEVER = 362,
TOKEN_ALWAYS = 363,
TOKEN_WHEN_NOT_PRESENT = 364,
TOKEN_LOGGING = 365,
TOKEN_LOGGERS = 366,
TOKEN_OUTPUT_OPTIONS = 367,
TOKEN_OUTPUT = 368,
TOKEN_DEBUGLEVEL = 369,
TOKEN_SEVERITY = 370,
TOKEN_DHCP6 = 371,
TOKEN_DHCPDDNS = 372,
TOKEN_TOPLEVEL_JSON = 373,
TOKEN_TOPLEVEL_DHCP4 = 374,
TOKEN_SUB_DHCP4 = 375,
TOKEN_SUB_INTERFACES4 = 376,
TOKEN_SUB_SUBNET4 = 377,
TOKEN_SUB_POOL4 = 378,
TOKEN_SUB_RESERVATION = 379,
TOKEN_SUB_OPTION_DEF = 380,
TOKEN_SUB_OPTION_DATA = 381,
TOKEN_SUB_HOOKS_LIBRARY = 382,
TOKEN_SUB_DHCP_DDNS = 383,
TOKEN_STRING = 384,
TOKEN_INTEGER = 385,
TOKEN_FLOAT = 386,
TOKEN_BOOLEAN = 387
TOKEN_PORT = 286,
TOKEN_PERSIST = 287,
TOKEN_LFC_INTERVAL = 288,
TOKEN_READONLY = 289,
TOKEN_CONNECT_TIMEOUT = 290,
TOKEN_CONTACT_POINTS = 291,
TOKEN_KEYSPACE = 292,
TOKEN_VALID_LIFETIME = 293,
TOKEN_RENEW_TIMER = 294,
TOKEN_REBIND_TIMER = 295,
TOKEN_DECLINE_PROBATION_PERIOD = 296,
TOKEN_SUBNET4 = 297,
TOKEN_SUBNET_4O6_INTERFACE = 298,
TOKEN_SUBNET_4O6_INTERFACE_ID = 299,
TOKEN_SUBNET_4O6_SUBNET = 300,
TOKEN_OPTION_DEF = 301,
TOKEN_OPTION_DATA = 302,
TOKEN_NAME = 303,
TOKEN_DATA = 304,
TOKEN_CODE = 305,
TOKEN_SPACE = 306,
TOKEN_CSV_FORMAT = 307,
TOKEN_RECORD_TYPES = 308,
TOKEN_ENCAPSULATE = 309,
TOKEN_ARRAY = 310,
TOKEN_POOLS = 311,
TOKEN_POOL = 312,
TOKEN_USER_CONTEXT = 313,
TOKEN_SUBNET = 314,
TOKEN_INTERFACE = 315,
TOKEN_INTERFACE_ID = 316,
TOKEN_ID = 317,
TOKEN_RAPID_COMMIT = 318,
TOKEN_RESERVATION_MODE = 319,
TOKEN_HOST_RESERVATION_IDENTIFIERS = 320,
TOKEN_CLIENT_CLASSES = 321,
TOKEN_TEST = 322,
TOKEN_CLIENT_CLASS = 323,
TOKEN_RESERVATIONS = 324,
TOKEN_DUID = 325,
TOKEN_HW_ADDRESS = 326,
TOKEN_CIRCUIT_ID = 327,
TOKEN_CLIENT_ID = 328,
TOKEN_HOSTNAME = 329,
TOKEN_RELAY = 330,
TOKEN_IP_ADDRESS = 331,
TOKEN_HOOKS_LIBRARIES = 332,
TOKEN_LIBRARY = 333,
TOKEN_PARAMETERS = 334,
TOKEN_EXPIRED_LEASES_PROCESSING = 335,
TOKEN_RECLAIM_TIMER_WAIT_TIME = 336,
TOKEN_FLUSH_RECLAIMED_TIMER_WAIT_TIME = 337,
TOKEN_HOLD_RECLAIMED_TIME = 338,
TOKEN_MAX_RECLAIM_LEASES = 339,
TOKEN_MAX_RECLAIM_TIME = 340,
TOKEN_UNWARNED_RECLAIM_CYCLES = 341,
TOKEN_DHCP4O6_PORT = 342,
TOKEN_CONTROL_SOCKET = 343,
TOKEN_SOCKET_TYPE = 344,
TOKEN_SOCKET_NAME = 345,
TOKEN_DHCP_DDNS = 346,
TOKEN_ENABLE_UPDATES = 347,
TOKEN_QUALIFYING_SUFFIX = 348,
TOKEN_SERVER_IP = 349,
TOKEN_SERVER_PORT = 350,
TOKEN_SENDER_IP = 351,
TOKEN_SENDER_PORT = 352,
TOKEN_MAX_QUEUE_SIZE = 353,
TOKEN_NCR_PROTOCOL = 354,
TOKEN_NCR_FORMAT = 355,
TOKEN_ALWAYS_INCLUDE_FQDN = 356,
TOKEN_ALLOW_CLIENT_UPDATE = 357,
TOKEN_OVERRIDE_NO_UPDATE = 358,
TOKEN_OVERRIDE_CLIENT_UPDATE = 359,
TOKEN_REPLACE_CLIENT_NAME = 360,
TOKEN_GENERATED_PREFIX = 361,
TOKEN_TCP = 362,
TOKEN_JSON = 363,
TOKEN_WHEN_PRESENT = 364,
TOKEN_NEVER = 365,
TOKEN_ALWAYS = 366,
TOKEN_WHEN_NOT_PRESENT = 367,
TOKEN_LOGGING = 368,
TOKEN_LOGGERS = 369,
TOKEN_OUTPUT_OPTIONS = 370,
TOKEN_OUTPUT = 371,
TOKEN_DEBUGLEVEL = 372,
TOKEN_SEVERITY = 373,
TOKEN_DHCP6 = 374,
TOKEN_DHCPDDNS = 375,
TOKEN_TOPLEVEL_JSON = 376,
TOKEN_TOPLEVEL_DHCP4 = 377,
TOKEN_SUB_DHCP4 = 378,
TOKEN_SUB_INTERFACES4 = 379,
TOKEN_SUB_SUBNET4 = 380,
TOKEN_SUB_POOL4 = 381,
TOKEN_SUB_RESERVATION = 382,
TOKEN_SUB_OPTION_DEF = 383,
TOKEN_SUB_OPTION_DATA = 384,
TOKEN_SUB_HOOKS_LIBRARY = 385,
TOKEN_SUB_DHCP_DDNS = 386,
TOKEN_STRING = 387,
TOKEN_INTEGER = 388,
TOKEN_FLOAT = 389,
TOKEN_BOOLEAN = 390
};
};
......@@ -706,6 +709,10 @@ namespace isc { namespace dhcp {
symbol_type
make_HOST (const location_type& l);
static inline
symbol_type
make_PORT (const location_type& l);
static inline
symbol_type