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.
17 def safe_get(key_val, key):
18 return key_val[key] if key in key_val else ""
21 def find_node_name(node_id, node_list):
22 for node in node_list:
23 if node['id'] == node_id:
24 return node['template_name']
25 raise Exception('can not find node(%s).' % node_id)
28 def find_node_type(node_id, node_list):
29 for node in node_list:
30 if node['id'] == node_id:
31 return node['type_name']
32 raise Exception('can not find node(%s).' % node_id)
35 def find_related_node(node_id, src_json_model, requirement_name):
37 for model_tpl in safe_get(src_json_model, "node_templates"):
38 for rt in safe_get(model_tpl, 'requirement_templates'):
39 if safe_get(rt, 'name') == requirement_name and \
40 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 {}
55 def convert_factor_unit(value):
56 if isinstance(value, (str, unicode)):
58 return "%s %s" % (value["factor"], value["unit"])
60 def convert_inputs(src_json):
62 if 'inputs' in src_json:
63 src_inputs = src_json['inputs']
64 for param_name, param_info in src_inputs.items():
66 if 'type_name' in param_info:
67 input_param['type'] = param_info['type_name']
68 if 'description' in param_info:
69 input_param['description'] = param_info['description']
70 if 'value' in param_info:
71 input_param['value'] = param_info['value']
72 inputs[param_name] = input_param
76 def convert_vnf_node(src_node, src_json_model):
77 vnf_node = {'type': src_node['type_name'], 'vnf_id': src_node['template_name'],
78 'description': '', 'properties': {}, 'dependencies': [], 'networks': []}
79 convert_props(src_node, vnf_node)
80 for model_tpl in safe_get(src_json_model, "node_templates"):
81 if model_tpl['name'] != vnf_node['vnf_id']:
83 vnf_node['dependencies'] = [{
84 'key_name': requirement['name'],
85 'vl_id': requirement['target_node_template_name']} for \
86 requirement in safe_get(model_tpl, 'requirement_templates') if \
87 safe_get(requirement, 'target_capability_name') == 'virtual_linkable']
88 vnf_node['networks'] = [requirement['target_node_template_name'] for \
89 requirement in safe_get(model_tpl, 'requirement_templates') if \
90 safe_get(requirement, 'name') == 'dependency']
94 def convert_pnf_node(src_node, src_json_model):
95 pnf_node = {'pnf_id': src_node['template_name'], 'description': '', 'properties': {}}
96 convert_props(src_node, pnf_node)
97 pnf_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
101 def convert_vl_node(src_node, src_node_list):
102 vl_node = {'vl_id': src_node['template_name'], 'description': '', 'properties': {}}
103 convert_props(src_node, vl_node)
104 vl_node['route_id'] = ''
105 for relation in safe_get(src_node, 'relationships'):
106 if safe_get(relation, 'type_name').endswith('.VirtualLinksTo'):
107 vl_node['route_id'] = find_node_name(relation['target_node_id'], src_node_list)
109 vl_node['route_external'] = (src_node['type_name'].find('.RouteExternalVL') > 0)
113 def convert_cp_node(src_node, src_node_list, model_type='NSD'):
114 cp_node = {'cp_id': src_node['template_name'], 'description': '', 'properties': {}}
115 convert_props(src_node, cp_node)
116 src_relationships = src_node['relationships']
117 for relation in src_relationships:
118 if safe_get(relation, 'name') in ('virtualLink', 'virtual_link'):
119 cp_node['vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
120 elif safe_get(relation, 'name') in ('virtualbinding', 'virtual_binding'):
121 node_key = 'pnf_id' if model_type == 'NSD' else 'vdu_id'
122 cp_node[node_key] = find_node_name(relation['target_node_id'], src_node_list)
126 def convert_router_node(src_node, src_node_list):
127 router_node = {'router_id': src_node['template_name'], 'description': '', 'properties': {}}
128 convert_props(src_node, router_node)
129 for relation in src_node['relationships']:
130 if safe_get(relation, 'name') != 'external_virtual_link':
132 router_node['external_vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
133 router_node['external_ip_addresses'] = []
134 if 'properties' not in relation:
136 for prop_name, prop_info in relation['properties'].items():
137 if prop_name == 'router_ip_address':
138 router_node['external_ip_addresses'].append(prop_info['value'])
143 def convert_fp_node(src_node, src_node_list, src_json_model):
144 fp_node = {'fp_id': src_node['template_name'], 'description': '',
145 'properties': {}, 'forwarder_list': []}
146 convert_props(src_node, fp_node)
147 for relation in safe_get(src_node, 'relationships'):
148 if safe_get(relation, 'name') != 'forwarder':
150 forwarder_point = {'type': 'vnf'}
151 target_node_type = find_node_type(relation['target_node_id'], src_node_list).upper()
152 if target_node_type.find('.CP.') >= 0 or target_node_type.endswith('.CP'):
153 forwarder_point['type'] = 'cp'
154 forwarder_point['node_name'] = find_node_name(relation['target_node_id'], src_node_list)
155 forwarder_point['capability'] = ''
156 if forwarder_point['type'] == 'vnf':
157 for node_tpl in src_json_model["node_templates"]:
158 if fp_node['fp_id'] != node_tpl["name"]:
160 for r_tpl in safe_get(node_tpl, "requirement_templates"):
161 if safe_get(r_tpl, "target_node_template_name") != forwarder_point['node_name']:
163 forwarder_point['capability'] = safe_get(r_tpl, "target_capability_name")
166 fp_node['forwarder_list'].append(forwarder_point)
170 def convert_vnffg_group(src_group, src_group_list, src_node_list):
171 vnffg = {'vnffg_id': src_group['template_name'], 'description': '',
172 'properties': {}, 'members': []}
173 convert_props(src_group, vnffg)
174 for member_node_id in src_group['member_node_ids']:
175 vnffg['members'].append(find_node_name(member_node_id, src_node_list))
179 def convert_imagefile_node(src_node, src_node_list):
180 image_node = {'image_file_id': src_node['template_name'], 'description': '',
182 convert_props(src_node, image_node)
186 def convert_localstorage_node(src_node, src_node_list):
187 localstorage_node = {'local_storage_id': src_node['template_name'], 'description': '',
189 convert_props(src_node, localstorage_node)
190 return localstorage_node
192 def convert_volumestorage_node(src_node, src_node_list):
193 volumestorage_node = {
194 'volume_storage_id': src_node['id'],
197 convert_props(src_node, volumestorage_node)
198 volumestorage_node["properties"]["size"] = convert_factor_unit(
199 volumestorage_node["properties"]["size_of_storage"])
200 return volumestorage_node
202 def convert_vdu_node(src_node, src_node_list, src_json_model):
203 vdu_node = {'vdu_id': src_node['template_name'], 'description': '', 'properties': {},
204 'image_file': '', 'local_storages': [], 'dependencies': [], 'nfv_compute': {},
205 'vls': [], 'artifacts': [], 'volume_storages': []}
206 convert_props(src_node, vdu_node)
208 for relation in src_node.get('relationships', ''):
209 r_id, r_name = safe_get(relation, 'target_node_id'), safe_get(relation, 'name')
210 if r_name == 'guest_os':
211 vdu_node['image_file'] = find_node_name(r_id, src_node_list)
212 elif r_name == 'local_storage':
213 vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
214 elif r_name == 'virtual_storage':
215 vdu_node['volume_storages'].append(r_id)
216 elif r_name.endswith('.AttachesTo'):
217 nt = find_node_type(r_id, src_node_list)
218 if nt.endswith('.BlockStorage.Local') or nt.endswith('.LocalStorage'):
219 vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
221 for capability in src_node['capabilities']:
222 if not capability['type_name'].endswith('.VirtualCompute'):
224 vdu_node['nfv_compute']['flavor_extra_specs'] = {}
225 for prop_name, prop_info in capability['properties'].items():
226 if prop_name == "virtual_cpu":
227 vdu_node['nfv_compute']['num_cpus'] = prop_info["value"]["num_virtual_cpu"]
228 vdu_node['nfv_compute']['cpu_frequency'] = convert_factor_unit(
229 prop_info["value"]["virtual_cpu_clock"])
230 elif prop_name == "virtual_memory":
231 vdu_node['nfv_compute']['mem_size'] = convert_factor_unit(
232 prop_info["value"]["virtual_mem_size"])
233 elif prop_name == "requested_additional_capabilities":
234 for key, val in prop_info["value"].items():
235 vdu_node['nfv_compute']['flavor_extra_specs'].update(
236 val["target_performance_parameters"])
238 vdu_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
240 for cp_node in vdu_node['cps']:
241 for src_cp_node in src_node_list:
242 if src_cp_node['template_name'] != cp_node:
244 for relation in safe_get(src_cp_node, 'relationships'):
245 if relation['name'] != 'virtualLink':
247 vl_node_name = find_node_name(relation['target_node_id'], src_node_list)
248 if vl_node_name not in vdu_node['vls']:
249 vdu_node['vls'].append(vl_node_name)
251 for item in safe_get(src_node, 'artifacts'):
252 artifact = {'artifact_name': item['name'], 'type': item['type_name'],
253 'file': item['source_path'], 'properties': {}}
254 convert_props(item, artifact)
255 for key in artifact['properties']:
256 if 'factor' in artifact['properties'][key] and 'unit' in artifact['properties'][key]:
257 artifact['properties'][key] = convert_factor_unit(artifact['properties'][key])
258 vdu_node['artifacts'].append(artifact)
259 if artifact["type"].endswith(".SwImage"):
260 vdu_node['image_file'] = artifact["artifact_name"]
264 def convert_exposed_node(src_json, src_nodes, exposed):
265 for item in safe_get(safe_get(src_json, 'substitution'), 'requirements'):
266 exposed['external_cps'].append({'key_name': item['mapped_name'],
267 "cp_id": find_node_name(item['node_id'], src_nodes)})
268 for item in safe_get(safe_get(src_json, 'substitution'), 'capabilities'):
269 exposed['forward_cps'].append({'key_name': item['mapped_name'],
270 "cp_id": find_node_name(item['node_id'], src_nodes)})
273 def convert_vnffgs(src_json_inst, src_nodes):
275 src_groups = safe_get(src_json_inst, 'groups')
276 for group in src_groups:
277 type_name = group['type_name'].upper()
278 if type_name.find('.VNFFG.') >= 0 or type_name.endswith('.VNFFG'):
279 vnffgs.append(convert_vnffg_group(group, src_groups, src_nodes))
282 def merge_imagefile_node(img_nodes, vdu_nodes):
283 for vdu_node in vdu_nodes:
284 for artifact in vdu_node.get("artifacts", []):
285 if not artifact["type"].endswith(".SwImage"):
287 imgids = [img["image_file_id"] for img in img_nodes]
288 if artifact["artifact_name"] in imgids:
291 "image_file_id": artifact["artifact_name"],
293 "properties": artifact["properties"]
296 def convert_common(src_json, target_json):
297 if isinstance(src_json, (unicode, str)):
298 src_json_dict = json.loads(src_json)
300 src_json_dict = src_json
301 src_json_inst = src_json_dict["instance"]
302 src_json_model = src_json_dict["model"] if "model" in src_json_dict else {}
304 target_json['metadata'] = convert_metadata(src_json_inst)
305 target_json['inputs'] = convert_inputs(src_json_inst)
306 target_json['vls'] = []
307 target_json['cps'] = []
308 target_json['routers'] = []
310 return src_json_inst, src_json_model
313 def convert_nsd_model(src_json):
314 target_json = {'vnfs': [], 'pnfs': [], 'fps': []}
315 src_json_inst, src_json_model = convert_common(src_json, target_json)
317 src_nodes = src_json_inst['nodes']
318 for node in src_nodes:
319 type_name = node['type_name']
320 if type_name.find('.VNF.') > 0 or type_name.endswith('.VNF'):
321 target_json['vnfs'].append(convert_vnf_node(node, src_json_model))
322 elif type_name.find('.PNF.') > 0 or type_name.endswith('.PNF'):
323 target_json['pnfs'].append(convert_pnf_node(node, src_json_model))
324 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
325 or node['type_name'].find('.RouteExternalVL') > 0:
326 target_json['vls'].append(convert_vl_node(node, src_nodes))
327 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP'):
328 target_json['cps'].append(convert_cp_node(node, src_nodes))
329 elif type_name.find('.FP.') > 0 or type_name.endswith('.FP'):
330 target_json['fps'].append(convert_fp_node(node, src_nodes, src_json_model))
331 elif type_name.endswith('.Router'):
332 target_json['routers'].append(convert_router_node(node, src_nodes))
334 target_json['vnffgs'] = convert_vnffgs(src_json_inst, src_nodes)
336 target_json['ns_exposed'] = {'external_cps': [], 'forward_cps': []}
337 convert_exposed_node(src_json_inst, src_nodes, target_json['ns_exposed'])
338 return json.dumps(target_json)
341 def convert_vnfd_model(src_json):
342 target_json = {'image_files': [], 'local_storages': [], 'vdus': [], 'volume_storages': []}
343 src_json_inst, src_json_model = convert_common(src_json, target_json)
345 src_nodes = src_json_inst['nodes']
346 for node in src_nodes:
347 type_name = node['type_name']
348 if type_name.endswith('.ImageFile'):
349 target_json['image_files'].append(convert_imagefile_node(node, src_nodes))
350 elif type_name.endswith('.BlockStorage.Local') or type_name.endswith('.LocalStorage'):
351 target_json['local_storages'].append(convert_localstorage_node(node, src_nodes))
352 elif type_name.endswith('VDU.VirtualStorage'):
353 target_json['volume_storages'].append(convert_volumestorage_node(node, src_nodes))
354 elif type_name.endswith('VDU.Compute'):
355 target_json['vdus'].append(convert_vdu_node(node, src_nodes, src_json_model))
356 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
357 or type_name.endswith('.VnfVirtualLinkDesc') \
358 or type_name.endswith('.RouteExternalVL'):
359 target_json['vls'].append(convert_vl_node(node, src_nodes))
360 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP') or type_name.endswith(".VduCpd"):
361 target_json['cps'].append(convert_cp_node(node, src_nodes, 'VNFD'))
362 elif type_name.endswith('.Router'):
363 target_json['routers'].append(convert_router_node(node, src_nodes))
365 target_json['vnf_exposed'] = {'external_cps': [], 'forward_cps': []}
366 convert_exposed_node(src_json_inst, src_nodes, target_json['vnf_exposed'])
367 merge_imagefile_node(target_json['image_files'], target_json['vdus'])
368 return json.dumps(target_json)
370 if __name__ == '__main__':
371 src_json = json.dumps({
374 "vnfSoftwareVersion": "1.0.0",
375 "vnfProductName": "zte",
376 "localizationLanguage": [
380 "vnfProvider": "zte",
382 "defaultLocalizationLanguage": "english",
383 "vnfdId": "zte-hss-1.0",
384 "vnfProductInfoDescription": "hss",
385 "vnfdVersion": "1.0.0",
386 "vnfProductInfoName": "hss"
390 "id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
391 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
392 "template_name": "vNAT_Storage",
395 "type_name": "scalar-unit.size",
397 "value": 10000000000,
400 "unit_size": 1000000000
404 "type_name": "string",
408 "type_name": "boolean",
415 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
416 "type_name": "tosca.interfaces.node.lifecycle.Standard",
420 "description": "Standard lifecycle create operation."
424 "description": "Standard lifecycle stop operation."
428 "description": "Standard lifecycle start operation."
432 "description": "Standard lifecycle delete operation."
436 "description": "Standard lifecycle configure operation."
444 "type_name": "tosca.capabilities.Node"
447 "name": "virtual_storage",
448 "type_name": "tosca.capabilities.nfv.VirtualStorage"
453 "id": "sriov_link_2610d7gund4e645wo39dvp238",
454 "type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
455 "template_name": "sriov_link",
463 "connectivity_type": {
464 "type_name": "tosca.datatypes.nfv.ConnectivityType",
466 "layer_protocol": "ipv4",
467 "flow_pattern": "flat"
471 "type_name": "string",
472 "value": "sriov_link"
484 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
485 "type_name": "tosca.interfaces.node.lifecycle.Standard",
489 "description": "Standard lifecycle create operation."
493 "description": "Standard lifecycle stop operation."
497 "description": "Standard lifecycle start operation."
501 "description": "Standard lifecycle delete operation."
505 "description": "Standard lifecycle configure operation."
513 "type_name": "tosca.capabilities.Node"
516 "name": "virtual_linkable",
517 "type_name": "tosca.capabilities.nfv.VirtualLinkable"
522 "id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
523 "type_name": "tosca.nodes.nfv.VDU.Compute",
524 "template_name": "vdu_vNat",
526 "configurable_properties": {
530 "additional_vnfc_configurable_properties": {
545 "type_name": "string",
548 "nfvi_constraints": {
555 "type_name": "string",
556 "value": "the virtual machine of vNat"
562 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
563 "type_name": "tosca.interfaces.node.lifecycle.Standard",
567 "description": "Standard lifecycle create operation."
571 "description": "Standard lifecycle stop operation."
575 "description": "Standard lifecycle start operation."
579 "description": "Standard lifecycle delete operation."
583 "description": "Standard lifecycle configure operation."
590 "name": "vNatVNFImage",
591 "type_name": "tosca.artifacts.nfv.SwImage",
592 "source_path": "/swimages/vRouterVNF_ControlPlane.qcow2",
594 "operating_system": {
595 "type_name": "string",
599 "type_name": "string",
600 "value": "/swimages/vRouterVNF_ControlPlane.qcow2"
603 "type_name": "string",
604 "value": "vNatVNFImage"
607 "type_name": "string",
611 "type_name": "scalar-unit.size",
616 "unit_size": 1000000000
620 "type_name": "string",
624 "type_name": "string",
627 "container_format": {
628 "type_name": "string",
632 "type_name": "scalar-unit.size",
634 "value": 10000000000,
637 "unit_size": 1000000000
640 "supported_virtualisation_environments": {
647 "type_name": "scalar-unit.size",
649 "value": 10000000000,
652 "unit_size": 1000000000
661 "type_name": "tosca.capabilities.Node"
665 "type_name": "tosca.capabilities.OperatingSystem",
668 "type_name": "string",
669 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
672 "type_name": "version",
673 "description": "The Operating System version."
676 "type_name": "string",
677 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
680 "type_name": "string",
681 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
687 "type_name": "tosca.capabilities.Container",
690 "type_name": "scalar-unit.frequency",
691 "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\"."
694 "type_name": "scalar-unit.size",
695 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
698 "type_name": "integer",
699 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
702 "type_name": "scalar-unit.size",
703 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
709 "type_name": "tosca.capabilities.network.Bindable"
713 "type_name": "tosca.capabilities.Scalable",
716 "type_name": "integer",
718 "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."
720 "default_instances": {
721 "type_name": "integer",
722 "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."
725 "type_name": "integer",
727 "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."
732 "name": "virtual_compute",
733 "type_name": "tosca.capabilities.nfv.VirtualCompute",
735 "requested_additional_capabilities": {
739 "requested_additional_capability_name": "ovs_dpdk",
740 "min_requested_additional_capability_version": "1.0",
741 "support_mandatory": True,
742 "target_performance_parameters": {
743 "sw:ovs_dpdk": "true"
745 "preferred_requested_additional_capability_version": "1.0"
748 "requested_additional_capability_name": "hyper_threading",
749 "min_requested_additional_capability_version": "1.0",
750 "support_mandatory": True,
751 "target_performance_parameters": {
753 "hw:cpu_threads": "2",
754 "hw:cpu_threads_policy": "isolate",
755 "hw:cpu_sockets": "2"
757 "preferred_requested_additional_capability_version": "1.0"
760 "requested_additional_capability_name": "numa",
761 "min_requested_additional_capability_version": "1.0",
762 "support_mandatory": True,
763 "target_performance_parameters": {
764 "hw:numa_cpus.0": "0,1",
765 "hw:numa_cpus.1": "2,3,4,5",
766 "hw:numa_nodes": "2",
767 "hw:numa_mem.1": "3072",
768 "hw:numa_mem.0": "1024"
770 "preferred_requested_additional_capability_version": "1.0"
775 "type_name": "tosca.datatypes.nfv.VirtualCpu",
777 "num_virtual_cpu": 2,
778 "virtual_cpu_clock": {
782 "unit_size": 1000000000
784 "cpu_architecture": "X86",
785 "virtual_cpu_oversubscription_policy": "test",
786 "virtual_cpu_pinning": {
790 "cpu_pinning_policy": "static"
795 "type_name": "tosca.datatypes.nfv.VirtualMemory",
797 "virtual_mem_oversubscription_policy": "mem_policy_test",
798 "numa_enabled": True,
799 "virtual_mem_size": {
800 "value": 10000000000,
803 "unit_size": 1000000000
810 "name": "virtual_binding",
811 "type_name": "tosca.capabilities.nfv.VirtualBindable"
816 "name": "virtual_storage",
817 "source_requirement_index": 0,
818 "target_node_id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
821 "type_name": "string",
822 "value": "/mnt/volume_0",
823 "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\"."
826 "source_interfaces": [
829 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
830 "type_name": "tosca.interfaces.relationship.Configure",
833 "name": "add_source",
834 "description": "Operation to notify the target node of a source node which is now available via a relationship."
837 "name": "pre_configure_target",
838 "description": "Operation to pre-configure the target endpoint."
841 "name": "post_configure_source",
842 "description": "Operation to post-configure the source endpoint."
845 "name": "target_changed",
846 "description": "Operation to notify source some property or attribute of the target changed"
849 "name": "pre_configure_source",
850 "description": "Operation to pre-configure the source endpoint."
853 "name": "post_configure_target",
854 "description": "Operation to post-configure the target endpoint."
857 "name": "remove_target",
858 "description": "Operation to remove a target node."
861 "name": "add_target",
862 "description": "Operation to notify the source node of a target node being added via a relationship."
871 "id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
872 "type_name": "tosca.nodes.nfv.VduCpd",
873 "template_name": "SRIOV_Port",
879 "address_type": "ip_address",
881 "ip_address_type": "ipv4",
882 "floating_ip_activated": False,
883 "number_of_ip_address": 1,
884 "ip_address_assignment": True
890 "type_name": "string",
891 "value": "sriov port"
894 "type_name": "string",
897 "virtual_network_interface_requirements": {
904 "support_mandatory": False,
906 "description": "sriov"
912 "support_mandatory": False,
914 "description": "normal"
919 "type_name": "string",
922 "bitrate_requirement": {
923 "type_name": "integer",
930 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
931 "type_name": "tosca.interfaces.node.lifecycle.Standard",
935 "description": "Standard lifecycle create operation."
939 "description": "Standard lifecycle stop operation."
943 "description": "Standard lifecycle start operation."
947 "description": "Standard lifecycle delete operation."
951 "description": "Standard lifecycle configure operation."
959 "type_name": "tosca.capabilities.Node"
964 "name": "virtual_binding",
965 "source_requirement_index": 0,
966 "target_node_id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
967 "source_interfaces": [
970 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
971 "type_name": "tosca.interfaces.relationship.Configure",
974 "name": "add_source",
975 "description": "Operation to notify the target node of a source node which is now available via a relationship."
978 "name": "pre_configure_target",
979 "description": "Operation to pre-configure the target endpoint."
982 "name": "post_configure_source",
983 "description": "Operation to post-configure the source endpoint."
986 "name": "target_changed",
987 "description": "Operation to notify source some property or attribute of the target changed"
990 "name": "pre_configure_source",
991 "description": "Operation to pre-configure the source endpoint."
994 "name": "post_configure_target",
995 "description": "Operation to post-configure the target endpoint."
998 "name": "remove_target",
999 "description": "Operation to remove a target node."
1002 "name": "add_target",
1003 "description": "Operation to notify the source node of a target node being added via a relationship."
1010 "name": "virtual_link",
1011 "source_requirement_index": 1,
1012 "target_node_id": "sriov_link_2610d7gund4e645wo39dvp238",
1013 "target_capability_name": "feature",
1014 "source_interfaces": [
1016 "name": "Configure",
1017 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
1018 "type_name": "tosca.interfaces.relationship.Configure",
1021 "name": "add_source",
1022 "description": "Operation to notify the target node of a source node which is now available via a relationship."
1025 "name": "pre_configure_target",
1026 "description": "Operation to pre-configure the target endpoint."
1029 "name": "post_configure_source",
1030 "description": "Operation to post-configure the source endpoint."
1033 "name": "target_changed",
1034 "description": "Operation to notify source some property or attribute of the target changed"
1037 "name": "pre_configure_source",
1038 "description": "Operation to pre-configure the source endpoint."
1041 "name": "post_configure_target",
1042 "description": "Operation to post-configure the target endpoint."
1045 "name": "remove_target",
1046 "description": "Operation to remove a target node."
1049 "name": "add_target",
1050 "description": "Operation to notify the source node of a target node being added via a relationship."
1060 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1063 "mapped_name": "sriov_plane",
1064 "node_id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
1065 "name": "virtual_link"
1072 "vnfSoftwareVersion": "1.0.0",
1073 "vnfProductName": "openNAT",
1074 "localizationLanguage": [
1078 "vnfProvider": "intel",
1079 "vnfmInfo": "GVNFM",
1080 "defaultLocalizationLanguage": "english",
1081 "vnfdId": "openNAT-1.0",
1082 "vnfProductInfoDescription": "openNAT",
1083 "vnfdVersion": "1.0.0",
1084 "vnfProductInfoName": "openNAT"
1088 "name": "vNAT_Storage",
1089 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
1090 "default_instances": 1,
1093 "size_of_storage": {
1094 "type_name": "scalar-unit.size",
1096 "value": 10000000000,
1099 "unit_size": 1000000000
1102 "type_of_storage": {
1103 "type_name": "string",
1107 "type_name": "boolean",
1111 "interface_templates": [
1114 "capability_templates": [
1117 "type_name": "tosca.capabilities.Node"
1120 "name": "virtual_storage",
1121 "type_name": "tosca.capabilities.nfv.VirtualStorage"
1127 "type_name": "tosca.nodes.nfv.VDU.Compute",
1128 "default_instances": 1,
1131 "configurable_properties": {
1135 "additional_vnfc_configurable_properties": {
1144 "type_name": "list",
1150 "type_name": "string",
1153 "nfvi_constraints": {
1154 "type_name": "list",
1160 "type_name": "string",
1161 "value": "the virtual machine of vNat"
1164 "interface_templates": [
1167 "artifact_templates": [
1170 "capability_templates": [
1173 "type_name": "tosca.capabilities.Node"
1177 "type_name": "tosca.capabilities.OperatingSystem",
1180 "type_name": "string",
1181 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
1184 "type_name": "version",
1185 "description": "The Operating System version."
1188 "type_name": "string",
1189 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
1192 "type_name": "string",
1193 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
1199 "type_name": "tosca.capabilities.Container",
1200 "valid_source_node_type_names": [
1201 "tosca.nodes.SoftwareComponent"
1205 "type_name": "scalar-unit.frequency",
1206 "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\"."
1209 "type_name": "scalar-unit.size",
1210 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
1213 "type_name": "integer",
1214 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
1217 "type_name": "scalar-unit.size",
1218 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
1224 "type_name": "tosca.capabilities.network.Bindable"
1228 "type_name": "tosca.capabilities.Scalable",
1231 "type_name": "integer",
1233 "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."
1235 "default_instances": {
1236 "type_name": "integer",
1237 "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."
1240 "type_name": "integer",
1242 "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."
1247 "name": "virtual_compute",
1248 "type_name": "tosca.capabilities.nfv.VirtualCompute",
1250 "requested_additional_capabilities": {
1254 "requested_additional_capability_name": "ovs_dpdk",
1255 "min_requested_additional_capability_version": "1.0",
1256 "support_mandatory": True,
1257 "target_performance_parameters": {
1258 "sw:ovs_dpdk": "true"
1260 "preferred_requested_additional_capability_version": "1.0"
1262 "hyper_threading": {
1263 "requested_additional_capability_name": "hyper_threading",
1264 "min_requested_additional_capability_version": "1.0",
1265 "support_mandatory": True,
1266 "target_performance_parameters": {
1267 "hw:cpu_cores": "2",
1268 "hw:cpu_threads": "2",
1269 "hw:cpu_threads_policy": "isolate",
1270 "hw:cpu_sockets": "2"
1272 "preferred_requested_additional_capability_version": "1.0"
1275 "requested_additional_capability_name": "numa",
1276 "min_requested_additional_capability_version": "1.0",
1277 "support_mandatory": True,
1278 "target_performance_parameters": {
1279 "hw:numa_cpus.0": "0,1",
1280 "hw:numa_cpus.1": "2,3,4,5",
1281 "hw:numa_nodes": "2",
1282 "hw:numa_mem.1": "3072",
1283 "hw:numa_mem.0": "1024"
1285 "preferred_requested_additional_capability_version": "1.0"
1290 "type_name": "tosca.datatypes.nfv.VirtualCpu",
1292 "num_virtual_cpu": 2,
1293 "virtual_cpu_clock": {
1294 "value": 2400000000,
1297 "unit_size": 1000000000
1299 "cpu_architecture": "X86",
1300 "virtual_cpu_oversubscription_policy": "test",
1301 "virtual_cpu_pinning": {
1302 "cpu_pinning_map": {
1303 "cpu_pinning_0": "1"
1305 "cpu_pinning_policy": "static"
1310 "type_name": "tosca.datatypes.nfv.VirtualMemory",
1312 "virtual_mem_oversubscription_policy": "mem_policy_test",
1313 "numa_enabled": True,
1314 "virtual_mem_size": {
1315 "value": 10000000000,
1318 "unit_size": 1000000000
1325 "name": "virtual_binding",
1326 "type_name": "tosca.capabilities.nfv.VirtualBindable"
1329 "requirement_templates": [
1331 "name": "virtual_storage",
1332 "target_node_template_name": "vNAT_Storage",
1333 "relationship_template": {
1334 "type_name": "tosca.relationships.nfv.VDU.AttachedTo",
1337 "type_name": "string",
1338 "value": "/mnt/volume_0",
1339 "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\"."
1342 "source_interface_templates": [
1350 "name": "SRIOV_Port",
1351 "type_name": "tosca.nodes.nfv.VduCpd",
1352 "default_instances": 1,
1356 "type_name": "list",
1359 "address_type": "ip_address",
1360 "l3_address_data": {
1361 "ip_address_type": "ipv4",
1362 "floating_ip_activated": False,
1363 "number_of_ip_address": 1,
1364 "ip_address_assignment": True
1370 "type_name": "string",
1371 "value": "sriov port"
1374 "type_name": "string",
1377 "virtual_network_interface_requirements": {
1378 "type_name": "list",
1384 "support_mandatory": False,
1386 "description": "sriov"
1392 "support_mandatory": False,
1394 "description": "normal"
1399 "type_name": "string",
1402 "bitrate_requirement": {
1403 "type_name": "integer",
1407 "interface_templates": [
1410 "capability_templates": [
1413 "type_name": "tosca.capabilities.Node"
1416 "requirement_templates": [
1418 "name": "virtual_binding",
1419 "target_node_template_name": "vdu_vNat",
1420 "relationship_template": {
1421 "type_name": "tosca.relationships.nfv.VirtualBindsTo",
1422 "source_interface_templates": [
1428 "name": "virtual_link",
1429 "target_node_type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
1430 "relationship_template": {
1431 "type_name": "tosca.relationships.nfv.VirtualLinksTo",
1432 "source_interface_templates": [
1440 "substitution_template": {
1441 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1442 "requirement_templates": [
1444 "mapped_name": "sriov_plane",
1445 "node_template_name": "SRIOV_Port",
1446 "name": "virtual_link"
1452 print convert_vnfd_model(src_json)