2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.istanbul;
24 import java.util.HashMap;
26 import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
27 import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
28 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
29 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
30 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo;
31 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo7;
32 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.KeepDataSearchHitConverter;
33 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.MariaDBTableInfo;
34 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
35 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
36 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.honolulu.HonoluluReleaseInformation;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
39 public class IstanbulReleaseInformation extends ReleaseInformation {
41 private static final String TIMEZONE_TYPE_FORMAT =
42 "CHAR(6) DEFAULT NULL CHECK (`%s` regexp '^[+-]\\\\d\\\\d:\\\\d\\\\d$')";
43 private static final String TABLENAME_CONTROLLER_FORMAT = "controller%s";
44 private static final String TABLEMAPPING_CONTROLLER =
45 "`id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,`desc` VARCHAR(255) CHARACTER SET utf8 ,primary key(id)";
46 private static final String TABLEMAPPING_CONNECTIONLOG_FORMAT = "`id` int(11) NOT NULL AUTO_INCREMENT,\n"
47 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`timestamp` DATETIME(3) ,\n"
48 + "`status` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
49 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
50 private static final String TABLEMAPPING_EVENTLOG_FORMAT = "`id` int(11) NOT NULL AUTO_INCREMENT,\n"
51 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
52 + "`source-type` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`object-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
53 + "`timestamp` DATETIME(3) ,\n" + "`timestamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz")
54 + " ,\n" + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`counter` INTEGER ,\n"
55 + "`attribute-name` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`new-value` VARCHAR(255) CHARACTER SET utf8 ,\n"
56 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
57 private static final String TABLEMAPPING_FAULTCURRENT_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
58 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
59 + "`object-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`timestamp` DATETIME(3) ,\n" + "`timestamp-tz` "
60 + String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz") + " ,\n"
61 + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`counter` INTEGER ,\n"
62 + "`severity` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`problem` VARCHAR(255) CHARACTER SET utf8 ,\n"
63 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
64 private static final String TABLEMAPPING_FAULTLOG_FORMAT = "`id` int(11) NOT NULL AUTO_INCREMENT,\n"
65 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
66 + "`source-type` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`object-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
67 + "`timestamp` DATETIME(3) ,\n" + "`timestamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz")
68 + " ,\n" + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`counter` INTEGER ,\n"
69 + "`severity` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`problem` VARCHAR(255) CHARACTER SET utf8 ,\n"
70 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
71 private static final String TABLEMAPPING_GUICUTTHROUGH_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
72 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
73 + "`name` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`weburi` VARCHAR(255) CHARACTER SET utf8 ,\n"
74 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
75 private static final String TABLEMAPPING_HISTORICALPM15M_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
76 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`performance-data` JSON ,\n"
77 + "`granularity-period` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`time-stamp` DATETIME(3) ,\n"
78 + "`time-stamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "time-stamp-tz") + " ,\n"
79 + "`node-name` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`uuid-interface` VARCHAR(255) CHARACTER SET utf8 ,\n"
80 + "`layer-protocol-name` VARCHAR(255) CHARACTER SET utf8 ,\n"
81 + "`radio-signal-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`suspect-interval-flag` BOOLEAN ,\n"
82 + "`scanner-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
83 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
84 private static final String TABLEMAPPING_HISTORICALPM24H_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
85 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`performance-data` JSON ,\n"
86 + "`granularity-period` VARCHAR(100) CHARACTER SET utf8 ,\n" + "`time-stamp` DATETIME(3) ,\n"
87 + "`time-stamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "time-stamp-tz") + " ,\n"
88 + "`node-name` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`uuid-interface` VARCHAR(255) CHARACTER SET utf8 ,\n"
89 + "`layer-protocol-name` VARCHAR(255) CHARACTER SET utf8 ,\n"
90 + "`radio-signal-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`suspect-interval-flag` BOOLEAN ,\n"
91 + "`scanner-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
92 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
93 private static final String TABLEMAPPING_INVENTORY_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
94 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
95 + "`version` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`type-name` VARCHAR(255) CHARACTER SET utf8 ,\n"
96 + "`date` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`description` VARCHAR(255) CHARACTER SET utf8 ,\n"
97 + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`uuid` VARCHAR(255) CHARACTER SET utf8 ,\n"
98 + "`part-type-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
99 + "`model-identifier` VARCHAR(255) CHARACTER SET utf8 ,\n"
100 + "`manufacturer-identifier` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`tree-level` BIGINT ,\n"
101 + "`parent-uuid` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`contained-holder` JSON ,\n"
102 + "`serial` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`manufacturer-name` VARCHAR(255) CHARACTER SET utf8 ,\n"
103 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
104 private static final String TABLEMAPPING_MAINTENANCE_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
105 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`active` BOOLEAN ,\n"
106 + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`description` VARCHAR(255) CHARACTER SET utf8 ,\n"
107 + "`problem` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`start` DATETIME(3) ,\n" + "`start-tz` "
108 + String.format(TIMEZONE_TYPE_FORMAT, "start-tz") + " ,\n" + "`end` DATETIME(3) ,\n" + "`end-tz` "
109 + String.format(TIMEZONE_TYPE_FORMAT, "end-tz") + " ,\n"
110 + "`object-id-ref` VARCHAR(255) CHARACTER SET utf8 ,\n"
111 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
112 private static final String TABLEMAPPING_MEDIATORSERVER_FORMAT =
113 "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
114 + "`name` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`url` VARCHAR(255) CHARACTER SET utf8 ,\n"
115 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
116 private static final String TABLEMAPPING_NETWORKELEMENT_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
117 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
118 + "`password` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`host` VARCHAR(255) CHARACTER SET utf8 ,\n"
119 + "`port` BIGINT ,\n" + "`status` VARCHAR(100) CHARACTER SET utf8 ,\n"
120 + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`username` VARCHAR(255) CHARACTER SET utf8 ,\n"
121 + "`is-required` BOOLEAN ,\n" + "`core-model-capability` VARCHAR(255) CHARACTER SET utf8 ,\n"
122 + "`device-type` VARCHAR(100) CHARACTER SET utf8 ,\n"
123 + "`device-function` VARCHAR(512) CHARACTER SET utf8 ,\n" + "`node-details` JSON ,\n"
124 + "`tls-key` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`mount-method` VARCHAR(255) CHARACTER SET utf8 ,\n"
125 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
126 private static final String TABLEMAPPING_USERDATA_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
127 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`value` JSON ,\n"
128 + "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
131 public IstanbulReleaseInformation() {
132 super(Release.ISTANBUL_R1, createDBMap(), createMariaDBMap(Release.ISTANBUL_R1.getDBSuffix()));
135 private static Map<ComponentName, MariaDBTableInfo> createMariaDBMap(String suffix) {
136 Map<ComponentName, MariaDBTableInfo> map = new HashMap<>();
137 map.put(ComponentName.CONNECTIONLOG,
138 new MariaDBTableInfo(Entity.Connectionlog.getName(), TABLEMAPPING_CONNECTIONLOG_FORMAT));
139 map.put(ComponentName.EVENTLOG, new MariaDBTableInfo(Entity.Eventlog.getName(), TABLEMAPPING_EVENTLOG_FORMAT));
140 map.put(ComponentName.FAULTCURRENT,
141 new MariaDBTableInfo(Entity.Faultcurrent.getName(), TABLEMAPPING_FAULTCURRENT_FORMAT));
142 map.put(ComponentName.FAULTLOG, new MariaDBTableInfo(Entity.Faultlog.getName(), TABLEMAPPING_FAULTLOG_FORMAT));
143 map.put(ComponentName.GUICUTTHROUGH,
144 new MariaDBTableInfo(Entity.Guicutthrough.getName(), TABLEMAPPING_GUICUTTHROUGH_FORMAT));
145 map.put(ComponentName.HISTORICAL_PERFORMANCE_15M,
146 new MariaDBTableInfo(Entity.Historicalperformance15min.getName(), TABLEMAPPING_HISTORICALPM15M_FORMAT));
147 map.put(ComponentName.HISTORICAL_PERFORMANCE_24H,
148 new MariaDBTableInfo(Entity.Historicalperformance24h.getName(), TABLEMAPPING_HISTORICALPM24H_FORMAT));
149 map.put(ComponentName.INVENTORY,
150 new MariaDBTableInfo(Entity.Inventoryequipment.getName(), TABLEMAPPING_INVENTORY_FORMAT));
151 map.put(ComponentName.MAINTENANCE,
152 new MariaDBTableInfo(Entity.Maintenancemode.getName(), TABLEMAPPING_MAINTENANCE_FORMAT));
153 map.put(ComponentName.MEDIATOR_SERVER,
154 new MariaDBTableInfo(Entity.MediatorServer.getName(), TABLEMAPPING_MEDIATORSERVER_FORMAT));
155 map.put(ComponentName.REQUIRED_NETWORKELEMENT,
156 new MariaDBTableInfo(Entity.NetworkelementConnection.getName(), TABLEMAPPING_NETWORKELEMENT_FORMAT));
157 map.put(ComponentName.USERDATA, new MariaDBTableInfo(Entity.Userdata.getName(), TABLEMAPPING_USERDATA_FORMAT));
161 private static Map<ComponentName, DatabaseInfo> createDBMap() {
162 Map<ComponentName, DatabaseInfo> map = HonoluluReleaseInformation.createDBMap();
163 map.put(ComponentName.USERDATA, new DatabaseInfo7("userdata", "userdata", "{}"));
164 map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo7("networkelement-connection",
165 "networkelement-connection",
166 "{\"node-id\": {\"type\": \"keyword\"},\"host\": {\"type\": \"keyword\"},\"port\": "
167 + "{\"type\": \"long\"},\"username\": {\"type\": \"keyword\"},\"password\": {\"type\": \"keyword\"},"
168 + "\"core-model-capability\": {\"type\": \"keyword\"},\"device-type\": {\"type\": \"keyword\"},"
169 + "\"device-function\": {\"type\": \"keyword\"},\"is-required\": {\"type\": \"boolean\"},"
170 + "\"status\": {\"type\": \"keyword\"},\"tls-key\": {\"type\": \"keyword\"},"
171 + "\"mount-method\": {\"type\":\"keyword\"}}"));
176 public SearchHitConverter getConverter(Release dst, ComponentName comp) {
177 if (dst == Release.ISTANBUL_R1) {
178 return new KeepDataSearchHitConverter(comp);
184 public boolean runPreInitCommands(HtDatabaseClient dbClient) {
189 public boolean runPostInitCommands(HtDatabaseClient dbClient) {
194 public boolean runPreInitCommands(SqlDBClient dbClient) {
195 boolean success = dbClient.createTable(
196 String.format(TABLENAME_CONTROLLER_FORMAT, this.getReleas().getDBSuffix()), TABLEMAPPING_CONTROLLER);
201 public boolean runPostInitCommands(SqlDBClient dbClient) {