Skip to content

Commit 90cd003

Browse files
author
Build2 CI
committed
Task 4: Database schema for VNF Framework
- Created schema-vnf-framework.sql with 5 tables - vnf_dictionaries: YAML dictionary storage with template/network association - vnf_appliances: VNF VM instance tracking with health status - vnf_operations: Operation tracking with state machine (Pending/InProgress/Completed/Failed) - vnf_reconciliation_log: Network drift detection audit trail - vnf_broker_audit: Broker API call audit with latency tracking - All tables have proper indexes for query performance - Follows CloudStack schema naming conventions
1 parent 29ad725 commit 90cd003

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
--;
19+
-- Schema upgrade for VNF Framework
20+
--;
21+
22+
--
23+
-- Table structure for VNF Dictionary storage
24+
--
25+
DROP TABLE IF EXISTS `cloud`.`vnf_dictionaries`;
26+
CREATE TABLE `cloud`.`vnf_dictionaries` (
27+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
28+
`uuid` varchar(40) NOT NULL COMMENT 'UUID of the dictionary',
29+
`name` varchar(255) NOT NULL COMMENT 'Name of the dictionary',
30+
`template_id` bigint unsigned DEFAULT NULL COMMENT 'Template ID this dictionary applies to',
31+
`network_id` bigint unsigned DEFAULT NULL COMMENT 'Network ID this dictionary applies to',
32+
`yaml_content` mediumtext NOT NULL COMMENT 'YAML dictionary content',
33+
`vendor` varchar(255) DEFAULT NULL COMMENT 'Vendor name',
34+
`product` varchar(255) DEFAULT NULL COMMENT 'Product name',
35+
`version` varchar(64) DEFAULT NULL COMMENT 'Product version',
36+
`created` datetime NOT NULL COMMENT 'Date created',
37+
`updated` datetime DEFAULT NULL COMMENT 'Date last updated',
38+
`removed` datetime DEFAULT NULL COMMENT 'Date removed',
39+
PRIMARY KEY (`id`),
40+
UNIQUE KEY `uuid` (`uuid`),
41+
KEY `idx_template_id` (`template_id`),
42+
KEY `idx_network_id` (`network_id`),
43+
KEY `idx_removed` (`removed`)
44+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='VNF YAML dictionaries';
45+
46+
--
47+
-- Table structure for VNF Appliance instances
48+
--
49+
DROP TABLE IF EXISTS `cloud`.`vnf_appliances`;
50+
CREATE TABLE `cloud`.`vnf_appliances` (
51+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
52+
`uuid` varchar(40) NOT NULL COMMENT 'UUID of the VNF appliance',
53+
`vm_instance_id` bigint unsigned NOT NULL COMMENT 'VM instance ID',
54+
`network_id` bigint unsigned NOT NULL COMMENT 'Network ID',
55+
`template_id` bigint unsigned NOT NULL COMMENT 'Template ID',
56+
`dictionary_id` bigint unsigned DEFAULT NULL COMMENT 'Associated dictionary ID',
57+
`management_ip` varchar(40) DEFAULT NULL COMMENT 'Management IP address',
58+
`state` varchar(32) NOT NULL DEFAULT 'Unknown' COMMENT 'VNF state (Unknown, Reachable, Unreachable)',
59+
`health_status` varchar(32) DEFAULT NULL COMMENT 'Health check status',
60+
`last_contact` datetime DEFAULT NULL COMMENT 'Last successful contact timestamp',
61+
`created` datetime NOT NULL COMMENT 'Date created',
62+
`removed` datetime DEFAULT NULL COMMENT 'Date removed',
63+
PRIMARY KEY (`id`),
64+
UNIQUE KEY `uuid` (`uuid`),
65+
UNIQUE KEY `vm_instance_id` (`vm_instance_id`),
66+
KEY `idx_network_id` (`network_id`),
67+
KEY `idx_template_id` (`template_id`),
68+
KEY `idx_dictionary_id` (`dictionary_id`),
69+
KEY `idx_state` (`state`),
70+
KEY `idx_removed` (`removed`)
71+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='VNF appliance instances';
72+
73+
--
74+
-- Table structure for VNF Operations tracking
75+
--
76+
DROP TABLE IF EXISTS `cloud`.`vnf_operations`;
77+
CREATE TABLE `cloud`.`vnf_operations` (
78+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
79+
`uuid` varchar(40) NOT NULL COMMENT 'UUID of the operation',
80+
`operation_id` varchar(255) DEFAULT NULL COMMENT 'External operation ID from broker',
81+
`rule_id` varchar(255) DEFAULT NULL COMMENT 'Rule ID (for idempotency)',
82+
`vnf_instance_id` bigint unsigned DEFAULT NULL COMMENT 'VNF instance ID',
83+
`vnf_appliance_id` bigint unsigned DEFAULT NULL COMMENT 'VNF appliance ID',
84+
`operation_type` varchar(64) NOT NULL COMMENT 'Operation type (CreateFirewallRule, CreateNATRule, etc)',
85+
`op_hash` varchar(64) DEFAULT NULL COMMENT 'Hash of operation parameters for duplicate detection',
86+
`request_payload` mediumtext COMMENT 'Request payload sent to broker',
87+
`response_payload` mediumtext COMMENT 'Response payload from broker',
88+
`vendor_ref` varchar(255) DEFAULT NULL COMMENT 'Vendor-specific reference from response',
89+
`state` varchar(32) NOT NULL DEFAULT 'Pending' COMMENT 'State (Pending, InProgress, Completed, Failed)',
90+
`error_code` varchar(64) DEFAULT NULL COMMENT 'Error code if failed',
91+
`error_message` text COMMENT 'Error message if failed',
92+
`created_at` datetime NOT NULL COMMENT 'When operation was created',
93+
`started_at` datetime DEFAULT NULL COMMENT 'When operation started processing',
94+
`completed_at` datetime DEFAULT NULL COMMENT 'When operation completed',
95+
`removed` datetime DEFAULT NULL COMMENT 'Date removed',
96+
PRIMARY KEY (`id`),
97+
UNIQUE KEY `uuid` (`uuid`),
98+
KEY `idx_operation_id` (`operation_id`),
99+
KEY `idx_rule_id` (`rule_id`),
100+
KEY `idx_vnf_instance_id` (`vnf_instance_id`),
101+
KEY `idx_vnf_appliance_id` (`vnf_appliance_id`),
102+
KEY `idx_state` (`state`),
103+
KEY `idx_operation_type` (`operation_type`),
104+
KEY `idx_op_hash` (`op_hash`),
105+
KEY `idx_created_at` (`created_at`),
106+
KEY `idx_removed` (`removed`)
107+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='VNF operations tracking';
108+
109+
--
110+
-- Table structure for VNF Reconciliation logs
111+
--
112+
DROP TABLE IF EXISTS `cloud`.`vnf_reconciliation_log`;
113+
CREATE TABLE `cloud`.`vnf_reconciliation_log` (
114+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
115+
`uuid` varchar(40) NOT NULL COMMENT 'UUID of the reconciliation log entry',
116+
`network_id` bigint unsigned NOT NULL COMMENT 'Network ID',
117+
`vnf_appliance_id` bigint unsigned DEFAULT NULL COMMENT 'VNF appliance ID',
118+
`drift_detected` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Whether drift was detected',
119+
`drift_summary` text COMMENT 'Summary of drift (missing, extra, mismatched rules)',
120+
`actions_taken` text COMMENT 'Actions taken to remediate drift',
121+
`created_at` datetime NOT NULL COMMENT 'When reconciliation was performed',
122+
`dry_run` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Whether this was a dry run',
123+
PRIMARY KEY (`id`),
124+
UNIQUE KEY `uuid` (`uuid`),
125+
KEY `idx_network_id` (`network_id`),
126+
KEY `idx_vnf_appliance_id` (`vnf_appliance_id`),
127+
KEY `idx_created_at` (`created_at`),
128+
KEY `idx_drift_detected` (`drift_detected`)
129+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='VNF network reconciliation audit log';
130+
131+
--
132+
-- Table structure for VNF Broker audit trail
133+
--
134+
DROP TABLE IF EXISTS `cloud`.`vnf_broker_audit`;
135+
CREATE TABLE `cloud`.`vnf_broker_audit` (
136+
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
137+
`uuid` varchar(40) NOT NULL COMMENT 'UUID of the audit entry',
138+
`appliance_id` bigint unsigned DEFAULT NULL COMMENT 'VNF appliance ID',
139+
`operation` varchar(64) NOT NULL COMMENT 'Broker operation (POST /rules, GET /health, etc)',
140+
`request_payload` mediumtext COMMENT 'Request payload sent',
141+
`response_payload` mediumtext COMMENT 'Response payload received',
142+
`status_code` int DEFAULT NULL COMMENT 'HTTP status code',
143+
`error_message` text COMMENT 'Error message if failed',
144+
`latency_ms` int DEFAULT NULL COMMENT 'Latency in milliseconds',
145+
`created_at` datetime NOT NULL COMMENT 'When broker call was made',
146+
PRIMARY KEY (`id`),
147+
UNIQUE KEY `uuid` (`uuid`),
148+
KEY `idx_appliance_id` (`appliance_id`),
149+
KEY `idx_operation` (`operation`),
150+
KEY `idx_status_code` (`status_code`),
151+
KEY `idx_created_at` (`created_at`)
152+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='VNF broker API call audit trail';

0 commit comments

Comments
 (0)