X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fnfvo.py;h=4b7ecc415ae12c9139bc90c5dbbd80b95c70bfae;hb=0ea9b0f0cbd4c5567289c4c80c73de94901d7047;hp=00738e98a3d0b8d98dc1648acb85d91d914ab795;hpb=89aada4f5e6bd52afd284ed8b2a27a5b36e677bb;p=osm%2FRO.git diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index 00738e98..4b7ecc41 100644 --- a/osm_ro/nfvo.py +++ b/osm_ro/nfvo.py @@ -61,6 +61,7 @@ from .http_tools import errors as httperrors from .wim.engine import WimEngine from .wim.persistence import WimPersistence from copy import deepcopy +from pprint import pformat # global global_config @@ -3055,6 +3056,8 @@ def create_instance(mydb, tenant_id, instance_dict): # Auxiliary dictionaries from x to y sce_net2instance = {} net2task_id = {'scenario': {}} + # Mapping between local networks and WIMs + wim_usage = {} def ip_profile_IM2RO(ip_profile_im): # translate from input format to database format @@ -3200,6 +3203,20 @@ def create_instance(mydb, tenant_id, instance_dict): if not involved_datacenters: involved_datacenters.append(default_datacenter_id) + # --> WIM + # TODO: use this information during network creation + wim_account_id = wim_account_name = None + if len(involved_datacenters) > 1 and 'uuid' in sce_net: + # OBS: sce_net without uuid are used internally to VNFs + # and the assumption is that VNFs will not be split among + # different datacenters + wim_account = wim_engine.find_suitable_wim_account( + involved_datacenters, tenant_id) + wim_account_id = wim_account['uuid'] + wim_account_name = wim_account['name'] + wim_usage[sce_net['uuid']] = wim_account_id + # <-- WIM + descriptor_net = {} if instance_dict.get("networks") and instance_dict["networks"].get(sce_net["name"]): descriptor_net = instance_dict["networks"][sce_net["name"]] @@ -3288,7 +3305,7 @@ def create_instance(mydb, tenant_id, instance_dict): task_extra = {} if create_network: task_action = "CREATE" - task_extra["params"] = (net_vim_name, net_type, sce_net.get('ip_profile', None)) + task_extra["params"] = (net_vim_name, net_type, sce_net.get('ip_profile', None), wim_account_name) if lookfor_network: task_extra["find"] = (lookfor_filter,) elif lookfor_network: @@ -3527,7 +3544,8 @@ def create_instance(mydb, tenant_id, instance_dict): db_instance_action["number_tasks"] = task_index # --> WIM - wan_links = wim_engine.derive_wan_links(db_instance_nets, tenant_id) + logger.debug('wim_usage:\n%s\n\n', pformat(wim_usage)) + wan_links = wim_engine.derive_wan_links(wim_usage, db_instance_nets, tenant_id) wim_actions = wim_engine.create_actions(wan_links) wim_actions, db_instance_action = ( wim_engine.incorporate_actions(wim_actions, db_instance_action)) @@ -5534,9 +5552,8 @@ def datacenter_sdn_port_mapping_set(mydb, tenant_id, datacenter_id, sdn_port_map pci = port.get("pci") element["switch_port"] = port.get("switch_port") element["switch_mac"] = port.get("switch_mac") - if not pci or not (element["switch_port"] or element["switch_mac"]): - raise NfvoException ("The mapping must contain the 'pci' and at least one of the elements 'switch_port'" - " or 'switch_mac'", httperrors.Bad_Request) + if not element["switch_port"] and not element["switch_mac"]: + raise NfvoException ("The mapping must contain 'switch_port' or 'switch_mac'", httperrors.Bad_Request) for pci_expanded in utils.expand_brackets(pci): element["pci"] = pci_expanded maps.append(dict(element))