Merge "Set up DB schema in DevStack plugin using Alembic"
This commit is contained in:
commit
4681262d82
|
@ -48,6 +48,10 @@ postgresql:
|
|||
database: mon
|
||||
|
||||
notification_types:
|
||||
plugins:
|
||||
- monasca_notification.plugins.email_notifier:EmailNotifier
|
||||
- monasca_notification.plugins.webhook_notifier:WebhookNotifier
|
||||
- monasca_notification.plugins.pagerduty_notifier:PagerdutyNotifier
|
||||
|
||||
email:
|
||||
server: "localhost"
|
||||
|
|
|
@ -1,198 +0,0 @@
|
|||
/*
|
||||
* (C) Copyright 2015,2016 Hewlett Packard Enterprise Development LP
|
||||
* Copyright 2017 FUJITSU LIMITED
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
USE `mon`;
|
||||
SET foreign_key_checks = 0;
|
||||
|
||||
/*
|
||||
* Enum tables
|
||||
*/
|
||||
CREATE TABLE `alarm_state` (
|
||||
`name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `alarm_definition_severity` (
|
||||
`name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `notification_method_type` (
|
||||
`name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `alarm` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`alarm_definition_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`state` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`lifecycle_state` varchar(50) DEFAULT NULL,
|
||||
`link` varchar(512) DEFAULT NULL,
|
||||
`created_at` datetime NOT NULL,
|
||||
`state_updated_at` datetime,
|
||||
`updated_at` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `alarm_definition_id` (`alarm_definition_id`),
|
||||
CONSTRAINT `fk_alarm_definition_id` FOREIGN KEY (`alarm_definition_id`) REFERENCES `alarm_definition` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_alarm_alarm_state` FOREIGN KEY (`state`) REFERENCES `alarm_state` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `alarm_action` (
|
||||
`alarm_definition_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`alarm_state` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`action_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`alarm_definition_id`,`alarm_state`,`action_id`),
|
||||
CONSTRAINT `fk_alarm_action_alarm_definition_id` FOREIGN KEY (`alarm_definition_id`) REFERENCES `alarm_definition` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_alarm_action_notification_method_id` FOREIGN KEY (`action_id`) REFERENCES `notification_method` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_alarm_action_alarm_state` FOREIGN KEY (`alarm_state`) REFERENCES `alarm_state` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `alarm_definition` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`tenant_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`expression` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`severity` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`match_by` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT '',
|
||||
`actions_enabled` tinyint(1) NOT NULL DEFAULT '1',
|
||||
`created_at` datetime NOT NULL,
|
||||
`updated_at` datetime NOT NULL,
|
||||
`deleted_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tenant_id` (`tenant_id`),
|
||||
KEY `deleted_at` (`deleted_at`),
|
||||
CONSTRAINT `fk_alarm_definition_severity` FOREIGN KEY (`severity`) REFERENCES `alarm_definition_severity` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `alarm_metric` (
|
||||
`alarm_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`metric_definition_dimensions_id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
PRIMARY KEY (`alarm_id`,`metric_definition_dimensions_id`),
|
||||
KEY `alarm_id` (`alarm_id`),
|
||||
KEY `metric_definition_dimensions_id` (`metric_definition_dimensions_id`),
|
||||
CONSTRAINT `fk_alarm_id` FOREIGN KEY (`alarm_id`) REFERENCES `alarm` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `metric_definition` (
|
||||
`id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`tenant_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`region` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `metric_definition_dimensions` (
|
||||
`id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`metric_definition_id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`metric_dimension_set_id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
KEY `metric_definition_id` (`metric_definition_id`),
|
||||
KEY `metric_dimension_set_id` (`metric_dimension_set_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
/*
|
||||
* mysql limits the size of a unique key to 767 bytes. The utf8mb4 charset requires
|
||||
* 4 bytes to be allocated for each character while the utf8 charset requires 3 bytes.
|
||||
* The utf8 charset should be sufficient for any reasonable characters, see the definition
|
||||
* of supplementary characters for what it doesn't support.
|
||||
* Even with utf8, the unique key length would be 785 bytes so only a subset of the
|
||||
* name is used. Potentially the size of the name should be limited to 250 characters
|
||||
* which would resolve this issue.
|
||||
*
|
||||
* The unique key is required to allow high performance inserts without doing a select by using
|
||||
* the "insert into metric_dimension ... on duplicate key update dimension_set_id=dimension_set_id
|
||||
* syntax
|
||||
*/
|
||||
CREATE TABLE `metric_dimension` (
|
||||
`dimension_set_id` binary(20) NOT NULL DEFAULT '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
|
||||
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
`value` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
|
||||
UNIQUE KEY `metric_dimension_key` (`dimension_set_id`,`name`(252)),
|
||||
KEY `dimension_set_id` (`dimension_set_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='PRIMARY KEY (`id`)';
|
||||
|
||||
CREATE TABLE `notification_method` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`tenant_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`name` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`type` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`address` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`period` int NOT NULL DEFAULT 0,
|
||||
`created_at` datetime NOT NULL,
|
||||
`updated_at` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_alarm_noticication_method_type` FOREIGN KEY (`type`) REFERENCES `notification_method_type` (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `sub_alarm_definition` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`alarm_definition_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`function` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`metric_name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
`operator` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`threshold` double NOT NULL,
|
||||
`period` int(11) NOT NULL,
|
||||
`periods` int(11) NOT NULL,
|
||||
`is_deterministic` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`created_at` datetime NOT NULL,
|
||||
`updated_at` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `fk_sub_alarm_definition` (`alarm_definition_id`),
|
||||
CONSTRAINT `fk_sub_alarm_definition` FOREIGN KEY (`alarm_definition_id`) REFERENCES `alarm_definition` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `sub_alarm_definition_dimension` (
|
||||
`sub_alarm_definition_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`dimension_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`value` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||
CONSTRAINT `fk_sub_alarm_definition_dimension` FOREIGN KEY (`sub_alarm_definition_id`) REFERENCES `sub_alarm_definition` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE `sub_alarm` (
|
||||
`id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`alarm_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`sub_expression_id` varchar(36) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
|
||||
`expression` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`created_at` datetime NOT NULL,
|
||||
`updated_at` datetime NOT NULL,
|
||||
`state` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'OK',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `fk_sub_alarm` (`alarm_id`),
|
||||
KEY `fk_sub_alarm_expr` (`sub_expression_id`),
|
||||
CONSTRAINT `fk_sub_alarm` FOREIGN KEY (`alarm_id`) REFERENCES `alarm` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_sub_alarm_state` FOREIGN KEY (`state`) REFERENCES `alarm_state` (`name`),
|
||||
CONSTRAINT `fk_sub_alarm_expr` FOREIGN KEY (`sub_expression_id`) REFERENCES `sub_alarm_definition` (`id`)
|
||||
);
|
||||
|
||||
SET foreign_key_checks = 1;
|
||||
|
||||
/* provide data for enum tables */
|
||||
insert into `alarm_state` values ('UNDETERMINED');
|
||||
insert into `alarm_state` values ('OK');
|
||||
insert into `alarm_state` values ('ALARM');
|
||||
|
||||
insert into `alarm_definition_severity` values ('LOW');
|
||||
insert into `alarm_definition_severity` values ('MEDIUM');
|
||||
insert into `alarm_definition_severity` values ('HIGH');
|
||||
insert into `alarm_definition_severity` values ('CRITICAL');
|
||||
|
||||
insert into `notification_method_type` values ('EMAIL');
|
||||
insert into `notification_method_type` values ('WEBHOOK');
|
||||
insert into `notification_method_type` values ('PAGERDUTY');
|
||||
/* provide data for enum tables */
|
|
@ -1,227 +0,0 @@
|
|||
---
|
||||
-- # Copyright 2017 FUJITSU LIMITED
|
||||
---
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET client_encoding = 'UTF8';
|
||||
SET standard_conforming_strings = on;
|
||||
SET check_function_bodies = false;
|
||||
SET client_min_messages = warning;
|
||||
|
||||
---
|
||||
-- enum tables
|
||||
---
|
||||
|
||||
CREATE TABLE alarm_state (
|
||||
name character varying(20) NOT NULL,
|
||||
CONSTRAINT alarm_state_pkey PRIMARY KEY (name)
|
||||
);
|
||||
|
||||
CREATE TABLE alarm_definition_severity (
|
||||
name character varying(20) NOT NULL,
|
||||
CONSTRAINT alarm_definition_severity_pkey PRIMARY KEY (name)
|
||||
);
|
||||
|
||||
CREATE TABLE notification_method_type (
|
||||
name character varying(20) NOT NULL,
|
||||
CONSTRAINT notification_method_type_pkey PRIMARY KEY (name)
|
||||
);
|
||||
|
||||
---
|
||||
-- tables
|
||||
---
|
||||
|
||||
CREATE TABLE alarm (
|
||||
id character varying(36) NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
lifecycle_state character varying(50),
|
||||
link character varying(512),
|
||||
state character varying(20) NOT NULL,
|
||||
state_updated_at timestamp without time zone,
|
||||
alarm_definition_id character varying(36) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE alarm_action (
|
||||
action_id character varying(36) NOT NULL,
|
||||
alarm_state character varying(20) NOT NULL,
|
||||
alarm_definition_id character varying(36) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE alarm_definition (
|
||||
id character varying(36) NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
actions_enabled boolean NOT NULL,
|
||||
deleted_at timestamp without time zone,
|
||||
description character varying(255),
|
||||
expression text NOT NULL,
|
||||
match_by character varying(255),
|
||||
name character varying(255) NOT NULL,
|
||||
severity character varying(20) NOT NULL,
|
||||
tenant_id character varying(36) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE alarm_metric (
|
||||
metric_definition_dimensions_id bytea NOT NULL,
|
||||
alarm_id character varying(36) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE metric_definition (
|
||||
id bytea NOT NULL,
|
||||
name character varying(255) NOT NULL,
|
||||
region character varying(255) NOT NULL,
|
||||
tenant_id character varying(36) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE metric_definition_dimensions (
|
||||
id bytea NOT NULL,
|
||||
metric_definition_id bytea NOT NULL,
|
||||
metric_dimension_set_id bytea NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE metric_dimension (
|
||||
dimension_set_id bytea NOT NULL,
|
||||
name character varying(255) NOT NULL,
|
||||
value character varying(255) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE notification_method (
|
||||
id character varying(36) NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
address character varying(512) NOT NULL,
|
||||
name character varying(250),
|
||||
tenant_id character varying(36) NOT NULL,
|
||||
type character varying(20) NOT NULL,
|
||||
period integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE sub_alarm (
|
||||
id character varying(36) NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
expression text NOT NULL,
|
||||
alarm_id character varying(36) NOT NULL,
|
||||
sub_expression_id character varying(36),
|
||||
state character varying(20) NOT NULL DEFAULT 'OK'
|
||||
);
|
||||
|
||||
CREATE TABLE sub_alarm_definition (
|
||||
id character varying(36) NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL,
|
||||
function character varying(10) NOT NULL,
|
||||
metric_name character varying(100),
|
||||
operator character varying(5) NOT NULL,
|
||||
period integer NOT NULL,
|
||||
periods integer NOT NULL,
|
||||
threshold double precision NOT NULL,
|
||||
is_deterministic boolean NOT NULL,
|
||||
alarm_definition_id character varying(36) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE sub_alarm_definition_dimension (
|
||||
dimension_name character varying(255) NOT NULL,
|
||||
value character varying(255),
|
||||
sub_alarm_definition_id character varying(36) NOT NULL
|
||||
);
|
||||
|
||||
---
|
||||
-- primary keys
|
||||
---
|
||||
ALTER TABLE ONLY alarm_action
|
||||
ADD CONSTRAINT alarm_action_pkey PRIMARY KEY (action_id, alarm_definition_id, alarm_state);
|
||||
|
||||
ALTER TABLE ONLY alarm_definition
|
||||
ADD CONSTRAINT alarm_definition_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY alarm_metric
|
||||
ADD CONSTRAINT alarm_metric_pkey PRIMARY KEY (alarm_id, metric_definition_dimensions_id);
|
||||
|
||||
ALTER TABLE ONLY alarm
|
||||
ADD CONSTRAINT alarm_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY metric_definition_dimensions
|
||||
ADD CONSTRAINT metric_definition_dimensions_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY metric_definition
|
||||
ADD CONSTRAINT metric_definition_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY notification_method
|
||||
ADD CONSTRAINT notification_method_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY sub_alarm_definition_dimension
|
||||
ADD CONSTRAINT sub_alarm_definition_dimension_pkey PRIMARY KEY (dimension_name, sub_alarm_definition_id);
|
||||
|
||||
ALTER TABLE ONLY sub_alarm_definition
|
||||
ADD CONSTRAINT sub_alarm_definition_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY sub_alarm
|
||||
ADD CONSTRAINT sub_alarm_pkey PRIMARY KEY (id);
|
||||
|
||||
---
|
||||
-- indexes
|
||||
---
|
||||
|
||||
CREATE INDEX alarm_id ON alarm_metric USING btree (alarm_id);
|
||||
CREATE INDEX deleted_at ON alarm_definition USING btree (deleted_at);
|
||||
CREATE INDEX dimension_set_id ON metric_dimension USING btree (dimension_set_id);
|
||||
CREATE INDEX metric_definition_dimensions_id ON alarm_metric USING btree (metric_definition_dimensions_id);
|
||||
CREATE INDEX metric_definition_id ON metric_definition_dimensions USING btree (metric_definition_id);
|
||||
CREATE UNIQUE INDEX metric_dimension_key ON metric_dimension USING btree (dimension_set_id, name);
|
||||
CREATE INDEX metric_dimension_set_id ON metric_definition_dimensions USING btree (metric_dimension_set_id);
|
||||
CREATE INDEX tenant_id ON alarm_definition USING btree (tenant_id);
|
||||
|
||||
---
|
||||
-- foreign key constraints
|
||||
---
|
||||
ALTER TABLE ONLY alarm_action
|
||||
ADD CONSTRAINT fk_alarm_action_alarm_definition FOREIGN KEY (alarm_definition_id) REFERENCES alarm_definition(id);
|
||||
|
||||
ALTER TABLE ONLY sub_alarm
|
||||
ADD CONSTRAINT fk_sub_alarm_sub_alarm_definition FOREIGN KEY (sub_expression_id) REFERENCES sub_alarm_definition(id);
|
||||
|
||||
ALTER TABLE ONLY alarm
|
||||
ADD CONSTRAINT fk_alarm_alarm_definition FOREIGN KEY (alarm_definition_id) REFERENCES alarm_definition(id);
|
||||
|
||||
ALTER TABLE ONLY sub_alarm_definition_dimension
|
||||
ADD CONSTRAINT fk_sub_alarm_def_dim_sub_alarm_def FOREIGN KEY (sub_alarm_definition_id) REFERENCES sub_alarm_definition(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY alarm_metric
|
||||
ADD CONSTRAINT fk_alarm_metric_alamr FOREIGN KEY (alarm_id) REFERENCES alarm(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY sub_alarm_definition
|
||||
ADD CONSTRAINT fk_sub_alarm_def_alarm_def FOREIGN KEY (alarm_definition_id) REFERENCES alarm_definition(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY sub_alarm
|
||||
ADD CONSTRAINT fk_sub_alarm_alarm FOREIGN KEY (alarm_id) REFERENCES alarm(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY alarm
|
||||
ADD CONSTRAINT fk_alarm_state FOREIGN KEY (state) REFERENCES alarm_state (name);
|
||||
|
||||
ALTER TABLE ONLY alarm_action
|
||||
ADD CONSTRAINT fk_alarm_action_state FOREIGN KEY (alarm_state) REFERENCES alarm_state (name);
|
||||
|
||||
ALTER TABLE ONLY alarm_definition
|
||||
ADD CONSTRAINT fk_alarm_definition_severity FOREIGN KEY (severity) REFERENCES alarm_definition_severity (name);
|
||||
|
||||
ALTER TABLE ONLY notification_method
|
||||
ADD CONSTRAINT fk_alarm_noticication_method_type FOREIGN KEY (type) REFERENCES notification_method_type (name);
|
||||
|
||||
---
|
||||
-- data for enum tables
|
||||
---
|
||||
insert into alarm_state values ('UNDETERMINED');
|
||||
insert into alarm_state values ('OK');
|
||||
insert into alarm_state values ('ALARM');
|
||||
|
||||
insert into alarm_definition_severity values ('LOW');
|
||||
insert into alarm_definition_severity values ('MEDIUM');
|
||||
insert into alarm_definition_severity values ('HIGH');
|
||||
insert into alarm_definition_severity values ('CRITICAL');
|
||||
|
||||
insert into notification_method_type values ('EMAIL');
|
||||
insert into notification_method_type values ('WEBHOOK');
|
||||
insert into notification_method_type values ('PAGERDUTY');
|
|
@ -46,7 +46,7 @@ install_monasca-notification() {
|
|||
if python3_enabled; then
|
||||
enable_python3_package monasca-notification
|
||||
fi
|
||||
setup_develop ${MONASCA_NOTIFICATION_DIR}
|
||||
setup_develop ${MONASCA_NOTIFICATION_DIR} jira_plugin
|
||||
# see devstack/plugin.sh
|
||||
install_monasca_common
|
||||
install_monasca_statsd
|
||||
|
|
|
@ -148,14 +148,13 @@ function install_monasca {
|
|||
|
||||
function configure_monasca {
|
||||
echo_summary "Configuring Monasca"
|
||||
#(trebskit) Installing should happen in post-config phase
|
||||
# at this point databases is already configured
|
||||
install_schema
|
||||
|
||||
configure_storm
|
||||
configure_ui
|
||||
configure_monasca_api
|
||||
configure_monasca-notification
|
||||
configure_monasca-persister
|
||||
install_schema
|
||||
}
|
||||
|
||||
function configure_system_encoding_format {
|
||||
|
@ -653,17 +652,9 @@ function install_schema_kafka_topics {
|
|||
function install_schema_alarm_database {
|
||||
local databaseName="mon"
|
||||
|
||||
# copy the file with the $DATABASE_TYPE to just know what DB is used
|
||||
sudo cp -f "${MONASCA_API_DIR}"/devstack/files/schema/mon_$DATABASE_TYPE.sql $MONASCA_SCHEMA_DIR/mon_$DATABASE_TYPE.sql
|
||||
sudo ln -sf $MONASCA_SCHEMA_DIR/mon_$DATABASE_TYPE.sql $MONASCA_SCHEMA_DIR/mon.sql
|
||||
sudo chmod 0644 $MONASCA_SCHEMA_DIR/mon.sql
|
||||
sudo chown root:root $MONASCA_SCHEMA_DIR/mon.sql
|
||||
|
||||
recreate_database $databaseName
|
||||
if is_service_enabled mysql; then
|
||||
sudo mysql -u$DATABASE_USER -p$DATABASE_PASSWORD -h$MYSQL_HOST < $MONASCA_SCHEMA_DIR/mon.sql
|
||||
elif is_service_enabled postgresql; then
|
||||
sudo -u root sudo -u postgres -i psql -d $databaseName -f $MONASCA_SCHEMA_DIR/mon.sql
|
||||
if is_service_enabled mysql postgresql; then
|
||||
recreate_database $databaseName
|
||||
$MONASCA_API_BIN_DIR/monasca_db upgrade
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -401,25 +401,22 @@ def upgrade():
|
|||
op.create_table(
|
||||
'sub_alarm',
|
||||
sa.Column('id',
|
||||
sa.dialects.mysql.VARCHAR(length=36,
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
sa.String(length=36),
|
||||
nullable=False),
|
||||
sa.Column('alarm_id',
|
||||
sa.dialects.mysql.VARCHAR(length=36,
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
sa.String(length=36),
|
||||
sa.ForeignKey('alarm.id', ondelete='CASCADE',
|
||||
name='fk_sub_alarm'),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('sub_expression_id',
|
||||
sa.dialects.mysql.VARCHAR(length=36,
|
||||
collation='utf8mb4_unicode_ci'),
|
||||
sa.String(length=36),
|
||||
sa.ForeignKey('sub_alarm_definition.id',
|
||||
name='fk_sub_alarm_expr'),
|
||||
nullable=False,
|
||||
server_default=''),
|
||||
sa.Column('expression',
|
||||
sa.dialects.mysql.LONGTEXT(collation='utf8mb4_unicode_ci'),
|
||||
sa.dialects.mysql.LONGTEXT(),
|
||||
nullable=False),
|
||||
sa.Column('created_at',
|
||||
sa.DateTime(),
|
||||
|
@ -427,7 +424,9 @@ def upgrade():
|
|||
sa.Column('updated_at',
|
||||
sa.DateTime(),
|
||||
nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'))
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_charset='utf8mb4',
|
||||
mysql_collate='utf8mb4_unicode_ci')
|
||||
|
||||
op.create_table(
|
||||
'schema_migrations',
|
||||
|
|
|
@ -34,8 +34,7 @@ def upgrade():
|
|||
op.add_column(
|
||||
'sub_alarm',
|
||||
sa.Column('state',
|
||||
sa.dialects.mysql.VARCHAR(length=20,
|
||||
collate='utf8mb4_unicode_ci'),
|
||||
sa.String(length=20),
|
||||
sa.ForeignKey('alarm_state.name'),
|
||||
nullable=False,
|
||||
server_default='OK'))
|
||||
|
|
Loading…
Reference in New Issue