[ $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
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'"
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'])
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)
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.
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)
#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
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:
#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"):
#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)
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)
'''
__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