From 54467bb7f4edec1fa4fe195fe4ccf34fea5d7f9e Mon Sep 17 00:00:00 2001 From: tierno Date: Wed, 11 Apr 2018 23:21:02 +0200 Subject: [PATCH] Change vnf_member_index to be coherent with model Change-Id: Ia8f465aed54996087905e3d3aeb6bfa6a2a2946c Signed-off-by: tierno --- database_utils/migrate_mano_db.sh | 20 +++++++++++++++++++- openmanod | 4 ++-- osm_ro/nfvo_db.py | 7 ++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/database_utils/migrate_mano_db.sh b/database_utils/migrate_mano_db.sh index 61e2ac68..b8f4fe8b 100755 --- a/database_utils/migrate_mano_db.sh +++ b/database_utils/migrate_mano_db.sh @@ -33,7 +33,7 @@ DBPORT="3306" 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) @@ -196,6 +196,7 @@ fi #[ $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(){ @@ -1237,6 +1238,23 @@ function downgrade_from_28(){ 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);" diff --git a/openmanod b/openmanod index d65645ba..229281c4 100755 --- a/openmanod +++ b/openmanod @@ -48,9 +48,9 @@ import osm_ro __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 diff --git a/osm_ro/nfvo_db.py b/osm_ro/nfvo_db.py index 055699e4..80697a3d 100644 --- a/osm_ro/nfvo_db.py +++ b/osm_ro/nfvo_db.py @@ -954,7 +954,7 @@ class nfvo_db(db_base.db_base): 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) @@ -973,7 +973,7 @@ class nfvo_db(db_base.db_base): # 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='{}'" \ @@ -984,7 +984,8 @@ class nfvo_db(db_base.db_base): 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) -- 2.25.1