From: tierno Date: Thu, 3 May 2018 15:37:40 +0000 (+0200) Subject: Fixed the use of vim_network_name at NSD VLD X-Git-Tag: v4.0.0~12 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F62%2F6062%2F1;p=osm%2FRO.git Fixed the use of vim_network_name at NSD VLD Add new vim-config parameter management_network_id or management_network_name for setting the mgmt vim network Change-Id: I9b5224c5af22c914bda14f8fb9f4edbf29da02bf Signed-off-by: tierno --- diff --git a/database_utils/migrate_mano_db.sh b/database_utils/migrate_mano_db.sh index 2d70f85e..37527f1f 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=30 +LAST_DB_VERSION=31 # Detect paths MYSQL=$(which mysql) @@ -198,6 +198,7 @@ fi #[ $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(){ @@ -1267,6 +1268,17 @@ function downgrade_from_30(){ 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'" diff --git a/openmanod b/openmanod index 7ac608b6..6a5d9888 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.60-r570" -version_date = "Apr 2018" -database_version = 30 # expected database schema version +__version__ = "0.5.61-r571" +version_date = "May 2018" +database_version = 31 # expected database schema version global global_config diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index 6e7a4006..19af2256 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -2303,6 +2303,8 @@ def new_nsd_v3(mydb, tenant_id, nsd_descriptor): 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(): @@ -3043,6 +3045,7 @@ def create_instance(mydb, tenant_id, instance_dict): # 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"], {}) @@ -3070,38 +3073,49 @@ def create_instance(mydb, tenant_id, instance_dict): 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 @@ -3542,7 +3556,6 @@ def instantiate_vnf(mydb, sce_vnf, params, params_out, rollbackList): 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 diff --git a/osm_ro/nfvo_db.py b/osm_ro/nfvo_db.py index 71ccfbf7..c34a44f9 100644 --- a/osm_ro/nfvo_db.py +++ b/osm_ro/nfvo_db.py @@ -582,7 +582,7 @@ class nfvo_db(db_base.db_base): 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) @@ -672,7 +672,7 @@ class nfvo_db(db_base.db_base): 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)