mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[392-search-of-reservations-by-hostname] Checkpoint: updated shcemas, todo tests
This commit is contained in:
@@ -1796,6 +1796,7 @@ AC_CONFIG_FILES([Makefile
|
||||
src/share/database/scripts/cql/upgrade_1.0_to_2.0.sh
|
||||
src/share/database/scripts/cql/upgrade_2.0_to_3.0.sh
|
||||
src/share/database/scripts/cql/upgrade_3.0_to_4.0.sh
|
||||
src/share/database/scripts/cql/upgrade_4.0_to_5.0.sh
|
||||
src/share/database/scripts/cql/wipe_data.sh
|
||||
src/share/database/scripts/mysql/Makefile
|
||||
src/share/database/scripts/mysql/upgrade_1.0_to_2.0.sh
|
||||
@@ -1810,6 +1811,7 @@ AC_CONFIG_FILES([Makefile
|
||||
src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh
|
||||
src/share/database/scripts/mysql/upgrade_8.0_to_8.1.sh
|
||||
src/share/database/scripts/mysql/upgrade_8.1_to_8.2.sh
|
||||
src/share/database/scripts/mysql/upgrade_8.2_to_9.0.sh
|
||||
src/share/database/scripts/mysql/wipe_data.sh
|
||||
src/share/database/scripts/pgsql/Makefile
|
||||
src/share/database/scripts/pgsql/upgrade_1.0_to_2.0.sh
|
||||
@@ -1820,6 +1822,7 @@ AC_CONFIG_FILES([Makefile
|
||||
src/share/database/scripts/pgsql/upgrade_3.3_to_4.0.sh
|
||||
src/share/database/scripts/pgsql/upgrade_4.0_to_5.0.sh
|
||||
src/share/database/scripts/pgsql/upgrade_5.0_to_5.1.sh
|
||||
src/share/database/scripts/pgsql/upgrade_5.1_to_6.0.sh
|
||||
src/share/database/scripts/pgsql/wipe_data.sh
|
||||
src/share/yang/Makefile
|
||||
src/share/yang/modules/Makefile
|
||||
|
@@ -85,7 +85,7 @@ cql_db_version_test() {
|
||||
|
||||
# Verify that kea-admin db-version returns the correct version.
|
||||
version=$($keaadmin db-version cql -u $db_user -p $db_password -n $db_name)
|
||||
assert_str_eq "4.0" $version "Expected kea-admin to return %s, returned value was %s"
|
||||
assert_str_eq "5.0" $version "Expected kea-admin to return %s, returned value was %s"
|
||||
|
||||
# Wipe the database.
|
||||
cql_wipe
|
||||
@@ -315,16 +315,16 @@ cql_unused_subnet_id_test() {
|
||||
|
||||
# Now we need insert some hosts to "migrate" for both v4 and v6
|
||||
qry="\
|
||||
INSERT INTO host_reservations (id, host_identifier_type, host_identifier, host_ipv4_subnet_id, host_ipv6_subnet_id, option_subnet_id) \
|
||||
VALUES (1, 0, textAsBlob('0123456'), 0, 0, 0);\
|
||||
INSERT INTO host_reservations (id, host_identifier_type, host_identifier, host_ipv4_subnet_id, host_ipv6_subnet_id, option_subnet_id) \
|
||||
VALUES (2, 0, textAsBlob('1123456'), 4, 0, 4);\
|
||||
INSERT INTO host_reservations (id, host_identifier_type, host_identifier, host_ipv4_subnet_id, host_ipv6_subnet_id, option_subnet_id) \
|
||||
VALUES (3, 0, textAsBlob('2123456'), 0, 6, 6);\
|
||||
INSERT INTO host_reservations (id, host_identifier_type, host_identifier, host_ipv4_subnet_id, host_ipv6_subnet_id, option_subnet_id) \
|
||||
VALUES (4, 0, textAsBlob('3123456'), 4, 6, 0);\
|
||||
INSERT INTO host_reservations (id, host_identifier_type, host_identifier, host_ipv4_subnet_id, host_ipv6_subnet_id, option_subnet_id) \
|
||||
VALUES (5, 0, textAsBlob('3123456'), -1, 6, 6);"
|
||||
INSERT INTO host_reservations (id, host_identifier_type, host_identifier, host_ipv4_subnet_id, host_ipv6_subnet_id, hostname, option_subnet_id) \
|
||||
VALUES (1, 0, textAsBlob('0123456'), 0, 0, 'host0', 0);\
|
||||
INSERT INTO host_reservations (id, host_identifier_type, host_identifier, host_ipv4_subnet_id, host_ipv6_subnet_id, hostname, option_subnet_id) \
|
||||
VALUES (2, 0, textAsBlob('1123456'), 4, 0, 'Host1', 4);\
|
||||
INSERT INTO host_reservations (id, host_identifier_type, host_identifier, host_ipv4_subnet_id, host_ipv6_subnet_id, hostname, option_subnet_id) \
|
||||
VALUES (3, 0, textAsBlob('2123456'), 0, 6, 'host2', 6);\
|
||||
INSERT INTO host_reservations (id, host_identifier_type, host_identifier, host_ipv4_subnet_id, host_ipv6_subnet_id, hostname, option_subnet_id) \
|
||||
VALUES (4, 0, textAsBlob('3123456'), 4, 6, 'Host3', 0);\
|
||||
INSERT INTO host_reservations (id, host_identifier_type, host_identifier, host_ipv4_subnet_id, host_ipv6_subnet_id, hostname, option_subnet_id) \
|
||||
VALUES (5, 0, textAsBlob('3123456'), -1, 6, 'host3', 6);"
|
||||
|
||||
cql_execute "$qry"
|
||||
assert_eq 0 $? "insert hosts failed, expected exit code: %d, actual: %d"
|
||||
@@ -347,7 +347,7 @@ cql_unused_subnet_id_test() {
|
||||
echo "Exporting host_reservation data to $export_file ..."
|
||||
|
||||
qry="\
|
||||
SELECT id, host_ipv4_subnet_id, host_ipv6_subnet_id, option_subnet_id\
|
||||
SELECT id, host_ipv4_subnet_id, host_ipv6_subnet_id, hostname, lower_case_hostname, option_subnet_id\
|
||||
FROM hosts WHERE id IN (1,2,3,4,5) ALLOW FILTERING;"
|
||||
|
||||
cql_execute "$qry" > $export_file
|
||||
@@ -433,7 +433,8 @@ cql_upgrade_hosts_test() {
|
||||
(id, key, host_identifier, host_identifier_type, host_ipv4_subnet_id, \
|
||||
host_ipv6_subnet_id, host_ipv4_address, host_ipv4_next_server, \
|
||||
host_ipv4_server_hostname, host_ipv4_boot_file_name, hostname, \
|
||||
auth_key, user_context, host_ipv4_client_classes, \
|
||||
lower_case_hostname, auth_key, user_context, \
|
||||
host_ipv4_client_classes, \
|
||||
host_ipv6_client_classes, reserved_ipv6_prefix_address, \
|
||||
reserved_ipv6_prefix_length, reserved_ipv6_prefix_address_type, \
|
||||
iaid, option_universe, option_code, option_value, \
|
||||
|
@@ -1,6 +1,6 @@
|
||||
1105657659805715115,0x4142434445464748494b,1,1,101,0,0,,,,,,,,2001:db8::1,128,0,0,1,17,0x,2495,dhcp6,False,,0,,3
|
||||
2129388898029710264,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,0,1,0x,312131,vendor-encapsulated-options,False,,0,,3
|
||||
2370585748436022247,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,0,67,0x,my-boot-file,dhcp4,True,,0,,3
|
||||
1105657659805715115,0x4142434445464748494b,1,1,101,0,0,,,host60,,,,,2001:db8::1,128,0,0,1,17,0x,2495,dhcp6,False,,0,,3
|
||||
2129388898029710264,0x414243444548,0,2,102,0,0,,,Host61,,,,,2001:db8::1,128,0,0,0,1,0x,312131,vendor-encapsulated-options,False,,0,,3
|
||||
2370585748436022247,0x414243444548,0,2,102,0,0,,,host62,,,,,2001:db8::1,128,0,0,0,67,0x,my-boot-file,dhcp4,True,,0,,3
|
||||
2459636980433777721,0x4142434445464748494b,1,1,101,0,0,,,,,,,,2001:db8::1,128,0,0,1,59,0x,my-boot-file,dhcp6,True,,0,{ \"comment\": \"a host reservation\" },3
|
||||
5403514763123047131,0x414243444547,0,1,101,-1073741307,0,,,,,,,,::,0,-1,-1,0,254,0x,192.0.2.3,dhcp4,False,,0,,3
|
||||
5501234819855171334,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,1,17,0x,2495,dhcp6,False,,0,,3
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 121.
|
@@ -1,24 +1,24 @@
|
||||
1105657659805715115,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,2001:db8::1,128,0,0,1,17,0x,2495,dhcp6,False,,0,,3
|
||||
2129388898029710264,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,0,1,0x,312131,vendor-encapsulated-options,False,,0,,3
|
||||
2370585748436022247,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,0,67,0x,my-boot-file,dhcp4,True,,0,,3
|
||||
2459636980433777721,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,2001:db8::1,128,0,0,1,59,0x,my-boot-file,dhcp6,True,,0,{ \"comment\": \"a host reservation\" },3
|
||||
5403514763123047131,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,::,0,-1,-1,0,254,0x,192.0.2.3,dhcp4,False,,0,,3
|
||||
5501234819855171334,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,1,17,0x,2495,dhcp6,False,,0,,3
|
||||
5747907930644082856,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,2001:db8::1,128,0,0,1,1,0x,,isc2,True,,0,,3
|
||||
5955003068494074400,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,1,59,0x,my-boot-file,dhcp6,True,,0,,3
|
||||
6399013866147252670,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,2001:db8::1,128,0,0,1,32,0x,3600,dhcp6,False,,0,,3
|
||||
6783601303445960591,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,1,32,0x,3600,dhcp6,False,,0,,3
|
||||
7821756928114620236,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,::,0,-1,-1,0,23,0x,64,dhcp4,False,,0,,3
|
||||
8973539074684426388,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,0,1,0x,,isc,True,,0,,3
|
||||
9211831388923168274,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,::,0,-1,-1,0,2,0x,"10.0.0.5,10.0.0.3,10.0.3.4",isc,False,,0,,3
|
||||
-650687214220680074,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,2001:db8::1,128,0,0,1,1024,0x,2001:db8:1::1,dhcp6,False,,0,,3
|
||||
-1123502337428230752,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,0,254,0x,192.0.2.3,dhcp4,False,,0,,3
|
||||
-1210691761766369036,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,::,0,-1,-1,0,67,0x,my-boot-file,dhcp4,True,,0,{ \"comment\": \"a host reservation\" },3
|
||||
-3907456719587717375,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,0,2,0x,"10.0.0.5,10.0.0.3,10.0.3.4",isc,False,,0,,3
|
||||
-5169419091664697091,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,2001:db8::1,128,0,0,1,2,0x,"3000::1,3000::2,3000::3",isc2,False,,0,,3
|
||||
-6372549629773775261,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,::,0,-1,-1,0,1,0x,312131,vendor-encapsulated-options,False,,0,,3
|
||||
-6378104957663278797,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,::,0,-1,-1,0,1,0x,,isc,True,,0,,3
|
||||
-7724068518921719729,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,1,1024,0x,2001:db8:1::1,dhcp6,False,,0,,3
|
||||
-7804940982500935489,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,0,23,0x,64,dhcp4,False,,0,,3
|
||||
-8100784457292204371,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,1,1,0x,,isc2,True,,0,,3
|
||||
-8306770918748488616,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,2001:db8::1,128,0,0,1,2,0x,"3000::1,3000::2,3000::3",isc2,False,,0,,3
|
||||
1105657659805715115,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,host60,host60,,,,,2001:db8::1,128,0,0,1,17,0x,2495,dhcp6,False,,0,,3
|
||||
2129388898029710264,-4885955325122621964,0x414243444548,0,2,102,0,0,,,Host61,host61,,,,,2001:db8::1,128,0,0,0,1,0x,312131,vendor-encapsulated-options,False,,0,,3
|
||||
2370585748436022247,-4885955325122621964,0x414243444548,0,2,102,0,0,,,host62,host62,,,,,2001:db8::1,128,0,0,0,67,0x,my-boot-file,dhcp4,True,,0,,3
|
||||
2459636980433777721,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,,2001:db8::1,128,0,0,1,59,0x,my-boot-file,dhcp6,True,,0,{ \"comment\": \"a host reservation\" },3
|
||||
5403514763123047131,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,,::,0,-1,-1,0,254,0x,192.0.2.3,dhcp4,False,,0,,3
|
||||
5501234819855171334,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,,2001:db8::1,128,0,0,1,17,0x,2495,dhcp6,False,,0,,3
|
||||
5747907930644082856,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,,2001:db8::1,128,0,0,1,1,0x,,isc2,True,,0,,3
|
||||
5955003068494074400,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,,2001:db8::1,128,0,0,1,59,0x,my-boot-file,dhcp6,True,,0,,3
|
||||
6399013866147252670,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,,2001:db8::1,128,0,0,1,32,0x,3600,dhcp6,False,,0,,3
|
||||
6783601303445960591,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,,2001:db8::1,128,0,0,1,32,0x,3600,dhcp6,False,,0,,3
|
||||
7821756928114620236,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,,::,0,-1,-1,0,23,0x,64,dhcp4,False,,0,,3
|
||||
8973539074684426388,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,,2001:db8::1,128,0,0,0,1,0x,,isc,True,,0,,3
|
||||
9211831388923168274,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,,::,0,-1,-1,0,2,0x,"10.0.0.5,10.0.0.3,10.0.3.4",isc,False,,0,,3
|
||||
-650687214220680074,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,,2001:db8::1,128,0,0,1,1024,0x,2001:db8:1::1,dhcp6,False,,0,,3
|
||||
-1123502337428230752,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,,2001:db8::1,128,0,0,0,254,0x,192.0.2.3,dhcp4,False,,0,,3
|
||||
-1210691761766369036,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,,::,0,-1,-1,0,67,0x,my-boot-file,dhcp4,True,,0,{ \"comment\": \"a host reservation\" },3
|
||||
-3907456719587717375,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,,2001:db8::1,128,0,0,0,2,0x,"10.0.0.5,10.0.0.3,10.0.3.4",isc,False,,0,,3
|
||||
-5169419091664697091,5367868710821401223,0x4142434445464748494b,1,1,101,0,0,,,,,,,,,2001:db8::1,128,0,0,1,2,0x,"3000::1,3000::2,3000::3",isc2,False,,0,,3
|
||||
-6372549629773775261,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,,::,0,-1,-1,0,1,0x,312131,vendor-encapsulated-options,False,,0,,3
|
||||
-6378104957663278797,4012104063077014549,0x414243444547,0,1,101,-1073741307,0,,,,,,,,,::,0,-1,-1,0,1,0x,,isc,True,,0,,3
|
||||
-7724068518921719729,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,,2001:db8::1,128,0,0,1,1024,0x,2001:db8:1::1,dhcp6,False,,0,,3
|
||||
-7804940982500935489,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,,2001:db8::1,128,0,0,0,23,0x,64,dhcp4,False,,0,,3
|
||||
-8100784457292204371,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,,2001:db8::1,128,0,0,1,1,0x,,isc2,True,,0,,3
|
||||
-8306770918748488616,-4885955325122621964,0x414243444548,0,2,102,0,0,,,,,,,,,2001:db8::1,128,0,0,1,2,0x,"3000::1,3000::2,3000::3",isc2,False,,0,,3
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 141.
|
@@ -1,6 +1,6 @@
|
||||
id,host_ipv4_subnet_id,host_ipv6_subnet_id,option_subnet_id
|
||||
1,-1,-1,-1
|
||||
2,4,-1,4
|
||||
3,-1,6,6
|
||||
4,4,6,-1
|
||||
5,-1,6,6
|
||||
id,host_ipv4_subnet_id,host_ipv6_subnet_id,hostname,lower_case_hostname,option_subnet_id
|
||||
1,-1,-1,host0,host0,-1
|
||||
2,4,-1,Host1,host1,4
|
||||
3,-1,6,host2,host2,6
|
||||
4,4,6,Host3,host3,-1
|
||||
5,-1,6,host3,host3,6
|
||||
|
|
@@ -258,7 +258,7 @@ mysql_upgrade_test() {
|
||||
|
||||
assert_str_eq "1.0" ${version} "Expected kea-admin to return %s, returned value was %s"
|
||||
|
||||
# Ok, we have a 1.0 database. Let's upgrade it to 8.2
|
||||
# Ok, we have a 1.0 database. Let's upgrade it to 9.0
|
||||
${keaadmin} db-upgrade mysql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir
|
||||
ERRCODE=$?
|
||||
|
||||
@@ -721,10 +721,6 @@ EOF
|
||||
qry="select client_class, require_client_classes, user_context from dhcp6_pool"
|
||||
run_statement "dhcp6_pool" "$qry"
|
||||
|
||||
# Verify upgraded schema reports version 8.2
|
||||
version=$(${keaadmin} db-version mysql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir)
|
||||
assert_str_eq "8.2" ${version} "Expected kea-admin to return %s, returned value was %s"
|
||||
|
||||
# Verify that dhcp4_option_def column name is is_array
|
||||
qry="select is_array from dhcp4_option_def"
|
||||
run_statement "dhcp4_option_def verify is_array column" "$qry"
|
||||
@@ -733,6 +729,10 @@ EOF
|
||||
qry="select is_array from dhcp6_option_def"
|
||||
run_statement "dhcp6_option_def verify is_array column" "$qry"
|
||||
|
||||
# Verify upgraded schema reports version 9.0
|
||||
version=$(${keaadmin} db-version mysql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir)
|
||||
assert_str_eq "9.0" ${version} "Expected kea-admin to return %s, returned value was %s"
|
||||
|
||||
# Let's wipe the whole database
|
||||
mysql_wipe
|
||||
|
||||
|
@@ -120,7 +120,7 @@ pgsql_db_version_test() {
|
||||
|
||||
# Verify that kea-admin db-version returns the correct version
|
||||
version=$(${keaadmin} db-version pgsql -u $db_user -p $db_password -n $db_name)
|
||||
assert_str_eq "5.1" ${version} "Expected kea-admin to return %s, returned value was %s"
|
||||
assert_str_eq "6.0" ${version} "Expected kea-admin to return %s, returned value was %s"
|
||||
|
||||
# Let's wipe the whole database
|
||||
pgsql_wipe
|
||||
@@ -230,10 +230,10 @@ pgsql_upgrade_2_0_to_3_0() {
|
||||
assert_eq 1 "$output" "lease_hwaddr_source does not contain entry for HWADDR_SOURCE_UNKNOWN. (record count %d, expected %d)"
|
||||
}
|
||||
|
||||
pgsql_upgrade_3_0_to_5_1() {
|
||||
# Verify upgraded schema reports version 5.1.
|
||||
pgsql_upgrade_3_0_to_6_0() {
|
||||
# Verify upgraded schema reports version 6.0.
|
||||
version=$(${keaadmin} db-version pgsql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir)
|
||||
assert_str_eq "5.1" ${version} "Expected kea-admin to return %s, returned value was %s"
|
||||
assert_str_eq "6.0" ${version} "Expected kea-admin to return %s, returned value was %s"
|
||||
|
||||
# Added user_context to lease4
|
||||
output=`pgsql_execute "select user_context from lease4;"`
|
||||
@@ -270,8 +270,8 @@ pgsql_upgrade_test() {
|
||||
# Check 2.0 to 3.0 upgrade
|
||||
pgsql_upgrade_2_0_to_3_0
|
||||
|
||||
# Check 3.0 to 5.1 upgrade
|
||||
pgsql_upgrade_3_0_to_5_1
|
||||
# Check 3.0 to 6.0 upgrade
|
||||
pgsql_upgrade_3_0_to_6_0
|
||||
|
||||
# Let's wipe the whole database
|
||||
pgsql_wipe
|
||||
|
@@ -49,9 +49,9 @@ constexpr uint32_t CQL_DRIVER_VERSION_MAJOR = CASS_VERSION_MAJOR;
|
||||
constexpr uint32_t CQL_DRIVER_VERSION_MINOR = CASS_VERSION_MINOR;
|
||||
/// @}
|
||||
|
||||
/// Define CQL schema version: 4.0
|
||||
/// Define CQL schema version: 5.0
|
||||
/// @{
|
||||
constexpr uint32_t CQL_SCHEMA_VERSION_MAJOR = 4u;
|
||||
constexpr uint32_t CQL_SCHEMA_VERSION_MAJOR = 5u;
|
||||
constexpr uint32_t CQL_SCHEMA_VERSION_MINOR = 0u;
|
||||
/// @}
|
||||
|
||||
|
@@ -419,6 +419,9 @@ private:
|
||||
/// @brief Name reserved for the host
|
||||
std::string hostname_;
|
||||
|
||||
/// @brief Lower case name reserved for the host
|
||||
std::string lower_case_hostname_;
|
||||
|
||||
/// @brief User context
|
||||
std::string user_context_;
|
||||
|
||||
@@ -513,6 +516,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
|
||||
"host_ipv4_boot_file_name, "
|
||||
"auth_key, "
|
||||
"hostname, "
|
||||
"lower_case_hostname, "
|
||||
"user_context, "
|
||||
"host_ipv4_client_classes, "
|
||||
"host_ipv6_client_classes, "
|
||||
@@ -536,7 +540,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
|
||||
// id
|
||||
"?, "
|
||||
// host
|
||||
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
|
||||
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, "
|
||||
// denormalized reservation, option
|
||||
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? "
|
||||
") "
|
||||
@@ -952,7 +956,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
|
||||
"option_user_context, "
|
||||
"option_scope_id "
|
||||
"FROM hosts "
|
||||
"WHERE hostname = ? "
|
||||
"WHERE lower_case_hostname = ? "
|
||||
"ALLOW FILTERING "
|
||||
}},
|
||||
|
||||
@@ -989,7 +993,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
|
||||
"option_user_context, "
|
||||
"option_scope_id "
|
||||
"FROM hosts "
|
||||
"WHERE hostname = ? "
|
||||
"WHERE lower_case_hostname = ? "
|
||||
"AND host_ipv4_subnet_id = ? "
|
||||
"ALLOW FILTERING "
|
||||
}},
|
||||
@@ -1027,7 +1031,7 @@ StatementMap CqlHostExchange::tagged_statements_ = {
|
||||
"option_user_context, "
|
||||
"option_scope_id "
|
||||
"FROM hosts "
|
||||
"WHERE hostname = ? "
|
||||
"WHERE lower_case_hostname = ? "
|
||||
"AND host_ipv6_subnet_id = ? "
|
||||
"ALLOW FILTERING "
|
||||
}},
|
||||
@@ -1496,6 +1500,15 @@ CqlHostExchange::prepareExchange(const HostPtr& host,
|
||||
<< " is greater than allowed of " << HOSTNAME_MAX_LEN);
|
||||
}
|
||||
|
||||
// lower_case_hostname: text
|
||||
lower_case_hostname_ = host->getLowerHostname();
|
||||
if (lower_case_hostname_.size() > HOSTNAME_MAX_LEN) {
|
||||
isc_throw(BadValue, "CqlHostExchange::prepareExchange(): lower "
|
||||
"case hostname " << lower_case_hostname_ << " of length "
|
||||
<< lower_case_hostname_.size()
|
||||
<< " is greater than allowed of " << HOSTNAME_MAX_LEN);
|
||||
}
|
||||
|
||||
// user_context: text
|
||||
ConstElementPtr ctx = host->getContext();
|
||||
if (ctx) {
|
||||
@@ -1656,6 +1669,7 @@ CqlHostExchange::createBindForMutation(const HostPtr& host,
|
||||
data.add(&host_ipv4_boot_file_name_);
|
||||
data.add(&auth_key_);
|
||||
data.add(&hostname_);
|
||||
data.add(&lower_case_hostname_);
|
||||
data.add(&user_context_);
|
||||
data.add(&host_ipv4_client_classes_);
|
||||
data.add(&host_ipv6_client_classes_);
|
||||
|
@@ -51,8 +51,8 @@ const int MLM_MYSQL_FETCH_FAILURE = 0;
|
||||
|
||||
/// @name Current database schema version values.
|
||||
//@{
|
||||
const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 8;
|
||||
const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 2;
|
||||
const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 9;
|
||||
const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 0;
|
||||
|
||||
//@}
|
||||
|
||||
|
@@ -17,9 +17,9 @@
|
||||
namespace isc {
|
||||
namespace db {
|
||||
|
||||
/// @brief Define PostgreSQL backend version: 5.1
|
||||
const uint32_t PG_SCHEMA_VERSION_MAJOR = 5;
|
||||
const uint32_t PG_SCHEMA_VERSION_MINOR = 1;
|
||||
/// @brief Define PostgreSQL backend version: 6.0
|
||||
const uint32_t PG_SCHEMA_VERSION_MAJOR = 6;
|
||||
const uint32_t PG_SCHEMA_VERSION_MINOR = 0;
|
||||
|
||||
// Maximum number of parameters that can be used a statement
|
||||
// @todo This allows us to use an initializer list (since we can't
|
||||
|
@@ -6,6 +6,7 @@ sqlscripts_DATA += dhcpdb_drop.cql
|
||||
sqlscripts_DATA += upgrade_1.0_to_2.0.sh
|
||||
sqlscripts_DATA += upgrade_2.0_to_3.0.sh
|
||||
sqlscripts_DATA += upgrade_3.0_to_4.0.sh
|
||||
sqlscripts_DATA += upgrade_4.0_to_5.0.sh
|
||||
sqlscripts_DATA += wipe_data.sh
|
||||
|
||||
EXTRA_DIST = ${sqlscripts_DATA}
|
||||
|
@@ -365,3 +365,16 @@ DELETE FROM schema_version WHERE version=3;
|
||||
INSERT INTO schema_version (version, minor) VALUES(4, 0);
|
||||
|
||||
-- This line concludes database upgrade to version 4.0
|
||||
|
||||
-- This line starts database upgrade to version 5.0
|
||||
|
||||
-- Add the lower case hostname column to reservations.
|
||||
ALTER TABLE hosts ADD lower_case_hostname VARCHAR;
|
||||
|
||||
-- Make the lower case hostname an index.
|
||||
CREATE INDEX IF NOT EXISTS hostsindex8 ON hosts (lower_case_hostname);
|
||||
|
||||
DELETE FROM schema_version WHERE version=4;
|
||||
INSERT INTO schema_version (version, minor) VALUES(5, 0);
|
||||
|
||||
-- This line concludes database upgrade to version 5.0
|
||||
|
@@ -48,5 +48,6 @@ DROP INDEX IF EXISTS hostsindex4;
|
||||
DROP INDEX IF EXISTS hostsindex5;
|
||||
DROP INDEX IF EXISTS hostsindex6;
|
||||
DROP INDEX IF EXISTS hostsindex7;
|
||||
DROP INDEX IF EXISTS hostsindex8;
|
||||
|
||||
DROP INDEX IF EXISTS logsindex;
|
||||
|
197
src/share/database/scripts/cql/upgrade_4.0_to_5.0.sh.in
Normal file
197
src/share/database/scripts/cql/upgrade_4.0_to_5.0.sh.in
Normal file
@@ -0,0 +1,197 @@
|
||||
#!/bin/sh
|
||||
|
||||
prefix=@prefix@
|
||||
# Include utilities. Use installed version if available and
|
||||
# use build version if it isn't.
|
||||
if [ -e "@datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh" ]; then
|
||||
. @datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh
|
||||
else
|
||||
. @abs_top_builddir@/src/bin/admin/admin-utils.sh
|
||||
fi
|
||||
|
||||
# Need a path for temporary files created during data update
|
||||
# Use the state directory in the install path directory if it exists, otherwise
|
||||
# use the build tree
|
||||
if [ -e "@localstatedir@/lib/@PACKAGE_NAME@" ]; then
|
||||
temp_file_dir="@localstatedir@/lib/@PACKAGE_NAME@"
|
||||
else
|
||||
temp_file_dir="@abs_top_builddir@/src/share/database/scripts/cql"
|
||||
fi
|
||||
|
||||
cqlargs=$@
|
||||
|
||||
# Ensures the current schema version is 4.0. If not it exits.
|
||||
check_version() {
|
||||
version=$(cql_version $cqlargs)
|
||||
|
||||
if [ "${version}" != "4.0" ]; then
|
||||
printf "This script upgrades 4.0 to 5.0. Reported version is %s. Skipping upgrade.\n" "${version}"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Peforms the schema changes from 4.0 to 5.0
|
||||
update_schema() {
|
||||
cqlsh $cqlargs <<EOF
|
||||
-- This line starts database upgrade to version 5.0
|
||||
|
||||
-- Add the lower case hostname column to reservations.
|
||||
ALTER TABLE hosts ADD lower_case_hostname VARCHAR;
|
||||
|
||||
-- Make the lower case hostname an index.
|
||||
CREATE INDEX IF NOT EXISTS hostsindex8 ON hosts (lower_case_hostname);
|
||||
|
||||
DELETE FROM schema_version WHERE version=4;
|
||||
INSERT INTO schema_version (version, minor) VALUES(5, 0);
|
||||
|
||||
-- This line concludes database upgrade to version 5.0
|
||||
EOF
|
||||
|
||||
if [ "$?" -ne 0 ]
|
||||
then
|
||||
echo Schema udpate FAILED!
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to delete temporary update files
|
||||
clean_up() {
|
||||
# clean up the files
|
||||
if [ -e "$export_file" ]
|
||||
then
|
||||
rm $export_file
|
||||
fi
|
||||
|
||||
if [ -e "$update_file" ]
|
||||
then
|
||||
rm $update_file
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to clean up and exit the script gracefully
|
||||
#
|
||||
# Called by update_host_data()
|
||||
#
|
||||
# Parameters:
|
||||
# status - integer value to pass to sh:exit
|
||||
# explanation - "quoted" text message to emit to stdout
|
||||
exit_now() {
|
||||
status=$1;shift
|
||||
explanation=$1
|
||||
|
||||
clean_up
|
||||
if [ "$status" -eq 0 ]
|
||||
then
|
||||
echo "Data Update SUCCESS! $explanation"
|
||||
else
|
||||
echo "Data Update FAILURE! $explanation"
|
||||
fi
|
||||
|
||||
exit $status
|
||||
}
|
||||
|
||||
# This function adds host 'lower_case_hostname' column.
|
||||
#
|
||||
# After exhausting the export file, the update file is submitted to
|
||||
# cqlsh for execution.
|
||||
#
|
||||
# No parameters.
|
||||
update_host_data() {
|
||||
export_file="$temp_file_dir/cql_export.csv"
|
||||
update_file="$temp_file_dir/cql_update.cql"
|
||||
|
||||
clean_up
|
||||
|
||||
# Fetch hosts data so we have primary key components and hostname.
|
||||
echo "Exporting hostnames to $export_file ..."
|
||||
query="COPY hosts (key, id, hostname) TO '$export_file'"
|
||||
|
||||
cqlsh $cqlargs -e "$query"
|
||||
if [ "$?" -ne 0 ]
|
||||
then
|
||||
exit_now 1 "Cassandra get hostname failed! Could not update data!"
|
||||
fi
|
||||
|
||||
# Strip the carriage returns that CQL insists on adding.
|
||||
if [ -e "$export_file" ]
|
||||
then
|
||||
cat $export_file | tr -d '\015' > $export_file.2
|
||||
mv $export_file.2 $export_file
|
||||
else
|
||||
# Shouldn't happen but then again we're talking about CQL here
|
||||
exit_now 1 "Cassandra export file $export_file is missing?"
|
||||
fi
|
||||
|
||||
# Iterate through the exported data, accumulating update statements,
|
||||
# one for each reservation that needs updating. We should have one
|
||||
# host per line.
|
||||
line_cnt=0;
|
||||
update_cnt=0;
|
||||
|
||||
while read -r line
|
||||
do
|
||||
line_cnt=$((line_cnt + 1));
|
||||
xIFS="$IFS"
|
||||
IFS=$','
|
||||
|
||||
i=1
|
||||
hostname=
|
||||
# Parse the column values
|
||||
for val in $line
|
||||
do
|
||||
case $i in
|
||||
1)
|
||||
key="$val"
|
||||
;;
|
||||
2)
|
||||
host_id="$val"
|
||||
;;
|
||||
3)
|
||||
hostname="$val"
|
||||
;;
|
||||
*)
|
||||
# We're going to assume that since any error is fatal
|
||||
exit_now 1 "Line# $line_cnt, too many values, wrong or corrupt file"
|
||||
;;
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
if [ "$i" -lt 3 ]
|
||||
then
|
||||
# We're going to assume that since any error is fatal
|
||||
exit_now 1 "Line# $line_cnt, too few values, wrong or corrupt file"
|
||||
fi
|
||||
|
||||
# If the hostname was not null set the lower case value
|
||||
if [ "$hostname" != "" ]
|
||||
then
|
||||
lower=$(echo $hostname | tr '[:upper:]' '[:lower:]')
|
||||
echo "update hosts set lower_case_hostname = '$lower' where key = $key and id = $host_id;" >> $update_file
|
||||
update_cnt=$((update_cnt + 1))
|
||||
fi
|
||||
|
||||
IFS="$xIFS"
|
||||
done < $export_file
|
||||
|
||||
# If we didn't record any updates, then hey, we're good to go!
|
||||
if [ "$update_cnt" -eq 0 ]
|
||||
then
|
||||
exit_now 0 "Completed successfully: No updates were needed"
|
||||
fi
|
||||
|
||||
# We have at least one update in the update file, so submit it # to cqlsh.
|
||||
echo "$update_cnt update statements written to $update_file"
|
||||
echo "Running the updates..."
|
||||
cqlsh $cqlargs -f "$update_file"
|
||||
if [ "$?" -ne 0 ]
|
||||
then
|
||||
exit_now 1 "Cassandra updates failed"
|
||||
fi
|
||||
|
||||
exit_now 0 "Updated $update_cnt of $line_cnt records"
|
||||
}
|
||||
|
||||
check_version
|
||||
update_schema
|
||||
update_host_data
|
@@ -15,6 +15,7 @@ sqlscripts_DATA += upgrade_6.0_to_7.0.sh
|
||||
sqlscripts_DATA += upgrade_7.0_to_8.0.sh
|
||||
sqlscripts_DATA += upgrade_8.0_to_8.1.sh
|
||||
sqlscripts_DATA += upgrade_8.1_to_8.2.sh
|
||||
sqlscripts_DATA += upgrade_8.2_to_9.0.sh
|
||||
sqlscripts_DATA += wipe_data.sh
|
||||
|
||||
DISTCLEANFILES = upgrade_1.0_to_2.0.sh
|
||||
@@ -28,6 +29,7 @@ DISTCLEANFILES += upgrade_5.2_to_6.0.sh
|
||||
DISTCLEANFILES += upgrade_6.0_to_7.0.sh
|
||||
DISTCLEANFILES += upgrade_7.0_to_8.0.sh
|
||||
DISTCLEANFILES += upgrade_8.1_to_8.2.sh
|
||||
DISTCLEANFILES += upgrade_8.2_to_9.0.sh
|
||||
DISTCLEANFILES += wipe_data.sh
|
||||
|
||||
EXTRA_DIST = ${sqlscripts_DATA}
|
||||
|
@@ -2782,6 +2782,15 @@ SET version = '8', minor = '2';
|
||||
|
||||
# This line concludes database upgrade to version 8.2.
|
||||
|
||||
# Create hostname index for host reservations
|
||||
CREATE INDEX hosts_by_hostname ON hosts (hostname);
|
||||
|
||||
# Update the schema version number
|
||||
UPDATE schema_version
|
||||
SET version = '9', minor = '0';
|
||||
|
||||
# This line concludes database upgrade to version 9.0.
|
||||
|
||||
|
||||
# Notes:
|
||||
#
|
||||
|
34
src/share/database/scripts/mysql/upgrade_8.2_to_9.0.sh.in
Normal file
34
src/share/database/scripts/mysql/upgrade_8.2_to_9.0.sh.in
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
prefix=@prefix@
|
||||
# Include utilities. Use installed version if available and
|
||||
# use build version if it isn't.
|
||||
if [ -e @datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh ]; then
|
||||
. @datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh
|
||||
else
|
||||
. @abs_top_builddir@/src/bin/admin/admin-utils.sh
|
||||
fi
|
||||
|
||||
VERSION=`mysql_version "$@"`
|
||||
|
||||
if [ "$VERSION" != "8.2" ]; then
|
||||
printf "This script upgrades 8.2 to 9.0. Reported version is $VERSION. Skipping upgrade.\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mysql "$@" <<EOF
|
||||
|
||||
# Create hostname index for host reservations
|
||||
CREATE INDEX hosts_by_hostname ON hosts (hostname);
|
||||
|
||||
# Update the schema version number
|
||||
UPDATE schema_version
|
||||
SET version = '9', minor = '0';
|
||||
|
||||
# This line concludes database upgrade to version 9.0.
|
||||
|
||||
EOF
|
||||
|
||||
RESULT=$?
|
||||
|
||||
exit $?
|
@@ -11,6 +11,7 @@ sqlscripts_DATA += upgrade_3.2_to_3.3.sh
|
||||
sqlscripts_DATA += upgrade_3.3_to_4.0.sh
|
||||
sqlscripts_DATA += upgrade_4.0_to_5.0.sh
|
||||
sqlscripts_DATA += upgrade_5.0_to_5.1.sh
|
||||
sqlscripts_DATA += upgrade_5.1_to_6.0.sh
|
||||
sqlscripts_DATA += wipe_data.sh
|
||||
|
||||
DISTCLEANFILES = upgrade_1.0_to_2.0.sh
|
||||
@@ -21,6 +22,7 @@ DISTCLEANFILES += upgrade_3.2_to_3.3.sh
|
||||
DISTCLEANFILES += upgrade_3.3_to_4.0.sh
|
||||
DISTCLEANFILES += upgrade_4.0_to_5.0.sh
|
||||
DISTCLEANFILES += upgrade_5.0_to_5.1.sh
|
||||
DISTCLEANFILES += upgrade_5.1_to_6.0.sh
|
||||
DISTCLEANFILES += wipe_data.sh
|
||||
|
||||
EXTRA_DIST = ${sqlscripts_DATA}
|
||||
|
@@ -887,7 +887,21 @@ UPDATE schema_version
|
||||
|
||||
-- Schema 5.1 specification ends here.
|
||||
|
||||
-- Commit the script transaction.
|
||||
-- Upgrade to schema 6.0 begins here:
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
-- Create a lower case hostname index.
|
||||
CREATE INDEX hosts_by_hostname ON hosts (lower(hostname))
|
||||
WHERE hostname IS NOT NULL;
|
||||
|
||||
-- Set 6.0 schema version.
|
||||
UPDATE schema_version
|
||||
SET version = '6', minor = '0';
|
||||
|
||||
-- Schema 5.1a specification ends here.
|
||||
|
||||
-- Commit the script transaction
|
||||
COMMIT;
|
||||
|
||||
-- Notes:
|
||||
|
39
src/share/database/scripts/pgsql/upgrade_5.1_to_6.0.sh.in
Normal file
39
src/share/database/scripts/pgsql/upgrade_5.1_to_6.0.sh.in
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
prefix=@prefix@
|
||||
# Include utilities. Use installed version if available and
|
||||
# use build version if it isn't.
|
||||
if [ -e @datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh ]; then
|
||||
. @datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh
|
||||
else
|
||||
. @abs_top_builddir@/src/bin/admin/admin-utils.sh
|
||||
fi
|
||||
|
||||
VERSION=`pgsql_version "$@"`
|
||||
|
||||
if [ "$VERSION" != "5.1" ]; then
|
||||
printf "This script upgrades 5.1 to 6.0. Reported version is $VERSION. Skipping upgrade.\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
psql "$@" >/dev/null <<EOF
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
-- Create a lower case hostname index.
|
||||
CREATE INDEX hosts_by_hostname ON hosts (lower(hostname))
|
||||
WHERE hostname IS NOT NULL;
|
||||
|
||||
-- Set 6.0 schema version.
|
||||
UPDATE schema_version
|
||||
SET version = '6', minor = '0';
|
||||
|
||||
-- Schema 5.1a specification ends here.
|
||||
|
||||
-- Commit the script transaction
|
||||
COMMIT;
|
||||
|
||||
EOF
|
||||
|
||||
exit $RESULT
|
||||
|
Reference in New Issue
Block a user