kea-manage/lib/database/postgres/queries.go
Matthew Stobbs a78f001a41 working configuration for reservations
- Make ipv4 reservations in kea by directly writing to the database
- uses same configuration file as database configuration under the
heading reservationV4
2024-09-24 14:43:54 -06:00

27 lines
849 B
Go

package postgres
const insertHostReservation = `INSERT INTO hosts (dhcp_identifier,
dhcp_identifier_type,
dhcp4_subnet_id,
ipv4_address,
hostname)
VALUES (DECODE(REPLACE($1, ':', ''), 'hex'), $2, $3, (SELECT ($4::inet - '0.0.0.0'::inet)), $5);`
const getHostIDWithMacAddr = `SELECT host_id
FROM hosts
WHERE dhcp4_subnet_id = $1
AND dhcp_identifier_type = $2
AND dhcp_identifier = (DECODE(REPLACE($3, ':', ''), 'hex'));`
const insertIfNotExists = `INSERT INTO hosts (dhcp_identifier,
dhcp_identifier_type,
dhcp4_subnet_id,
ipv4_address,
hostname)
SELECT DECODE(REPLACE($1, ':', ''), 'hex'), $2, $3, (SELECT ($4::inet - '0.0.0.0'::inet)), $5
WHERE NOT EXISTS (
SELECT host_id FROM hosts
WHERE dhcp4_subnet_id = $3
AND dhcp_identifier_type = $2
AND dhcp_identifier = DECODE(REPLACE($1, ':', ''), 'hex'));`