1 # Copyright 2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 def safe_get(key_val, key):
19 return key_val[key] if key in key_val else ""
22 def find_node_name(node_id, node_list):
23 for node in node_list:
24 if node['id'] == node_id:
25 return node['template_name']
26 raise Exception('can not find node(%s).' % node_id)
29 def find_node_type(node_id, node_list):
30 for node in node_list:
31 if node['id'] == node_id:
32 return node['type_name']
33 raise Exception('can not find node(%s).' % node_id)
36 def find_related_node(node_id, src_json_model, requirement_name):
38 for model_tpl in safe_get(src_json_model, "node_templates"):
39 for rt in safe_get(model_tpl, 'requirement_templates'):
40 if safe_get(rt, 'name') == requirement_name and safe_get(rt, 'target_node_template_name') == node_id:
41 related_nodes.append(model_tpl['name'])
45 def convert_props(src_node, dest_node):
46 if 'properties' in src_node and src_node['properties']:
47 for prop_name, prop_info in src_node['properties'].items():
48 if 'value' in prop_info:
49 dest_node['properties'][prop_name] = prop_info['value']
52 def convert_metadata(src_json):
53 return src_json['metadata'] if 'metadata' in src_json else {}
56 def convert_factor_unit(value):
57 if isinstance(value, (str, unicode)):
59 return "%s %s" % (value["factor"], value["unit"])
62 def convert_inputs(src_json):
64 if 'inputs' in src_json:
65 src_inputs = src_json['inputs']
66 for param_name, param_info in src_inputs.items():
68 if 'type_name' in param_info:
69 input_param['type'] = param_info['type_name']
70 if 'description' in param_info:
71 input_param['description'] = param_info['description']
72 if 'value' in param_info:
73 input_param['value'] = param_info['value']
74 inputs[param_name] = input_param
78 def convert_vnf_node(src_node, src_json_model):
80 'type': src_node['type_name'],
81 'vnf_id': src_node['template_name'],
87 convert_props(src_node, vnf_node)
88 for model_tpl in safe_get(src_json_model, "node_templates"):
89 if model_tpl['name'] != vnf_node['vnf_id']:
91 vnf_node['dependencies'] = [
93 'key_name': requirement['name'],
94 'vl_id': requirement['target_node_template_name']
95 } for requirement in safe_get(model_tpl, 'requirement_templates')
96 if safe_get(requirement, 'target_capability_name') == 'virtual_linkable'
98 vnf_node['networks'] = [requirement['target_node_template_name'] for
99 requirement in safe_get(model_tpl, 'requirement_templates') if
100 safe_get(requirement, 'name') == 'dependency']
104 def convert_pnf_node(src_node, src_json_model):
105 pnf_node = {'pnf_id': src_node['template_name'], 'description': '', 'properties': {}}
106 convert_props(src_node, pnf_node)
107 pnf_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
111 def convert_vl_node(src_node, src_node_list):
112 vl_node = {'vl_id': src_node['template_name'], 'description': '', 'properties': {}}
113 convert_props(src_node, vl_node)
114 vl_node['route_id'] = ''
115 for relation in safe_get(src_node, 'relationships'):
116 if safe_get(relation, 'type_name').endswith('.VirtualLinksTo'):
117 vl_node['route_id'] = find_node_name(relation['target_node_id'], src_node_list)
119 vl_node['route_external'] = (src_node['type_name'].find('.RouteExternalVL') > 0)
123 def convert_cp_node(src_node, src_node_list, model_type='NSD'):
124 cp_node = {'cp_id': src_node['template_name'], 'description': '', 'properties': {}}
125 convert_props(src_node, cp_node)
126 src_relationships = src_node['relationships']
127 for relation in src_relationships:
128 if safe_get(relation, 'name') in ('virtualLink', 'virtual_link'):
129 cp_node['vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
130 elif safe_get(relation, 'name') in ('virtualbinding', 'virtual_binding'):
131 node_key = 'pnf_id' if model_type == 'NSD' else 'vdu_id'
132 cp_node[node_key] = find_node_name(relation['target_node_id'], src_node_list)
136 def convert_router_node(src_node, src_node_list):
137 router_node = {'router_id': src_node['template_name'], 'description': '', 'properties': {}}
138 convert_props(src_node, router_node)
139 for relation in src_node['relationships']:
140 if safe_get(relation, 'name') != 'external_virtual_link':
142 router_node['external_vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
143 router_node['external_ip_addresses'] = []
144 if 'properties' not in relation:
146 for prop_name, prop_info in relation['properties'].items():
147 if prop_name == 'router_ip_address':
148 router_node['external_ip_addresses'].append(prop_info['value'])
153 def convert_fp_node(src_node, src_node_list, src_json_model):
155 'fp_id': src_node['template_name'],
160 convert_props(src_node, fp_node)
161 for relation in safe_get(src_node, 'relationships'):
162 if safe_get(relation, 'name') != 'forwarder':
164 forwarder_point = {'type': 'vnf'}
165 target_node_type = find_node_type(relation['target_node_id'], src_node_list).upper()
166 if target_node_type.find('.CP.') >= 0 or target_node_type.endswith('.CP'):
167 forwarder_point['type'] = 'cp'
168 forwarder_point['node_name'] = find_node_name(relation['target_node_id'], src_node_list)
169 forwarder_point['capability'] = ''
170 if forwarder_point['type'] == 'vnf':
171 for node_tpl in src_json_model["node_templates"]:
172 if fp_node['fp_id'] != node_tpl["name"]:
174 for r_tpl in safe_get(node_tpl, "requirement_templates"):
175 if safe_get(r_tpl, "target_node_template_name") != forwarder_point['node_name']:
177 forwarder_point['capability'] = safe_get(r_tpl, "target_capability_name")
180 fp_node['forwarder_list'].append(forwarder_point)
184 def convert_vnffg_group(src_group, src_group_list, src_node_list):
186 'vnffg_id': src_group['template_name'],
191 convert_props(src_group, vnffg)
192 for member_node_id in src_group['member_node_ids']:
193 vnffg['members'].append(find_node_name(member_node_id, src_node_list))
197 def convert_imagefile_node(src_node, src_node_list):
199 'image_file_id': src_node['template_name'],
203 convert_props(src_node, image_node)
207 def convert_localstorage_node(src_node, src_node_list):
208 localstorage_node = {
209 'local_storage_id': src_node['template_name'],
213 convert_props(src_node, localstorage_node)
214 return localstorage_node
217 def convert_volumestorage_node(src_node, src_node_list):
218 volumestorage_node = {
219 'volume_storage_id': src_node['id'],
222 convert_props(src_node, volumestorage_node)
223 volumestorage_node["properties"]["size"] = convert_factor_unit(
224 volumestorage_node["properties"]["size_of_storage"])
225 return volumestorage_node
228 def convert_vdu_node(src_node, src_node_list, src_json_model):
230 'vdu_id': src_node['template_name'],
234 'local_storages': [],
239 'volume_storages': []
241 convert_props(src_node, vdu_node)
243 for relation in src_node.get('relationships', ''):
244 r_id, r_name = safe_get(relation, 'target_node_id'), safe_get(relation, 'name')
245 if r_name == 'guest_os':
246 vdu_node['image_file'] = find_node_name(r_id, src_node_list)
247 elif r_name == 'local_storage':
248 vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
249 elif r_name == 'virtual_storage':
250 vdu_node['volume_storages'].append(r_id)
251 elif r_name.endswith('.AttachesTo'):
252 nt = find_node_type(r_id, src_node_list)
253 if nt.endswith('.BlockStorage.Local') or nt.endswith('.LocalStorage'):
254 vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
256 for capability in src_node['capabilities']:
257 if not capability['type_name'].endswith('.VirtualCompute'):
259 vdu_node['nfv_compute']['flavor_extra_specs'] = {}
260 for prop_name, prop_info in capability['properties'].items():
261 if prop_name == "virtual_cpu":
262 vdu_node['nfv_compute']['num_cpus'] = prop_info["value"]["num_virtual_cpu"]
263 if "virtual_cpu_clock" in prop_info["value"]:
264 vdu_node['nfv_compute']['cpu_frequency'] =\
265 convert_factor_unit(prop_info["value"]["virtual_cpu_clock"])
266 elif prop_name == "virtual_memory":
267 vdu_node['nfv_compute']['mem_size'] = convert_factor_unit(
268 prop_info["value"]["virtual_mem_size"])
269 elif prop_name == "requested_additional_capabilities":
270 if prop_info and "value" in prop_info:
271 for key, val in prop_info["value"].items():
272 vdu_node['nfv_compute']['flavor_extra_specs'].update(
273 val["target_performance_parameters"])
275 vdu_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
277 for cp_node in vdu_node['cps']:
278 for src_cp_node in src_node_list:
279 if src_cp_node['template_name'] != cp_node:
281 for relation in safe_get(src_cp_node, 'relationships'):
282 if relation['name'] != 'virtualLink':
284 vl_node_name = find_node_name(relation['target_node_id'], src_node_list)
285 if vl_node_name not in vdu_node['vls']:
286 vdu_node['vls'].append(vl_node_name)
288 for item in safe_get(src_node, 'artifacts'):
290 'artifact_name': item['name'],
291 'type': item['type_name'],
292 'file': item['source_path'],
295 convert_props(item, artifact)
296 for key in artifact['properties']:
297 if 'factor' in artifact['properties'][key] and 'unit' in artifact['properties'][key]:
298 artifact['properties'][key] = convert_factor_unit(artifact['properties'][key])
299 vdu_node['artifacts'].append(artifact)
300 if artifact["type"].endswith(".SwImage"):
301 vdu_node['image_file'] = artifact["artifact_name"]
305 def convert_exposed_node(src_json, src_nodes, exposed):
306 for item in safe_get(safe_get(src_json, 'substitution'), 'requirements'):
308 'key_name': item['mapped_name'],
309 "cp_id": find_node_name(item['node_id'], src_nodes)
311 exposed['external_cps'].append(external_cps)
312 for item in safe_get(safe_get(src_json, 'substitution'), 'capabilities'):
314 'key_name': item['mapped_name'],
315 "cp_id": find_node_name(item['node_id'], src_nodes)
317 exposed['forward_cps'].append(forward_cps)
320 def convert_vnffgs(src_json_inst, src_nodes):
322 src_groups = safe_get(src_json_inst, 'groups')
323 for group in src_groups:
324 type_name = group['type_name'].upper()
325 if type_name.find('.VNFFG.') >= 0 or type_name.endswith('.VNFFG'):
326 vnffgs.append(convert_vnffg_group(group, src_groups, src_nodes))
330 def merge_imagefile_node(img_nodes, vdu_nodes):
331 for vdu_node in vdu_nodes:
332 for artifact in vdu_node.get("artifacts", []):
333 if not artifact["type"].endswith(".SwImage"):
335 imgids = [img["image_file_id"] for img in img_nodes]
336 if artifact["artifact_name"] in imgids:
339 "image_file_id": artifact["artifact_name"],
341 "properties": artifact["properties"]
345 def convert_common(src_json, target_json):
346 if isinstance(src_json, (unicode, str)):
347 src_json_dict = json.loads(src_json)
349 src_json_dict = src_json
350 src_json_inst = src_json_dict["instance"]
351 src_json_model = src_json_dict["model"] if "model" in src_json_dict else {}
353 target_json['metadata'] = convert_metadata(src_json_inst)
354 target_json['inputs'] = convert_inputs(src_json_inst)
355 target_json['vls'] = []
356 target_json['cps'] = []
357 target_json['routers'] = []
359 return src_json_inst, src_json_model
362 def convert_nsd_model(src_json):
363 target_json = {'vnfs': [], 'pnfs': [], 'fps': []}
364 src_json_inst, src_json_model = convert_common(src_json, target_json)
366 src_nodes = src_json_inst['nodes']
367 for node in src_nodes:
368 type_name = node['type_name']
369 if type_name.find('.VNF.') > 0 or type_name.endswith('.VNF'):
370 target_json['vnfs'].append(convert_vnf_node(node, src_json_model))
371 elif type_name.find('.PNF.') > 0 or type_name.endswith('.PNF'):
372 target_json['pnfs'].append(convert_pnf_node(node, src_json_model))
373 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
374 or node['type_name'].find('.RouteExternalVL') > 0:
375 target_json['vls'].append(convert_vl_node(node, src_nodes))
376 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP'):
377 target_json['cps'].append(convert_cp_node(node, src_nodes))
378 elif type_name.find('.FP.') > 0 or type_name.endswith('.FP'):
379 target_json['fps'].append(convert_fp_node(node, src_nodes, src_json_model))
380 elif type_name.endswith('.Router'):
381 target_json['routers'].append(convert_router_node(node, src_nodes))
383 target_json['vnffgs'] = convert_vnffgs(src_json_inst, src_nodes)
385 target_json['ns_exposed'] = {'external_cps': [], 'forward_cps': []}
386 convert_exposed_node(src_json_inst, src_nodes, target_json['ns_exposed'])
387 return json.dumps(target_json)
390 def convert_vnfd_model(src_json):
391 target_json = {'image_files': [], 'local_storages': [], 'vdus': [], 'volume_storages': []}
392 src_json_inst, src_json_model = convert_common(src_json, target_json)
394 src_nodes = src_json_inst['nodes']
395 for node in src_nodes:
396 type_name = node['type_name']
397 if type_name.endswith('.ImageFile'):
398 target_json['image_files'].append(convert_imagefile_node(node, src_nodes))
399 elif type_name.endswith('.BlockStorage.Local') or type_name.endswith('.LocalStorage'):
400 target_json['local_storages'].append(convert_localstorage_node(node, src_nodes))
401 elif type_name.endswith('VDU.VirtualStorage'):
402 target_json['volume_storages'].append(convert_volumestorage_node(node, src_nodes))
403 elif type_name.endswith('VDU.Compute'):
404 target_json['vdus'].append(convert_vdu_node(node, src_nodes, src_json_model))
405 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
406 or type_name.endswith('.VnfVirtualLinkDesc') \
407 or type_name.endswith('.RouteExternalVL'):
408 target_json['vls'].append(convert_vl_node(node, src_nodes))
409 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP') or type_name.endswith(".VduCpd"):
410 target_json['cps'].append(convert_cp_node(node, src_nodes, 'VNFD'))
411 elif type_name.endswith('.Router'):
412 target_json['routers'].append(convert_router_node(node, src_nodes))
414 target_json['vnf_exposed'] = {'external_cps': [], 'forward_cps': []}
415 convert_exposed_node(src_json_inst, src_nodes, target_json['vnf_exposed'])
416 merge_imagefile_node(target_json['image_files'], target_json['vdus'])
417 return json.dumps(target_json)
420 if __name__ == '__main__':
421 src_json = json.dumps({
424 "vnfSoftwareVersion": "1.0.0",
425 "vnfProductName": "zte",
426 "localizationLanguage": [
430 "vnfProvider": "zte",
432 "defaultLocalizationLanguage": "english",
433 "vnfdId": "zte-hss-1.0",
434 "vnfProductInfoDescription": "hss",
435 "vnfdVersion": "1.0.0",
436 "vnfProductInfoName": "hss"
440 "id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
441 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
442 "template_name": "vNAT_Storage",
445 "type_name": "scalar-unit.size",
447 "value": 10000000000,
450 "unit_size": 1000000000
454 "type_name": "string",
458 "type_name": "boolean",
465 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
466 "type_name": "tosca.interfaces.node.lifecycle.Standard",
470 "description": "Standard lifecycle create operation."
474 "description": "Standard lifecycle stop operation."
478 "description": "Standard lifecycle start operation."
482 "description": "Standard lifecycle delete operation."
486 "description": "Standard lifecycle configure operation."
494 "type_name": "tosca.capabilities.Node"
497 "name": "virtual_storage",
498 "type_name": "tosca.capabilities.nfv.VirtualStorage"
503 "id": "sriov_link_2610d7gund4e645wo39dvp238",
504 "type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
505 "template_name": "sriov_link",
513 "connectivity_type": {
514 "type_name": "tosca.datatypes.nfv.ConnectivityType",
516 "layer_protocol": "ipv4",
517 "flow_pattern": "flat"
521 "type_name": "string",
522 "value": "sriov_link"
534 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
535 "type_name": "tosca.interfaces.node.lifecycle.Standard",
539 "description": "Standard lifecycle create operation."
543 "description": "Standard lifecycle stop operation."
547 "description": "Standard lifecycle start operation."
551 "description": "Standard lifecycle delete operation."
555 "description": "Standard lifecycle configure operation."
563 "type_name": "tosca.capabilities.Node"
566 "name": "virtual_linkable",
567 "type_name": "tosca.capabilities.nfv.VirtualLinkable"
572 "id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
573 "type_name": "tosca.nodes.nfv.VDU.Compute",
574 "template_name": "vdu_vNat",
576 "configurable_properties": {
580 "additional_vnfc_configurable_properties": {
595 "type_name": "string",
598 "nfvi_constraints": {
605 "type_name": "string",
606 "value": "the virtual machine of vNat"
612 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
613 "type_name": "tosca.interfaces.node.lifecycle.Standard",
617 "description": "Standard lifecycle create operation."
621 "description": "Standard lifecycle stop operation."
625 "description": "Standard lifecycle start operation."
629 "description": "Standard lifecycle delete operation."
633 "description": "Standard lifecycle configure operation."
640 "name": "vNatVNFImage",
641 "type_name": "tosca.artifacts.nfv.SwImage",
642 "source_path": "/swimages/vRouterVNF_ControlPlane.qcow2",
644 "operating_system": {
645 "type_name": "string",
649 "type_name": "string",
650 "value": "/swimages/vRouterVNF_ControlPlane.qcow2"
653 "type_name": "string",
654 "value": "vNatVNFImage"
657 "type_name": "string",
661 "type_name": "scalar-unit.size",
666 "unit_size": 1000000000
670 "type_name": "string",
674 "type_name": "string",
677 "container_format": {
678 "type_name": "string",
682 "type_name": "scalar-unit.size",
684 "value": 10000000000,
687 "unit_size": 1000000000
690 "supported_virtualisation_environments": {
697 "type_name": "scalar-unit.size",
699 "value": 10000000000,
702 "unit_size": 1000000000
711 "type_name": "tosca.capabilities.Node"
715 "type_name": "tosca.capabilities.OperatingSystem",
718 "type_name": "string",
719 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
722 "type_name": "version",
723 "description": "The Operating System version."
726 "type_name": "string",
727 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
730 "type_name": "string",
731 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
737 "type_name": "tosca.capabilities.Container",
740 "type_name": "scalar-unit.frequency",
741 "description": "Specifies the operating frequency of CPU's core. This property expresses the expected frequency of one (1) CPU as provided by the property \"num_cpus\"."
744 "type_name": "scalar-unit.size",
745 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
748 "type_name": "integer",
749 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
752 "type_name": "scalar-unit.size",
753 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
759 "type_name": "tosca.capabilities.network.Bindable"
763 "type_name": "tosca.capabilities.Scalable",
766 "type_name": "integer",
768 "description": "This property is used to indicate the minimum number of instances that should be created for the associated TOSCA Node Template by a TOSCA orchestrator."
770 "default_instances": {
771 "type_name": "integer",
772 "description": "An optional property that indicates the requested default number of instances that should be the starting number of instances a TOSCA orchestrator should attempt to allocate. Note: The value for this property MUST be in the range between the values set for \"min_instances\" and \"max_instances\" properties."
775 "type_name": "integer",
777 "description": "This property is used to indicate the maximum number of instances that should be created for the associated TOSCA Node Template by a TOSCA orchestrator."
782 "name": "virtual_compute",
783 "type_name": "tosca.capabilities.nfv.VirtualCompute",
785 "requested_additional_capabilities": {
789 "requested_additional_capability_name": "ovs_dpdk",
790 "min_requested_additional_capability_version": "1.0",
791 "support_mandatory": True,
792 "target_performance_parameters": {
793 "sw:ovs_dpdk": "true"
795 "preferred_requested_additional_capability_version": "1.0"
798 "requested_additional_capability_name": "hyper_threading",
799 "min_requested_additional_capability_version": "1.0",
800 "support_mandatory": True,
801 "target_performance_parameters": {
803 "hw:cpu_threads": "2",
804 "hw:cpu_threads_policy": "isolate",
805 "hw:cpu_sockets": "2"
807 "preferred_requested_additional_capability_version": "1.0"
810 "requested_additional_capability_name": "numa",
811 "min_requested_additional_capability_version": "1.0",
812 "support_mandatory": True,
813 "target_performance_parameters": {
814 "hw:numa_cpus.0": "0,1",
815 "hw:numa_cpus.1": "2,3,4,5",
816 "hw:numa_nodes": "2",
817 "hw:numa_mem.1": "3072",
818 "hw:numa_mem.0": "1024"
820 "preferred_requested_additional_capability_version": "1.0"
825 "type_name": "tosca.datatypes.nfv.VirtualCpu",
827 "num_virtual_cpu": 2,
828 "virtual_cpu_clock": {
832 "unit_size": 1000000000
834 "cpu_architecture": "X86",
835 "virtual_cpu_oversubscription_policy": "test",
836 "virtual_cpu_pinning": {
840 "cpu_pinning_policy": "static"
845 "type_name": "tosca.datatypes.nfv.VirtualMemory",
847 "virtual_mem_oversubscription_policy": "mem_policy_test",
848 "numa_enabled": True,
849 "virtual_mem_size": {
850 "value": 10000000000,
853 "unit_size": 1000000000
860 "name": "virtual_binding",
861 "type_name": "tosca.capabilities.nfv.VirtualBindable"
866 "name": "virtual_storage",
867 "source_requirement_index": 0,
868 "target_node_id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
871 "type_name": "string",
872 "value": "/mnt/volume_0",
873 "description": "The relative location (e.g., path on the file system), which provides the root location to address an attached node. e.g., a mount point / path such as '/usr/data'. Note: The user must provide it and it cannot be \"root\"."
876 "source_interfaces": [
879 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
880 "type_name": "tosca.interfaces.relationship.Configure",
883 "name": "add_source",
884 "description": "Operation to notify the target node of a source node which is now available via a relationship."
887 "name": "pre_configure_target",
888 "description": "Operation to pre-configure the target endpoint."
891 "name": "post_configure_source",
892 "description": "Operation to post-configure the source endpoint."
895 "name": "target_changed",
896 "description": "Operation to notify source some property or attribute of the target changed"
899 "name": "pre_configure_source",
900 "description": "Operation to pre-configure the source endpoint."
903 "name": "post_configure_target",
904 "description": "Operation to post-configure the target endpoint."
907 "name": "remove_target",
908 "description": "Operation to remove a target node."
911 "name": "add_target",
912 "description": "Operation to notify the source node of a target node being added via a relationship."
921 "id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
922 "type_name": "tosca.nodes.nfv.VduCpd",
923 "template_name": "SRIOV_Port",
929 "address_type": "ip_address",
931 "ip_address_type": "ipv4",
932 "floating_ip_activated": False,
933 "number_of_ip_address": 1,
934 "ip_address_assignment": True
940 "type_name": "string",
941 "value": "sriov port"
944 "type_name": "string",
947 "virtual_network_interface_requirements": {
954 "support_mandatory": False,
956 "description": "sriov"
962 "support_mandatory": False,
964 "description": "normal"
969 "type_name": "string",
972 "bitrate_requirement": {
973 "type_name": "integer",
980 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
981 "type_name": "tosca.interfaces.node.lifecycle.Standard",
985 "description": "Standard lifecycle create operation."
989 "description": "Standard lifecycle stop operation."
993 "description": "Standard lifecycle start operation."
997 "description": "Standard lifecycle delete operation."
1000 "name": "configure",
1001 "description": "Standard lifecycle configure operation."
1009 "type_name": "tosca.capabilities.Node"
1014 "name": "virtual_binding",
1015 "source_requirement_index": 0,
1016 "target_node_id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
1017 "source_interfaces": [
1019 "name": "Configure",
1020 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
1021 "type_name": "tosca.interfaces.relationship.Configure",
1024 "name": "add_source",
1025 "description": "Operation to notify the target node of a source node which is now available via a relationship."
1028 "name": "pre_configure_target",
1029 "description": "Operation to pre-configure the target endpoint."
1032 "name": "post_configure_source",
1033 "description": "Operation to post-configure the source endpoint."
1036 "name": "target_changed",
1037 "description": "Operation to notify source some property or attribute of the target changed"
1040 "name": "pre_configure_source",
1041 "description": "Operation to pre-configure the source endpoint."
1044 "name": "post_configure_target",
1045 "description": "Operation to post-configure the target endpoint."
1048 "name": "remove_target",
1049 "description": "Operation to remove a target node."
1052 "name": "add_target",
1053 "description": "Operation to notify the source node of a target node being added via a relationship."
1060 "name": "virtual_link",
1061 "source_requirement_index": 1,
1062 "target_node_id": "sriov_link_2610d7gund4e645wo39dvp238",
1063 "target_capability_name": "feature",
1064 "source_interfaces": [
1066 "name": "Configure",
1067 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
1068 "type_name": "tosca.interfaces.relationship.Configure",
1071 "name": "add_source",
1072 "description": "Operation to notify the target node of a source node which is now available via a relationship."
1075 "name": "pre_configure_target",
1076 "description": "Operation to pre-configure the target endpoint."
1079 "name": "post_configure_source",
1080 "description": "Operation to post-configure the source endpoint."
1083 "name": "target_changed",
1084 "description": "Operation to notify source some property or attribute of the target changed"
1087 "name": "pre_configure_source",
1088 "description": "Operation to pre-configure the source endpoint."
1091 "name": "post_configure_target",
1092 "description": "Operation to post-configure the target endpoint."
1095 "name": "remove_target",
1096 "description": "Operation to remove a target node."
1099 "name": "add_target",
1100 "description": "Operation to notify the source node of a target node being added via a relationship."
1110 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1113 "mapped_name": "sriov_plane",
1114 "node_id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
1115 "name": "virtual_link"
1122 "vnfSoftwareVersion": "1.0.0",
1123 "vnfProductName": "openNAT",
1124 "localizationLanguage": [
1128 "vnfProvider": "intel",
1129 "vnfmInfo": "GVNFM",
1130 "defaultLocalizationLanguage": "english",
1131 "vnfdId": "openNAT-1.0",
1132 "vnfProductInfoDescription": "openNAT",
1133 "vnfdVersion": "1.0.0",
1134 "vnfProductInfoName": "openNAT"
1138 "name": "vNAT_Storage",
1139 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
1140 "default_instances": 1,
1143 "size_of_storage": {
1144 "type_name": "scalar-unit.size",
1146 "value": 10000000000,
1149 "unit_size": 1000000000
1152 "type_of_storage": {
1153 "type_name": "string",
1157 "type_name": "boolean",
1161 "interface_templates": [
1164 "capability_templates": [
1167 "type_name": "tosca.capabilities.Node"
1170 "name": "virtual_storage",
1171 "type_name": "tosca.capabilities.nfv.VirtualStorage"
1177 "type_name": "tosca.nodes.nfv.VDU.Compute",
1178 "default_instances": 1,
1181 "configurable_properties": {
1185 "additional_vnfc_configurable_properties": {
1194 "type_name": "list",
1200 "type_name": "string",
1203 "nfvi_constraints": {
1204 "type_name": "list",
1210 "type_name": "string",
1211 "value": "the virtual machine of vNat"
1214 "interface_templates": [
1217 "artifact_templates": [
1220 "capability_templates": [
1223 "type_name": "tosca.capabilities.Node"
1227 "type_name": "tosca.capabilities.OperatingSystem",
1230 "type_name": "string",
1231 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
1234 "type_name": "version",
1235 "description": "The Operating System version."
1238 "type_name": "string",
1239 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
1242 "type_name": "string",
1243 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
1249 "type_name": "tosca.capabilities.Container",
1250 "valid_source_node_type_names": [
1251 "tosca.nodes.SoftwareComponent"
1255 "type_name": "scalar-unit.frequency",
1256 "description": "Specifies the operating frequency of CPU's core. This property expresses the expected frequency of one (1) CPU as provided by the property \"num_cpus\"."
1259 "type_name": "scalar-unit.size",
1260 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
1263 "type_name": "integer",
1264 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
1267 "type_name": "scalar-unit.size",
1268 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
1274 "type_name": "tosca.capabilities.network.Bindable"
1278 "type_name": "tosca.capabilities.Scalable",
1281 "type_name": "integer",
1283 "description": "This property is used to indicate the minimum number of instances that should be created for the associated TOSCA Node Template by a TOSCA orchestrator."
1285 "default_instances": {
1286 "type_name": "integer",
1287 "description": "An optional property that indicates the requested default number of instances that should be the starting number of instances a TOSCA orchestrator should attempt to allocate. Note: The value for this property MUST be in the range between the values set for \"min_instances\" and \"max_instances\" properties."
1290 "type_name": "integer",
1292 "description": "This property is used to indicate the maximum number of instances that should be created for the associated TOSCA Node Template by a TOSCA orchestrator."
1297 "name": "virtual_compute",
1298 "type_name": "tosca.capabilities.nfv.VirtualCompute",
1300 "requested_additional_capabilities": {
1304 "requested_additional_capability_name": "ovs_dpdk",
1305 "min_requested_additional_capability_version": "1.0",
1306 "support_mandatory": True,
1307 "target_performance_parameters": {
1308 "sw:ovs_dpdk": "true"
1310 "preferred_requested_additional_capability_version": "1.0"
1312 "hyper_threading": {
1313 "requested_additional_capability_name": "hyper_threading",
1314 "min_requested_additional_capability_version": "1.0",
1315 "support_mandatory": True,
1316 "target_performance_parameters": {
1317 "hw:cpu_cores": "2",
1318 "hw:cpu_threads": "2",
1319 "hw:cpu_threads_policy": "isolate",
1320 "hw:cpu_sockets": "2"
1322 "preferred_requested_additional_capability_version": "1.0"
1325 "requested_additional_capability_name": "numa",
1326 "min_requested_additional_capability_version": "1.0",
1327 "support_mandatory": True,
1328 "target_performance_parameters": {
1329 "hw:numa_cpus.0": "0,1",
1330 "hw:numa_cpus.1": "2,3,4,5",
1331 "hw:numa_nodes": "2",
1332 "hw:numa_mem.1": "3072",
1333 "hw:numa_mem.0": "1024"
1335 "preferred_requested_additional_capability_version": "1.0"
1340 "type_name": "tosca.datatypes.nfv.VirtualCpu",
1342 "num_virtual_cpu": 2,
1343 "virtual_cpu_clock": {
1344 "value": 2400000000,
1347 "unit_size": 1000000000
1349 "cpu_architecture": "X86",
1350 "virtual_cpu_oversubscription_policy": "test",
1351 "virtual_cpu_pinning": {
1352 "cpu_pinning_map": {
1353 "cpu_pinning_0": "1"
1355 "cpu_pinning_policy": "static"
1360 "type_name": "tosca.datatypes.nfv.VirtualMemory",
1362 "virtual_mem_oversubscription_policy": "mem_policy_test",
1363 "numa_enabled": True,
1364 "virtual_mem_size": {
1365 "value": 10000000000,
1368 "unit_size": 1000000000
1375 "name": "virtual_binding",
1376 "type_name": "tosca.capabilities.nfv.VirtualBindable"
1379 "requirement_templates": [
1381 "name": "virtual_storage",
1382 "target_node_template_name": "vNAT_Storage",
1383 "relationship_template": {
1384 "type_name": "tosca.relationships.nfv.VDU.AttachedTo",
1387 "type_name": "string",
1388 "value": "/mnt/volume_0",
1389 "description": "The relative location (e.g., path on the file system), which provides the root location to address an attached node. e.g., a mount point / path such as '/usr/data'. Note: The user must provide it and it cannot be \"root\"."
1392 "source_interface_templates": [
1400 "name": "SRIOV_Port",
1401 "type_name": "tosca.nodes.nfv.VduCpd",
1402 "default_instances": 1,
1406 "type_name": "list",
1409 "address_type": "ip_address",
1410 "l3_address_data": {
1411 "ip_address_type": "ipv4",
1412 "floating_ip_activated": False,
1413 "number_of_ip_address": 1,
1414 "ip_address_assignment": True
1420 "type_name": "string",
1421 "value": "sriov port"
1424 "type_name": "string",
1427 "virtual_network_interface_requirements": {
1428 "type_name": "list",
1434 "support_mandatory": False,
1436 "description": "sriov"
1442 "support_mandatory": False,
1444 "description": "normal"
1449 "type_name": "string",
1452 "bitrate_requirement": {
1453 "type_name": "integer",
1457 "interface_templates": [
1460 "capability_templates": [
1463 "type_name": "tosca.capabilities.Node"
1466 "requirement_templates": [
1468 "name": "virtual_binding",
1469 "target_node_template_name": "vdu_vNat",
1470 "relationship_template": {
1471 "type_name": "tosca.relationships.nfv.VirtualBindsTo",
1472 "source_interface_templates": [
1478 "name": "virtual_link",
1479 "target_node_type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
1480 "relationship_template": {
1481 "type_name": "tosca.relationships.nfv.VirtualLinksTo",
1482 "source_interface_templates": [
1490 "substitution_template": {
1491 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1492 "requirement_templates": [
1494 "mapped_name": "sriov_plane",
1495 "node_template_name": "SRIOV_Port",
1496 "name": "virtual_link"
1502 print convert_vnfd_model(src_json)