DBNAME="mano_db"
QUIET_MODE=""
#TODO update it with the last database version
-LAST_DB_VERSION=30
+LAST_DB_VERSION=31
# Detect paths
MYSQL=$(which mysql)
#[ $OPENMANO_VER_NUM -ge 5052 ] && DB_VERSION=28 #0.5.52 => 28
#[ $OPENMANO_VER_NUM -ge 5059 ] && DB_VERSION=29 #0.5.59 => 29
#[ $OPENMANO_VER_NUM -ge 5060 ] && DB_VERSION=30 #0.5.60 => 30
+#[ $OPENMANO_VER_NUM -ge 5061 ] && DB_VERSION=31 #0.5.61 => 31
#TODO ... put next versions here
function upgrade_to_1(){
sql "ALTER TABLE vms DROP COLUMN image_list;"
sql "DELETE FROM schema_version WHERE version_int='30';"
}
+function upgrade_to_31(){
+ echo " Add 'vim_network_name' at 'sce_nets'"
+ sql "ALTER TABLE sce_nets ADD COLUMN vim_network_name VARCHAR(255) NULL DEFAULT NULL AFTER description;"
+ sql "INSERT INTO schema_version (version_int, version, openmano_ver, comments, date) "\
+ "VALUES (31, '0.31', '0.5.61', 'Add vim_network_name to sce_nets', '2018-05-03');"
+}
+function downgrade_from_31(){
+ echo " Remove back 'vim_network_name' from 'sce_nets'"
+ sql "ALTER TABLE sce_nets DROP COLUMN vim_network_name;"
+ sql "DELETE FROM schema_version WHERE version_int='31';"
+}
function upgrade_to_X(){
echo " change 'datacenter_nets'"
str(nsd["id"]), str(vld["id"]), str(vld["ip-profile-ref"])),
HTTP_Bad_Request)
db_ip_profiles[ip_profile_name2db_table_index[ip_profile_name]]["sce_net_id"] = sce_net_uuid
+ elif vld.get("vim-network-name"):
+ db_sce_net["vim_network_name"] = get_str(vld, "vim-network-name", 255)
# table sce_interfaces (vld:vnfd-connection-point-ref)
for iface in vld.get("vnfd-connection-point-ref").itervalues():
# yaml.safe_dump(scenarioDict, indent=4, default_flow_style=False))
# 1. Creating new nets (sce_nets) in the VIM"
+ number_mgmt_networks = 0
db_instance_nets = []
for sce_net in scenarioDict['nets']:
descriptor_net = instance_dict.get("networks", {}).get(sce_net["name"], {})
net_name = "{}.{}".format(instance_name, sce_net["name"])
net_name = net_name[:255] # limit length
+ if sce_net["external"]:
+ number_mgmt_networks += 1
if "netmap-use" in site or "netmap-create" in site:
create_network = False
lookfor_network = False
if "netmap-use" in site:
lookfor_network = True
if utils.check_valid_uuid(site["netmap-use"]):
- filter_text = "scenario id '%s'" % site["netmap-use"]
lookfor_filter["id"] = site["netmap-use"]
else:
- filter_text = "scenario name '%s'" % site["netmap-use"]
lookfor_filter["name"] = site["netmap-use"]
if "netmap-create" in site:
create_network = True
net_vim_name = net_name
if site["netmap-create"]:
net_vim_name = site["netmap-create"]
+ elif sce_net.get("vim_network_name"):
+ create_network = False
+ lookfor_network = True
+ lookfor_filter["name"] = sce_net.get("vim_network_name")
elif sce_net["external"]:
if sce_net['vim_id'] != None:
# there is a netmap at datacenter_nets database # TODO REVISE!!!!
create_network = False
lookfor_network = True
lookfor_filter["id"] = sce_net['vim_id']
- filter_text = "vim_id '{}' datacenter_netmap name '{}'. Try to reload vims with "\
- "datacenter-net-update".format(sce_net['vim_id'], sce_net["name"])
- # look for network at datacenter and return error
+ elif vim["config"].get("management_network_id") or vim["config"].get("management_network_name"):
+ if number_mgmt_networks > 1:
+ raise NfvoException("Found several VLD of type mgmt. "
+ "You must concrete what vim-network must be use for each one",
+ HTTP_Bad_Request)
+ create_network = False
+ lookfor_network = True
+ if vim["config"].get("management_network_id"):
+ lookfor_filter["id"] = vim["config"]["management_network_id"]
+ else:
+ lookfor_filter["name"] = vim["config"]["management_network_name"]
else:
# There is not a netmap, look at datacenter for a net with this name and create if not found
create_network = True
lookfor_network = True
lookfor_filter["name"] = sce_net["name"]
net_vim_name = sce_net["name"]
- filter_text = "scenario name '%s'" % sce_net["name"]
else:
net_vim_name = net_name
create_network = True
WHERE={'vim_id': flavor_id})
if not extended_flavor_dict:
raise NfvoException("flavor '{}' not found".format(flavor_id), HTTP_Not_Found)
- return
# extended_flavor_dict_yaml = yaml.load(extended_flavor_dict[0])
myVMDict['disks'] = None
if scenario_dict["cloud_config"]:
scenario_dict["cloud-config"] = yaml.load(scenario_dict["cloud_config"])
del scenario_dict["cloud_config"]
- #sce_vnfs
+ # sce_vnfs
cmd = "SELECT uuid,name,member_vnf_index,vnf_id,description FROM sce_vnfs WHERE scenario_id='{}' "\
"ORDER BY created_at".format(scenario_dict['uuid'])
self.logger.debug(cmd)
raise db_base.db_base_Exception("More than one ip-profile found with this criteria: net_id='{}'".format(vnf_net['uuid']), db_base.HTTP_Bad_Request)
#sce_nets
- cmd = "SELECT uuid,name,type,external,description" \
+ cmd = "SELECT uuid,name,type,external,description,vim_network_name" \
" FROM sce_nets WHERE scenario_id='{}'" \
" ORDER BY created_at ".format(scenario_dict['uuid'])
self.logger.debug(cmd)