X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fnfvo.py;h=4341422f60ac0bcd4e03820b3fb61f618917d9c7;hb=db1b22de8331161d80ef3a65ffd41ba8ea206cb9;hp=7225da5daf74609da451aac25dbb419e910077a7;hpb=0a48054ff0fa22026ec2fec206d6d93ad195672e;p=osm%2FRO.git diff --git a/osm_ro/nfvo.py b/osm_ro/nfvo.py index 7225da5d..4341422f 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 @@ -343,7 +344,7 @@ def get_imagelist(mydb, vnf_id, nfvo_tenant=None): image_list = [] vms = mydb.get_rows(SELECT=('image_id','image_list'), FROM='vms', WHERE={'vnf_id': vnf_id}) for vm in vms: - if vm["image_id"] not in image_list: + if vm["image_id"] and vm["image_id"] not in image_list: image_list.append(vm["image_id"]) if vm["image_list"]: vm_image_list = yaml.load(vm["image_list"]) @@ -1069,6 +1070,11 @@ def new_vnfd_v3(mydb, tenant_id, vnf_descriptor): devices.append(device) + if not db_vm.get("image_id"): + if not db_vm["pdu_type"]: + raise NfvoException("Not defined image for VDU") + # create a fake image + # cloud-init boot_data = {} if vdu.get("cloud-init"): @@ -3050,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 @@ -3195,6 +3203,18 @@ 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 = 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_id = wim_engine.find_suitable_wim_account( + involved_datacenters, tenant_id) + 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"]] @@ -3253,7 +3273,7 @@ def create_instance(mydb, tenant_id, instance_dict): lookfor_network = True lookfor_filter["name"] = sce_net.get("vim_network_name") elif sce_net["external"]: - if sce_net['vim_id'] is not None: + if sce_net.get('vim_id'): # there is a netmap at datacenter_nets database # TODO REVISE!!!! create_network = False lookfor_network = True @@ -3522,7 +3542,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))