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 \
41 safe_get(rt, 'target_node_template_name') == node_id:
42 related_nodes.append(model_tpl['name'])
46 def convert_props(src_node, dest_node):
47 if 'properties' in src_node and src_node['properties']:
48 for prop_name, prop_info in src_node['properties'].items():
49 if 'value' in prop_info:
50 dest_node['properties'][prop_name] = prop_info['value']
53 def convert_metadata(src_json):
54 return src_json['metadata'] if 'metadata' in src_json else {}
57 def convert_factor_unit(value):
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):
79 vnf_node = {'type': src_node['type_name'], 'vnf_id': src_node['template_name'],
80 'description': '', 'properties': {}, 'dependencies': [], 'networks': []}
81 convert_props(src_node, vnf_node)
82 for model_tpl in safe_get(src_json_model, "node_templates"):
83 if model_tpl['name'] != vnf_node['vnf_id']:
85 vnf_node['dependencies'] = [{
86 'key_name': requirement['name'],
87 'vl_id': requirement['target_node_template_name']} for \
88 requirement in safe_get(model_tpl, 'requirement_templates') if \
89 safe_get(requirement, 'target_capability_name') == 'virtual_linkable']
90 vnf_node['networks'] = [requirement['target_node_template_name'] for \
91 requirement in safe_get(model_tpl, 'requirement_templates') if \
92 safe_get(requirement, 'name') == 'dependency']
96 def convert_pnf_node(src_node, src_json_model):
97 pnf_node = {'pnf_id': src_node['template_name'], 'description': '', 'properties': {}}
98 convert_props(src_node, pnf_node)
99 pnf_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
103 def convert_vl_node(src_node, src_node_list):
104 vl_node = {'vl_id': src_node['template_name'], 'description': '', 'properties': {}}
105 convert_props(src_node, vl_node)
106 vl_node['route_id'] = ''
107 for relation in safe_get(src_node, 'relationships'):
108 if safe_get(relation, 'type_name').endswith('.VirtualLinksTo'):
109 vl_node['route_id'] = find_node_name(relation['target_node_id'], src_node_list)
111 vl_node['route_external'] = (src_node['type_name'].find('.RouteExternalVL') > 0)
115 def convert_cp_node(src_node, src_node_list, model_type='NSD'):
116 cp_node = {'cp_id': src_node['template_name'], 'description': '', 'properties': {}}
117 convert_props(src_node, cp_node)
118 src_relationships = src_node['relationships']
119 for relation in src_relationships:
120 if safe_get(relation, 'name') in ('virtualLink', 'virtual_link'):
121 cp_node['vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
122 elif safe_get(relation, 'name') in ('virtualbinding', 'virtual_binding'):
123 node_key = 'pnf_id' if model_type == 'NSD' else 'vdu_id'
124 cp_node[node_key] = find_node_name(relation['target_node_id'], src_node_list)
128 def convert_router_node(src_node, src_node_list):
129 router_node = {'router_id': src_node['template_name'], 'description': '', 'properties': {}}
130 convert_props(src_node, router_node)
131 for relation in src_node['relationships']:
132 if safe_get(relation, 'name') != 'external_virtual_link':
134 router_node['external_vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
135 router_node['external_ip_addresses'] = []
136 if 'properties' not in relation:
138 for prop_name, prop_info in relation['properties'].items():
139 if prop_name == 'router_ip_address':
140 router_node['external_ip_addresses'].append(prop_info['value'])
145 def convert_fp_node(src_node, src_node_list, src_json_model):
146 fp_node = {'fp_id': src_node['template_name'], 'description': '',
147 'properties': {}, 'forwarder_list': []}
148 convert_props(src_node, fp_node)
149 for relation in safe_get(src_node, 'relationships'):
150 if safe_get(relation, 'name') != 'forwarder':
152 forwarder_point = {'type': 'vnf'}
153 target_node_type = find_node_type(relation['target_node_id'], src_node_list).upper()
154 if target_node_type.find('.CP.') >= 0 or target_node_type.endswith('.CP'):
155 forwarder_point['type'] = 'cp'
156 forwarder_point['node_name'] = find_node_name(relation['target_node_id'], src_node_list)
157 forwarder_point['capability'] = ''
158 if forwarder_point['type'] == 'vnf':
159 for node_tpl in src_json_model["node_templates"]:
160 if fp_node['fp_id'] != node_tpl["name"]:
162 for r_tpl in safe_get(node_tpl, "requirement_templates"):
163 if safe_get(r_tpl, "target_node_template_name") != forwarder_point['node_name']:
165 forwarder_point['capability'] = safe_get(r_tpl, "target_capability_name")
168 fp_node['forwarder_list'].append(forwarder_point)
172 def convert_vnffg_group(src_group, src_group_list, src_node_list):
173 vnffg = {'vnffg_id': src_group['template_name'], 'description': '',
174 'properties': {}, 'members': []}
175 convert_props(src_group, vnffg)
176 for member_node_id in src_group['member_node_ids']:
177 vnffg['members'].append(find_node_name(member_node_id, src_node_list))
181 def convert_imagefile_node(src_node, src_node_list):
182 image_node = {'image_file_id': src_node['template_name'], 'description': '',
184 convert_props(src_node, image_node)
188 def convert_localstorage_node(src_node, src_node_list):
189 localstorage_node = {'local_storage_id': src_node['template_name'], 'description': '',
191 convert_props(src_node, localstorage_node)
192 return localstorage_node
195 def convert_volumestorage_node(src_node, src_node_list):
196 volumestorage_node = {
197 'volume_storage_id': src_node['id'],
200 convert_props(src_node, volumestorage_node)
201 volumestorage_node["properties"]["size"] = convert_factor_unit(
202 volumestorage_node["properties"]["size_of_storage"])
203 return volumestorage_node
206 def convert_vdu_node(src_node, src_node_list, src_json_model):
207 vdu_node = {'vdu_id': src_node['template_name'], 'description': '', 'properties': {},
208 'image_file': '', 'local_storages': [], 'dependencies': [], 'nfv_compute': {},
209 'vls': [], 'artifacts': [], 'volume_storages': []}
210 convert_props(src_node, vdu_node)
212 for relation in src_node.get('relationships', ''):
213 r_id, r_name = safe_get(relation, 'target_node_id'), safe_get(relation, 'name')
214 if r_name == 'guest_os':
215 vdu_node['image_file'] = find_node_name(r_id, src_node_list)
216 elif r_name == 'local_storage':
217 vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
218 elif r_name == 'virtual_storage':
219 vdu_node['volume_storages'].append(r_id)
220 elif r_name.endswith('.AttachesTo'):
221 nt = find_node_type(r_id, src_node_list)
222 if nt.endswith('.BlockStorage.Local') or nt.endswith('.LocalStorage'):
223 vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
225 for capability in src_node['capabilities']:
226 if not capability['type_name'].endswith('.VirtualCompute'):
228 vdu_node['nfv_compute']['flavor_extra_specs'] = {}
229 for prop_name, prop_info in capability['properties'].items():
230 if prop_name == "virtual_cpu":
231 vdu_node['nfv_compute']['num_cpus'] = prop_info["value"]["num_virtual_cpu"]
232 vdu_node['nfv_compute']['cpu_frequency'] = convert_factor_unit(
233 prop_info["value"]["virtual_cpu_clock"])
234 elif prop_name == "virtual_memory":
235 vdu_node['nfv_compute']['mem_size'] = convert_factor_unit(
236 prop_info["value"]["virtual_mem_size"])
237 elif prop_name == "requested_additional_capabilities":
238 for key, val in prop_info["value"].items():
239 vdu_node['nfv_compute']['flavor_extra_specs'].update(
240 val["target_performance_parameters"])
242 vdu_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
244 for cp_node in vdu_node['cps']:
245 for src_cp_node in src_node_list:
246 if src_cp_node['template_name'] != cp_node:
248 for relation in safe_get(src_cp_node, 'relationships'):
249 if relation['name'] != 'virtualLink':
251 vl_node_name = find_node_name(relation['target_node_id'], src_node_list)
252 if vl_node_name not in vdu_node['vls']:
253 vdu_node['vls'].append(vl_node_name)
255 for item in safe_get(src_node, 'artifacts'):
256 artifact = {'artifact_name': item['name'], 'type': item['type_name'],
257 'file': item['source_path'], 'properties': {}}
258 convert_props(item, artifact)
259 for key in artifact['properties']:
260 if 'factor' in artifact['properties'][key] and 'unit' in artifact['properties'][key]:
261 artifact['properties'][key] = convert_factor_unit(artifact['properties'][key])
262 vdu_node['artifacts'].append(artifact)
263 if artifact["type"].endswith(".SwImage"):
264 vdu_node['image_file'] = artifact["artifact_name"]
268 def convert_exposed_node(src_json, src_nodes, exposed):
269 for item in safe_get(safe_get(src_json, 'substitution'), 'requirements'):
270 exposed['external_cps'].append({'key_name': item['mapped_name'],
271 "cp_id": find_node_name(item['node_id'], src_nodes)})
272 for item in safe_get(safe_get(src_json, 'substitution'), 'capabilities'):
273 exposed['forward_cps'].append({'key_name': item['mapped_name'],
274 "cp_id": find_node_name(item['node_id'], src_nodes)})
277 def convert_vnffgs(src_json_inst, src_nodes):
279 src_groups = safe_get(src_json_inst, 'groups')
280 for group in src_groups:
281 type_name = group['type_name'].upper()
282 if type_name.find('.VNFFG.') >= 0 or type_name.endswith('.VNFFG'):
283 vnffgs.append(convert_vnffg_group(group, src_groups, src_nodes))
287 def merge_imagefile_node(img_nodes, vdu_nodes):
288 for vdu_node in vdu_nodes:
289 for artifact in vdu_node.get("artifacts", []):
290 if not artifact["type"].endswith(".SwImage"):
292 imgids = [img["image_file_id"] for img in img_nodes]
293 if artifact["artifact_name"] in imgids:
296 "image_file_id": artifact["artifact_name"],
298 "properties": artifact["properties"]
302 def convert_common(src_json, target_json):
303 if isinstance(src_json, (unicode, str)):
304 src_json_dict = json.loads(src_json)
306 src_json_dict = src_json
307 src_json_inst = src_json_dict["instance"]
308 src_json_model = src_json_dict["model"] if "model" in src_json_dict else {}
310 target_json['metadata'] = convert_metadata(src_json_inst)
311 target_json['inputs'] = convert_inputs(src_json_inst)
312 target_json['vls'] = []
313 target_json['cps'] = []
314 target_json['routers'] = []
316 return src_json_inst, src_json_model
319 def convert_nsd_model(src_json):
320 target_json = {'vnfs': [], 'pnfs': [], 'fps': []}
321 src_json_inst, src_json_model = convert_common(src_json, target_json)
323 src_nodes = src_json_inst['nodes']
324 for node in src_nodes:
325 type_name = node['type_name']
326 if type_name.find('.VNF.') > 0 or type_name.endswith('.VNF'):
327 target_json['vnfs'].append(convert_vnf_node(node, src_json_model))
328 elif type_name.find('.PNF.') > 0 or type_name.endswith('.PNF'):
329 target_json['pnfs'].append(convert_pnf_node(node, src_json_model))
330 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
331 or node['type_name'].find('.RouteExternalVL') > 0:
332 target_json['vls'].append(convert_vl_node(node, src_nodes))
333 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP'):
334 target_json['cps'].append(convert_cp_node(node, src_nodes))
335 elif type_name.find('.FP.') > 0 or type_name.endswith('.FP'):
336 target_json['fps'].append(convert_fp_node(node, src_nodes, src_json_model))
337 elif type_name.endswith('.Router'):
338 target_json['routers'].append(convert_router_node(node, src_nodes))
340 target_json['vnffgs'] = convert_vnffgs(src_json_inst, src_nodes)
342 target_json['ns_exposed'] = {'external_cps': [], 'forward_cps': []}
343 convert_exposed_node(src_json_inst, src_nodes, target_json['ns_exposed'])
344 return json.dumps(target_json)
347 def convert_vnfd_model(src_json):
348 target_json = {'image_files': [], 'local_storages': [], 'vdus': [], 'volume_storages': []}
349 src_json_inst, src_json_model = convert_common(src_json, target_json)
351 src_nodes = src_json_inst['nodes']
352 for node in src_nodes:
353 type_name = node['type_name']
354 if type_name.endswith('.ImageFile'):
355 target_json['image_files'].append(convert_imagefile_node(node, src_nodes))
356 elif type_name.endswith('.BlockStorage.Local') or type_name.endswith('.LocalStorage'):
357 target_json['local_storages'].append(convert_localstorage_node(node, src_nodes))
358 elif type_name.endswith('VDU.VirtualStorage'):
359 target_json['volume_storages'].append(convert_volumestorage_node(node, src_nodes))
360 elif type_name.endswith('VDU.Compute'):
361 target_json['vdus'].append(convert_vdu_node(node, src_nodes, src_json_model))
362 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
363 or type_name.endswith('.VnfVirtualLinkDesc') \
364 or type_name.endswith('.RouteExternalVL'):
365 target_json['vls'].append(convert_vl_node(node, src_nodes))
366 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP') or type_name.endswith(".VduCpd"):
367 target_json['cps'].append(convert_cp_node(node, src_nodes, 'VNFD'))
368 elif type_name.endswith('.Router'):
369 target_json['routers'].append(convert_router_node(node, src_nodes))
371 target_json['vnf_exposed'] = {'external_cps': [], 'forward_cps': []}
372 convert_exposed_node(src_json_inst, src_nodes, target_json['vnf_exposed'])
373 merge_imagefile_node(target_json['image_files'], target_json['vdus'])
374 return json.dumps(target_json)
377 if __name__ == '__main__':
378 src_json = json.dumps({
381 "vnfSoftwareVersion": "1.0.0",
382 "vnfProductName": "zte",
383 "localizationLanguage": [
387 "vnfProvider": "zte",
389 "defaultLocalizationLanguage": "english",
390 "vnfdId": "zte-hss-1.0",
391 "vnfProductInfoDescription": "hss",
392 "vnfdVersion": "1.0.0",
393 "vnfProductInfoName": "hss"
397 "id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
398 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
399 "template_name": "vNAT_Storage",
402 "type_name": "scalar-unit.size",
404 "value": 10000000000,
407 "unit_size": 1000000000
411 "type_name": "string",
415 "type_name": "boolean",
422 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
423 "type_name": "tosca.interfaces.node.lifecycle.Standard",
427 "description": "Standard lifecycle create operation."
431 "description": "Standard lifecycle stop operation."
435 "description": "Standard lifecycle start operation."
439 "description": "Standard lifecycle delete operation."
443 "description": "Standard lifecycle configure operation."
451 "type_name": "tosca.capabilities.Node"
454 "name": "virtual_storage",
455 "type_name": "tosca.capabilities.nfv.VirtualStorage"
460 "id": "sriov_link_2610d7gund4e645wo39dvp238",
461 "type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
462 "template_name": "sriov_link",
470 "connectivity_type": {
471 "type_name": "tosca.datatypes.nfv.ConnectivityType",
473 "layer_protocol": "ipv4",
474 "flow_pattern": "flat"
478 "type_name": "string",
479 "value": "sriov_link"
491 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
492 "type_name": "tosca.interfaces.node.lifecycle.Standard",
496 "description": "Standard lifecycle create operation."
500 "description": "Standard lifecycle stop operation."
504 "description": "Standard lifecycle start operation."
508 "description": "Standard lifecycle delete operation."
512 "description": "Standard lifecycle configure operation."
520 "type_name": "tosca.capabilities.Node"
523 "name": "virtual_linkable",
524 "type_name": "tosca.capabilities.nfv.VirtualLinkable"
529 "id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
530 "type_name": "tosca.nodes.nfv.VDU.Compute",
531 "template_name": "vdu_vNat",
533 "configurable_properties": {
537 "additional_vnfc_configurable_properties": {
552 "type_name": "string",
555 "nfvi_constraints": {
562 "type_name": "string",
563 "value": "the virtual machine of vNat"
569 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
570 "type_name": "tosca.interfaces.node.lifecycle.Standard",
574 "description": "Standard lifecycle create operation."
578 "description": "Standard lifecycle stop operation."
582 "description": "Standard lifecycle start operation."
586 "description": "Standard lifecycle delete operation."
590 "description": "Standard lifecycle configure operation."
597 "name": "vNatVNFImage",
598 "type_name": "tosca.artifacts.nfv.SwImage",
599 "source_path": "/swimages/vRouterVNF_ControlPlane.qcow2",
601 "operating_system": {
602 "type_name": "string",
606 "type_name": "string",
607 "value": "/swimages/vRouterVNF_ControlPlane.qcow2"
610 "type_name": "string",
611 "value": "vNatVNFImage"
614 "type_name": "string",
618 "type_name": "scalar-unit.size",
623 "unit_size": 1000000000
627 "type_name": "string",
631 "type_name": "string",
634 "container_format": {
635 "type_name": "string",
639 "type_name": "scalar-unit.size",
641 "value": 10000000000,
644 "unit_size": 1000000000
647 "supported_virtualisation_environments": {
654 "type_name": "scalar-unit.size",
656 "value": 10000000000,
659 "unit_size": 1000000000
668 "type_name": "tosca.capabilities.Node"
672 "type_name": "tosca.capabilities.OperatingSystem",
675 "type_name": "string",
676 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
679 "type_name": "version",
680 "description": "The Operating System version."
683 "type_name": "string",
684 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
687 "type_name": "string",
688 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
694 "type_name": "tosca.capabilities.Container",
697 "type_name": "scalar-unit.frequency",
698 "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\"."
701 "type_name": "scalar-unit.size",
702 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
705 "type_name": "integer",
706 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
709 "type_name": "scalar-unit.size",
710 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
716 "type_name": "tosca.capabilities.network.Bindable"
720 "type_name": "tosca.capabilities.Scalable",
723 "type_name": "integer",
725 "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."
727 "default_instances": {
728 "type_name": "integer",
729 "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."
732 "type_name": "integer",
734 "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."
739 "name": "virtual_compute",
740 "type_name": "tosca.capabilities.nfv.VirtualCompute",
742 "requested_additional_capabilities": {
746 "requested_additional_capability_name": "ovs_dpdk",
747 "min_requested_additional_capability_version": "1.0",
748 "support_mandatory": True,
749 "target_performance_parameters": {
750 "sw:ovs_dpdk": "true"
752 "preferred_requested_additional_capability_version": "1.0"
755 "requested_additional_capability_name": "hyper_threading",
756 "min_requested_additional_capability_version": "1.0",
757 "support_mandatory": True,
758 "target_performance_parameters": {
760 "hw:cpu_threads": "2",
761 "hw:cpu_threads_policy": "isolate",
762 "hw:cpu_sockets": "2"
764 "preferred_requested_additional_capability_version": "1.0"
767 "requested_additional_capability_name": "numa",
768 "min_requested_additional_capability_version": "1.0",
769 "support_mandatory": True,
770 "target_performance_parameters": {
771 "hw:numa_cpus.0": "0,1",
772 "hw:numa_cpus.1": "2,3,4,5",
773 "hw:numa_nodes": "2",
774 "hw:numa_mem.1": "3072",
775 "hw:numa_mem.0": "1024"
777 "preferred_requested_additional_capability_version": "1.0"
782 "type_name": "tosca.datatypes.nfv.VirtualCpu",
784 "num_virtual_cpu": 2,
785 "virtual_cpu_clock": {
789 "unit_size": 1000000000
791 "cpu_architecture": "X86",
792 "virtual_cpu_oversubscription_policy": "test",
793 "virtual_cpu_pinning": {
797 "cpu_pinning_policy": "static"
802 "type_name": "tosca.datatypes.nfv.VirtualMemory",
804 "virtual_mem_oversubscription_policy": "mem_policy_test",
805 "numa_enabled": True,
806 "virtual_mem_size": {
807 "value": 10000000000,
810 "unit_size": 1000000000
817 "name": "virtual_binding",
818 "type_name": "tosca.capabilities.nfv.VirtualBindable"
823 "name": "virtual_storage",
824 "source_requirement_index": 0,
825 "target_node_id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
828 "type_name": "string",
829 "value": "/mnt/volume_0",
830 "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\"."
833 "source_interfaces": [
836 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
837 "type_name": "tosca.interfaces.relationship.Configure",
840 "name": "add_source",
841 "description": "Operation to notify the target node of a source node which is now available via a relationship."
844 "name": "pre_configure_target",
845 "description": "Operation to pre-configure the target endpoint."
848 "name": "post_configure_source",
849 "description": "Operation to post-configure the source endpoint."
852 "name": "target_changed",
853 "description": "Operation to notify source some property or attribute of the target changed"
856 "name": "pre_configure_source",
857 "description": "Operation to pre-configure the source endpoint."
860 "name": "post_configure_target",
861 "description": "Operation to post-configure the target endpoint."
864 "name": "remove_target",
865 "description": "Operation to remove a target node."
868 "name": "add_target",
869 "description": "Operation to notify the source node of a target node being added via a relationship."
878 "id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
879 "type_name": "tosca.nodes.nfv.VduCpd",
880 "template_name": "SRIOV_Port",
886 "address_type": "ip_address",
888 "ip_address_type": "ipv4",
889 "floating_ip_activated": False,
890 "number_of_ip_address": 1,
891 "ip_address_assignment": True
897 "type_name": "string",
898 "value": "sriov port"
901 "type_name": "string",
904 "virtual_network_interface_requirements": {
911 "support_mandatory": False,
913 "description": "sriov"
919 "support_mandatory": False,
921 "description": "normal"
926 "type_name": "string",
929 "bitrate_requirement": {
930 "type_name": "integer",
937 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
938 "type_name": "tosca.interfaces.node.lifecycle.Standard",
942 "description": "Standard lifecycle create operation."
946 "description": "Standard lifecycle stop operation."
950 "description": "Standard lifecycle start operation."
954 "description": "Standard lifecycle delete operation."
958 "description": "Standard lifecycle configure operation."
966 "type_name": "tosca.capabilities.Node"
971 "name": "virtual_binding",
972 "source_requirement_index": 0,
973 "target_node_id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
974 "source_interfaces": [
977 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
978 "type_name": "tosca.interfaces.relationship.Configure",
981 "name": "add_source",
982 "description": "Operation to notify the target node of a source node which is now available via a relationship."
985 "name": "pre_configure_target",
986 "description": "Operation to pre-configure the target endpoint."
989 "name": "post_configure_source",
990 "description": "Operation to post-configure the source endpoint."
993 "name": "target_changed",
994 "description": "Operation to notify source some property or attribute of the target changed"
997 "name": "pre_configure_source",
998 "description": "Operation to pre-configure the source endpoint."
1001 "name": "post_configure_target",
1002 "description": "Operation to post-configure the target endpoint."
1005 "name": "remove_target",
1006 "description": "Operation to remove a target node."
1009 "name": "add_target",
1010 "description": "Operation to notify the source node of a target node being added via a relationship."
1017 "name": "virtual_link",
1018 "source_requirement_index": 1,
1019 "target_node_id": "sriov_link_2610d7gund4e645wo39dvp238",
1020 "target_capability_name": "feature",
1021 "source_interfaces": [
1023 "name": "Configure",
1024 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
1025 "type_name": "tosca.interfaces.relationship.Configure",
1028 "name": "add_source",
1029 "description": "Operation to notify the target node of a source node which is now available via a relationship."
1032 "name": "pre_configure_target",
1033 "description": "Operation to pre-configure the target endpoint."
1036 "name": "post_configure_source",
1037 "description": "Operation to post-configure the source endpoint."
1040 "name": "target_changed",
1041 "description": "Operation to notify source some property or attribute of the target changed"
1044 "name": "pre_configure_source",
1045 "description": "Operation to pre-configure the source endpoint."
1048 "name": "post_configure_target",
1049 "description": "Operation to post-configure the target endpoint."
1052 "name": "remove_target",
1053 "description": "Operation to remove a target node."
1056 "name": "add_target",
1057 "description": "Operation to notify the source node of a target node being added via a relationship."
1067 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1070 "mapped_name": "sriov_plane",
1071 "node_id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
1072 "name": "virtual_link"
1079 "vnfSoftwareVersion": "1.0.0",
1080 "vnfProductName": "openNAT",
1081 "localizationLanguage": [
1085 "vnfProvider": "intel",
1086 "vnfmInfo": "GVNFM",
1087 "defaultLocalizationLanguage": "english",
1088 "vnfdId": "openNAT-1.0",
1089 "vnfProductInfoDescription": "openNAT",
1090 "vnfdVersion": "1.0.0",
1091 "vnfProductInfoName": "openNAT"
1095 "name": "vNAT_Storage",
1096 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
1097 "default_instances": 1,
1100 "size_of_storage": {
1101 "type_name": "scalar-unit.size",
1103 "value": 10000000000,
1106 "unit_size": 1000000000
1109 "type_of_storage": {
1110 "type_name": "string",
1114 "type_name": "boolean",
1118 "interface_templates": [
1121 "capability_templates": [
1124 "type_name": "tosca.capabilities.Node"
1127 "name": "virtual_storage",
1128 "type_name": "tosca.capabilities.nfv.VirtualStorage"
1134 "type_name": "tosca.nodes.nfv.VDU.Compute",
1135 "default_instances": 1,
1138 "configurable_properties": {
1142 "additional_vnfc_configurable_properties": {
1151 "type_name": "list",
1157 "type_name": "string",
1160 "nfvi_constraints": {
1161 "type_name": "list",
1167 "type_name": "string",
1168 "value": "the virtual machine of vNat"
1171 "interface_templates": [
1174 "artifact_templates": [
1177 "capability_templates": [
1180 "type_name": "tosca.capabilities.Node"
1184 "type_name": "tosca.capabilities.OperatingSystem",
1187 "type_name": "string",
1188 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
1191 "type_name": "version",
1192 "description": "The Operating System version."
1195 "type_name": "string",
1196 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
1199 "type_name": "string",
1200 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
1206 "type_name": "tosca.capabilities.Container",
1207 "valid_source_node_type_names": [
1208 "tosca.nodes.SoftwareComponent"
1212 "type_name": "scalar-unit.frequency",
1213 "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\"."
1216 "type_name": "scalar-unit.size",
1217 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
1220 "type_name": "integer",
1221 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
1224 "type_name": "scalar-unit.size",
1225 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
1231 "type_name": "tosca.capabilities.network.Bindable"
1235 "type_name": "tosca.capabilities.Scalable",
1238 "type_name": "integer",
1240 "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."
1242 "default_instances": {
1243 "type_name": "integer",
1244 "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."
1247 "type_name": "integer",
1249 "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."
1254 "name": "virtual_compute",
1255 "type_name": "tosca.capabilities.nfv.VirtualCompute",
1257 "requested_additional_capabilities": {
1261 "requested_additional_capability_name": "ovs_dpdk",
1262 "min_requested_additional_capability_version": "1.0",
1263 "support_mandatory": True,
1264 "target_performance_parameters": {
1265 "sw:ovs_dpdk": "true"
1267 "preferred_requested_additional_capability_version": "1.0"
1269 "hyper_threading": {
1270 "requested_additional_capability_name": "hyper_threading",
1271 "min_requested_additional_capability_version": "1.0",
1272 "support_mandatory": True,
1273 "target_performance_parameters": {
1274 "hw:cpu_cores": "2",
1275 "hw:cpu_threads": "2",
1276 "hw:cpu_threads_policy": "isolate",
1277 "hw:cpu_sockets": "2"
1279 "preferred_requested_additional_capability_version": "1.0"
1282 "requested_additional_capability_name": "numa",
1283 "min_requested_additional_capability_version": "1.0",
1284 "support_mandatory": True,
1285 "target_performance_parameters": {
1286 "hw:numa_cpus.0": "0,1",
1287 "hw:numa_cpus.1": "2,3,4,5",
1288 "hw:numa_nodes": "2",
1289 "hw:numa_mem.1": "3072",
1290 "hw:numa_mem.0": "1024"
1292 "preferred_requested_additional_capability_version": "1.0"
1297 "type_name": "tosca.datatypes.nfv.VirtualCpu",
1299 "num_virtual_cpu": 2,
1300 "virtual_cpu_clock": {
1301 "value": 2400000000,
1304 "unit_size": 1000000000
1306 "cpu_architecture": "X86",
1307 "virtual_cpu_oversubscription_policy": "test",
1308 "virtual_cpu_pinning": {
1309 "cpu_pinning_map": {
1310 "cpu_pinning_0": "1"
1312 "cpu_pinning_policy": "static"
1317 "type_name": "tosca.datatypes.nfv.VirtualMemory",
1319 "virtual_mem_oversubscription_policy": "mem_policy_test",
1320 "numa_enabled": True,
1321 "virtual_mem_size": {
1322 "value": 10000000000,
1325 "unit_size": 1000000000
1332 "name": "virtual_binding",
1333 "type_name": "tosca.capabilities.nfv.VirtualBindable"
1336 "requirement_templates": [
1338 "name": "virtual_storage",
1339 "target_node_template_name": "vNAT_Storage",
1340 "relationship_template": {
1341 "type_name": "tosca.relationships.nfv.VDU.AttachedTo",
1344 "type_name": "string",
1345 "value": "/mnt/volume_0",
1346 "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\"."
1349 "source_interface_templates": [
1357 "name": "SRIOV_Port",
1358 "type_name": "tosca.nodes.nfv.VduCpd",
1359 "default_instances": 1,
1363 "type_name": "list",
1366 "address_type": "ip_address",
1367 "l3_address_data": {
1368 "ip_address_type": "ipv4",
1369 "floating_ip_activated": False,
1370 "number_of_ip_address": 1,
1371 "ip_address_assignment": True
1377 "type_name": "string",
1378 "value": "sriov port"
1381 "type_name": "string",
1384 "virtual_network_interface_requirements": {
1385 "type_name": "list",
1391 "support_mandatory": False,
1393 "description": "sriov"
1399 "support_mandatory": False,
1401 "description": "normal"
1406 "type_name": "string",
1409 "bitrate_requirement": {
1410 "type_name": "integer",
1414 "interface_templates": [
1417 "capability_templates": [
1420 "type_name": "tosca.capabilities.Node"
1423 "requirement_templates": [
1425 "name": "virtual_binding",
1426 "target_node_template_name": "vdu_vNat",
1427 "relationship_template": {
1428 "type_name": "tosca.relationships.nfv.VirtualBindsTo",
1429 "source_interface_templates": [
1435 "name": "virtual_link",
1436 "target_node_type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
1437 "relationship_template": {
1438 "type_name": "tosca.relationships.nfv.VirtualLinksTo",
1439 "source_interface_templates": [
1447 "substitution_template": {
1448 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1449 "requirement_templates": [
1451 "mapped_name": "sriov_plane",
1452 "node_template_name": "SRIOV_Port",
1453 "name": "virtual_link"
1459 print convert_vnfd_model(src_json)