DBNAME="mano_db"
QUIET_MODE=""
#TODO update it with the last database version
-LAST_DB_VERSION=28
+LAST_DB_VERSION=29
# Detect paths
MYSQL=$(which mysql)
#[ $OPENMANO_VER_NUM -ge 5024 ] && DB_VERSION=26 #0.5.24 => 26
#[ $OPENMANO_VER_NUM -ge 5025 ] && DB_VERSION=27 #0.5.25 => 27
#[ $OPENMANO_VER_NUM -ge 5052 ] && DB_VERSION=28 #0.5.52 => 28
+#[ $OPENMANO_VER_NUM -ge 5059 ] && DB_VERSION=28 #0.5.59 => 29
#TODO ... put next versions here
function upgrade_to_1(){
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';"
}
+function upgrade_to_29(){
+ echo " Change 'member_vnf_index' from int to str at 'sce_vnfs'"
+ sql "ALTER TABLE sce_vnfs CHANGE COLUMN member_vnf_index member_vnf_index VARCHAR(255) NULL DEFAULT NULL AFTER uuid;"
+ echo " Add osm_id to 'nets's and 'sce_nets'"
+ sql "ALTER TABLE nets ADD COLUMN osm_id VARCHAR(255) NULL AFTER uuid;"
+ sql "ALTER TABLE sce_nets ADD COLUMN osm_id VARCHAR(255) NULL AFTER uuid;"
+ sql "INSERT INTO schema_version (version_int, version, openmano_ver, comments, date) "\
+ "VALUES (29, '0.29', '0.5.59', 'Change member_vnf_index to str accordingly to the model', '2018-04-11');"
+}
+function downgrade_from_29(){
+ echo " Change back 'member_vnf_index' from str to int at 'sce_vnfs'"
+ sql "ALTER TABLE sce_vnfs CHANGE COLUMN member_vnf_index member_vnf_index SMALLINT NULL DEFAULT NULL AFTER uuid;"
+ echo " Remove osm_id from 'nets's and 'sce_nets'"
+ sql "ALTER TABLE nets DROP COLUMN osm_id;"
+ sql "ALTER TABLE sce_nets DROP COLUMN osm_id;"
+ sql "DELETE FROM schema_version WHERE version_int='29';"
+}
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);"
__author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ = "$26-aug-2014 11:09:29$"
-__version__ = "0.5.58-r568"
+__version__ = "0.5.59-r569"
version_date = "Apr 2018"
-database_version = 28 # expected database schema version
+database_version = 29 # expected database schema version
global global_config
cmd = "SELECT inst.uuid as uuid, inst.name as name, inst.scenario_id as scenario_id, datacenter_id"\
" ,datacenter_tenant_id, s.name as scenario_name,inst.tenant_id as tenant_id" \
" ,inst.description as description, inst.created_at as created_at" \
- " ,inst.cloud_config as cloud_config" \
+ " ,inst.cloud_config as cloud_config, s.osm_id as nsd_osm_id" \
" FROM instance_scenarios as inst left join scenarios as s on inst.scenario_id=s.uuid" \
" WHERE " + where_text
self.logger.debug(cmd)
# instance_vnfs
cmd = "SELECT iv.uuid as uuid, iv.vnf_id as vnf_id, sv.name as vnf_name, sce_vnf_id, datacenter_id"\
- " ,datacenter_tenant_id, v.mgmt_access, sv.member_vnf_index "\
+ " ,datacenter_tenant_id, v.mgmt_access, sv.member_vnf_index, v.osm_id as vnfd_osm_id "\
" FROM instance_vnfs as iv left join sce_vnfs as sv "\
"on iv.sce_vnf_id=sv.uuid join vnfs as v on iv.vnf_id=v.uuid" \
" WHERE iv.instance_scenario_id='{}'" \
for vnf in instance_dict['vnfs']:
vnf_manage_iface_list=[]
#instance vms
- cmd = "SELECT iv.uuid as uuid, vim_vm_id, status, error_msg, vim_info, iv.created_at as created_at, name"\
+ cmd = "SELECT iv.uuid as uuid, vim_vm_id, status, error_msg, vim_info, iv.created_at as "\
+ "created_at, name, vms.osm_id as vdu_osm_id"\
" FROM instance_vms as iv join vms on iv.vm_id=vms.uuid "\
" WHERE instance_vnf_id='{}' ORDER BY iv.created_at".format(vnf['uuid'])
self.logger.debug(cmd)