from .wim.engine import WimEngine
from .wim.persistence import WimPersistence
from copy import deepcopy
+from pprint import pformat
#
global global_config
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"])
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"):
# 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
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"]]
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
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:
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))
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))