...
 
Commits (5)
......@@ -3,7 +3,9 @@
Created data model for services and implemented a mechanism to
to automatically associate a new Kea application with a High
Availability service when the application is configured to use
High Availability. This mechanism is not yet used in the UI.
High Availability. This mechanism is not yet used by the server
when the Kea application is added via the UI. The usage of
this mechanism will be added in the future tickets.
(Gitlab #137)
* 29 [func] godfryd
......
......@@ -19,8 +19,11 @@ func init() {
-- This enum is used in the ha_service table to indicate if
-- the given service is the DHCPv4 or DHCPv6 High Availability
-- service.
CREATE TYPE HADHCPTYPE AS ENUM
('dhcp4', 'dhcp6');
DO $$ BEGIN
CREATE TYPE HADHCPTYPE AS ENUM ('dhcp4', 'dhcp6');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
-- Trigger function generating a default name for a new service.
-- The name is only generated if the name specified by the
......@@ -58,13 +61,17 @@ func init() {
);
-- Generate a name for an inserted service if it is blank.
CREATE TRIGGER service_before_insert
BEFORE INSERT OR UPDATE ON service
FOR EACH ROW EXECUTE PROCEDURE service_name_gen();
DO $$ BEGIN
CREATE TRIGGER service_before_insert
BEFORE INSERT OR UPDATE ON service
FOR EACH ROW EXECUTE PROCEDURE service_name_gen();
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
-- This table includes a details about the DHCP High Availability
-- service. This table is in 1:1 relationship with the service table.
-- A new entry should be created in this table of the ha_type in the
-- A new entry should be created in this table of the type in the
-- service table is set to ha_dhcp.
CREATE TABLE IF NOT EXISTS ha_service (
id BIGSERIAL NOT NULL,
......@@ -105,9 +112,13 @@ func init() {
END;
$function$;
CREATE TRIGGER ha_service_before_insert_update
BEFORE INSERT OR UPDATE ON ha_service
FOR EACH ROW EXECUTE PROCEDURE ha_service_type_set();
DO $$ BEGIN
CREATE TRIGGER ha_service_before_insert_update
BEFORE INSERT OR UPDATE ON ha_service
FOR EACH ROW EXECUTE PROCEDURE ha_service_type_set();
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
-- Provides M:M relationship between app and service tables.
CREATE TABLE IF NOT EXISTS app_to_service (
......
......@@ -240,7 +240,7 @@ func TestGetHAHooksLibrary(t *testing.T) {
}
}
// There should be two distinct peers found.
// There should be three distinct peers found.
require.Len(t, peersFound, 3)
}
......