[ $OPENMANO_VER_NUM -ge 4032 ] && DATABASE_TARGET_VER_NUM=8 #0.4.32=> 8
[ $OPENMANO_VER_NUM -ge 4033 ] && DATABASE_TARGET_VER_NUM=9 #0.4.33=> 9
[ $OPENMANO_VER_NUM -ge 4036 ] && DATABASE_TARGET_VER_NUM=10 #0.4.36=> 10
+[ $OPENMANO_VER_NUM -ge 4043 ] && DATABASE_TARGET_VER_NUM=11 #0.4.43=> 11
#TODO ... put next versions here
echo "DELETE FROM schema_version WHERE version_int='10';" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
}
+function upgrade_to_11(){
+ echo " upgrade database from version 0.10 to version 0.11"
+ echo " remove unique name at 'scenarios', 'instance_scenarios'"
+ echo "ALTER TABLE scenarios DROP INDEX name;" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+ echo "ALTER TABLE instance_scenarios DROP INDEX name;" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+ echo "INSERT INTO schema_version (version_int, version, openmano_ver, comments, date) VALUES (11, '0.11', '0.4.43', 'remove unique name at scenarios,instance_scenarios', '2016-07-18');" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+}
+function downgrade_from_11(){
+ echo " downgrade database from version 0.11 to version 0.10"
+ echo " add unique name at 'scenarios', 'instance_scenarios'"
+ echo "ALTER TABLE scenarios ADD UNIQUE INDEX name (name);" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+ echo "ALTER TABLE instance_scenarios ADD UNIQUE INDEX name (name);" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+ echo "DELETE FROM schema_version WHERE version_int='11';" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
+}
+
function upgrade_to_X(){
echo " change 'datacenter_nets'"
echo "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);" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1
#1.2: Check that VNF are present at database table vnfs. Insert uuid, description and external interfaces
for name,vnf in vnfs.items():
- WHERE_={}
+ where={}
+ where_or={"tenant_id": tenant_id, 'public': "true"}
error_text = ""
error_pos = "'topology':'nodes':'" + name + "'"
if 'vnf_id' in vnf:
error_text += " 'vnf_id' " + vnf['vnf_id']
- WHERE_['uuid'] = vnf['vnf_id']
+ where['uuid'] = vnf['vnf_id']
if 'VNF model' in vnf:
error_text += " 'VNF model' " + vnf['VNF model']
- WHERE_['name'] = vnf['VNF model']
- if len(WHERE_) == 0:
+ where['name'] = vnf['VNF model']
+ if len(where) == 0:
raise NfvoException("Descriptor need a 'vnf_id' or 'VNF model' field at " + error_pos, HTTP_Bad_Request)
- vnf_db = mydb.get_rows(SELECT=('uuid','name','description'), FROM='vnfs', WHERE=WHERE_)
+ vnf_db = mydb.get_rows(SELECT=('uuid','name','description'),
+ FROM='vnfs',
+ WHERE=where,
+ WHERE_OR=where_or,
+ WHERE_AND_OR="AND")
if len(vnf_db)==0:
raise NfvoException("unknown" + error_text + " at " + error_pos, HTTP_Not_Found)
elif len(vnf_db)>1:
#1: Check that VNF are present at database table vnfs and update content into scenario dict
for name,vnf in scenario["vnfs"].iteritems():
- WHERE_={}
+ where={}
+ where_or={"tenant_id": tenant_id, 'public': "true"}
error_text = ""
error_pos = "'topology':'nodes':'" + name + "'"
if 'vnf_id' in vnf:
error_text += " 'vnf_id' " + vnf['vnf_id']
- WHERE_['uuid'] = vnf['vnf_id']
+ where['uuid'] = vnf['vnf_id']
if 'vnf_name' in vnf:
error_text += " 'vnf_name' " + vnf['vnf_name']
- WHERE_['name'] = vnf['vnf_name']
- if len(WHERE_) == 0:
+ where['name'] = vnf['vnf_name']
+ if len(where) == 0:
raise NfvoException("Needed a 'vnf_id' or 'VNF model' at " + error_pos, HTTP_Bad_Request)
- vnf_db = mydb.get_rows(SELECT=('uuid','name','description'), FROM='vnfs', WHERE=WHERE_)
+ vnf_db = mydb.get_rows(SELECT=('uuid','name','description'),
+ FROM='vnfs',
+ WHERE=where,
+ WHERE_OR=where_or,
+ WHERE_AND_OR="AND")
if len(vnf_db)==0:
raise NfvoException("Unknown" + error_text + " at " + error_pos, HTTP_Not_Found)
elif len(vnf_db)>1:
'''
__author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ ="$26-aug-2014 11:09:29$"
-__version__="0.4.42-r479"
+__version__="0.4.43-r480"
version_date="Jul 2016"
-database_version="0.10" #expected database schema version
+database_version="0.11" #expected database schema version
import httpserver
import time