mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 14:05:33 +00:00
[master] Replace lease-dump scripts with stored procedures for MySQL/Postgres
Merges in branch 'trac3916'
This commit is contained in:
@@ -312,42 +312,21 @@ check_file_overwrite () {
|
||||
get_dump_query() {
|
||||
local version=$1
|
||||
|
||||
dump_qry=""
|
||||
dump_sql_file="$scripts_dir/${backend}/lease_dump_$version.sh"
|
||||
if [ ! -e $dump_sql_file ]
|
||||
then
|
||||
log_error "lease-dump: cannot access dump_sql_file: $dump_sql_file"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# source in the dump file which defines the sql text we'll need
|
||||
. $dump_sql_file
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
log_error "lease-dump: error sourcing dump_sql_file: $dump_sql_file"
|
||||
case ${backend} in
|
||||
mysql)
|
||||
invoke="call"
|
||||
;;
|
||||
pgsql)
|
||||
invoke="select * from"
|
||||
;;
|
||||
*)
|
||||
log_error "unsupported backend ${backend}"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Construct the SQL text to dump the leases based on protocol type
|
||||
case ${dump_type} in
|
||||
4)
|
||||
dump_qry="$lease4_dump_sql";
|
||||
;;
|
||||
6)
|
||||
dump_qry="$lease6_dump_sql";
|
||||
;;
|
||||
*)
|
||||
log_error "you must specify -4 or -6 for lease-dump"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$dump_qry" = "" ]
|
||||
then
|
||||
log_error "lease-dump: dump query appears to be undefined"
|
||||
exit 1
|
||||
fi
|
||||
dump_qry="${invoke} lease${dump_type}DumpHeader();${invoke} lease${dump_type}DumpData();";
|
||||
}
|
||||
|
||||
memfile_dump() {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
SUBDIRS = .
|
||||
|
||||
sqlscriptsdir = ${datarootdir}/${PACKAGE_NAME}/scripts/mysql
|
||||
sqlscripts_DATA = dhcpdb_create.mysql upgrade_1.0_to_2.0.sh upgrade_2.0_to_3.0.sh lease_dump_1.0.sh lease_dump_2.0.sh lease_dump_3.0.sh
|
||||
sqlscripts_DATA = dhcpdb_create.mysql upgrade_1.0_to_2.0.sh upgrade_2.0_to_3.0.sh
|
||||
|
||||
EXTRA_DIST = dhcpdb_create.mysql upgrade_1.0_to_2.0.sh upgrade_2.0_to_3.0.sh lease_dump_1.0.sh lease_dump_2.0.sh lease_dump_3.0.sh
|
||||
EXTRA_DIST = dhcpdb_create.mysql upgrade_1.0_to_2.0.sh upgrade_2.0_to_3.0.sh
|
||||
|
@@ -53,7 +53,7 @@ CREATE TABLE lease4 (
|
||||
) ENGINE = INNODB;
|
||||
|
||||
|
||||
# Create search indexes for lease4 table
|
||||
# Create search indexes for lease4 table
|
||||
# index by hwaddr and subnet_id
|
||||
CREATE INDEX lease4_by_hwaddr_subnet_id ON lease4 (hwaddr, subnet_id);
|
||||
|
||||
@@ -280,6 +280,75 @@ INSERT INTO lease_state VALUES (0, "default");
|
||||
INSERT INTO lease_state VALUES (1, "declined");
|
||||
INSERT INTO lease_state VALUES (2, "expired-reclaimed");
|
||||
|
||||
# FUNCTION that returns a result set containing the column names for lease4 dumps
|
||||
DROP PROCEDURE IF EXISTS lease4DumpHeader;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE lease4DumpHeader()
|
||||
BEGIN
|
||||
SELECT 'address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state';
|
||||
END $$
|
||||
DELIMITER ;
|
||||
|
||||
# FUNCTION that returns a result set containing the data for lease4 dumps
|
||||
DROP PROCEDURE IF EXISTS lease4DumpData;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE lease4DumpData()
|
||||
BEGIN
|
||||
SELECT
|
||||
INET_NTOA(l.address),
|
||||
IFNULL(HEX(l.hwaddr), ''),
|
||||
IFNULL(HEX(l.client_id), ''),
|
||||
l.valid_lifetime,
|
||||
l.expire,
|
||||
l.subnet_id,
|
||||
l.fqdn_fwd,
|
||||
l.fqdn_rev,
|
||||
l.hostname,
|
||||
s.name
|
||||
from
|
||||
lease4 l
|
||||
LEFT OUTER JOIN lease_state s on (l.state = s.state);
|
||||
END $$
|
||||
DELIMITER ;
|
||||
|
||||
# FUNCTION that returns a result set containing the column names for lease6 dumps
|
||||
DROP PROCEDURE IF EXISTS lease6DumpHeader;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE lease6DumpHeader()
|
||||
BEGIN
|
||||
SELECT 'address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,hwtype,hwaddr_source,state';
|
||||
END $$
|
||||
DELIMITER ;
|
||||
|
||||
# FUNCTION that returns a result set containing the data for lease6 dumps
|
||||
DROP PROCEDURE IF EXISTS lease6DumpData;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE lease6DumpData()
|
||||
BEGIN
|
||||
SELECT
|
||||
l.address,
|
||||
IFNULL(HEX(l.duid), ''),
|
||||
l.valid_lifetime,
|
||||
l.expire,
|
||||
l.subnet_id,
|
||||
l.pref_lifetime,
|
||||
IFNULL(t.name, ''),
|
||||
l.iaid,
|
||||
l.prefix_len,
|
||||
l.fqdn_fwd,
|
||||
l.fqdn_rev,
|
||||
l.hostname,
|
||||
IFNULL(HEX(l.hwaddr), ''),
|
||||
IFNULL(l.hwtype, ''),
|
||||
IFNULL(l.hwaddr_source, ''),
|
||||
IFNULL(s.name, '')
|
||||
FROM lease6 l
|
||||
left outer join lease6_types t on (l.lease_type = t.lease_type)
|
||||
left outer join lease_state s on (l.state = s.state);
|
||||
END $$
|
||||
DELIMITER ;
|
||||
|
||||
# Update the schema version number
|
||||
UPDATE schema_version
|
||||
SET version = '4', minor = '0';
|
||||
# This line concludes database upgrade to version 4.0.
|
||||
|
@@ -1,37 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2015 Internet Systems Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
# Specifies the MySQL sql for schema-version 1.0 required to produce
|
||||
# lease output that includes a header row containing column names,
|
||||
# followed by the lease data. The text is used in a single call
|
||||
# to the mysql command line tool.
|
||||
|
||||
# SQL for DHCPv4 leases
|
||||
lease4_dump_sql="\
|
||||
SELECT 'address', 'hwaddr', 'client_id', 'valid_lifetime', 'expire',\
|
||||
'subnet_id', 'fqdn_fwd', 'fqdn_rev', 'hostname';\
|
||||
SELECT INET_NTOA(address), IFNULL(HEX(hwaddr), ''), IFNULL(HEX(client_id), ''),\
|
||||
valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname from lease4"
|
||||
|
||||
# SQL for DHCPv6 leases
|
||||
lease6_dump_sql="\
|
||||
SELECT 'address', 'duid', 'valid_lifetime', 'expire',\
|
||||
'subnet_id', 'pref_lifetime', 'lease_type', 'iaid', 'prefix_len', 'fqdn_fwd',\
|
||||
'fqdn_rev', 'hostname';\
|
||||
SELECT a.address, IFNULL(HEX(a.duid), ''), a.valid_lifetime,\
|
||||
a.expire, a.subnet_id, a.pref_lifetime, IFNULL(b.name, ''), a.iaid, a.prefix_len,\
|
||||
a.fqdn_fwd, a.fqdn_rev, hostname \
|
||||
FROM lease6 a left outer join lease6_types b on (a.lease_type = b.lease_type)"
|
@@ -1,38 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2015 Internet Systems Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
# Specifies the MySQL sql for schema-version 2.0 required to produce
|
||||
# lease output that includes a header row containing column names,
|
||||
# followed by the lease data. The text is used in a single call
|
||||
# to the mysql command line tool.
|
||||
|
||||
# SQL for DHCPv4 leases
|
||||
lease4_dump_sql="\
|
||||
SELECT 'address', 'hwaddr', 'client_id', 'valid_lifetime', 'expire',\
|
||||
'subnet_id', 'fqdn_fwd', 'fqdn_rev', 'hostname';\
|
||||
SELECT INET_NTOA(address), IFNULL(HEX(hwaddr), ''), IFNULL(HEX(client_id), ''),\
|
||||
valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname from lease4"
|
||||
|
||||
# SQL for DHCPv6 leases
|
||||
lease6_dump_sql="\
|
||||
SELECT 'address', 'duid', 'valid_lifetime', 'expire',\
|
||||
'subnet_id', 'pref_lifetime', 'lease_type', 'iaid', 'prefix_len', 'fqdn_fwd',\
|
||||
'fqdn_rev', 'hostname', 'hwaddr', 'hwtype', 'hwaddr_source';\
|
||||
SELECT a.address, IFNULL(HEX(a.duid), ''), a.valid_lifetime,\
|
||||
a.expire, a.subnet_id, a.pref_lifetime, IFNULL(b.name, ''), a.iaid, a.prefix_len,\
|
||||
a.fqdn_fwd, a.fqdn_rev, hostname, IFNULL(HEX(hwaddr), ''), IFNULL(hwtype, ''),\
|
||||
IFNULL(hwaddr_source, '') \
|
||||
FROM lease6 a left outer join lease6_types b on (a.lease_type = b.lease_type)"
|
@@ -1,38 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2015 Internet Systems Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
# Specifies the MySQL sql for schema-version 3.0 required to produce
|
||||
# lease output that includes a header row containing column names,
|
||||
# followed by the lease data. The text is used in a single call
|
||||
# to the mysql command line tool.
|
||||
|
||||
# SQL for DHCPv4 leases
|
||||
lease4_dump_sql="\
|
||||
SELECT 'address', 'hwaddr', 'client_id', 'valid_lifetime', 'expire',\
|
||||
'subnet_id', 'fqdn_fwd', 'fqdn_rev', 'hostname';\
|
||||
SELECT INET_NTOA(address), IFNULL(HEX(hwaddr), ''), IFNULL(HEX(client_id), ''),\
|
||||
valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname from lease4"
|
||||
|
||||
# SQL for DHCPv6 leases
|
||||
lease6_dump_sql="\
|
||||
SELECT 'address', 'duid', 'valid_lifetime', 'expire',\
|
||||
'subnet_id', 'pref_lifetime', 'lease_type', 'iaid', 'prefix_len', 'fqdn_fwd',\
|
||||
'fqdn_rev', 'hostname', 'hwaddr', 'hwtype', 'hwaddr_source';\
|
||||
SELECT a.address, IFNULL(HEX(a.duid), ''), a.valid_lifetime,\
|
||||
a.expire, a.subnet_id, a.pref_lifetime, IFNULL(b.name, ''), a.iaid, a.prefix_len,\
|
||||
a.fqdn_fwd, a.fqdn_rev, hostname, IFNULL(HEX(hwaddr), ''), IFNULL(hwtype, ''),\
|
||||
IFNULL(hwaddr_source, '') \
|
||||
FROM lease6 a left outer join lease6_types b on (a.lease_type = b.lease_type)"
|
@@ -1,38 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2015 Internet Systems Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
# Specifies the MySQL sql for schema-version 4.0 required to produce
|
||||
# lease output that includes a header row containing column names,
|
||||
# followed by the lease data. The text is used in a single call
|
||||
# to the mysql command line tool.
|
||||
|
||||
# SQL for DHCPv4 leases
|
||||
lease4_dump_sql="\
|
||||
SELECT 'address', 'hwaddr', 'client_id', 'valid_lifetime', 'expire',\
|
||||
'subnet_id', 'fqdn_fwd', 'fqdn_rev', 'hostname', 'state';\
|
||||
SELECT INET_NTOA(address), IFNULL(HEX(hwaddr), ''), IFNULL(HEX(client_id), ''),\
|
||||
valid_lifetime, expire, subnet_id, fqdn_fwd, fqdn_rev, hostname, state from lease4"
|
||||
|
||||
# SQL for DHCPv6 leases
|
||||
lease6_dump_sql="\
|
||||
SELECT 'address', 'duid', 'valid_lifetime', 'expire',\
|
||||
'subnet_id', 'pref_lifetime', 'lease_type', 'iaid', 'prefix_len', 'fqdn_fwd',\
|
||||
'fqdn_rev', 'hostname', 'hwaddr', 'hwtype', 'hwaddr_source', 'state';\
|
||||
SELECT a.address, IFNULL(HEX(a.duid), ''), a.valid_lifetime,\
|
||||
a.expire, a.subnet_id, a.pref_lifetime, IFNULL(b.name, ''), a.iaid, a.prefix_len,\
|
||||
a.fqdn_fwd, a.fqdn_rev, hostname, IFNULL(HEX(hwaddr), ''), IFNULL(hwtype, ''),\
|
||||
IFNULL(hwaddr_source, ''), state \
|
||||
FROM lease6 a left outer join lease6_types b on (a.lease_type = b.lease_type)"
|
@@ -1,6 +1,6 @@
|
||||
SUBDIRS = .
|
||||
|
||||
sqlscriptsdir = ${datarootdir}/${PACKAGE_NAME}/scripts/pgsql
|
||||
sqlscripts_DATA = dhcpdb_create.pgsql lease_dump_1.0.sh
|
||||
sqlscripts_DATA = dhcpdb_create.pgsql
|
||||
|
||||
EXTRA_DIST = dhcpdb_create.pgsql lease_dump_1.0.sh
|
||||
EXTRA_DIST = dhcpdb_create.pgsql
|
||||
|
@@ -50,6 +50,41 @@ CREATE INDEX lease4_by_hwaddr_subnet_id ON lease4 (hwaddr, subnet_id);
|
||||
-- index by client_id and subnet_id
|
||||
CREATE INDEX lease4_by_client_id_subnet_id ON lease4 (client_id, subnet_id);
|
||||
|
||||
--
|
||||
-- FUNCTION that returns a result set containing the column names for lease4 dumps
|
||||
DROP FUNCTION IF EXISTS lease4DumpHeader();
|
||||
CREATE FUNCTION lease4DumpHeader() RETURNS text AS $$
|
||||
select cast('address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname' as text) as result;
|
||||
$$ LANGUAGE SQL;
|
||||
--
|
||||
|
||||
--
|
||||
-- FUNCTION that returns a result set containing the data for lease4 dumps
|
||||
DROP FUNCTION IF EXISTS lease4DumpData();
|
||||
CREATE FUNCTION lease4DumpData() RETURNS
|
||||
table (address inet,
|
||||
hwaddr text,
|
||||
client_id text,
|
||||
valid_lifetime bigint,
|
||||
expire timestamp with time zone,
|
||||
subnet_id bigint,
|
||||
fqdn_fwd int,
|
||||
fqdn_rev int,
|
||||
hostname text
|
||||
) as $$
|
||||
SELECT ('0.0.0.0'::inet + address),
|
||||
encode(hwaddr,'hex'),
|
||||
encode(client_id,'hex'),
|
||||
valid_lifetime,
|
||||
expire,
|
||||
subnet_id,
|
||||
fqdn_fwd::int,
|
||||
fqdn_rev::int,
|
||||
hostname
|
||||
from lease4;
|
||||
$$ LANGUAGE SQL;
|
||||
--
|
||||
|
||||
-- Holds the IPv6 leases.
|
||||
-- N.B. The use of a VARCHAR for the address is temporary for development:
|
||||
-- it will eventually be replaced by BINARY(16).
|
||||
@@ -103,6 +138,48 @@ START TRANSACTION;
|
||||
INSERT INTO schema_version VALUES (1, 0);
|
||||
COMMIT;
|
||||
|
||||
--
|
||||
-- FUNCTION that returns a result set containing the column names for lease6 dumps
|
||||
DROP FUNCTION IF EXISTS lease6DumpHeader();
|
||||
CREATE FUNCTION lease6DumpHeader() RETURNS text AS $$
|
||||
select cast('address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname' as text) as result;
|
||||
$$ LANGUAGE SQL;
|
||||
--
|
||||
|
||||
--
|
||||
-- FUNCTION that returns a result set containing the data for lease6 dumps
|
||||
DROP FUNCTION IF EXISTS lease6DumpData();
|
||||
CREATE FUNCTION lease6DumpData() RETURNS
|
||||
TABLE (
|
||||
address text,
|
||||
duid text,
|
||||
valid_lifetime bigint,
|
||||
expire timestamp with time zone,
|
||||
subnet_id bigint,
|
||||
pref_lifetime bigint,
|
||||
name text,
|
||||
iaid integer,
|
||||
prefix_len smallint,
|
||||
fqdn_fwd int,
|
||||
fqdn_rev int,
|
||||
hostname text
|
||||
) AS $$
|
||||
SELECT (l.address,
|
||||
encode(l.duid,'hex'),
|
||||
l.valid_lifetime,
|
||||
l.expire,
|
||||
l.subnet_id,
|
||||
l.pref_lifetime,
|
||||
t.name,
|
||||
l.iaid,
|
||||
l.prefix_len,
|
||||
l.fqdn_fwd::int,
|
||||
l.fqdn_rev::int,
|
||||
l.hostname)
|
||||
FROM lease6 l left outer join lease6_types t on (l.lease_type = t.lease_type);
|
||||
$$ LANGUAGE SQL;
|
||||
--
|
||||
|
||||
-- Notes:
|
||||
|
||||
-- Indexes
|
||||
|
@@ -1,39 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2015 Internet Systems Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
# Specifies the PostgreSQL sql for schema-version 1.0 required to produce
|
||||
# lease output that includes a header row containing column names,
|
||||
# followed by the lease data. The text is used in a single call
|
||||
# to the mysql command line tool.
|
||||
|
||||
# SQL for DHCPv4 leases
|
||||
lease4_dump_sql="\
|
||||
SELECT 'address', 'hwaddr', 'client_id', 'valid_lifetime', 'expire',\
|
||||
'subnet_id', 'fqdn_fwd', 'fqdn_rev', 'hostname';\
|
||||
SELECT ('0.0.0.0'::inet + address) AS address,\
|
||||
encode(hwaddr,'hex'), encode(client_id,'hex'), valid_lifetime,\
|
||||
expire, subnet_id, fqdn_fwd::int AS fqdn_fwd, fqdn_rev::int AS fqdn_rev,\
|
||||
hostname FROM lease4"
|
||||
|
||||
# SQL for DHCPv6 leases
|
||||
lease6_dump_sql="\
|
||||
SELECT 'address', 'duid', 'valid_lifetime', 'expire',\
|
||||
'subnet_id', 'pref_lifetime', 'lease_type', 'iaid', 'prefix_len', 'fqdn_fwd',\
|
||||
'fqdn_rev', 'hostname';\
|
||||
SELECT a.address, encode(a.duid,'hex'), a.valid_lifetime,\
|
||||
a.expire, a.subnet_id, a.pref_lifetime, b.name, a.iaid, a.prefix_len,\
|
||||
a.fqdn_fwd, a.fqdn_rev, hostname \
|
||||
FROM lease6 a left outer join lease6_types b on (a.lease_type = b.lease_type)"
|
@@ -1,4 +1,4 @@
|
||||
address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state
|
||||
0.0.0.10,3230,3330,40,2015-01-01 01:15:30,50,1,1,one.example.com,0
|
||||
0.0.0.11,,313233,40,2015-02-02 02:30:45,50,1,1,,0
|
||||
0.0.0.12,3232,,40,2015-03-03 11:01:07,50,1,1,three.example.com,0
|
||||
0.0.0.10,3230,3330,40,2015-01-01 01:15:30,50,1,1,one.example.com,default
|
||||
0.0.0.11,,313233,40,2015-02-02 02:30:45,50,1,1,,declined
|
||||
0.0.0.12,3232,,40,2015-03-03 11:01:07,50,1,1,three.example.com,expired-reclaimed
|
||||
|
|
@@ -1,4 +1,4 @@
|
||||
address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,hwtype,hwaddr_source,state
|
||||
10,3230,30,2015-04-04 01:15:30,40,50,IA_TA,60,70,1,1,one.example.com,3830,90,100,0
|
||||
11,,30,2015-05-05 02:30:45,40,50,IA_TA,60,70,1,1,,3830,90,100,0
|
||||
12,3231,30,2015-06-06 11:01:07,40,50,IA_TA,60,70,1,1,three.example.com,3830,90,100,0
|
||||
10,3230,30,2015-04-04 01:15:30,40,50,IA_TA,60,70,1,1,one.example.com,3830,90,100,default
|
||||
11,,30,2015-05-05 02:30:45,40,50,IA_TA,60,70,1,1,,3830,90,100,declined
|
||||
12,3231,30,2015-06-06 11:01:07,40,50,IA_TA,60,70,1,1,three.example.com,3830,90,100,expired-reclaimed
|
||||
|
|
@@ -1,4 +1,4 @@
|
||||
address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname
|
||||
12,21,30,<timestamp3>,40,50,IA_TA,60,70,t,t,three.example.com
|
||||
11,,30,<timestamp2>,40,50,IA_TA,60,70,t,t,
|
||||
10,20,30,<timestamp1>,40,50,IA_TA,60,70,t,t,one.example.com
|
||||
12,21,30,<timestamp3>,40,50,IA_TA,60,70,1,1,three.example.com
|
||||
11,,30,<timestamp2>,40,50,IA_TA,60,70,1,1,
|
||||
10,20,30,<timestamp1>,40,50,IA_TA,60,70,1,1,one.example.com
|
||||
|
|
@@ -303,8 +303,8 @@ mysql_lease4_dump_test() {
|
||||
# Insert the reference record
|
||||
insert_sql="\
|
||||
insert into lease4 values(10,20,30,40,\"2015-01-01 01:15:30\",50,1,1,\"one.example.com\", 0);\
|
||||
insert into lease4 values(11,NULL,123,40,\"2015-02-02 02:30:45\",50,1,1,\"\", 0);\
|
||||
insert into lease4 values(12,22,NULL,40,\"2015-03-03 11:01:07\",50,1,1,\"three.example.com\", 0);"
|
||||
insert into lease4 values(11,NULL,123,40,\"2015-02-02 02:30:45\",50,1,1,\"\", 1);\
|
||||
insert into lease4 values(12,22,NULL,40,\"2015-03-03 11:01:07\",50,1,1,\"three.example.com\", 2);"
|
||||
|
||||
mysql_execute "$insert_sql"
|
||||
ERRCODE=$?
|
||||
@@ -363,8 +363,8 @@ mysql_lease6_dump_test() {
|
||||
# Insert the reference record
|
||||
insert_sql="\
|
||||
insert into lease6 values(10,20,30,\"2015-04-04 01:15:30\",40,50,1,60,70,1,1,\"one.example.com\",80,90,100, 0);\
|
||||
insert into lease6 values(11,NULL,30,\"2015-05-05 02:30:45\",40,50,1,60,70,1,1,\"\",80,90,100, 0);\
|
||||
insert into lease6 values(12,21,30,\"2015-06-06 11:01:07\",40,50,1,60,70,1,1,\"three.example.com\",80,90,100, 0);"
|
||||
insert into lease6 values(11,NULL,30,\"2015-05-05 02:30:45\",40,50,1,60,70,1,1,\"\",80,90,100, 1);\
|
||||
insert into lease6 values(12,21,30,\"2015-06-06 11:01:07\",40,50,1,60,70,1,1,\"three.example.com\",80,90,100, 2);"
|
||||
|
||||
mysql_execute "$insert_sql"
|
||||
ERRCODE=$?
|
||||
|
Reference in New Issue
Block a user