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 if "virtual_cpu_clock" in prop_info["value"]:
229 vdu_node['nfv_compute']['cpu_frequency'] = convert_factor_unit(
230 prop_info["value"]["virtual_cpu_clock"])
231 elif prop_name == "virtual_memory":
232 vdu_node['nfv_compute']['mem_size'] = convert_factor_unit(
233 prop_info["value"]["virtual_mem_size"])
234 elif prop_name == "requested_additional_capabilities":
235 if prop_info and "value" in prop_info:
236 for key, val in prop_info["value"].items():
237 vdu_node['nfv_compute']['flavor_extra_specs'].update(
238 val["target_performance_parameters"])
240 vdu_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
242 for cp_node in vdu_node['cps']:
243 for src_cp_node in src_node_list:
244 if src_cp_node['template_name'] != cp_node:
246 for relation in safe_get(src_cp_node, 'relationships'):
247 if relation['name'] != 'virtualLink':
249 vl_node_name = find_node_name(relation['target_node_id'], src_node_list)
250 if vl_node_name not in vdu_node['vls']:
251 vdu_node['vls'].append(vl_node_name)
253 for item in safe_get(src_node, 'artifacts'):
254 artifact = {'artifact_name': item['name'], 'type': item['type_name'],
255 'file': item['source_path'], 'properties': {}}
256 convert_props(item, artifact)
257 for key in artifact['properties']:
258 if 'factor' in artifact['properties'][key] and 'unit' in artifact['properties'][key]:
259 artifact['properties'][key] = convert_factor_unit(artifact['properties'][key])
260 vdu_node['artifacts'].append(artifact)
261 if artifact["type"].endswith(".SwImage"):
262 vdu_node['image_file'] = artifact["artifact_name"]
266 def convert_exposed_node(src_json, src_nodes, exposed):
267 for item in safe_get(safe_get(src_json, 'substitution'), 'requirements'):
268 exposed['external_cps'].append({'key_name': item['mapped_name'],
269 "cp_id": find_node_name(item['node_id'], src_nodes)})
270 for item in safe_get(safe_get(src_json, 'substitution'), 'capabilities'):
271 exposed['forward_cps'].append({'key_name': item['mapped_name'],
272 "cp_id": find_node_name(item['node_id'], src_nodes)})
275 def convert_vnffgs(src_json_inst, src_nodes):
277 src_groups = safe_get(src_json_inst, 'groups')
278 for group in src_groups:
279 type_name = group['type_name'].upper()
280 if type_name.find('.VNFFG.') >= 0 or type_name.endswith('.VNFFG'):
281 vnffgs.append(convert_vnffg_group(group, src_groups, src_nodes))
284 def merge_imagefile_node(img_nodes, vdu_nodes):
285 for vdu_node in vdu_nodes:
286 for artifact in vdu_node.get("artifacts", []):
287 if not artifact["type"].endswith(".SwImage"):
289 imgids = [img["image_file_id"] for img in img_nodes]
290 if artifact["artifact_name"] in imgids:
293 "image_file_id": artifact["artifact_name"],
295 "properties": artifact["properties"]
298 def convert_common(src_json, target_json):
299 if isinstance(src_json, (unicode, str)):
300 src_json_dict = json.loads(src_json)
302 src_json_dict = src_json
303 src_json_inst = src_json_dict["instance"]
304 src_json_model = src_json_dict["model"] if "model" in src_json_dict else {}
306 target_json['metadata'] = convert_metadata(src_json_inst)
307 target_json['inputs'] = convert_inputs(src_json_inst)
308 target_json['vls'] = []
309 target_json['cps'] = []
310 target_json['routers'] = []
312 return src_json_inst, src_json_model
315 def convert_nsd_model(src_json):
316 target_json = {'vnfs': [], 'pnfs': [], 'fps': []}
317 src_json_inst, src_json_model = convert_common(src_json, target_json)
319 src_nodes = src_json_inst['nodes']
320 for node in src_nodes:
321 type_name = node['type_name']
322 if type_name.find('.VNF.') > 0 or type_name.endswith('.VNF'):
323 target_json['vnfs'].append(convert_vnf_node(node, src_json_model))
324 elif type_name.find('.PNF.') > 0 or type_name.endswith('.PNF'):
325 target_json['pnfs'].append(convert_pnf_node(node, src_json_model))
326 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
327 or node['type_name'].find('.RouteExternalVL') > 0:
328 target_json['vls'].append(convert_vl_node(node, src_nodes))
329 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP'):
330 target_json['cps'].append(convert_cp_node(node, src_nodes))
331 elif type_name.find('.FP.') > 0 or type_name.endswith('.FP'):
332 target_json['fps'].append(convert_fp_node(node, src_nodes, src_json_model))
333 elif type_name.endswith('.Router'):
334 target_json['routers'].append(convert_router_node(node, src_nodes))
336 target_json['vnffgs'] = convert_vnffgs(src_json_inst, src_nodes)
338 target_json['ns_exposed'] = {'external_cps': [], 'forward_cps': []}
339 convert_exposed_node(src_json_inst, src_nodes, target_json['ns_exposed'])
340 return json.dumps(target_json)
343 def convert_vnfd_model(src_json):
344 target_json = {'image_files': [], 'local_storages': [], 'vdus': [], 'volume_storages': []}
345 src_json_inst, src_json_model = convert_common(src_json, target_json)
347 src_nodes = src_json_inst['nodes']
348 for node in src_nodes:
349 type_name = node['type_name']
350 if type_name.endswith('.ImageFile'):
351 target_json['image_files'].append(convert_imagefile_node(node, src_nodes))
352 elif type_name.endswith('.BlockStorage.Local') or type_name.endswith('.LocalStorage'):
353 target_json['local_storages'].append(convert_localstorage_node(node, src_nodes))
354 elif type_name.endswith('VDU.VirtualStorage'):
355 target_json['volume_storages'].append(convert_volumestorage_node(node, src_nodes))
356 elif type_name.endswith('VDU.Compute'):
357 target_json['vdus'].append(convert_vdu_node(node, src_nodes, src_json_model))
358 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
359 or type_name.endswith('.VnfVirtualLinkDesc') \
360 or type_name.endswith('.RouteExternalVL'):
361 target_json['vls'].append(convert_vl_node(node, src_nodes))
362 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP') or type_name.endswith(".VduCpd"):
363 target_json['cps'].append(convert_cp_node(node, src_nodes, 'VNFD'))
364 elif type_name.endswith('.Router'):
365 target_json['routers'].append(convert_router_node(node, src_nodes))
367 target_json['vnf_exposed'] = {'external_cps': [], 'forward_cps': []}
368 convert_exposed_node(src_json_inst, src_nodes, target_json['vnf_exposed'])
369 merge_imagefile_node(target_json['image_files'], target_json['vdus'])
370 return json.dumps(target_json)
372 if __name__ == '__main__':
373 src_json = json.dumps({
376 "vnfSoftwareVersion": "1.0.0",
377 "vnfProductName": "zte",
378 "localizationLanguage": [
382 "vnfProvider": "zte",
384 "defaultLocalizationLanguage": "english",
385 "vnfdId": "zte-hss-1.0",
386 "vnfProductInfoDescription": "hss",
387 "vnfdVersion": "1.0.0",
388 "vnfProductInfoName": "hss"
392 "id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
393 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
394 "template_name": "vNAT_Storage",
397 "type_name": "scalar-unit.size",
399 "value": 10000000000,
402 "unit_size": 1000000000
406 "type_name": "string",
410 "type_name": "boolean",
417 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
418 "type_name": "tosca.interfaces.node.lifecycle.Standard",
422 "description": "Standard lifecycle create operation."
426 "description": "Standard lifecycle stop operation."
430 "description": "Standard lifecycle start operation."
434 "description": "Standard lifecycle delete operation."
438 "description": "Standard lifecycle configure operation."
446 "type_name": "tosca.capabilities.Node"
449 "name": "virtual_storage",
450 "type_name": "tosca.capabilities.nfv.VirtualStorage"
455 "id": "sriov_link_2610d7gund4e645wo39dvp238",
456 "type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
457 "template_name": "sriov_link",
465 "connectivity_type": {
466 "type_name": "tosca.datatypes.nfv.ConnectivityType",
468 "layer_protocol": "ipv4",
469 "flow_pattern": "flat"
473 "type_name": "string",
474 "value": "sriov_link"
486 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
487 "type_name": "tosca.interfaces.node.lifecycle.Standard",
491 "description": "Standard lifecycle create operation."
495 "description": "Standard lifecycle stop operation."
499 "description": "Standard lifecycle start operation."
503 "description": "Standard lifecycle delete operation."
507 "description": "Standard lifecycle configure operation."
515 "type_name": "tosca.capabilities.Node"
518 "name": "virtual_linkable",
519 "type_name": "tosca.capabilities.nfv.VirtualLinkable"
524 "id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
525 "type_name": "tosca.nodes.nfv.VDU.Compute",
526 "template_name": "vdu_vNat",
528 "configurable_properties": {
532 "additional_vnfc_configurable_properties": {
547 "type_name": "string",
550 "nfvi_constraints": {
557 "type_name": "string",
558 "value": "the virtual machine of vNat"
564 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
565 "type_name": "tosca.interfaces.node.lifecycle.Standard",
569 "description": "Standard lifecycle create operation."
573 "description": "Standard lifecycle stop operation."
577 "description": "Standard lifecycle start operation."
581 "description": "Standard lifecycle delete operation."
585 "description": "Standard lifecycle configure operation."
592 "name": "vNatVNFImage",
593 "type_name": "tosca.artifacts.nfv.SwImage",
594 "source_path": "/swimages/vRouterVNF_ControlPlane.qcow2",
596 "operating_system": {
597 "type_name": "string",
601 "type_name": "string",
602 "value": "/swimages/vRouterVNF_ControlPlane.qcow2"
605 "type_name": "string",
606 "value": "vNatVNFImage"
609 "type_name": "string",
613 "type_name": "scalar-unit.size",
618 "unit_size": 1000000000
622 "type_name": "string",
626 "type_name": "string",
629 "container_format": {
630 "type_name": "string",
634 "type_name": "scalar-unit.size",
636 "value": 10000000000,
639 "unit_size": 1000000000
642 "supported_virtualisation_environments": {
649 "type_name": "scalar-unit.size",
651 "value": 10000000000,
654 "unit_size": 1000000000
663 "type_name": "tosca.capabilities.Node"
667 "type_name": "tosca.capabilities.OperatingSystem",
670 "type_name": "string",
671 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
674 "type_name": "version",
675 "description": "The Operating System version."
678 "type_name": "string",
679 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
682 "type_name": "string",
683 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
689 "type_name": "tosca.capabilities.Container",
692 "type_name": "scalar-unit.frequency",
693 "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\"."
696 "type_name": "scalar-unit.size",
697 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
700 "type_name": "integer",
701 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
704 "type_name": "scalar-unit.size",
705 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
711 "type_name": "tosca.capabilities.network.Bindable"
715 "type_name": "tosca.capabilities.Scalable",
718 "type_name": "integer",
720 "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."
722 "default_instances": {
723 "type_name": "integer",
724 "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."
727 "type_name": "integer",
729 "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."
734 "name": "virtual_compute",
735 "type_name": "tosca.capabilities.nfv.VirtualCompute",
737 "requested_additional_capabilities": {
741 "requested_additional_capability_name": "ovs_dpdk",
742 "min_requested_additional_capability_version": "1.0",
743 "support_mandatory": True,
744 "target_performance_parameters": {
745 "sw:ovs_dpdk": "true"
747 "preferred_requested_additional_capability_version": "1.0"
750 "requested_additional_capability_name": "hyper_threading",
751 "min_requested_additional_capability_version": "1.0",
752 "support_mandatory": True,
753 "target_performance_parameters": {
755 "hw:cpu_threads": "2",
756 "hw:cpu_threads_policy": "isolate",
757 "hw:cpu_sockets": "2"
759 "preferred_requested_additional_capability_version": "1.0"
762 "requested_additional_capability_name": "numa",
763 "min_requested_additional_capability_version": "1.0",
764 "support_mandatory": True,
765 "target_performance_parameters": {
766 "hw:numa_cpus.0": "0,1",
767 "hw:numa_cpus.1": "2,3,4,5",
768 "hw:numa_nodes": "2",
769 "hw:numa_mem.1": "3072",
770 "hw:numa_mem.0": "1024"
772 "preferred_requested_additional_capability_version": "1.0"
777 "type_name": "tosca.datatypes.nfv.VirtualCpu",
779 "num_virtual_cpu": 2,
780 "virtual_cpu_clock": {
784 "unit_size": 1000000000
786 "cpu_architecture": "X86",
787 "virtual_cpu_oversubscription_policy": "test",
788 "virtual_cpu_pinning": {
792 "cpu_pinning_policy": "static"
797 "type_name": "tosca.datatypes.nfv.VirtualMemory",
799 "virtual_mem_oversubscription_policy": "mem_policy_test",
800 "numa_enabled": True,
801 "virtual_mem_size": {
802 "value": 10000000000,
805 "unit_size": 1000000000
812 "name": "virtual_binding",
813 "type_name": "tosca.capabilities.nfv.VirtualBindable"
818 "name": "virtual_storage",
819 "source_requirement_index": 0,
820 "target_node_id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
823 "type_name": "string",
824 "value": "/mnt/volume_0",
825 "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\"."
828 "source_interfaces": [
831 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
832 "type_name": "tosca.interfaces.relationship.Configure",
835 "name": "add_source",
836 "description": "Operation to notify the target node of a source node which is now available via a relationship."
839 "name": "pre_configure_target",
840 "description": "Operation to pre-configure the target endpoint."
843 "name": "post_configure_source",
844 "description": "Operation to post-configure the source endpoint."
847 "name": "target_changed",
848 "description": "Operation to notify source some property or attribute of the target changed"
851 "name": "pre_configure_source",
852 "description": "Operation to pre-configure the source endpoint."
855 "name": "post_configure_target",
856 "description": "Operation to post-configure the target endpoint."
859 "name": "remove_target",
860 "description": "Operation to remove a target node."
863 "name": "add_target",
864 "description": "Operation to notify the source node of a target node being added via a relationship."
873 "id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
874 "type_name": "tosca.nodes.nfv.VduCpd",
875 "template_name": "SRIOV_Port",
881 "address_type": "ip_address",
883 "ip_address_type": "ipv4",
884 "floating_ip_activated": False,
885 "number_of_ip_address": 1,
886 "ip_address_assignment": True
892 "type_name": "string",
893 "value": "sriov port"
896 "type_name": "string",
899 "virtual_network_interface_requirements": {
906 "support_mandatory": False,
908 "description": "sriov"
914 "support_mandatory": False,
916 "description": "normal"
921 "type_name": "string",
924 "bitrate_requirement": {
925 "type_name": "integer",
932 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
933 "type_name": "tosca.interfaces.node.lifecycle.Standard",
937 "description": "Standard lifecycle create operation."
941 "description": "Standard lifecycle stop operation."
945 "description": "Standard lifecycle start operation."
949 "description": "Standard lifecycle delete operation."
953 "description": "Standard lifecycle configure operation."
961 "type_name": "tosca.capabilities.Node"
966 "name": "virtual_binding",
967 "source_requirement_index": 0,
968 "target_node_id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
969 "source_interfaces": [
972 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
973 "type_name": "tosca.interfaces.relationship.Configure",
976 "name": "add_source",
977 "description": "Operation to notify the target node of a source node which is now available via a relationship."
980 "name": "pre_configure_target",
981 "description": "Operation to pre-configure the target endpoint."
984 "name": "post_configure_source",
985 "description": "Operation to post-configure the source endpoint."
988 "name": "target_changed",
989 "description": "Operation to notify source some property or attribute of the target changed"
992 "name": "pre_configure_source",
993 "description": "Operation to pre-configure the source endpoint."
996 "name": "post_configure_target",
997 "description": "Operation to post-configure the target endpoint."
1000 "name": "remove_target",
1001 "description": "Operation to remove a target node."
1004 "name": "add_target",
1005 "description": "Operation to notify the source node of a target node being added via a relationship."
1012 "name": "virtual_link",
1013 "source_requirement_index": 1,
1014 "target_node_id": "sriov_link_2610d7gund4e645wo39dvp238",
1015 "target_capability_name": "feature",
1016 "source_interfaces": [
1018 "name": "Configure",
1019 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
1020 "type_name": "tosca.interfaces.relationship.Configure",
1023 "name": "add_source",
1024 "description": "Operation to notify the target node of a source node which is now available via a relationship."
1027 "name": "pre_configure_target",
1028 "description": "Operation to pre-configure the target endpoint."
1031 "name": "post_configure_source",
1032 "description": "Operation to post-configure the source endpoint."
1035 "name": "target_changed",
1036 "description": "Operation to notify source some property or attribute of the target changed"
1039 "name": "pre_configure_source",
1040 "description": "Operation to pre-configure the source endpoint."
1043 "name": "post_configure_target",
1044 "description": "Operation to post-configure the target endpoint."
1047 "name": "remove_target",
1048 "description": "Operation to remove a target node."
1051 "name": "add_target",
1052 "description": "Operation to notify the source node of a target node being added via a relationship."
1062 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1065 "mapped_name": "sriov_plane",
1066 "node_id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
1067 "name": "virtual_link"
1074 "vnfSoftwareVersion": "1.0.0",
1075 "vnfProductName": "openNAT",
1076 "localizationLanguage": [
1080 "vnfProvider": "intel",
1081 "vnfmInfo": "GVNFM",
1082 "defaultLocalizationLanguage": "english",
1083 "vnfdId": "openNAT-1.0",
1084 "vnfProductInfoDescription": "openNAT",
1085 "vnfdVersion": "1.0.0",
1086 "vnfProductInfoName": "openNAT"
1090 "name": "vNAT_Storage",
1091 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
1092 "default_instances": 1,
1095 "size_of_storage": {
1096 "type_name": "scalar-unit.size",
1098 "value": 10000000000,
1101 "unit_size": 1000000000
1104 "type_of_storage": {
1105 "type_name": "string",
1109 "type_name": "boolean",
1113 "interface_templates": [
1116 "capability_templates": [
1119 "type_name": "tosca.capabilities.Node"
1122 "name": "virtual_storage",
1123 "type_name": "tosca.capabilities.nfv.VirtualStorage"
1129 "type_name": "tosca.nodes.nfv.VDU.Compute",
1130 "default_instances": 1,
1133 "configurable_properties": {
1137 "additional_vnfc_configurable_properties": {
1146 "type_name": "list",
1152 "type_name": "string",
1155 "nfvi_constraints": {
1156 "type_name": "list",
1162 "type_name": "string",
1163 "value": "the virtual machine of vNat"
1166 "interface_templates": [
1169 "artifact_templates": [
1172 "capability_templates": [
1175 "type_name": "tosca.capabilities.Node"
1179 "type_name": "tosca.capabilities.OperatingSystem",
1182 "type_name": "string",
1183 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
1186 "type_name": "version",
1187 "description": "The Operating System version."
1190 "type_name": "string",
1191 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
1194 "type_name": "string",
1195 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
1201 "type_name": "tosca.capabilities.Container",
1202 "valid_source_node_type_names": [
1203 "tosca.nodes.SoftwareComponent"
1207 "type_name": "scalar-unit.frequency",
1208 "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\"."
1211 "type_name": "scalar-unit.size",
1212 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
1215 "type_name": "integer",
1216 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
1219 "type_name": "scalar-unit.size",
1220 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
1226 "type_name": "tosca.capabilities.network.Bindable"
1230 "type_name": "tosca.capabilities.Scalable",
1233 "type_name": "integer",
1235 "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."
1237 "default_instances": {
1238 "type_name": "integer",
1239 "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."
1242 "type_name": "integer",
1244 "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."
1249 "name": "virtual_compute",
1250 "type_name": "tosca.capabilities.nfv.VirtualCompute",
1252 "requested_additional_capabilities": {
1256 "requested_additional_capability_name": "ovs_dpdk",
1257 "min_requested_additional_capability_version": "1.0",
1258 "support_mandatory": True,
1259 "target_performance_parameters": {
1260 "sw:ovs_dpdk": "true"
1262 "preferred_requested_additional_capability_version": "1.0"
1264 "hyper_threading": {
1265 "requested_additional_capability_name": "hyper_threading",
1266 "min_requested_additional_capability_version": "1.0",
1267 "support_mandatory": True,
1268 "target_performance_parameters": {
1269 "hw:cpu_cores": "2",
1270 "hw:cpu_threads": "2",
1271 "hw:cpu_threads_policy": "isolate",
1272 "hw:cpu_sockets": "2"
1274 "preferred_requested_additional_capability_version": "1.0"
1277 "requested_additional_capability_name": "numa",
1278 "min_requested_additional_capability_version": "1.0",
1279 "support_mandatory": True,
1280 "target_performance_parameters": {
1281 "hw:numa_cpus.0": "0,1",
1282 "hw:numa_cpus.1": "2,3,4,5",
1283 "hw:numa_nodes": "2",
1284 "hw:numa_mem.1": "3072",
1285 "hw:numa_mem.0": "1024"
1287 "preferred_requested_additional_capability_version": "1.0"
1292 "type_name": "tosca.datatypes.nfv.VirtualCpu",
1294 "num_virtual_cpu": 2,
1295 "virtual_cpu_clock": {
1296 "value": 2400000000,
1299 "unit_size": 1000000000
1301 "cpu_architecture": "X86",
1302 "virtual_cpu_oversubscription_policy": "test",
1303 "virtual_cpu_pinning": {
1304 "cpu_pinning_map": {
1305 "cpu_pinning_0": "1"
1307 "cpu_pinning_policy": "static"
1312 "type_name": "tosca.datatypes.nfv.VirtualMemory",
1314 "virtual_mem_oversubscription_policy": "mem_policy_test",
1315 "numa_enabled": True,
1316 "virtual_mem_size": {
1317 "value": 10000000000,
1320 "unit_size": 1000000000
1327 "name": "virtual_binding",
1328 "type_name": "tosca.capabilities.nfv.VirtualBindable"
1331 "requirement_templates": [
1333 "name": "virtual_storage",
1334 "target_node_template_name": "vNAT_Storage",
1335 "relationship_template": {
1336 "type_name": "tosca.relationships.nfv.VDU.AttachedTo",
1339 "type_name": "string",
1340 "value": "/mnt/volume_0",
1341 "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\"."
1344 "source_interface_templates": [
1352 "name": "SRIOV_Port",
1353 "type_name": "tosca.nodes.nfv.VduCpd",
1354 "default_instances": 1,
1358 "type_name": "list",
1361 "address_type": "ip_address",
1362 "l3_address_data": {
1363 "ip_address_type": "ipv4",
1364 "floating_ip_activated": False,
1365 "number_of_ip_address": 1,
1366 "ip_address_assignment": True
1372 "type_name": "string",
1373 "value": "sriov port"
1376 "type_name": "string",
1379 "virtual_network_interface_requirements": {
1380 "type_name": "list",
1386 "support_mandatory": False,
1388 "description": "sriov"
1394 "support_mandatory": False,
1396 "description": "normal"
1401 "type_name": "string",
1404 "bitrate_requirement": {
1405 "type_name": "integer",
1409 "interface_templates": [
1412 "capability_templates": [
1415 "type_name": "tosca.capabilities.Node"
1418 "requirement_templates": [
1420 "name": "virtual_binding",
1421 "target_node_template_name": "vdu_vNat",
1422 "relationship_template": {
1423 "type_name": "tosca.relationships.nfv.VirtualBindsTo",
1424 "source_interface_templates": [
1430 "name": "virtual_link",
1431 "target_node_type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
1432 "relationship_template": {
1433 "type_name": "tosca.relationships.nfv.VirtualLinksTo",
1434 "source_interface_templates": [
1442 "substitution_template": {
1443 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1444 "requirement_templates": [
1446 "mapped_name": "sriov_plane",
1447 "node_template_name": "SRIOV_Port",
1448 "name": "virtual_link"
1454 print convert_vnfd_model(src_json)