Merge branch 'WIM'
Change-Id: Id314390ba524d22d4e1f74cfe8ef7c808bb8ac0e
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
diff --git a/database_utils/init_mano_db.sh b/database_utils/init_mano_db.sh
index be7d3ee..147ea38 100755
--- a/database_utils/init_mano_db.sh
+++ b/database_utils/init_mano_db.sh
@@ -161,7 +161,8 @@
DBPORT_="-P$DBPORT"
echo " loading ${DIRNAME}/mano_db_structure.sql"
-sed -e "s/{{mano_db}}/$DBNAME/" ${DIRNAME}/mano_db_structure.sql | mysql $DEF_EXTRA_FILE_PARAM
+sed -e "s/{{mano_db}}/$DBNAME/" ${DIRNAME}/mano_db_structure.sql | mysql $DEF_EXTRA_FILE_PARAM ||
+ ! echo "ERROR at init $DBNAME" || exit 1
echo " migrage database version"
# echo "${DIRNAME}/migrate_mano_db.sh $DBHOST_ $DBPORT_ $DBUSER_ $DBPASS_ -d$DBNAME $QUIET_MODE $DB_VERSION"
diff --git a/database_utils/mano_db_structure.sql b/database_utils/mano_db_structure.sql
index 2bedc38..9e2d911 100644
--- a/database_utils/mano_db_structure.sql
+++ b/database_utils/mano_db_structure.sql
@@ -19,11 +19,11 @@
* contact with: nfvlabs@tid.es
**/
--- MySQL dump 10.13 Distrib 5.7.20, for Linux (x86_64)
+-- MySQL dump 10.13 Distrib 5.7.24, for Linux (x86_64)
--
-- Host: localhost Database: {{mano_db}}
-- ------------------------------------------------------
--- Server version 5.7.20-0ubuntu0.16.04.1
+-- Server version 5.7.24
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -42,7 +42,7 @@
/*!40000 DROP DATABASE IF EXISTS `{{mano_db}}`*/;
-CREATE DATABASE /*!32312 IF NOT EXISTS*/ `{{mano_db}}` /*!40100 DEFAULT CHARACTER SET latin1 */;
+CREATE DATABASE /*!32312 IF NOT EXISTS*/ `{{mano_db}}` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `{{mano_db}}`;
@@ -229,6 +229,37 @@
/*!40101 SET character_set_client = @saved_cs_client */;
--
+-- Table structure for table `instance_classifications`
+--
+
+DROP TABLE IF EXISTS `instance_classifications`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `instance_classifications` (
+ `uuid` varchar(36) NOT NULL,
+ `instance_scenario_id` varchar(36) NOT NULL,
+ `vim_classification_id` varchar(36) DEFAULT NULL,
+ `sce_classifier_match_id` varchar(36) DEFAULT NULL,
+ `datacenter_id` varchar(36) DEFAULT NULL,
+ `datacenter_tenant_id` varchar(36) DEFAULT NULL,
+ `status` enum('ACTIVE','INACTIVE','BUILD','ERROR','VIM_ERROR','PAUSED','SUSPENDED','DELETED','SCHEDULED_CREATION','SCHEDULED_DELETION') NOT NULL DEFAULT 'BUILD',
+ `error_msg` varchar(1024) DEFAULT NULL,
+ `vim_info` text,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ KEY `FK_instance_classifications_instance_scenarios` (`instance_scenario_id`),
+ KEY `FK_instance_classifications_sce_classifier_matches` (`sce_classifier_match_id`),
+ KEY `FK_instance_classifications_datacenters` (`datacenter_id`),
+ KEY `FK_instance_classifications_datacenter_tenants` (`datacenter_tenant_id`),
+ CONSTRAINT `FK_instance_classifications_datacenter_tenants` FOREIGN KEY (`datacenter_tenant_id`) REFERENCES `datacenter_tenants` (`uuid`),
+ CONSTRAINT `FK_instance_classifications_datacenters` FOREIGN KEY (`datacenter_id`) REFERENCES `datacenters` (`uuid`),
+ CONSTRAINT `FK_instance_classifications_instance_scenarios` FOREIGN KEY (`instance_scenario_id`) REFERENCES `instance_scenarios` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_instance_classifications_sce_classifier_matches` FOREIGN KEY (`sce_classifier_match_id`) REFERENCES `sce_classifier_matches` (`uuid`) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
-- Table structure for table `instance_interfaces`
--
@@ -271,6 +302,7 @@
CREATE TABLE `instance_nets` (
`uuid` varchar(36) NOT NULL,
`vim_net_id` varchar(128) DEFAULT NULL,
+ `vim_name` varchar(255) DEFAULT NULL,
`instance_scenario_id` varchar(36) DEFAULT NULL,
`sce_net_id` varchar(36) DEFAULT NULL,
`net_id` varchar(36) DEFAULT NULL,
@@ -329,6 +361,99 @@
/*!40101 SET character_set_client = @saved_cs_client */;
--
+-- Table structure for table `instance_sfis`
+--
+
+DROP TABLE IF EXISTS `instance_sfis`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `instance_sfis` (
+ `uuid` varchar(36) NOT NULL,
+ `instance_scenario_id` varchar(36) NOT NULL,
+ `vim_sfi_id` varchar(36) DEFAULT NULL,
+ `sce_rsp_hop_id` varchar(36) DEFAULT NULL,
+ `datacenter_id` varchar(36) DEFAULT NULL,
+ `datacenter_tenant_id` varchar(36) DEFAULT NULL,
+ `status` enum('ACTIVE','INACTIVE','BUILD','ERROR','VIM_ERROR','PAUSED','SUSPENDED','DELETED','SCHEDULED_CREATION','SCHEDULED_DELETION') NOT NULL DEFAULT 'BUILD',
+ `error_msg` varchar(1024) DEFAULT NULL,
+ `vim_info` text,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ KEY `FK_instance_sfis_instance_scenarios` (`instance_scenario_id`),
+ KEY `FK_instance_sfis_sce_rsp_hops` (`sce_rsp_hop_id`),
+ KEY `FK_instance_sfis_datacenters` (`datacenter_id`),
+ KEY `FK_instance_sfis_datacenter_tenants` (`datacenter_tenant_id`),
+ CONSTRAINT `FK_instance_sfis_datacenter_tenants` FOREIGN KEY (`datacenter_tenant_id`) REFERENCES `datacenter_tenants` (`uuid`),
+ CONSTRAINT `FK_instance_sfis_datacenters` FOREIGN KEY (`datacenter_id`) REFERENCES `datacenters` (`uuid`),
+ CONSTRAINT `FK_instance_sfis_instance_scenarios` FOREIGN KEY (`instance_scenario_id`) REFERENCES `instance_scenarios` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_instance_sfis_sce_rsp_hops` FOREIGN KEY (`sce_rsp_hop_id`) REFERENCES `sce_rsp_hops` (`uuid`) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `instance_sfps`
+--
+
+DROP TABLE IF EXISTS `instance_sfps`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `instance_sfps` (
+ `uuid` varchar(36) NOT NULL,
+ `instance_scenario_id` varchar(36) NOT NULL,
+ `vim_sfp_id` varchar(36) DEFAULT NULL,
+ `sce_rsp_id` varchar(36) DEFAULT NULL,
+ `datacenter_id` varchar(36) DEFAULT NULL,
+ `datacenter_tenant_id` varchar(36) DEFAULT NULL,
+ `status` enum('ACTIVE','INACTIVE','BUILD','ERROR','VIM_ERROR','PAUSED','SUSPENDED','DELETED','SCHEDULED_CREATION','SCHEDULED_DELETION') NOT NULL DEFAULT 'BUILD',
+ `error_msg` varchar(1024) DEFAULT NULL,
+ `vim_info` text,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ KEY `FK_instance_sfps_instance_scenarios` (`instance_scenario_id`),
+ KEY `FK_instance_sfps_sce_rsps` (`sce_rsp_id`),
+ KEY `FK_instance_sfps_datacenters` (`datacenter_id`),
+ KEY `FK_instance_sfps_datacenter_tenants` (`datacenter_tenant_id`),
+ CONSTRAINT `FK_instance_sfps_datacenter_tenants` FOREIGN KEY (`datacenter_tenant_id`) REFERENCES `datacenter_tenants` (`uuid`),
+ CONSTRAINT `FK_instance_sfps_datacenters` FOREIGN KEY (`datacenter_id`) REFERENCES `datacenters` (`uuid`),
+ CONSTRAINT `FK_instance_sfps_instance_scenarios` FOREIGN KEY (`instance_scenario_id`) REFERENCES `instance_scenarios` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_instance_sfps_sce_rsps` FOREIGN KEY (`sce_rsp_id`) REFERENCES `sce_rsps` (`uuid`) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `instance_sfs`
+--
+
+DROP TABLE IF EXISTS `instance_sfs`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `instance_sfs` (
+ `uuid` varchar(36) NOT NULL,
+ `instance_scenario_id` varchar(36) NOT NULL,
+ `vim_sf_id` varchar(36) DEFAULT NULL,
+ `sce_rsp_hop_id` varchar(36) DEFAULT NULL,
+ `datacenter_id` varchar(36) DEFAULT NULL,
+ `datacenter_tenant_id` varchar(36) DEFAULT NULL,
+ `status` enum('ACTIVE','INACTIVE','BUILD','ERROR','VIM_ERROR','PAUSED','SUSPENDED','DELETED','SCHEDULED_CREATION','SCHEDULED_DELETION') NOT NULL DEFAULT 'BUILD',
+ `error_msg` varchar(1024) DEFAULT NULL,
+ `vim_info` text,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ KEY `FK_instance_sfs_instance_scenarios` (`instance_scenario_id`),
+ KEY `FK_instance_sfs_sce_rsp_hops` (`sce_rsp_hop_id`),
+ KEY `FK_instance_sfs_datacenters` (`datacenter_id`),
+ KEY `FK_instance_sfs_datacenter_tenants` (`datacenter_tenant_id`),
+ CONSTRAINT `FK_instance_sfs_datacenter_tenants` FOREIGN KEY (`datacenter_tenant_id`) REFERENCES `datacenter_tenants` (`uuid`),
+ CONSTRAINT `FK_instance_sfs_datacenters` FOREIGN KEY (`datacenter_id`) REFERENCES `datacenters` (`uuid`),
+ CONSTRAINT `FK_instance_sfs_instance_scenarios` FOREIGN KEY (`instance_scenario_id`) REFERENCES `instance_scenarios` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_instance_sfs_sce_rsp_hops` FOREIGN KEY (`sce_rsp_hop_id`) REFERENCES `sce_rsp_hops` (`uuid`) ON DELETE SET NULL ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
-- Table structure for table `instance_vms`
--
@@ -340,6 +465,7 @@
`instance_vnf_id` varchar(36) NOT NULL,
`vm_id` varchar(36) DEFAULT NULL,
`vim_vm_id` varchar(128) DEFAULT NULL,
+ `vim_name` varchar(255) DEFAULT NULL,
`status` enum('ACTIVE:NoMgmtIP','ACTIVE','INACTIVE','BUILD','ERROR','VIM_ERROR','PAUSED','SUSPENDED','DELETED','SCHEDULED_CREATION','SCHEDULED_DELETION') NOT NULL DEFAULT 'BUILD',
`error_msg` varchar(1024) DEFAULT NULL,
`vim_info` text,
@@ -385,6 +511,39 @@
/*!40101 SET character_set_client = @saved_cs_client */;
--
+-- Table structure for table `instance_wim_nets`
+--
+
+DROP TABLE IF EXISTS `instance_wim_nets`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `instance_wim_nets` (
+ `uuid` varchar(36) NOT NULL,
+ `wim_internal_id` varchar(128) DEFAULT NULL COMMENT 'Internal ID used by the WIM to refer to the network',
+ `instance_scenario_id` varchar(36) DEFAULT NULL,
+ `sce_net_id` varchar(36) DEFAULT NULL,
+ `wim_id` varchar(36) DEFAULT NULL,
+ `wim_account_id` varchar(36) NOT NULL,
+ `status` enum('ACTIVE','INACTIVE','DOWN','BUILD','ERROR','WIM_ERROR','DELETED','SCHEDULED_CREATION','SCHEDULED_DELETION') NOT NULL DEFAULT 'BUILD',
+ `error_msg` varchar(1024) DEFAULT NULL,
+ `wim_info` text,
+ `multipoint` enum('true','false') NOT NULL DEFAULT 'false',
+ `created` enum('true','false') NOT NULL DEFAULT 'false' COMMENT 'Created or already exists at WIM',
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ KEY `FK_instance_wim_nets_instance_scenarios` (`instance_scenario_id`),
+ KEY `FK_instance_wim_nets_sce_nets` (`sce_net_id`),
+ KEY `FK_instance_wim_nets_wims` (`wim_id`),
+ KEY `FK_instance_wim_nets_wim_accounts` (`wim_account_id`),
+ CONSTRAINT `FK_instance_wim_nets_instance_scenarios` FOREIGN KEY (`instance_scenario_id`) REFERENCES `instance_scenarios` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_instance_wim_nets_sce_nets` FOREIGN KEY (`sce_net_id`) REFERENCES `sce_nets` (`uuid`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `FK_instance_wim_nets_wim_accounts` FOREIGN KEY (`wim_account_id`) REFERENCES `wim_accounts` (`uuid`),
+ CONSTRAINT `FK_instance_wim_nets_wims` FOREIGN KEY (`wim_id`) REFERENCES `wims` (`uuid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='Instances of wim networks';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
-- Table structure for table `interfaces`
--
@@ -474,6 +633,7 @@
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `nets` (
`uuid` varchar(36) NOT NULL,
+ `osm_id` varchar(255) DEFAULT NULL,
`vnf_id` varchar(36) NOT NULL,
`name` varchar(255) NOT NULL,
`type` enum('bridge','data','ptp') NOT NULL DEFAULT 'data' COMMENT 'Type of network',
@@ -508,6 +668,58 @@
/*!40101 SET character_set_client = @saved_cs_client */;
--
+-- Table structure for table `sce_classifier_matches`
+--
+
+DROP TABLE IF EXISTS `sce_classifier_matches`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `sce_classifier_matches` (
+ `uuid` varchar(36) NOT NULL,
+ `ip_proto` varchar(2) NOT NULL,
+ `source_ip` varchar(16) NOT NULL,
+ `destination_ip` varchar(16) NOT NULL,
+ `source_port` varchar(5) NOT NULL,
+ `destination_port` varchar(5) NOT NULL,
+ `sce_classifier_id` varchar(36) NOT NULL,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ KEY `FK_classifiers_classifier_match` (`sce_classifier_id`),
+ CONSTRAINT `FK_sce_classifiers_classifier_match` FOREIGN KEY (`sce_classifier_id`) REFERENCES `sce_classifiers` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `sce_classifiers`
+--
+
+DROP TABLE IF EXISTS `sce_classifiers`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `sce_classifiers` (
+ `uuid` varchar(36) NOT NULL,
+ `tenant_id` varchar(36) DEFAULT NULL,
+ `name` varchar(255) NOT NULL,
+ `sce_vnffg_id` varchar(36) NOT NULL,
+ `sce_rsp_id` varchar(36) NOT NULL,
+ `sce_vnf_id` varchar(36) NOT NULL,
+ `interface_id` varchar(36) NOT NULL,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ KEY `FK_sce_vnffgs_classifier` (`sce_vnffg_id`),
+ KEY `FK_sce_rsps_classifier` (`sce_rsp_id`),
+ KEY `FK_sce_vnfs_classifier` (`sce_vnf_id`),
+ KEY `FK_interfaces_classifier` (`interface_id`),
+ CONSTRAINT `FK_interfaces_classifier` FOREIGN KEY (`interface_id`) REFERENCES `interfaces` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_sce_rsps_classifier` FOREIGN KEY (`sce_rsp_id`) REFERENCES `sce_rsps` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_sce_vnffgs_classifier` FOREIGN KEY (`sce_vnffg_id`) REFERENCES `sce_vnffgs` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_sce_vnfs_classifier` FOREIGN KEY (`sce_vnf_id`) REFERENCES `sce_vnfs` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
-- Table structure for table `sce_interfaces`
--
@@ -541,12 +753,14 @@
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sce_nets` (
`uuid` varchar(36) NOT NULL,
+ `osm_id` varchar(255) DEFAULT NULL,
`name` varchar(255) NOT NULL,
`scenario_id` varchar(36) DEFAULT NULL COMMENT 'NULL if net is matched to several scenarios',
`type` enum('bridge','data','ptp') NOT NULL DEFAULT 'data' COMMENT 'Type of network',
`multipoint` enum('true','false') NOT NULL DEFAULT 'true',
`external` enum('true','false') NOT NULL DEFAULT 'false' COMMENT 'If external, net is already present at VIM',
`description` varchar(255) DEFAULT NULL,
+ `vim_network_name` varchar(255) DEFAULT NULL,
`created_at` double NOT NULL,
`modified_at` double DEFAULT NULL,
`graph` varchar(2000) DEFAULT NULL,
@@ -557,6 +771,77 @@
/*!40101 SET character_set_client = @saved_cs_client */;
--
+-- Table structure for table `sce_rsp_hops`
+--
+
+DROP TABLE IF EXISTS `sce_rsp_hops`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `sce_rsp_hops` (
+ `uuid` varchar(36) NOT NULL,
+ `if_order` int(11) NOT NULL DEFAULT '0',
+ `ingress_interface_id` varchar(36) NOT NULL,
+ `egress_interface_id` varchar(36) NOT NULL,
+ `sce_vnf_id` varchar(36) NOT NULL,
+ `sce_rsp_id` varchar(36) NOT NULL,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ KEY `FK_interfaces_rsp_hop` (`ingress_interface_id`),
+ KEY `FK_sce_vnfs_rsp_hop` (`sce_vnf_id`),
+ KEY `FK_sce_rsps_rsp_hop` (`sce_rsp_id`),
+ KEY `FK_interfaces_rsp_hop_egress` (`egress_interface_id`),
+ CONSTRAINT `FK_interfaces_rsp_hop_egress` FOREIGN KEY (`egress_interface_id`) REFERENCES `interfaces` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_interfaces_rsp_hop_ingress` FOREIGN KEY (`ingress_interface_id`) REFERENCES `interfaces` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_sce_rsps_rsp_hop` FOREIGN KEY (`sce_rsp_id`) REFERENCES `sce_rsps` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_sce_vnfs_rsp_hop` FOREIGN KEY (`sce_vnf_id`) REFERENCES `sce_vnfs` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `sce_rsps`
+--
+
+DROP TABLE IF EXISTS `sce_rsps`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `sce_rsps` (
+ `uuid` varchar(36) NOT NULL,
+ `tenant_id` varchar(36) DEFAULT NULL,
+ `name` varchar(255) NOT NULL,
+ `sce_vnffg_id` varchar(36) NOT NULL,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ KEY `FK_sce_vnffgs_rsp` (`sce_vnffg_id`),
+ CONSTRAINT `FK_sce_vnffgs_rsp` FOREIGN KEY (`sce_vnffg_id`) REFERENCES `sce_vnffgs` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `sce_vnffgs`
+--
+
+DROP TABLE IF EXISTS `sce_vnffgs`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `sce_vnffgs` (
+ `uuid` varchar(36) NOT NULL,
+ `tenant_id` varchar(36) DEFAULT NULL,
+ `name` varchar(255) NOT NULL,
+ `description` varchar(255) DEFAULT NULL,
+ `vendor` varchar(255) DEFAULT NULL,
+ `scenario_id` varchar(36) NOT NULL,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ KEY `FK_scenarios_sce_vnffg` (`scenario_id`),
+ KEY `FK_scenarios_vnffg` (`tenant_id`),
+ CONSTRAINT `FK_scenarios_vnffg` FOREIGN KEY (`tenant_id`) REFERENCES `scenarios` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
-- Table structure for table `sce_vnfs`
--
@@ -565,7 +850,7 @@
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sce_vnfs` (
`uuid` varchar(36) NOT NULL,
- `member_vnf_index` smallint(6) DEFAULT NULL,
+ `member_vnf_index` varchar(255) DEFAULT NULL,
`name` varchar(255) NOT NULL,
`scenario_id` varchar(36) NOT NULL,
`vnf_id` varchar(36) NOT NULL,
@@ -668,19 +953,21 @@
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Table structure for table `vim_actions`
+-- Table structure for table `vim_wim_actions`
--
-DROP TABLE IF EXISTS `vim_actions`;
+DROP TABLE IF EXISTS `vim_wim_actions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
-CREATE TABLE `vim_actions` (
+CREATE TABLE `vim_wim_actions` (
`instance_action_id` varchar(36) NOT NULL,
`task_index` int(6) NOT NULL,
- `datacenter_vim_id` varchar(36) NOT NULL,
+ `datacenter_vim_id` varchar(36) DEFAULT NULL,
`vim_id` varchar(64) DEFAULT NULL,
+ `wim_account_id` varchar(36) DEFAULT NULL,
+ `wim_internal_id` varchar(64) DEFAULT NULL,
`action` varchar(36) NOT NULL COMMENT 'CREATE,DELETE,START,STOP...',
- `item` enum('datacenters_flavors','datacenter_images','instance_nets','instance_vms','instance_interfaces') NOT NULL COMMENT 'table where the item is stored',
+ `item` enum('datacenters_flavors','datacenter_images','instance_nets','instance_vms','instance_interfaces','instance_wim_nets') NOT NULL COMMENT 'table where the item is stored',
`item_id` varchar(36) DEFAULT NULL COMMENT 'uuid of the entry in the table',
`status` enum('SCHEDULED','BUILD','DONE','FAILED','SUPERSEDED') NOT NULL DEFAULT 'SCHEDULED',
`extra` text COMMENT 'json with params:, depends_on: for the task',
@@ -690,8 +977,11 @@
PRIMARY KEY (`task_index`,`instance_action_id`),
KEY `FK_actions_instance_actions` (`instance_action_id`),
KEY `FK_actions_vims` (`datacenter_vim_id`),
+ KEY `item_type_id` (`item`,`item_id`),
+ KEY `FK_actions_wims` (`wim_account_id`),
CONSTRAINT `FK_actions_instance_actions` FOREIGN KEY (`instance_action_id`) REFERENCES `instance_actions` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
- CONSTRAINT `FK_actions_vims` FOREIGN KEY (`datacenter_vim_id`) REFERENCES `datacenter_tenants` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
+ CONSTRAINT `FK_actions_vims` FOREIGN KEY (`datacenter_vim_id`) REFERENCES `datacenter_tenants` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_actions_wims` FOREIGN KEY (`wim_account_id`) REFERENCES `wim_accounts` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Table with the individual VIM actions.';
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -705,11 +995,13 @@
CREATE TABLE `vms` (
`uuid` varchar(36) NOT NULL,
`osm_id` varchar(255) DEFAULT NULL,
+ `pdu_type` varchar(255) DEFAULT NULL,
`name` varchar(255) NOT NULL,
`vnf_id` varchar(36) NOT NULL,
`count` smallint(6) NOT NULL DEFAULT '1',
`flavor_id` varchar(36) NOT NULL COMMENT 'Link to flavor table',
- `image_id` varchar(36) NOT NULL COMMENT 'Link to image table',
+ `image_id` varchar(36) DEFAULT NULL COMMENT 'Link to image table',
+ `image_list` text COMMENT 'Alternative images',
`image_path` varchar(100) DEFAULT NULL COMMENT 'Path where the image of the VM is located',
`boot_data` text,
`description` varchar(255) DEFAULT NULL,
@@ -757,7 +1049,104 @@
/*!40101 SET character_set_client = @saved_cs_client */;
--
--- Dumping routines for database '{{mano_db}}'
+-- Table structure for table `wim_accounts`
+--
+
+DROP TABLE IF EXISTS `wim_accounts`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `wim_accounts` (
+ `uuid` varchar(36) NOT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `wim_id` varchar(36) NOT NULL,
+ `created` enum('true','false') NOT NULL DEFAULT 'false',
+ `user` varchar(64) DEFAULT NULL,
+ `password` varchar(64) DEFAULT NULL,
+ `config` text,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ UNIQUE KEY `wim_name` (`wim_id`,`name`),
+ KEY `FK_wim_accounts_wims` (`wim_id`),
+ CONSTRAINT `FK_wim_accounts_wims` FOREIGN KEY (`wim_id`) REFERENCES `wims` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='WIM accounts by the user';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `wim_nfvo_tenants`
+--
+
+DROP TABLE IF EXISTS `wim_nfvo_tenants`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `wim_nfvo_tenants` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `nfvo_tenant_id` varchar(36) NOT NULL,
+ `wim_id` varchar(36) NOT NULL,
+ `wim_account_id` varchar(36) NOT NULL,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `wim_nfvo_tenant` (`wim_id`,`nfvo_tenant_id`),
+ KEY `FK_wims_nfvo_tenants` (`wim_id`),
+ KEY `FK_wim_accounts_nfvo_tenants` (`wim_account_id`),
+ KEY `FK_nfvo_tenants_wim_accounts` (`nfvo_tenant_id`),
+ CONSTRAINT `FK_nfvo_tenants_wim_accounts` FOREIGN KEY (`nfvo_tenant_id`) REFERENCES `nfvo_tenants` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_wim_accounts_nfvo_tenants` FOREIGN KEY (`wim_account_id`) REFERENCES `wim_accounts` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_wims_nfvo_tenants` FOREIGN KEY (`wim_id`) REFERENCES `wims` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='WIM accounts mapping to NFVO tenants';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `wim_port_mappings`
+--
+
+DROP TABLE IF EXISTS `wim_port_mappings`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `wim_port_mappings` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `wim_id` varchar(36) NOT NULL,
+ `datacenter_id` varchar(36) NOT NULL,
+ `pop_switch_dpid` varchar(64) NOT NULL,
+ `pop_switch_port` varchar(64) NOT NULL,
+ `wan_service_endpoint_id` varchar(256) NOT NULL COMMENT 'this field contains a unique identifier used to check the mapping_info consistency',
+ `wan_service_mapping_info` text,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `unique_datacenter_port_mapping` (`datacenter_id`,`pop_switch_dpid`,`pop_switch_port`),
+ UNIQUE KEY `unique_wim_port_mapping` (`wim_id`,`wan_service_endpoint_id`),
+ KEY `FK_wims_wim_physical_connections` (`wim_id`),
+ KEY `FK_datacenters_wim_port_mappings` (`datacenter_id`),
+ CONSTRAINT `FK_datacenters_wim_port_mappings` FOREIGN KEY (`datacenter_id`) REFERENCES `datacenters` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `FK_wims_wim_port_mappings` FOREIGN KEY (`wim_id`) REFERENCES `wims` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='WIM port mappings managed by the WIM.';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Table structure for table `wims`
+--
+
+DROP TABLE IF EXISTS `wims`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `wims` (
+ `uuid` varchar(36) NOT NULL,
+ `name` varchar(255) NOT NULL,
+ `description` varchar(255) DEFAULT NULL,
+ `type` varchar(36) NOT NULL DEFAULT 'odl',
+ `wim_url` varchar(150) NOT NULL,
+ `config` text,
+ `created_at` double NOT NULL,
+ `modified_at` double DEFAULT NULL,
+ PRIMARY KEY (`uuid`),
+ UNIQUE KEY `name` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='WIMs managed by the NFVO.';
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+--
+-- Dumping routines for database 'mano_db'
--
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -769,17 +1158,17 @@
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2017-11-23 10:24:39
+-- Dump completed on 2018-12-10 9:58:03
--- MySQL dump 10.13 Distrib 5.7.20, for Linux (x86_64)
+-- MySQL dump 10.13 Distrib 5.7.24, for Linux (x86_64)
--
-- Host: localhost Database: {{mano_db}}
-- ------------------------------------------------------
--- Server version 5.7.20-0ubuntu0.16.04.1
+-- Server version 5.7.24
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -798,7 +1187,44 @@
LOCK TABLES `schema_version` WRITE;
/*!40000 ALTER TABLE `schema_version` DISABLE KEYS */;
-INSERT INTO `schema_version` VALUES (1,'0.1','0.2.2','insert schema_version','2015-05-08'),(2,'0.2','0.2.5','new tables images,flavors','2015-07-13'),(3,'0.3','0.3.3','alter vim_tenant tables','2015-07-28'),(4,'0.4','0.3.5','enlarge graph field at sce_vnfs/nets','2015-10-20'),(5,'0.5','0.4.1','Add mac address for bridge interfaces','2015-12-14'),(6,'0.6','0.4.2','Adding VIM status info','2015-12-22'),(7,'0.7','0.4.3','Changing created_at time at database','2016-01-25'),(8,'0.8','0.4.32','Enlarging name at database','2016-02-01'),(9,'0.9','0.4.33','Add ACTIVE:NoMgmtIP to instance_vms table','2016-02-05'),(10,'0.10','0.4.36','tenant management of vnfs,scenarios','2016-03-08'),(11,'0.11','0.4.43','remove unique name at scenarios,instance_scenarios','2016-07-18'),(12,'0.12','0.4.46','create ip_profiles table, with foreign keys to all nets tables, and add ip_address column to interfaces and sce_interfaces','2016-08-29'),(13,'0.13','0.4.47','insert cloud-config at scenarios,instance_scenarios','2016-08-30'),(14,'0.14','0.4.57','remove unique index vim_net_id, instance_scenario_id','2016-09-26'),(15,'0.15','0.4.59','add columns universal_name and checksum at table images, add unique index universal_name_checksum, and change location to allow NULL; change column image_path in table vms to allow NULL','2016-09-27'),(16,'0.16','0.5.2','enlarge vim_tenant_name and id. New config at datacenter_tenants','2016-10-11'),(17,'0.17','0.5.3','Extra description json format of additional devices in datacenter_flavors','2016-12-20'),(18,'0.18','0.5.4','Add columns \'floating_ip\' and \'port_security\' at tables \'interfaces\' and \'instance_interfaces\'','2017-01-09'),(19,'0.19','0.5.5','Extra Boot-data content at VNFC (vms)','2017-01-11'),(20,'0.20','0.5.9','Added columns to store dataplane connectivity info','2017-03-13'),(21,'0.21','0.5.15','Edit instance_nets to allow instance_scenario_id=None and enlarge column dns_address at table ip_profiles','2017-06-02'),(22,'0.22','0.5.16','Changed type of ram in flavors from SMALLINT to MEDIUMINT','2017-06-02'),(23,'0.23','0.5.20','Changed type of ram in flavors from SMALLINT to MEDIUMINT','2017-08-29'),(24,'0.24','0.5.21','Added vnfd fields','2017-08-29'),(25,'0.25','0.5.22','Added osm_id to vnfs,scenarios','2017-09-01'),(26,'0.26','0.5.23','Several changes','2017-09-09'),(27,'0.27','0.5.25','Added encrypted_RO_priv_key,RO_pub_key to table nfvo_tenants','2017-09-29');
+INSERT INTO `schema_version` VALUES
+(0,'0.0','0.0.0','Database in init process','2015-05-08'),
+(1,'0.1','0.2.2','insert schema_version','2015-05-08'),
+(2,'0.2','0.2.5','new tables images,flavors','2015-07-13'),
+(3,'0.3','0.3.3','alter vim_tenant tables','2015-07-28'),
+(4,'0.4','0.3.5','enlarge graph field at sce_vnfs/nets','2015-10-20'),
+(5,'0.5','0.4.1','Add mac address for bridge interfaces','2015-12-14'),
+(6,'0.6','0.4.2','Adding VIM status info','2015-12-22'),
+(7,'0.7','0.4.3','Changing created_at time at database','2016-01-25'),
+(8,'0.8','0.4.32','Enlarging name at database','2016-02-01'),
+(9,'0.9','0.4.33','Add ACTIVE:NoMgmtIP to instance_vms table','2016-02-05'),
+(10,'0.10','0.4.36','tenant management of vnfs,scenarios','2016-03-08'),
+(11,'0.11','0.4.43','remove unique name at scenarios,instance_scenarios','2016-07-18'),
+(12,'0.12','0.4.46','create ip_profiles table, with foreign keys to all nets tables, and add ip_address column to interfaces and sce_interfaces','2016-08-29'),
+(13,'0.13','0.4.47','insert cloud-config at scenarios,instance_scenarios','2016-08-30'),
+(14,'0.14','0.4.57','remove unique index vim_net_id, instance_scenario_id','2016-09-26'),
+(15,'0.15','0.4.59','add columns universal_name and checksum at table images, add unique index universal_name_checksum, and change location to allow NULL; change column image_path in table vms to allow NULL','2016-09-27'),
+(16,'0.16','0.5.2','enlarge vim_tenant_name and id. New config at datacenter_tenants','2016-10-11'),
+(17,'0.17','0.5.3','Extra description json format of additional devices in datacenter_flavors','2016-12-20'),
+(18,'0.18','0.5.4','Add columns \'floating_ip\' and \'port_security\' at tables \'interfaces\' and \'instance_interfaces\'','2017-01-09'),
+(19,'0.19','0.5.5','Extra Boot-data content at VNFC (vms)','2017-01-11'),
+(20,'0.20','0.5.9','Added columns to store dataplane connectivity info','2017-03-13'),
+(21,'0.21','0.5.15','Edit instance_nets to allow instance_scenario_id=None and enlarge column dns_address at table ip_profiles','2017-06-02'),
+(22,'0.22','0.5.16','Changed type of ram in flavors from SMALLINT to MEDIUMINT','2017-06-02'),
+(23,'0.23','0.5.20','Changed type of ram in flavors from SMALLINT to MEDIUMINT','2017-08-29'),
+(24,'0.24','0.5.21','Added vnfd fields','2017-08-29'),
+(25,'0.25','0.5.22','Added osm_id to vnfs,scenarios','2017-09-01'),
+(26,'0.26','0.5.23','Several changes','2017-09-09'),
+(27,'0.27','0.5.25','Added encrypted_RO_priv_key,RO_pub_key to table nfvo_tenants','2017-09-29'),
+(28,'0.28','0.5.28','Adding VNFFG-related tables','2017-11-20'),
+(29,'0.29','0.5.59','Change member_vnf_index to str accordingly to the model','2018-04-11'),
+(30,'0.30','0.5.60','Add image_list to vms','2018-04-24'),
+(31,'0.31','0.5.61','Add vim_network_name to sce_nets','2018-05-03'),
+(32,'0.32','0.5.70','Add vim_name to instance vms','2018-06-28'),
+(33,'0.33','0.5.82','Add pdu information to vms','2018-11-13'),
+(34,'0.34','0.6.00','Added WIM tables','2018-09-10'),
+(35,'0.35','0.6.02','Adding ingress and egress ports for RSPs','2018-12-11'),
+(36,'0.36','0.6.03','Allow vm without image_id for PDUs','2018-12-19');
/*!40000 ALTER TABLE `schema_version` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
@@ -811,4 +1237,4 @@
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2017-11-23 10:24:39
+-- Dump completed on 2018-12-10 9:58:03
diff --git a/database_utils/migrate_mano_db.sh b/database_utils/migrate_mano_db.sh
index aa2e718..2d3f1bc 100755
--- a/database_utils/migrate_mano_db.sh
+++ b/database_utils/migrate_mano_db.sh
@@ -33,8 +33,10 @@
DBPORT="3306"
DBNAME="mano_db"
QUIET_MODE=""
+BACKUP_DIR=""
+BACKUP_FILE=""
#TODO update it with the last database version
-LAST_DB_VERSION=34
+LAST_DB_VERSION=36
# Detect paths
MYSQL=$(which mysql)
@@ -51,11 +53,12 @@
echo -e " -P PORT database port. '$DBPORT' by default"
echo -e " -h HOST database host. 'localhost' by default"
echo -e " -d NAME database name. '$DBNAME' by default. Prompts if DB access fails"
+ echo -e " -b DIR backup folder where to create rollback backup file"
echo -e " -q --quiet: Do not prompt for credentials and exit if cannot access to database"
echo -e " --help shows this help"
}
-while getopts ":u:p:P:h:d:q-:" o; do
+while getopts ":u:p:b:P:h:d:q-:" o; do
case "${o}" in
u)
DBUSER="$OPTARG"
@@ -72,6 +75,9 @@
h)
DBHOST="$OPTARG"
;;
+ b)
+ BACKUP_DIR="$OPTARG"
+ ;;
q)
export QUIET_MODE=yes
;;
@@ -143,7 +149,6 @@
DBCMD="mysql $DEF_EXTRA_FILE_PARAM $DBNAME"
#echo DBCMD $DBCMD
-#GET DATABASE VERSION
#check that the database seems a openmano database
if ! echo -e "show create table vnfs;\nshow create table scenarios" | $DBCMD >/dev/null 2>&1
then
@@ -151,22 +156,6 @@
exit 1;
fi
-if ! echo 'show create table schema_version;' | $DBCMD >/dev/null 2>&1
-then
- DATABASE_VER="0.0"
- DATABASE_VER_NUM=0
-else
- DATABASE_VER_NUM=`echo "select max(version_int) from schema_version;" | $DBCMD | tail -n+2`
- DATABASE_VER=`echo "select version from schema_version where version_int='$DATABASE_VER_NUM';" | $DBCMD | tail -n+2`
- [ "$DATABASE_VER_NUM" -lt 0 -o "$DATABASE_VER_NUM" -gt 100 ] &&
- echo " Error can not get database version ($DATABASE_VER?)" >&2 && exit 1
- #echo "_${DATABASE_VER_NUM}_${DATABASE_VER}"
-fi
-
-[ "$DATABASE_VER_NUM" -gt "$LAST_DB_VERSION" ] &&
- echo "Database has been upgraded with a newer version of this script. Use this version to downgrade" >&2 &&
- exit 1
-
#GET DATABASE TARGET VERSION
#DB_VERSION=0
#[ $OPENMANO_VER_NUM -ge 2002 ] && DB_VERSION=1 #0.2.2 => 1
@@ -203,6 +192,8 @@
#[ $OPENMANO_VER_NUM -ge 5070 ] && DB_VERSION=32 #0.5.70 => 32
#[ $OPENMANO_VER_NUM -ge 5082 ] && DB_VERSION=33 #0.5.82 => 33
#[ $OPENMANO_VER_NUM -ge 6000 ] && DB_VERSION=34 #0.6.00 => 34
+#[ $OPENMANO_VER_NUM -ge 6001 ] && DB_VERSION=35 #0.6.01 => 35
+#[ $OPENMANO_VER_NUM -ge 6003 ] && DB_VERSION=35 #0.6.03 => 36
#TODO ... put next versions here
function upgrade_to_1(){
@@ -1296,20 +1287,18 @@
}
function upgrade_to_33(){
- echo " Add PDU information to 'vms"
+ echo " Add PDU information to 'vms'"
sql "ALTER TABLE vms ADD COLUMN pdu_type VARCHAR(255) NULL DEFAULT NULL AFTER osm_id;"
sql "ALTER TABLE instance_nets ADD COLUMN vim_name VARCHAR(255) NULL DEFAULT NULL AFTER vim_net_id;"
sql "INSERT INTO schema_version (version_int, version, openmano_ver, comments, date) "\
"VALUES (33, '0.33', '0.5.82', 'Add pdu information to vms', '2018-11-13');"
}
function downgrade_from_33(){
- echo " Remove back PDU information from' vms'"
+ echo " Remove back PDU information from 'vms'"
sql "ALTER TABLE vms DROP COLUMN pdu_type;"
sql "ALTER TABLE instance_nets DROP COLUMN vim_name;"
sql "DELETE FROM schema_version WHERE version_int='33';"
}
-
-
function upgrade_to_X(){
echo " change 'datacenter_nets'"
sql "ALTER TABLE datacenter_nets ADD COLUMN vim_tenant_id VARCHAR(36) NOT NULL AFTER datacenter_id, DROP INDEX name_datacenter_id, ADD UNIQUE INDEX name_datacenter_id (name, datacenter_id, vim_tenant_id);"
@@ -1318,34 +1307,73 @@
echo " Change back 'datacenter_nets'"
sql "ALTER TABLE datacenter_nets DROP COLUMN vim_tenant_id, DROP INDEX name_datacenter_id, ADD UNIQUE INDEX name_datacenter_id (name, datacenter_id);"
}
-
function upgrade_to_34() {
echo " Create databases required for WIM features"
script="$(find "${DBUTILS}/migrations/up" -iname "34*.sql" | tail -1)"
sql "source ${script}"
}
-
function downgrade_from_34() {
echo " Drop databases required for WIM features"
script="$(find "${DBUTILS}/migrations/down" -iname "34*.sql" | tail -1)"
sql "source ${script}"
}
+function upgrade_to_35(){
+ echo " Create databases required for WIM features"
+ script="$(find "${DBUTILS}/migrations/up" -iname "35*.sql" | tail -1)"
+ sql "source ${script}"
+}
+function downgrade_from_35(){
+ echo " Drop databases required for WIM features"
+ script="$(find "${DBUTILS}/migrations/down" -iname "35*.sql" | tail -1)"
+ sql "source ${script}"
+}
+function upgrade_to_36(){
+ echo " Allow null for image_id at 'vms'"
+ sql "ALTER TABLE vms ALTER image_id DROP DEFAULT;"
+ sql "ALTER TABLE vms CHANGE COLUMN image_id image_id VARCHAR(36) NULL COMMENT 'Link to image table' AFTER " \
+ "flavor_id;"
+ echo " Enlarge config at 'wims' and 'wim_accounts'"
+ sql "ALTER TABLE wims CHANGE COLUMN config config TEXT NULL DEFAULT NULL AFTER wim_url;"
+ sql "ALTER TABLE wim_accounts CHANGE COLUMN config config TEXT NULL DEFAULT NULL AFTER password;"
+ sql "INSERT INTO schema_version (version_int, version, openmano_ver, comments, date) "\
+ "VALUES (36, '0.36', '0.6.03', 'Allow vm without image_id for PDUs', '2018-12-19');"
+}
+function downgrade_from_36(){
+ echo " Force back not null for image_id at 'vms'"
+ sql "ALTER TABLE vms ALTER image_id DROP DEFAULT;"
+ sql "ALTER TABLE vms CHANGE COLUMN image_id image_id VARCHAR(36) NOT NULL COMMENT 'Link to image table' AFTER " \
+ "flavor_id;"
+ # For downgrade do not restore wims/wim_accounts config to varchar 4000
+ sql "DELETE FROM schema_version WHERE version_int='36';"
+}
#TODO ... put functions here
-# echo "db version = "${DATABASE_VER_NUM}
-[ $DB_VERSION -eq $DATABASE_VER_NUM ] && echo " current database version '$DATABASE_VER_NUM' is ok" && exit 0
-# Create a backup database content
-TEMPFILE2="$(mktemp -q --tmpdir "backupdb.XXXXXX.sql")"
-trap 'rm -f "$TEMPFILE2"' EXIT
-mysqldump $DEF_EXTRA_FILE_PARAM --add-drop-table --add-drop-database --routines --databases $DBNAME > $TEMPFILE2
+function del_schema_version_process()
+{
+ echo "DELETE FROM schema_version WHERE version_int='0';" | $DBCMD ||
+ ! echo " ERROR writing on schema_version" >&2 || exit 1
+}
+
+function set_schema_version_process()
+{
+ echo "INSERT INTO schema_version (version_int, version, openmano_ver, comments, date) VALUES "\
+ "(0, '0.0', '0.0.0', 'migration from $DATABASE_VER_NUM to $DB_VERSION backup: $BACKUP_FILE',"\
+ "'$(date +%Y-%m-%d)');" | $DBCMD ||
+ ! echo " Cannot set database at migration process writing into schema_version" >&2 || exit 1
+
+}
function rollback_db()
{
- cat $TEMPFILE2 | mysql $DEF_EXTRA_FILE_PARAM && echo " Aborted! Rollback database OK" ||
- echo " Aborted! Rollback database FAIL"
- exit 1
+ if echo $DATABASE_PROCESS | grep -q init ; then # Empty database. No backup needed
+ echo " Aborted! Rollback database not needed" && exit 1
+ else # migration a non empty database or Recovering a migration process
+ cat $BACKUP_FILE | mysql $DEF_EXTRA_FILE_PARAM && echo " Aborted! Rollback database OK" &&
+ del_schema_version_process && rm -f "$BACKUP_FILE" && exit 1
+ echo " Aborted! Rollback database FAIL" && exit 1
+ fi
}
function sql() # send a sql command
@@ -1354,27 +1382,86 @@
return 0
}
-#UPGRADE DATABASE step by step
-while [ $DB_VERSION -gt $DATABASE_VER_NUM ]
-do
- echo " upgrade database from version '$DATABASE_VER_NUM' to '$((DATABASE_VER_NUM+1))'"
- DATABASE_VER_NUM=$((DATABASE_VER_NUM+1))
- upgrade_to_${DATABASE_VER_NUM}
- #FILE_="${DIRNAME}/upgrade_to_${DATABASE_VER_NUM}.sh"
- #[ ! -x "$FILE_" ] && echo "Error, can not find script '$FILE_' to upgrade" >&2 && exit -1
- #$FILE_ || exit -1 # if fail return
-done
+function migrate()
+{
+ #UPGRADE DATABASE step by step
+ while [ $DB_VERSION -gt $DATABASE_VER_NUM ]
+ do
+ echo " upgrade database from version '$DATABASE_VER_NUM' to '$((DATABASE_VER_NUM+1))'"
+ DATABASE_VER_NUM=$((DATABASE_VER_NUM+1))
+ upgrade_to_${DATABASE_VER_NUM}
+ #FILE_="${DIRNAME}/upgrade_to_${DATABASE_VER_NUM}.sh"
+ #[ ! -x "$FILE_" ] && echo "Error, can not find script '$FILE_' to upgrade" >&2 && exit -1
+ #$FILE_ || exit -1 # if fail return
+ done
-#DOWNGRADE DATABASE step by step
-while [ $DB_VERSION -lt $DATABASE_VER_NUM ]
-do
- echo " downgrade database from version '$DATABASE_VER_NUM' to '$((DATABASE_VER_NUM-1))'"
- #FILE_="${DIRNAME}/downgrade_from_${DATABASE_VER_NUM}.sh"
- #[ ! -x "$FILE_" ] && echo "Error, can not find script '$FILE_' to downgrade" >&2 && exit -1
- #$FILE_ || exit -1 # if fail return
- downgrade_from_${DATABASE_VER_NUM}
- DATABASE_VER_NUM=$((DATABASE_VER_NUM-1))
-done
+ #DOWNGRADE DATABASE step by step
+ while [ $DB_VERSION -lt $DATABASE_VER_NUM ]
+ do
+ echo " downgrade database from version '$DATABASE_VER_NUM' to '$((DATABASE_VER_NUM-1))'"
+ #FILE_="${DIRNAME}/downgrade_from_${DATABASE_VER_NUM}.sh"
+ #[ ! -x "$FILE_" ] && echo "Error, can not find script '$FILE_' to downgrade" >&2 && exit -1
+ #$FILE_ || exit -1 # if fail return
+ downgrade_from_${DATABASE_VER_NUM}
+ DATABASE_VER_NUM=$((DATABASE_VER_NUM-1))
+ done
+}
+
+
+# check if current database is ok
+function check_migration_needed()
+{
+ DATABASE_VER_NUM=`echo "select max(version_int) from schema_version;" | $DBCMD | tail -n+2` ||
+ ! echo " ERROR cannot read from schema_version" || exit 1
+
+ if [[ -z "$DATABASE_VER_NUM" ]] || [[ "$DATABASE_VER_NUM" -lt 0 ]] || [[ "$DATABASE_VER_NUM" -gt 100 ]] ; then
+ echo " Error can not get database version ($DATABASE_VER_NUM?)" >&2
+ exit 1
+ fi
+
+ [[ $DB_VERSION -eq $DATABASE_VER_NUM ]] && echo " current database version '$DATABASE_VER_NUM' is ok" && return 1
+ [[ "$DATABASE_VER_NUM" -gt "$LAST_DB_VERSION" ]] &&
+ echo "Database has been upgraded with a newer version of this script. Use this version to downgrade" >&2 &&
+ exit 1
+ return 0
+}
+
+DATABASE_PROCESS=`echo "select comments from schema_version where version_int=0;" | $DBCMD | tail -n+2` ||
+ ! echo " ERROR cannot read from schema_version" || exit 1
+if [[ -z "$DATABASE_PROCESS" ]] ; then # migration a non empty database
+ check_migration_needed || exit 0
+ # Create a backup database content
+ [[ -n "$BACKUP_DIR" ]] && BACKUP_FILE="$(mktemp -q "${BACKUP_DIR}/backupdb.XXXXXX.sql")"
+ [[ -z "$BACKUP_DIR" ]] && BACKUP_FILE="$(mktemp -q --tmpdir "backupdb.XXXXXX.sql")"
+ mysqldump $DEF_EXTRA_FILE_PARAM --add-drop-table --add-drop-database --routines --databases $DBNAME > $BACKUP_FILE ||
+ ! echo "Cannot create Backup file '$BACKUP_FILE'" >&2 || exit 1
+ echo " Backup file '$BACKUP_FILE' created"
+ # Set schema version
+ set_schema_version_process
+ migrate
+ del_schema_version_process
+ rm -f "$BACKUP_FILE"
+elif echo $DATABASE_PROCESS | grep -q init ; then # Empty database. No backup needed
+ echo " Migrating an empty database"
+ if check_migration_needed ; then
+ migrate
+ fi
+ del_schema_version_process
+
+else # Recover Migration process
+ BACKUP_FILE=${DATABASE_PROCESS##*backup: }
+ [[ -f "$BACKUP_FILE" ]] || ! echo "Previous migration process fail and cannot recover backup file '$BACKUP_FILE'" >&2 ||
+ exit 1
+ echo " Previous migration was killed. Restoring database from rollback file'$BACKUP_FILE'"
+ cat $BACKUP_FILE | mysql $DEF_EXTRA_FILE_PARAM || ! echo " Cannot load backup file '$BACKUP_FILE'" >&2 || exit 1
+ if check_migration_needed ; then
+ set_schema_version_process
+ migrate
+ fi
+ del_schema_version_process
+ rm -f "$BACKUP_FILE"
+fi
+exit 0
#echo done
diff --git a/database_utils/migrations/down/35_remove_sfc_ingress_and_egress.sql b/database_utils/migrations/down/35_remove_sfc_ingress_and_egress.sql
new file mode 100644
index 0000000..01f38f4
--- /dev/null
+++ b/database_utils/migrations/down/35_remove_sfc_ingress_and_egress.sql
@@ -0,0 +1,16 @@
+--
+-- Removing ingress and egress ports for SFC purposes.
+-- Inserting only one port for ingress and egress.
+--
+
+ALTER TABLE sce_rsp_hops
+ DROP FOREIGN KEY FK_interfaces_rsp_hop_ingress,
+ CHANGE COLUMN ingress_interface_id interface_id VARCHAR(36) NOT NULL
+ AFTER if_order,
+ ADD CONSTRAINT FK_interfaces_rsp_hop
+ FOREIGN KEY (interface_id)
+ REFERENCES interfaces (uuid) ON UPDATE CASCADE ON DELETE CASCADE,
+ DROP FOREIGN KEY FK_interfaces_rsp_hop_egress,
+ DROP COLUMN egress_interface_id;
+
+DELETE FROM schema_version WHERE version_int='35';
diff --git a/database_utils/migrations/up/35_add_sfc_ingress_and_egress.sql b/database_utils/migrations/up/35_add_sfc_ingress_and_egress.sql
new file mode 100644
index 0000000..b528c6d
--- /dev/null
+++ b/database_utils/migrations/up/35_add_sfc_ingress_and_egress.sql
@@ -0,0 +1,29 @@
+--
+-- Adding different ingress and egress ports for SFC.
+--
+
+ALTER TABLE sce_rsp_hops
+ DROP FOREIGN KEY FK_interfaces_rsp_hop,
+ CHANGE COLUMN interface_id ingress_interface_id VARCHAR(36) NOT NULL
+ AFTER if_order,
+ ADD CONSTRAINT FK_interfaces_rsp_hop_ingress
+ FOREIGN KEY (ingress_interface_id)
+ REFERENCES interfaces (uuid) ON UPDATE CASCADE ON DELETE CASCADE,
+ ADD COLUMN egress_interface_id VARCHAR(36) NULL DEFAULT NULL
+ AFTER ingress_interface_id;
+
+UPDATE sce_rsp_hops
+ SET egress_interface_id = ingress_interface_id;
+
+ALTER TABLE sce_rsp_hops
+ ALTER COLUMN egress_interface_id DROP DEFAULT;
+
+ALTER TABLE sce_rsp_hops
+ MODIFY COLUMN egress_interface_id VARCHAR(36) NOT NULL
+ AFTER ingress_interface_id,
+ ADD CONSTRAINT FK_interfaces_rsp_hop_egress
+ FOREIGN KEY (egress_interface_id)
+ REFERENCES interfaces (uuid) ON UPDATE CASCADE ON DELETE CASCADE;
+
+INSERT INTO schema_version (version_int, version, openmano_ver, comments, date)
+ VALUES (35, '0.35', '0.6.02', 'Adding ingress and egress ports for RSPs', '2018-12-11');
diff --git a/docker/Dockerfile-local b/docker/Dockerfile-local
index e7e05ce..8ec5e33 100644
--- a/docker/Dockerfile-local
+++ b/docker/Dockerfile-local
@@ -65,3 +65,6 @@
RO_LOG_LEVEL=DEBUG
CMD RO-start.sh
+
+# HEALTHCHECK --start-period=30s --interval=10s --timeout=5s --retries=12 \
+# CMD curl --silent --fail localhost:9090/openmano/tenants || exit 1
diff --git a/openmanod b/openmanod
index 5e9cc92..a4af12f 100755
--- a/openmanod
+++ b/openmanod
@@ -50,9 +50,9 @@
__author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ = "$26-aug-2014 11:09:29$"
-__version__ = "0.6.00"
-version_date = "Nov 2018"
-database_version = 34 # expected database schema version
+__version__ = "0.6.04"
+version_date = "Jan 2019"
+database_version = 36 # expected database schema version
global global_config
global logger
diff --git a/osm_ro/db_base.py b/osm_ro/db_base.py
index 7b48f43..e7a4fb3 100644
--- a/osm_ro/db_base.py
+++ b/osm_ro/db_base.py
@@ -169,11 +169,11 @@
def escape(self, value):
return self.con.escape(value)
-
def escape_string(self, value):
+ if isinstance(value, "unicode"):
+ value = value.encode("utf8")
return self.con.escape_string(value)
-
def get_db_version(self):
''' Obtain the database schema version.
Return: (negative, text) if error or version 0.0 where schema_version table is missing
@@ -274,13 +274,13 @@
httperrors.Internal_Server_Error)
def __str2db_format(self, data):
- '''Convert string data to database format.
+ """Convert string data to database format.
If data is None it returns the 'Null' text,
otherwise it returns the text surrounded by quotes ensuring internal quotes are escaped.
- '''
- if data==None:
+ """
+ if data is None:
return 'Null'
- elif isinstance(data[1], str):
+ elif isinstance(data[1], (str, unicode)):
return json.dumps(data)
else:
return json.dumps(str(data))
@@ -294,9 +294,9 @@
B can be also a dict with special keys:
{"INCREMENT": NUMBER}, then it produce "A=A+NUMBER"
"""
- if data[1] == None:
+ if data[1] is None:
return str(data[0]) + "=Null"
- elif isinstance(data[1], str):
+ elif isinstance(data[1], (str, unicode)):
return str(data[0]) + '=' + json.dumps(data[1])
elif isinstance(data[1], dict):
if "INCREMENT" in data[1]:
@@ -341,9 +341,13 @@
for v2 in v:
if v2 is None:
cmd2.append(k.replace("=", " is").replace("<>", " is not") + " Null")
+ elif isinstance(v2, (str, unicode)):
+ cmd2.append(k + json.dumps(v2))
else:
cmd2.append(k + json.dumps(str(v2)))
cmd.append("(" + " OR ".join(cmd2) + ")")
+ elif isinstance(v, (str, unicode)):
+ cmd.append(k + json.dumps(v))
else:
cmd.append(k + json.dumps(str(v)))
elif isinstance(data, (tuple, list)):
diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py
index b1c86f9..4341422 100644
--- a/osm_ro/nfvo.py
+++ b/osm_ro/nfvo.py
@@ -344,7 +344,7 @@
image_list = []
vms = mydb.get_rows(SELECT=('image_id','image_list'), FROM='vms', WHERE={'vnf_id': vnf_id})
for vm in vms:
- if vm["image_id"] not in image_list:
+ if vm["image_id"] and vm["image_id"] not in image_list:
image_list.append(vm["image_id"])
if vm["image_list"]:
vm_image_list = yaml.load(vm["image_list"])
@@ -1070,6 +1070,11 @@
devices.append(device)
+ if not db_vm.get("image_id"):
+ if not db_vm["pdu_type"]:
+ raise NfvoException("Not defined image for VDU")
+ # create a fake image
+
# cloud-init
boot_data = {}
if vdu.get("cloud-init"):
@@ -2460,25 +2465,41 @@
str(nsd["id"]), str(rsp["id"]), str(iface["member-vnf-index-ref"])),
httperrors.Bad_Request)
- existing_ifaces = mydb.get_rows(SELECT=('i.uuid as uuid',),
- FROM="interfaces as i join vms on i.vm_id=vms.uuid",
- WHERE={'vnf_id': vnf_index2vnf_uuid[vnf_index],
- 'external_name': get_str(iface, "vnfd-connection-point-ref",
- 255)})
- if not existing_ifaces:
+ ingress_existing_ifaces = mydb.get_rows(SELECT=('i.uuid as uuid',),
+ FROM="interfaces as i join vms on i.vm_id=vms.uuid",
+ WHERE={
+ 'vnf_id': vnf_index2vnf_uuid[vnf_index],
+ 'external_name': get_str(iface, "vnfd-ingress-connection-point-ref",
+ 255)})
+ if not ingress_existing_ifaces:
raise NfvoException("Error. Invalid NS descriptor at 'nsd[{}]':'rsp[{}]':'vnfd-connection-point"
- "-ref':'vnfd-connection-point-ref':'{}'. Reference to a non-existing "
+ "-ref':'vnfd-ingress-connection-point-ref':'{}'. Reference to a non-existing "
"connection-point name at VNFD '{}'".format(
- str(nsd["id"]), str(rsp["id"]), str(iface["vnfd-connection-point-ref"]),
- str(iface.get("vnfd-id-ref"))[:255]),
- httperrors.Bad_Request)
- interface_uuid = existing_ifaces[0]["uuid"]
+ str(nsd["id"]), str(rsp["id"]), str(iface["vnfd-ingress-connection-point-ref"]),
+ str(iface.get("vnfd-id-ref"))[:255]), httperrors.Bad_Request)
+
+ egress_existing_ifaces = mydb.get_rows(SELECT=('i.uuid as uuid',),
+ FROM="interfaces as i join vms on i.vm_id=vms.uuid",
+ WHERE={
+ 'vnf_id': vnf_index2vnf_uuid[vnf_index],
+ 'external_name': get_str(iface, "vnfd-egress-connection-point-ref",
+ 255)})
+ if not egress_existing_ifaces:
+ raise NfvoException("Error. Invalid NS descriptor at 'nsd[{}]':'rsp[{}]':'vnfd-connection-point"
+ "-ref':'vnfd-egress-connection-point-ref':'{}'. Reference to a non-existing "
+ "connection-point name at VNFD '{}'".format(
+ str(nsd["id"]), str(rsp["id"]), str(iface["vnfd-egress-connection-point-ref"]),
+ str(iface.get("vnfd-id-ref"))[:255]), HTTP_Bad_Request)
+
+ ingress_interface_uuid = ingress_existing_ifaces[0]["uuid"]
+ egress_interface_uuid = egress_existing_ifaces[0]["uuid"]
sce_rsp_hop_uuid = str(uuid4())
uuid_list.append(sce_rsp_hop_uuid)
db_sce_rsp_hop = {
"uuid": sce_rsp_hop_uuid,
"if_order": if_order,
- "interface_id": interface_uuid,
+ "ingress_interface_id": ingress_interface_uuid,
+ "egress_interface_id": egress_interface_uuid,
"sce_vnf_id": vnf_index2scevnf_uuid[vnf_index],
"sce_rsp_id": sce_rsp_uuid,
}
@@ -2959,8 +2980,8 @@
def update(d, u):
- '''Takes dict d and updates it with the values in dict u.'''
- '''It merges all depth levels'''
+ """Takes dict d and updates it with the values in dict u.
+ It merges all depth levels"""
for k, v in u.iteritems():
if isinstance(v, collections.Mapping):
r = update(d.get(k, {}), v)
@@ -3110,6 +3131,8 @@
raise NfvoException("Invalid net id or name '{}' at instance:vnfs:networks".format(net_id), httperrors.Bad_Request)
if net_instance_desc.get("vim-network-name"):
scenario_net["vim-network-name"] = net_instance_desc["vim-network-name"]
+ if net_instance_desc.get("vim-network-id"):
+ scenario_net["vim-network-id"] = net_instance_desc["vim-network-id"]
if net_instance_desc.get("name"):
scenario_net["name"] = net_instance_desc["name"]
if 'ip-profile' in net_instance_desc:
@@ -3250,7 +3273,7 @@
lookfor_network = True
lookfor_filter["name"] = sce_net.get("vim_network_name")
elif sce_net["external"]:
- if sce_net['vim_id'] is not None:
+ if sce_net.get('vim_id'):
# there is a netmap at datacenter_nets database # TODO REVISE!!!!
create_network = False
lookfor_network = True
@@ -3367,8 +3390,9 @@
sfs_created = []
for cp in rsp['connection_points']:
count = mydb.get_rows(
- SELECT=('vms.count'),
- FROM="vms join interfaces on vms.uuid=interfaces.vm_id join sce_rsp_hops as h on interfaces.uuid=h.interface_id",
+ SELECT='vms.count',
+ FROM="vms join interfaces on vms.uuid=interfaces.vm_id join sce_rsp_hops as h "
+ "on interfaces.uuid=h.ingress_interface_id",
WHERE={'h.uuid': cp['uuid']})[0]['count']
instance_vnf = next((item for item in db_instance_vnfs if item['sce_vnf_id'] == cp['sce_vnf_id']), None)
instance_vms = [item for item in db_instance_vms if item['instance_vnf_id'] == instance_vnf['uuid']]
@@ -3383,6 +3407,10 @@
for i in range(count):
# create sfis
sfi_uuid = str(uuid4())
+ extra_params = {
+ "ingress_interface_id": cp["ingress_interface_id"],
+ "egress_interface_id": cp["egress_interface_id"]
+ }
uuid_list.append(sfi_uuid)
db_sfi = {
"uuid": sfi_uuid,
@@ -3401,7 +3429,7 @@
"status": "SCHEDULED",
"item": "instance_sfis",
"item_id": sfi_uuid,
- "extra": yaml.safe_dump({"params": "", "depends_on": [dependencies[i]]},
+ "extra": yaml.safe_dump({"params": extra_params, "depends_on": [dependencies[i]]},
default_flow_style=True, width=256)
}
sfis_created.append(task_index)
@@ -3629,8 +3657,12 @@
}
db_instance_nets.append(db_net)
+ lookfor_filter = {}
if net.get("vim-network-name"):
- lookfor_filter = {"name": net["vim-network-name"]}
+ lookfor_filter["name"] = net["vim-network-name"]
+ if net.get("vim-network-id"):
+ lookfor_filter["id"] = net["vim-network-id"]
+ if lookfor_filter:
task_action = "FIND"
task_extra = {"params": (lookfor_filter,)}
else:
@@ -4523,7 +4555,7 @@
iface2iface = {}
where = {"item": "instance_vms", "item_id": target_vm["uuid"], "action": "CREATE"}
- vim_action_to_clone = mydb.get_rows(FROM="vim_actions", WHERE=where)
+ vim_action_to_clone = mydb.get_rows(FROM="vim_wim_actions", WHERE=where)
if not vim_action_to_clone:
raise NfvoException("Cannot find the vim_action at database with {}".format(where), httperrors.Internal_Server_Error)
vim_action_to_clone = vim_action_to_clone[0]
@@ -4621,7 +4653,7 @@
# {"instance_sfs": db_instance_sfs},
# {"instance_classifications": db_instance_classifications},
# {"instance_sfps": db_instance_sfps},
- {"vim_actions": db_vim_actions}
+ {"vim_wim_actions": db_vim_actions}
]
logger.debug("create_vdu done DB tables: %s",
yaml.safe_dump(db_tables, indent=4, default_flow_style=False))
diff --git a/osm_ro/nfvo_db.py b/osm_ro/nfvo_db.py
index 9d52803..bad7cec 100644
--- a/osm_ro/nfvo_db.py
+++ b/osm_ro/nfvo_db.py
@@ -21,9 +21,9 @@
# contact with: nfvlabs@tid.es
##
-'''
+"""
NFVO DB engine. It implements all the methods to interact with the Openmano Database
-'''
+"""
__author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ ="$28-aug-2014 10:05:01$"
@@ -629,18 +629,22 @@
else:
del vm["image_list"]
if datacenter_vim_id!=None:
- cmd = "SELECT vim_id FROM datacenters_images WHERE image_id='{}' AND datacenter_vim_id='{}'".format(vm['image_id'],datacenter_vim_id)
- self.logger.debug(cmd)
- self.cur.execute(cmd)
- if self.cur.rowcount==1:
- vim_image_dict = self.cur.fetchone()
- vm['vim_image_id']=vim_image_dict['vim_id']
- cmd = "SELECT vim_id FROM datacenters_flavors WHERE flavor_id='{}' AND datacenter_vim_id='{}'".format(vm['flavor_id'],datacenter_vim_id)
- self.logger.debug(cmd)
- self.cur.execute(cmd)
- if self.cur.rowcount==1:
- vim_flavor_dict = self.cur.fetchone()
- vm['vim_flavor_id']=vim_flavor_dict['vim_id']
+ if vm['image_id']:
+ cmd = "SELECT vim_id FROM datacenters_images WHERE image_id='{}' AND " \
+ "datacenter_vim_id='{}'".format(vm['image_id'], datacenter_vim_id)
+ self.logger.debug(cmd)
+ self.cur.execute(cmd)
+ if self.cur.rowcount==1:
+ vim_image_dict = self.cur.fetchone()
+ vm['vim_image_id']=vim_image_dict['vim_id']
+ if vm['flavor_id']:
+ cmd = "SELECT vim_id FROM datacenters_flavors WHERE flavor_id='{}' AND " \
+ "datacenter_vim_id='{}'".format(vm['flavor_id'], datacenter_vim_id)
+ self.logger.debug(cmd)
+ self.cur.execute(cmd)
+ if self.cur.rowcount==1:
+ vim_flavor_dict = self.cur.fetchone()
+ vm['vim_flavor_id']=vim_flavor_dict['vim_id']
#interfaces
cmd = "SELECT uuid,internal_name,external_name,net_id,type,vpci,mac,bw,model,ip_address," \
@@ -724,7 +728,8 @@
self.cur.execute(cmd)
vnffg['rsps'] = self.cur.fetchall()
for rsp in vnffg['rsps']:
- cmd = "SELECT uuid,if_order,interface_id,sce_vnf_id FROM sce_rsp_hops WHERE sce_rsp_id='{}' "\
+ cmd = "SELECT uuid,if_order,ingress_interface_id,egress_interface_id,sce_vnf_id " \
+ "FROM sce_rsp_hops WHERE sce_rsp_id='{}' "\
"ORDER BY created_at".format(rsp['uuid'])
self.logger.debug(cmd)
self.cur.execute(cmd)
diff --git a/osm_ro/openmano_schemas.py b/osm_ro/openmano_schemas.py
index d10f862..b53bbac 100644
--- a/osm_ro/openmano_schemas.py
+++ b/osm_ro/openmano_schemas.py
@@ -1056,6 +1056,7 @@
"type": "object",
"properties": {
"vim-network-name": name_schema,
+ "vim-network-id": name_schema,
"ip-profile": ip_profile_schema,
"name": name_schema,
}
@@ -1080,7 +1081,8 @@
"properties":{
"ip_address": ip_schema,
"datacenter": name_schema,
- "vim-network-name": name_schema
+ "vim-network-name": name_schema,
+ "vim-network-id": name_schema
},
"patternProperties":{
".": {"type": "string"}
@@ -1105,6 +1107,7 @@
#In oder words, it is the same as 'try to map to the VIM network (netmap-use) if exist, and if not create the network (netmap-create)
"netmap-use": name_schema, #
"vim-network-name": name_schema, #override network name
+ "vim-network-id": name_schema,
#"ip-profile": ip_profile_schema,
"datacenter": name_schema,
}
diff --git a/osm_ro/vim_thread.py b/osm_ro/vim_thread.py
index 48c8e32..f7bc40b 100644
--- a/osm_ro/vim_thread.py
+++ b/osm_ro/vim_thread.py
@@ -83,6 +83,7 @@
"vmware": vimconn_vmware,
}
+
def is_task_id(task_id):
return task_id.startswith("TASK-")
@@ -96,8 +97,8 @@
class vim_thread(threading.Thread):
- REFRESH_BUILD = 5 # 5 seconds
- REFRESH_ACTIVE = 60 # 1 minute
+ REFRESH_BUILD = 5 # 5 seconds
+ REFRESH_ACTIVE = 60 # 1 minute
def __init__(self, task_lock, name=None, datacenter_name=None, datacenter_tenant_id=None,
db=None, db_lock=None, ovim=None):
@@ -120,7 +121,7 @@
self.name = name
self.vim_persistent_info = {}
- self.logger = logging.getLogger('openmano.vim.'+self.name)
+ self.logger = logging.getLogger('openmano.vim.' + self.name)
self.db = db
self.db_lock = db_lock
@@ -142,7 +143,7 @@
def get_vimconnector(self):
try:
- from_= "datacenter_tenants as dt join datacenters as d on dt.datacenter_id=d.uuid"
+ from_ = "datacenter_tenants as dt join datacenters as d on dt.datacenter_id=d.uuid"
select_ = ('type', 'd.config as config', 'd.uuid as datacenter_id', 'vim_url', 'vim_url_admin',
'd.name as datacenter_name', 'dt.uuid as datacenter_tenant_id',
'dt.vim_tenant_name as vim_tenant_name', 'dt.vim_tenant_id as vim_tenant_id',
@@ -346,11 +347,11 @@
task_interface["sdn_port_id"] = sdn_port_id
task_need_update = True
except (ovimException, Exception) as e:
- error_text = "ovimException creating new_external_port compute_node={}"\
+ error_text = "ovimException creating new_external_port compute_node={}" \
" pci={} vlan={} {}".format(
- interface["compute_node"],
- interface["pci"],
- interface.get("vlan"), e)
+ interface["compute_node"],
+ interface["pci"],
+ interface.get("vlan"), e)
self.logger.error("task={} get-VM: {}".format(task_id, error_text), exc_info=True)
task_warning_msg += error_text
# TODO Set error_msg at instance_nets instead of instance VMs
@@ -360,6 +361,7 @@
'instance_interfaces',
UPDATE={"mac_address": interface.get("mac_address"),
"ip_address": interface.get("ip_address"),
+ "vim_interface_id": interface.get("vim_interface_id"),
"vim_info": interface.get("vim_info"),
"sdn_port_id": task_interface.get("sdn_port_id"),
"compute_node": interface.get("compute_node"),
@@ -441,8 +443,8 @@
vim_info_error_msg = str(sdn_net.get("last_error"))
else:
vim_info_error_msg = "VIM_ERROR: {} && SDN_ERROR: {}".format(
- self._format_vim_error_msg(vim_info_error_msg, 1024//2-14),
- self._format_vim_error_msg(sdn_net["last_error"], 1024//2-14))
+ self._format_vim_error_msg(vim_info_error_msg, 1024 // 2 - 14),
+ self._format_vim_error_msg(sdn_net["last_error"], 1024 // 2 - 14))
vim_info_status = "ERROR"
elif sdn_net["status"] == "BUILD":
if vim_info_status == "ACTIVE":
@@ -628,7 +630,7 @@
database_update["vim_net_id"] = None
no_refresh_tasks = ['instance_sfis', 'instance_sfs',
- 'instance_classifications', 'instance_sfps']
+ 'instance_classifications', 'instance_sfps']
if task["action"] == "DELETE":
action_key = task["item"] + task["item_id"]
del self.grouped_tasks[action_key]
@@ -692,10 +694,10 @@
continue
index = int(task_id)
- if index < len(vim_actions_list) and vim_actions_list[index]["task_index"] == index and\
- vim_actions_list[index]["instance_action_id"] == task["instance_action_id"]:
- task["depends"]["TASK-" + str(index)] = vim_actions_list[index]
- task["depends"]["TASK-{}.{}".format(task["instance_action_id"], index)] = vim_actions_list[index]
+ if index < len(vim_actions_list) and vim_actions_list[index]["task_index"] == index and \
+ vim_actions_list[index]["instance_action_id"] == task["instance_action_id"]:
+ task["depends"]["TASK-" + str(index)] = vim_actions_list[index]
+ task["depends"]["TASK-{}.{}".format(task["instance_action_id"], index)] = vim_actions_list[index]
if extra.get("interfaces"):
task["vim_interfaces"] = {}
else:
@@ -754,7 +756,7 @@
if task["status"] == "SCHEDULED":
task["status"] = "SUPERSEDED"
return True
- else: # task["status"] == "processing"
+ else: # task["status"] == "processing"
self.task_lock.release()
return False
@@ -831,7 +833,7 @@
@staticmethod
def _format_vim_error_msg(error_text, max_length=1024):
if error_text and len(error_text) >= max_length:
- return error_text[:max_length//2-3] + " ... " + error_text[-max_length//2+3:]
+ return error_text[:max_length // 2 - 3] + " ... " + error_text[-max_length // 2 + 3:]
return error_text
def new_vm(self, task):
@@ -864,14 +866,15 @@
task_interfaces[iface["vim_id"]] = {"iface_id": iface["uuid"]}
with self.db_lock:
result = self.db.get_rows(
- SELECT=('sdn_net_id',),
+ SELECT=('sdn_net_id', 'interface_id'),
FROM='instance_nets as ine join instance_interfaces as ii on ii.instance_net_id=ine.uuid',
WHERE={'ii.uuid': iface["uuid"]})
if result:
task_interfaces[iface["vim_id"]]["sdn_net_id"] = result[0]['sdn_net_id']
+ task_interfaces[iface["vim_id"]]["interface_id"] = result[0]['interface_id']
else:
self.logger.critical("task={} new-VM: instance_nets uuid={} not found at DB".format(task_id,
- iface["uuid"]), exc_info=True)
+ iface["uuid"]), exc_info=True)
task["vim_info"] = {}
task["vim_interfaces"] = {}
@@ -1064,17 +1067,39 @@
def new_sfi(self, task):
vim_sfi_id = None
try:
+ # Waits for interfaces to be ready (avoids failure)
+ time.sleep(1)
dep_id = "TASK-" + str(task["extra"]["depends_on"][0])
task_id = task["instance_action_id"] + "." + str(task["task_index"])
error_text = ""
- interfaces = task.get("depends").get(dep_id).get("extra").get("interfaces").keys()
+ interfaces = task.get("depends").get(dep_id).get("extra").get("interfaces")
+ ingress_interface_id = task.get("extra").get("params").get("ingress_interface_id")
+ egress_interface_id = task.get("extra").get("params").get("egress_interface_id")
+ ingress_vim_interface_id = None
+ egress_vim_interface_id = None
+ for vim_interface, interface_data in interfaces.iteritems():
+ if interface_data.get("interface_id") == ingress_interface_id:
+ ingress_vim_interface_id = vim_interface
+ break
+ if ingress_interface_id != egress_interface_id:
+ for vim_interface, interface_data in interfaces.iteritems():
+ if interface_data.get("interface_id") == egress_interface_id:
+ egress_vim_interface_id = vim_interface
+ break
+ else:
+ egress_vim_interface_id = ingress_vim_interface_id
+ if not ingress_vim_interface_id or not egress_vim_interface_id:
+ self.logger.error("Error creating Service Function Instance, Ingress: %s, Egress: %s",
+ ingress_vim_interface_id, egress_vim_interface_id)
+ return False, None
# At the moment, every port associated with the VM will be used both as ingress and egress ports.
# Bear in mind that different VIM connectors might support SFI differently. In the case of OpenStack, only the
# first ingress and first egress ports will be used to create the SFI (Port Pair).
- port_id_list = [interfaces[0]]
+ ingress_port_id_list = [ingress_vim_interface_id]
+ egress_port_id_list = [egress_vim_interface_id]
name = "sfi-%s" % task["item_id"][:8]
# By default no form of IETF SFC Encapsulation will be used
- vim_sfi_id = self.vim.new_sfi(name, port_id_list, port_id_list, sfc_encap=False)
+ vim_sfi_id = self.vim.new_sfi(name, ingress_port_id_list, egress_port_id_list, sfc_encap=False)
task["extra"]["created"] = True
task["error_msg"] = None
@@ -1114,8 +1139,8 @@
try:
task_id = task["instance_action_id"] + "." + str(task["task_index"])
error_text = ""
- depending_tasks = [ "TASK-" + str(dep_id) for dep_id in task["extra"]["depends_on"]]
- #sfis = task.get("depends").values()[0].get("extra").get("params")[5]
+ depending_tasks = ["TASK-" + str(dep_id) for dep_id in task["extra"]["depends_on"]]
+ # sfis = task.get("depends").values()[0].get("extra").get("params")[5]
sfis = [task.get("depends").get(dep_task) for dep_task in depending_tasks]
sfi_id_list = []
for sfi in sfis:
@@ -1162,9 +1187,9 @@
try:
params = task["params"]
task_id = task["instance_action_id"] + "." + str(task["task_index"])
- depending_task = "TASK-" + str(task.get("extra").get("depends_on")[0])
+ dep_id = "TASK-" + str(task["extra"]["depends_on"][0])
error_text = ""
- interfaces = task.get("depends").get(depending_task).get("vim_interfaces").keys()
+ interfaces = task.get("depends").get(dep_id).get("extra").get("interfaces").keys()
# Bear in mind that different VIM connectors might support Classifications differently.
# In the case of OpenStack, only the first VNF attached to the classifier will be used
# to create the Classification(s) (the "logical source port" of the "Flow Classifier").
@@ -1186,14 +1211,14 @@
if '/' not in destination_ip:
destination_ip += '/32'
definition = {
- "logical_source_port": interfaces[0],
- "protocol": ip_proto,
- "source_ip_prefix": source_ip,
- "destination_ip_prefix": destination_ip,
- "source_port_range_min": params.get("source_port"),
- "source_port_range_max": params.get("source_port"),
- "destination_port_range_min": params.get("destination_port"),
- "destination_port_range_max": params.get("destination_port"),
+ "logical_source_port": interfaces[0],
+ "protocol": ip_proto,
+ "source_ip_prefix": source_ip,
+ "destination_ip_prefix": destination_ip,
+ "source_port_range_min": params.get("source_port"),
+ "source_port_range_max": params.get("source_port"),
+ "destination_port_range_min": params.get("destination_port"),
+ "destination_port_range_max": params.get("destination_port"),
}
vim_classification_id = self.vim.new_classification(
diff --git a/osm_ro/vimconn_vmware.py b/osm_ro/vimconn_vmware.py
index fe11892..4a5ab97 100644
--- a/osm_ro/vimconn_vmware.py
+++ b/osm_ro/vimconn_vmware.py
@@ -3695,7 +3695,7 @@
#Creating all networks as Direct Org VDC type networks.
#Unused in case of Underlay (data/ptp) network interface.
- fence_mode="bridged"
+ fence_mode="isolated"
is_inherited='false'
dns_list = dns_address.split(";")
dns1 = dns_list[0]
@@ -3720,13 +3720,12 @@
</IpRanges>
</IpScope>
</IpScopes>
- <ParentNetwork href="{9:s}"/>
- <FenceMode>{10:s}</FenceMode>
+ <FenceMode>{9:s}</FenceMode>
</Configuration>
- <IsShared>{11:s}</IsShared>
+ <IsShared>{10:s}</IsShared>
</OrgVdcNetwork> """.format(escape(network_name), is_inherited, gateway_address,
subnet_address, dns1, dns2_text, dhcp_enabled,
- dhcp_start_address, dhcp_end_address, available_networks,
+ dhcp_start_address, dhcp_end_address,
fence_mode, isshared)
headers['Content-Type'] = 'application/vnd.vmware.vcloud.orgVdcNetwork+xml'
diff --git a/scenarios/examples/v3_3vnf_2vdu_1vnffg_nsd.yaml b/scenarios/examples/v3_3vnf_2vdu_1vnffg_nsd.yaml
index 228ce63..efe975f 100644
--- a/scenarios/examples/v3_3vnf_2vdu_1vnffg_nsd.yaml
+++ b/scenarios/examples/v3_3vnf_2vdu_1vnffg_nsd.yaml
@@ -77,11 +77,13 @@
- member-vnf-index-ref: 2
order: 0
vnfd-id-ref: 2vdu_vnfd
- vnfd-connection-point-ref: eth0
+ vnfd-ingress-connection-point-ref: eth0
+ vnfd-egress-connection-point-ref: eth0
- member-vnf-index-ref: 3
order: 1
vnfd-id-ref: 2vdu_vnfd
- vnfd-connection-point-ref: eth0
+ vnfd-ingress-connection-point-ref: eth0
+ vnfd-egress-connection-point-ref: eth0
classifier:
- id: class1
name: class1-name
diff --git a/scripts/RO-start.sh b/scripts/RO-start.sh
index 30365d5..9297559 100755
--- a/scripts/RO-start.sh
+++ b/scripts/RO-start.sh
@@ -14,13 +14,17 @@
db_user=$3
db_pswd=$4
db_name=$5
+ db_version=$6 # minimun database version
- RESULT=`mysqlshow -h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" | grep -v Wildcard | grep -o $db_name`
- if [ "$RESULT" == "$db_name" ]; then
-
- RESULT=`mysqlshow -h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" "$db_name" | grep -v Wildcard | grep schema_version`
- #TODO validate version
- if [ -n "$RESULT" ]; then
+ if mysqlshow -h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" | grep -v Wildcard | grep -q -e "$db_name" ; then
+ if echo "SELECT * FROM schema_version WHERE version='0'" |
+ mysql -h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" "$db_name" |
+ grep -q -e "init" ; then
+ echo " DB $db_name exists BUT failed in previous init"
+ return 1
+ elif echo "SELECT * FROM schema_version WHERE version='$db_version'" |
+ mysql -h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" "$db_name" |
+ grep -q -e "$db_version" ; then
echo " DB $db_name exists and inited"
return 0
else
@@ -90,7 +94,7 @@
echo "3/4 Init database"
RO_PATH=`python -c 'import osm_ro; print(osm_ro.__path__[0])'`
echo "RO_PATH: $RO_PATH"
-if ! is_db_created "$RO_DB_HOST" "$RO_DB_PORT" "$RO_DB_USER" "$RO_DB_PASSWORD" "$RO_DB_NAME"
+if ! is_db_created "$RO_DB_HOST" "$RO_DB_PORT" "$RO_DB_USER" "$RO_DB_PASSWORD" "$RO_DB_NAME" "0.27"
then
if [ -n "$RO_DB_ROOT_PASSWORD" ] ; then
mysqladmin -h"$RO_DB_HOST" -uroot -p"$RO_DB_ROOT_PASSWORD" create "$RO_DB_NAME"
@@ -102,14 +106,15 @@
${RO_PATH}/database_utils/init_mano_db.sh -u "$RO_DB_USER" -p "$RO_DB_PASSWORD" -h "$RO_DB_HOST" \
-P "${RO_DB_PORT}" -d "${RO_DB_NAME}" || exit 1
else
- echo " migrage database version"
+ echo " migrate database version"
${RO_PATH}/database_utils/migrate_mano_db.sh -u "$RO_DB_USER" -p "$RO_DB_PASSWORD" -h "$RO_DB_HOST" \
- -P "$RO_DB_PORT" -d "$RO_DB_NAME"
+ -P "$RO_DB_PORT" -d "$RO_DB_NAME" -b /var/log/osm
fi
OVIM_PATH=`python -c 'import lib_osm_openvim; print(lib_osm_openvim.__path__[0])'`
echo "OVIM_PATH: $OVIM_PATH"
-if ! is_db_created "$RO_DB_OVIM_HOST" "$RO_DB_OVIM_PORT" "$RO_DB_OVIM_USER" "$RO_DB_OVIM_PASSWORD" "$RO_DB_OVIM_NAME"
+if ! is_db_created "$RO_DB_OVIM_HOST" "$RO_DB_OVIM_PORT" "$RO_DB_OVIM_USER" "$RO_DB_OVIM_PASSWORD" "$RO_DB_OVIM_NAME" \
+ "0.22"
then
if [ -n "$RO_DB_OVIM_ROOT_PASSWORD" ] ; then
mysqladmin -h"$RO_DB_OVIM_HOST" -uroot -p"$RO_DB_OVIM_ROOT_PASSWORD" create "$RO_DB_OVIM_NAME"
@@ -123,9 +128,9 @@
${OVIM_PATH}/database_utils/init_vim_db.sh -u "$RO_DB_OVIM_USER" -p "$RO_DB_OVIM_PASSWORD" -h "$RO_DB_OVIM_HOST" \
-P "${RO_DB_OVIM_PORT}" -d "${RO_DB_OVIM_NAME}" || exit 1
else
- echo " migrage database version"
+ echo " migrate database version"
${OVIM_PATH}/database_utils/migrate_vim_db.sh -u "$RO_DB_OVIM_USER" -p "$RO_DB_OVIM_PASSWORD" -h "$RO_DB_OVIM_HOST"\
- -P "$RO_DB_OVIM_PORT" -d "$RO_DB_OVIM_NAME"
+ -P "$RO_DB_OVIM_PORT" -d "$RO_DB_OVIM_NAME" -b /var/log/osm
fi