"""
__author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ = "$09-oct-2014 09:09:48$"
-__version__ = "0.4.23-r533"
-version_date = "May 2018"
+__version__ = "0.4.24-r534"
+version_date = "Nov 2018"
from argcomplete.completers import FilesCompleter
import os
if not scenario:
print "you must provide a scenario in the file descriptor or with --scenario"
return -1
- myInstance["instance"]["scenario"] = _get_item_uuid("scenarios", scenario, tenant)
+ if isinstance(scenario, str):
+ myInstance["instance"]["scenario"] = _get_item_uuid("scenarios", scenario, tenant)
if args.netmap_use:
if "networks" not in myInstance["instance"]:
myInstance["instance"]["networks"] = {}
rollbackList = []
# print "Checking that the scenario exists and getting the scenario dictionary"
- scenarioDict = mydb.get_scenario(scenario, tenant_id, datacenter_vim_id=myvim_threads_id[default_datacenter_id],
- datacenter_id=default_datacenter_id)
+ if isinstance(scenario, str):
+ scenarioDict = mydb.get_scenario(scenario, tenant_id, datacenter_vim_id=myvim_threads_id[default_datacenter_id],
+ datacenter_id=default_datacenter_id)
+ else:
+ scenarioDict = scenario
+ scenarioDict["uuid"] = None
# logger.debug(">>>>>> Dictionaries before merging")
# logger.debug(">>>>>> InstanceDict:\n{}".format(yaml.safe_dump(instance_dict,default_flow_style=False, width=256)))
number_mgmt_networks = 0
db_instance_nets = []
for sce_net in scenarioDict['nets']:
+ sce_net_uuid = sce_net.get('uuid', sce_net["name"])
# get involved datacenters where this network need to be created
involved_datacenters = []
- for sce_vnf in scenarioDict.get("vnfs"):
+ for sce_vnf in scenarioDict.get("vnfs", ()):
vnf_datacenter = sce_vnf.get("datacenter", default_datacenter_id)
if vnf_datacenter in involved_datacenters:
continue
if instance_dict.get("networks") and instance_dict["networks"].get(sce_net["name"]):
descriptor_net = instance_dict["networks"][sce_net["name"]]
net_name = descriptor_net.get("vim-network-name")
- sce_net2instance[sce_net['uuid']] = {}
- net2task_id['scenario'][sce_net['uuid']] = {}
+ # add datacenters from instantiation parameters
+ if descriptor_net.get("sites"):
+ for site in descriptor_net["sites"]:
+ if site.get("datacenter") and site["datacenter"] not in involved_datacenters:
+ involved_datacenters.append(site["datacenter"])
+ sce_net2instance[sce_net_uuid] = {}
+ net2task_id['scenario'][sce_net_uuid] = {}
if sce_net["external"]:
number_mgmt_networks += 1
# fill database content
net_uuid = str(uuid4())
uuid_list.append(net_uuid)
- sce_net2instance[sce_net['uuid']][datacenter_id] = net_uuid
+ sce_net2instance[sce_net_uuid][datacenter_id] = net_uuid
db_net = {
"uuid": net_uuid,
'vim_net_id': None,
"vim_name": net_vim_name,
"instance_scenario_id": instance_uuid,
- "sce_net_id": sce_net["uuid"],
+ "sce_net_id": sce_net.get("uuid"),
"created": create_network,
'datacenter_id': datacenter_id,
'datacenter_tenant_id': myvim_thread_id,
"item_id": net_uuid,
"extra": yaml.safe_dump(task_extra, default_flow_style=True, width=256)
}
- net2task_id['scenario'][sce_net['uuid']][datacenter_id] = task_index
+ net2task_id['scenario'][sce_net_uuid][datacenter_id] = task_index
task_index += 1
db_vim_actions.append(db_vim_action)
"sce_net2instance": sce_net2instance,
}
# sce_vnf_list = sorted(scenarioDict['vnfs'], key=lambda k: k['name'])
- for sce_vnf in scenarioDict.get('vnfs'): # sce_vnf_list:
+ for sce_vnf in scenarioDict.get('vnfs', ()): # sce_vnf_list:
instantiate_vnf(mydb, sce_vnf, vnf_params, vnf_params_out, rollbackList)
task_index = vnf_params_out["task_index"]
uuid_list = vnf_params_out["uuid_list"]
# Create VNFFGs
# task_depends_on = []
- for vnffg in scenarioDict['vnffgs']:
+ for vnffg in scenarioDict.get('vnffgs', ()):
for rsp in vnffg['rsps']:
sfs_created = []
for cp in rsp['connection_points']:
"additionalProperties": False
}
+instance_scenario_object = {
+ "title": "scenario object used to create an instance not based on any nsd",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "nets": {
+ "type": "array",
+ "minLength": 1,
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": name_schema,
+ "external": {"type": "boolean"},
+ "type": {"enum": ["bridge", "ptp", "data"]}, # for overlay, underlay E-LINE, underlay E-LAN
+ },
+ "additionalProperties": False,
+ "required": ["name", "external", "type"]
+ }
+ }
+ },
+ "additionalProperties": False,
+ "required": ["nets"]
+}
+
instance_scenario_create_schema_v01 = {
"title": "instance scenario create information schema v0.1",
"$schema": "http://json-schema.org/draft-04/schema#",
"name": name_schema,
"description":description_schema,
"datacenter": name_schema,
- "scenario" : name_schema, #can be an UUID or name
+ "scenario" : {"oneOff": [name_schema, instance_scenario_object]}, # can be an UUID or name or a dict
"action":{"enum": ["deploy","reserve","verify" ]},
"connect_mgmt_interfaces": {"oneOf": [{"type":"boolean"}, {"type":"object"}]},# can be true or a dict with datacenter: net_name
"cloud-config": cloud_config_schema, #common to all vnfs in the instance scenario