From 5ab41adb7a5b2ad07aada30056d4374e8bbb6dfc Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Tue, 28 Feb 2017 16:25:41 +0100 Subject: [PATCH] [5061] contact_points converted to contact-points --- doc/examples/kea4/backends.json | 2 +- doc/examples/kea4/cassandra.json | 64 +++++++++++++++++++++++++ doc/examples/kea6/backends.json | 2 +- doc/examples/kea6/cassandra.json | 66 ++++++++++++++++++++++++++ src/bin/dhcp4/dhcp4_lexer.ll | 10 ---- src/bin/dhcp4/dhcp4_parser.yy | 4 +- src/bin/dhcp4/tests/parser_unittest.cc | 1 + src/bin/dhcp6/dhcp6_lexer.ll | 10 ---- src/bin/dhcp6/dhcp6_parser.yy | 4 +- src/lib/dhcpsrv/cql_connection.cc | 2 +- 10 files changed, 138 insertions(+), 27 deletions(-) create mode 100644 doc/examples/kea4/cassandra.json create mode 100644 doc/examples/kea6/cassandra.json diff --git a/doc/examples/kea4/backends.json b/doc/examples/kea4/backends.json index 5bafec0e7..f3cc1fcf2 100644 --- a/doc/examples/kea4/backends.json +++ b/doc/examples/kea4/backends.json @@ -70,7 +70,7 @@ # "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 # }, diff --git a/doc/examples/kea4/cassandra.json b/doc/examples/kea4/cassandra.json new file mode 100644 index 000000000..38c5521d7 --- /dev/null +++ b/doc/examples/kea4/cassandra.json @@ -0,0 +1,64 @@ +// 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" + } + ] +} + +} diff --git a/doc/examples/kea6/backends.json b/doc/examples/kea6/backends.json index d77277200..fa6f0f0ed 100644 --- a/doc/examples/kea6/backends.json +++ b/doc/examples/kea6/backends.json @@ -70,7 +70,7 @@ # "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 # }, diff --git a/doc/examples/kea6/cassandra.json b/doc/examples/kea6/cassandra.json new file mode 100644 index 000000000..d3101e004 --- /dev/null +++ b/doc/examples/kea6/cassandra.json @@ -0,0 +1,66 @@ +// 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" + } + ] +} + +} diff --git a/src/bin/dhcp4/dhcp4_lexer.ll b/src/bin/dhcp4/dhcp4_lexer.ll index c229e6cce..0c3ddaa77 100644 --- a/src/bin/dhcp4/dhcp4_lexer.ll +++ b/src/bin/dhcp4/dhcp4_lexer.ll @@ -380,16 +380,6 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} } } -\"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_); - } -} - \"contact-points\" { switch(driver.ctx_) { case isc::dhcp::Parser4Context::LEASE_DATABASE: diff --git a/src/bin/dhcp4/dhcp4_parser.yy b/src/bin/dhcp4/dhcp4_parser.yy index 125fb97f0..1ef6b4998 100644 --- a/src/bin/dhcp4/dhcp4_parser.yy +++ b/src/bin/dhcp4/dhcp4_parser.yy @@ -77,7 +77,7 @@ using namespace std; LFC_INTERVAL "lfc-interval" READONLY "readonly" CONNECT_TIMEOUT "connect-timeout" - CONTACT_POINTS "contact_points" + CONTACT_POINTS "contact-points" KEYSPACE "keyspace" VALID_LIFETIME "valid-lifetime" @@ -601,7 +601,7 @@ contact_points: CONTACT_POINTS { ctx.enter(ctx.NO_KEYWORD); } COLON STRING { ElementPtr cp(new StringElement($4, ctx.loc2pos(@4))); - ctx.stack_.back()->set("contact_points", cp); + ctx.stack_.back()->set("contact-points", cp); ctx.leave(); }; diff --git a/src/bin/dhcp4/tests/parser_unittest.cc b/src/bin/dhcp4/tests/parser_unittest.cc index 6b37b4fbc..95b2daa42 100644 --- a/src/bin/dhcp4/tests/parser_unittest.cc +++ b/src/bin/dhcp4/tests/parser_unittest.cc @@ -242,6 +242,7 @@ TEST(ParserTest, file) { vector configs = { "advanced.json" , "backends.json", "classify.json", + "cassandra.json", "dhcpv4-over-dhcpv6.json", "hooks.json", "leases-expiration.json", diff --git a/src/bin/dhcp6/dhcp6_lexer.ll b/src/bin/dhcp6/dhcp6_lexer.ll index 81b1093ae..37ed6c4cd 100644 --- a/src/bin/dhcp6/dhcp6_lexer.ll +++ b/src/bin/dhcp6/dhcp6_lexer.ll @@ -581,16 +581,6 @@ ControlCharacterFill [^"\\]|\\{JSONEscapeSequence} } } -\"contact_points\" { - switch(driver.ctx_) { - case isc::dhcp::Parser6Context::LEASE_DATABASE: - case isc::dhcp::Parser6Context::HOSTS_DATABASE: - return isc::dhcp::Dhcp6Parser::make_CONTACT_POINTS(driver.loc_); - default: - return isc::dhcp::Dhcp6Parser::make_STRING("contact_points", driver.loc_); - } -} - \"contact-points\" { switch(driver.ctx_) { case isc::dhcp::Parser6Context::LEASE_DATABASE: diff --git a/src/bin/dhcp6/dhcp6_parser.yy b/src/bin/dhcp6/dhcp6_parser.yy index 5274b8a5b..35391f7d9 100644 --- a/src/bin/dhcp6/dhcp6_parser.yy +++ b/src/bin/dhcp6/dhcp6_parser.yy @@ -68,7 +68,7 @@ using namespace std; LFC_INTERVAL "lfc-interval" READONLY "readonly" CONNECT_TIMEOUT "connect-timeout" - CONTACT_POINTS "contact_points" + CONTACT_POINTS "contact-points" KEYSPACE "keyspace" PREFERRED_LIFETIME "preferred-lifetime" @@ -586,7 +586,7 @@ contact_points: CONTACT_POINTS { ctx.enter(ctx.NO_KEYWORD); } COLON STRING { ElementPtr cp(new StringElement($4, ctx.loc2pos(@4))); - ctx.stack_.back()->set("contact_points", cp); + ctx.stack_.back()->set("contact-points", cp); ctx.leave(); }; diff --git a/src/lib/dhcpsrv/cql_connection.cc b/src/lib/dhcpsrv/cql_connection.cc index 1dec234eb..6959d227a 100644 --- a/src/lib/dhcpsrv/cql_connection.cc +++ b/src/lib/dhcpsrv/cql_connection.cc @@ -69,7 +69,7 @@ CqlConnection::openDatabase() { const char* contact_points = "127.0.0.1"; string scontact_points; try { - scontact_points = getParameter("contact_points"); + scontact_points = getParameter("contact-points"); contact_points = scontact_points.c_str(); } catch (...) { // No host. Fine, we'll use "localhost". -- GitLab