Implement feature 5949
Enable dynamic connectivity setup in multi-site Network Services
The code required to implement the feature is contained in `osm_ro/wim`
as much as possible.
* `wim/engine.py` works together with `nfvo.py` to implement the
feature
* `wim/persistence.py` is equivalent to `nfvo_db.py` and try to
encapsulate most of the SQL-specific code, implementing a persistence
layer
* `wim/http_handler.py` extends `httpserver.py` adding WIM-related HTTP
routes
* `wim/wim_thread.py` is similar to `vim_thread.py` and controls the
execution of WIM-related tasks
* `wim/actions.py` and `wim/wan_link_actions.py` implement the action
handling specific code, calling instances of the `wim/wimconn.py`
subclasses
WIM connectors are still a work in progress
Individual change details (newer to older)
- Add errors for inconsistent state
- Delay re-scheduled tasks
- Move lock to inside the persistence object
- Better errors for connector failures
- Try to cache the wan_link information before it is deleted from the database
- Integrate WanLinkDelete to NFVO
- Add WanLinkDelete implementation draft with some tests
- Add basic wim network creation
- Add minimal documentation for actions
- Add checks to the create action
- Improve documentation, rearrange insert_pending and remove unused functions on WimThread
- Integrate Action classes in refresh_tasks
- Add Action classes to avoid intricate conditions
- Adding Proposed License
- Move grouping of actions to persistence
- Change WimThread to use SQL to do the heavy lifting
- Simplify WimThread reload_actions
- Add tests for derive_wan_links
- Implement find_common_wim(s)
- Add tests for create_wim_account
- Add migration scripts for version 33
- Changes to WIM and VIM threads for vim_wim_actions
- Implement wim_account management according to the discussion
- Add WimHandler integration inside httpserver
- Add quick instructions to run the tests
- Add WIM functional tests using real database
- Add DB WIM port mapping
- RO WIM-related console scripts
- Add WIM integration to NFVO
- Improve database support focusing on tests
- RO NBI WIM-related commands in HTTP server
- Adding WIM tables to MANO DB
- Add wim http handler initial implementation
- Move http utility functions to separated files
This separation allows the code to be reused more easily and avoids
circular dependencies.
(The httpserver can import other modules implementing http routes,
and those modules can then use the utility functions without having
to import back httpserver)
- Add a HTTP handler class and custom route decorator
These tools can be used to create independent groups of bottle
routes/callbacks in a OOP fashion
- Extract http error codes and related logic to separated file
Change-Id: Icd5fc9fa345852b8cf571e48f427dc10bdbd24c5
Signed-off-by: Anderson Bravalheri <a.bravalheri@bristol.ac.uk>
diff --git a/database_utils/migrate_mano_db.sh b/database_utils/migrate_mano_db.sh
index 3187324..2657cda 100755
--- a/database_utils/migrate_mano_db.sh
+++ b/database_utils/migrate_mano_db.sh
@@ -24,6 +24,7 @@
#
#Upgrade/Downgrade openmano database preserving the content
#
+DBUTILS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DBUSER="mano"
DBPASS=""
@@ -33,7 +34,7 @@
DBNAME="mano_db"
QUIET_MODE=""
#TODO update it with the last database version
-LAST_DB_VERSION=32
+LAST_DB_VERSION=34
# Detect paths
MYSQL=$(which mysql)
@@ -200,6 +201,7 @@
#[ $OPENMANO_VER_NUM -ge 5060 ] && DB_VERSION=30 #0.5.60 => 30
#[ $OPENMANO_VER_NUM -ge 5061 ] && DB_VERSION=31 #0.5.61 => 31
#[ $OPENMANO_VER_NUM -ge 5070 ] && DB_VERSION=32 #0.5.70 => 32
+#[ $OPENMANO_VER_NUM -ge 6000 ] && DB_VERSION=34 #0.6.00 => 34
#TODO ... put next versions here
function upgrade_to_1(){
@@ -221,8 +223,8 @@
}
function downgrade_from_1(){
# echo " downgrade database from version 0.1 to version 0.0"
- echo " DROP TABLE \`schema_version\`"
- sql "DROP TABLE \`schema_version\`;"
+ echo " DROP TABLE IF EXISTS \`schema_version\`"
+ sql "DROP TABLE IF EXISTS \`schema_version\`;"
}
function upgrade_to_2(){
# echo " upgrade database from version 0.1 to version 0.2"
@@ -303,11 +305,11 @@
echo " Delete columns 'user/passwd' from 'vim_tenants'"
sql "ALTER TABLE vim_tenants DROP COLUMN user, DROP COLUMN passwd; "
echo " delete tables 'datacenter_images', 'images'"
- sql "DROP TABLE \`datacenters_images\`;"
- sql "DROP TABLE \`images\`;"
+ sql "DROP TABLE IF EXISTS \`datacenters_images\`;"
+ sql "DROP TABLE IF EXISTS \`images\`;"
echo " delete tables 'datacenter_flavors', 'flavors'"
- sql "DROP TABLE \`datacenters_flavors\`;"
- sql "DROP TABLE \`flavors\`;"
+ sql "DROP TABLE IF EXISTS \`datacenters_flavors\`;"
+ sql "DROP TABLE IF EXISTS \`flavors\`;"
sql "DELETE FROM schema_version WHERE version_int='2';"
}
@@ -621,7 +623,7 @@
function downgrade_from_12(){
# echo " downgrade database from version 0.12 to version 0.11"
echo " delete ip_profiles table, and remove ip_address column in 'interfaces' and 'sce_interfaces'"
- sql "DROP TABLE ip_profiles;"
+ sql "DROP TABLE IF EXISTS ip_profiles;"
sql "ALTER TABLE interfaces DROP COLUMN ip_address;"
sql "ALTER TABLE sce_interfaces DROP COLUMN ip_address;"
sql "DELETE FROM schema_version WHERE version_int='12';"
@@ -1005,8 +1007,8 @@
"REFERENCES scenarios (uuid);"
echo " Delete table instance_actions"
- sql "DROP TABLE vim_actions"
- sql "DROP TABLE instance_actions"
+ sql "DROP TABLE IF EXISTS vim_actions"
+ sql "DROP TABLE IF EXISTS instance_actions"
sql "DELETE FROM schema_version WHERE version_int='26';"
}
@@ -1219,24 +1221,24 @@
function downgrade_from_28(){
echo " [Undo adding the VNFFG tables]"
echo " Dropping instance_sfps"
- sql "DROP TABLE instance_sfps;"
+ sql "DROP TABLE IF EXISTS instance_sfps;"
echo " Dropping sce_classifications"
- sql "DROP TABLE instance_classifications;"
+ sql "DROP TABLE IF EXISTS instance_classifications;"
echo " Dropping instance_sfs"
- sql "DROP TABLE instance_sfs;"
+ sql "DROP TABLE IF EXISTS instance_sfs;"
echo " Dropping instance_sfis"
- sql "DROP TABLE instance_sfis;"
+ sql "DROP TABLE IF EXISTS instance_sfis;"
echo " Dropping sce_classifier_matches"
echo " [Undo adding the VNFFG-SFC instance mapping tables]"
- sql "DROP TABLE sce_classifier_matches;"
+ sql "DROP TABLE IF EXISTS sce_classifier_matches;"
echo " Dropping sce_classifiers"
- sql "DROP TABLE sce_classifiers;"
+ sql "DROP TABLE IF EXISTS sce_classifiers;"
echo " Dropping sce_rsp_hops"
- sql "DROP TABLE sce_rsp_hops;"
+ sql "DROP TABLE IF EXISTS sce_rsp_hops;"
echo " Dropping sce_rsps"
- sql "DROP TABLE sce_rsps;"
+ sql "DROP TABLE IF EXISTS sce_rsps;"
echo " Dropping sce_vnffgs"
- sql "DROP TABLE sce_vnffgs;"
+ sql "DROP TABLE IF EXISTS sce_vnffgs;"
echo " [Altering vim_actions table]"
sql "ALTER TABLE vim_actions MODIFY COLUMN item ENUM('datacenters_flavors','datacenter_images','instance_nets','instance_vms','instance_interfaces') NOT NULL COMMENT 'table where the item is stored'"
sql "DELETE FROM schema_version WHERE version_int='28';"
@@ -1300,6 +1302,19 @@
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}"
+}
+
#TODO ... put functions here
# echo "db version = "${DATABASE_VER_NUM}