db_sce_vnf = {
"uuid": sce_vnf_uuid,
"scenario_id": scenario_uuid,
- "name": get_str(vnf, "member-vnf-index", 255),
+ # "name": get_str(vnf, "member-vnf-index", 255),
+ "name": existing_vnf[0]["name"][:200] + "." + get_str(vnf, "member-vnf-index", 50),
"vnf_id": existing_vnf[0]["uuid"],
"member_vnf_index": str(vnf["member-vnf-index"]),
# TODO 'start-by-default': True
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():
for vnf_name, vnf_instance_desc in instance_dict.get("vnfs",{}).iteritems():
found = False
for scenario_vnf in scenarioDict['vnfs']:
- if vnf_name == scenario_vnf['name']:
+ if vnf_name == scenario_vnf['name'] or vnf_name == scenario_vnf['member_vnf_index']:
found = True
break
if not found:
- raise NfvoException("Invalid vnf name '{}' at instance:vnfs".format(vnf_instance_desc), HTTP_Bad_Request)
+ raise NfvoException("Invalid vnf name '{}' at instance:vnfs".format(vnf_name), HTTP_Bad_Request)
if "datacenter" in vnf_instance_desc:
# Add this datacenter to myvims
vnf_instance_desc["datacenter"] = get_datacenter_uuid(mydb, tenant_id, vnf_instance_desc["datacenter"])
# 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
input_vnfs = action_dict.pop("vnfs", [])
input_vms = action_dict.pop("vms", [])
- action_over_all = True if len(input_vnfs)==0 and len (input_vms)==0 else False
+ action_over_all = True if not input_vnfs and not input_vms else False
vm_result = {}
vm_error = 0
vm_ok = 0
for sce_vnf in instanceDict['vnfs']:
for vm in sce_vnf['vms']:
- if not action_over_all:
- if sce_vnf['uuid'] not in input_vnfs and sce_vnf['vnf_name'] not in input_vnfs and \
- vm['uuid'] not in input_vms and vm['name'] not in input_vms:
- continue
+ if not action_over_all and sce_vnf['uuid'] not in input_vnfs and sce_vnf['vnf_name'] not in input_vnfs and \
+ sce_vnf['member_vnf_index'] not in input_vnfs and \
+ vm['uuid'] not in input_vms and vm['name'] not in input_vms:
+ continue
try:
if "add_public_key" in action_dict:
mgmt_access = {}