From 66345bc7ec91854bbf82d8f3595eab33d4801b2b Mon Sep 17 00:00:00 2001 From: tierno Date: Mon, 26 Sep 2016 11:37:55 +0200 Subject: [PATCH] v0.4.57 Allow mapping several scenario netwoks on the same vim network. Change name at database table instance_nets from external to created Change-Id: I46cab007c4c5d3cdbd515b477aa25ee373d3e6fd Signed-off-by: tierno --- database_utils/migrate_mano_db.sh | 15 +++++++++++++++ nfvo.py | 7 ++++++- nfvo_db.py | 8 ++++---- openmanod.py | 4 ++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/database_utils/migrate_mano_db.sh b/database_utils/migrate_mano_db.sh index 4131c9ce..f9d4799c 100755 --- a/database_utils/migrate_mano_db.sh +++ b/database_utils/migrate_mano_db.sh @@ -182,6 +182,7 @@ DATABASE_TARGET_VER_NUM=0 [ $OPENMANO_VER_NUM -ge 4043 ] && DATABASE_TARGET_VER_NUM=11 #0.4.43=> 11 [ $OPENMANO_VER_NUM -ge 4046 ] && DATABASE_TARGET_VER_NUM=12 #0.4.46=> 12 [ $OPENMANO_VER_NUM -ge 4047 ] && DATABASE_TARGET_VER_NUM=13 #0.4.47=> 13 +[ $OPENMANO_VER_NUM -ge 4057 ] && DATABASE_TARGET_VER_NUM=14 #0.4.57=> 14 #TODO ... put next versions here @@ -625,6 +626,20 @@ function downgrade_from_13(){ echo "DELETE FROM schema_version WHERE version_int='13';" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 } +function upgrade_to_14(){ + echo " upgrade database from version 0.13 to version 0.14" + echo " remove unique index vim_net_id, instance_scenario_id at table 'instance_nets'" + echo "ALTER TABLE instance_nets DROP INDEX vim_net_id_instance_scenario_id;" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 + echo "ALTER TABLE instance_nets CHANGE COLUMN external created ENUM('true','false') NOT NULL DEFAULT 'false' COMMENT 'Created or already exists at VIM' AFTER multipoint;" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 + echo "INSERT INTO schema_version (version_int, version, openmano_ver, comments, date) VALUES (14, '0.14', '0.4.57', 'remove unique index vim_net_id, instance_scenario_id', '2016-09-26');" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 +} +function downgrade_from_14(){ + echo " downgrade database from version 0.14 to version 0.13" + echo " remove cloud_config at 'scenarios', 'instance_scenarios'" + echo "ALTER TABLE instance_nets ADD UNIQUE INDEX vim_net_id_instance_scenario_id (vim_net_id, instance_scenario_id);" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 + echo "ALTER TABLE instance_nets CHANGE COLUMN created external ENUM('true','false') NOT NULL DEFAULT 'false' COMMENT 'If external, means that it already exists at VIM' AFTER multipoint;" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 + echo "DELETE FROM schema_version WHERE version_int='14';" | $DBCMD || ! echo "ERROR. Aborted!" || exit -1 +} function upgrade_to_X(){ echo " change 'datacenter_nets'" diff --git a/nfvo.py b/nfvo.py index c27c51e1..cc2ed7f1 100644 --- a/nfvo.py +++ b/nfvo.py @@ -1320,6 +1320,7 @@ def start_scenario(mydb, tenant_id, scenario_id, instance_scenario_name, instanc sce_net['vim_id'] = network_id auxNetDict['scenario'][sce_net['uuid']] = network_id rollbackList.append({'what':'network','where':'vim','vim_id':datacenter_id,'uuid':network_id}) + sce_net["created"] = True else: if sce_net['vim_id'] == None: error_text = "Error, datacenter '%s' does not have external network '%s'." % (datacenter_name, sce_net['name']) @@ -1353,6 +1354,7 @@ def start_scenario(mydb, tenant_id, scenario_id, instance_scenario_name, instanc auxNetDict[sce_vnf['uuid']] = {} auxNetDict[sce_vnf['uuid']][net['uuid']] = network_id rollbackList.append({'what':'network','where':'vim','vim_id':datacenter_id,'uuid':network_id}) + net["created"] = True #print "auxNetDict:" #print yaml.safe_dump(auxNetDict, indent=4, default_flow_style=False) @@ -1820,6 +1822,7 @@ def create_instance(mydb, tenant_id, instance_dict): sce_net["vim_id_sites"][datacenter_id] = network_id auxNetDict['scenario'][sce_net['uuid']][datacenter_id] = network_id rollbackList.append({'what':'network', 'where':'vim', 'vim_id':datacenter_id, 'uuid':network_id}) + sce_net["created"] = True #2. Creating new nets (vnf internal nets) in the VIM" #For each vnf net, we create it and we add it to instanceNetlist. @@ -1843,6 +1846,8 @@ def create_instance(mydb, tenant_id, instance_dict): auxNetDict[sce_vnf['uuid']] = {} auxNetDict[sce_vnf['uuid']][net['uuid']] = network_id rollbackList.append({'what':'network','where':'vim','vim_id':datacenter_id,'uuid':network_id}) + net["created"] = True + #print "auxNetDict:" #print yaml.safe_dump(auxNetDict, indent=4, default_flow_style=False) @@ -2014,7 +2019,7 @@ def delete_instance(mydb, tenant_id, instance_id): #2.2 deleting NETS #net_fail_list=[] for net in instanceDict['nets']: - if net['external']: + if not net['created']: continue #skip not created nets if not myvim: continue diff --git a/nfvo_db.py b/nfvo_db.py index 1dcf6f6b..9d3b6485 100644 --- a/nfvo_db.py +++ b/nfvo_db.py @@ -776,7 +776,7 @@ class nfvo_db(db_base.db_base): sce_net_id = net.get("uuid") for datacenter_site_id,vim_id in net["vim_id_sites"].iteritems(): - INSERT_={'vim_net_id': vim_id, 'external': net['external'], 'instance_scenario_id':instance_uuid } #, 'type': net['type'] + INSERT_={'vim_net_id': vim_id, 'created': net.get('created', False), 'instance_scenario_id':instance_uuid } #, 'type': net['type'] INSERT_['datacenter_id'] = datacenter_site_id INSERT_['datacenter_tenant_id'] = net.get('datacenter_tenant_id', datacenter_tenant_id) #TODO revise if sce_net_id: @@ -809,7 +809,7 @@ class nfvo_db(db_base.db_base): #instance_nets #nets intraVNF for net in vnf['nets']: net_scene2instance[ net['uuid'] ] = {} - INSERT_={'vim_net_id': net['vim_id'], 'external': 'false', 'instance_scenario_id':instance_uuid } #, 'type': net['type'] + INSERT_={'vim_net_id': net['vim_id'], 'created': net.get('created', False), 'instance_scenario_id':instance_uuid } #, 'type': net['type'] INSERT_['datacenter_id'] = net.get('datacenter_id', datacenter_site_id) INSERT_['datacenter_tenant_id'] = net.get('datacenter_tenant_id', datacenter_site_tenant_id) if net.get("uuid"): @@ -935,7 +935,7 @@ class nfvo_db(db_base.db_base): #from_text = "instance_nets join instance_scenarios on instance_nets.instance_scenario_id=instance_scenarios.uuid " + \ # "join sce_nets on instance_scenarios.scenario_id=sce_nets.scenario_id" #where_text = "instance_nets.instance_scenario_id='"+ instance_dict['uuid'] + "'" - cmd = "SELECT uuid,vim_net_id,status,error_msg,vim_info,external, sce_net_id, net_id as vnf_net_id, datacenter_id, datacenter_tenant_id"\ + cmd = "SELECT uuid,vim_net_id,status,error_msg,vim_info,created, sce_net_id, net_id as vnf_net_id, datacenter_id, datacenter_tenant_id"\ " FROM instance_nets" \ " WHERE instance_scenario_id='{}' ORDER BY created_at".format(instance_dict['uuid']) self.logger.debug(cmd) @@ -943,7 +943,7 @@ class nfvo_db(db_base.db_base): instance_dict['nets'] = self.cur.fetchall() db_base._convert_datetime2str(instance_dict) - db_base._convert_str2boolean(instance_dict, ('public','shared','external') ) + db_base._convert_str2boolean(instance_dict, ('public','shared','created') ) return instance_dict except (mdb.Error, AttributeError) as e: self._format_error(e, tries) diff --git a/openmanod.py b/openmanod.py index 2fe61875..02c51c89 100755 --- a/openmanod.py +++ b/openmanod.py @@ -33,9 +33,9 @@ It loads the configuration file and launches the http_server thread that will li ''' __author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes" __date__ ="$26-aug-2014 11:09:29$" -__version__="0.4.56-r498" +__version__="0.4.57-r499" version_date="Sep 2016" -database_version="0.13" #expected database schema version +database_version="0.14" #expected database schema version import httpserver import time -- 2.25.1