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):
58 return "%s %s" % (value["factor"], value["unit"])
61 def convert_inputs(src_json):
63 if 'inputs' in src_json:
64 src_inputs = src_json['inputs']
65 for param_name, param_info in src_inputs.items():
67 if 'type_name' in param_info:
68 input_param['type'] = param_info['type_name']
69 if 'description' in param_info:
70 input_param['description'] = param_info['description']
71 if 'value' in param_info:
72 input_param['value'] = param_info['value']
73 inputs[param_name] = input_param
77 def convert_vnf_node(src_node, src_json_model):
78 vnf_node = {'type': src_node['type_name'], 'vnf_id': src_node['template_name'],
79 'description': '', 'properties': {}, 'dependencies': [], 'networks': []}
80 convert_props(src_node, vnf_node)
81 for model_tpl in safe_get(src_json_model, "node_templates"):
82 if model_tpl['name'] != vnf_node['vnf_id']:
84 vnf_node['dependencies'] = [{
85 'key_name': requirement['name'],
86 'vl_id': requirement['target_node_template_name']} for \
87 requirement in safe_get(model_tpl, 'requirement_templates') if \
88 safe_get(requirement, 'target_capability_name') == 'virtual_linkable']
89 vnf_node['networks'] = [requirement['target_node_template_name'] for \
90 requirement in safe_get(model_tpl, 'requirement_templates') if \
91 safe_get(requirement, 'name') == 'dependency']
95 def convert_pnf_node(src_node, src_json_model):
96 pnf_node = {'pnf_id': src_node['template_name'], 'description': '', 'properties': {}}
97 convert_props(src_node, pnf_node)
98 pnf_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
102 def convert_vl_node(src_node, src_node_list):
103 vl_node = {'vl_id': src_node['template_name'], 'description': '', 'properties': {}}
104 convert_props(src_node, vl_node)
105 vl_node['route_id'] = ''
106 for relation in safe_get(src_node, 'relationships'):
107 if safe_get(relation, 'type_name').endswith('.VirtualLinksTo'):
108 vl_node['route_id'] = find_node_name(relation['target_node_id'], src_node_list)
110 vl_node['route_external'] = (src_node['type_name'].find('.RouteExternalVL') > 0)
114 def convert_cp_node(src_node, src_node_list, model_type='NSD'):
115 cp_node = {'cp_id': src_node['template_name'], 'description': '', 'properties': {}}
116 convert_props(src_node, cp_node)
117 src_relationships = src_node['relationships']
118 for relation in src_relationships:
119 if safe_get(relation, 'name') in ('virtualLink', 'virtual_link'):
120 cp_node['vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
121 elif safe_get(relation, 'name') in ('virtualbinding', 'virtual_binding'):
122 node_key = 'pnf_id' if model_type == 'NSD' else 'vdu_id'
123 cp_node[node_key] = find_node_name(relation['target_node_id'], src_node_list)
127 def convert_router_node(src_node, src_node_list):
128 router_node = {'router_id': src_node['template_name'], 'description': '', 'properties': {}}
129 convert_props(src_node, router_node)
130 for relation in src_node['relationships']:
131 if safe_get(relation, 'name') != 'external_virtual_link':
133 router_node['external_vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
134 router_node['external_ip_addresses'] = []
135 if 'properties' not in relation:
137 for prop_name, prop_info in relation['properties'].items():
138 if prop_name == 'router_ip_address':
139 router_node['external_ip_addresses'].append(prop_info['value'])
144 def convert_fp_node(src_node, src_node_list, src_json_model):
145 fp_node = {'fp_id': src_node['template_name'], 'description': '',
146 'properties': {}, 'forwarder_list': []}
147 convert_props(src_node, fp_node)
148 for relation in safe_get(src_node, 'relationships'):
149 if safe_get(relation, 'name') != 'forwarder':
151 forwarder_point = {'type': 'vnf'}
152 target_node_type = find_node_type(relation['target_node_id'], src_node_list).upper()
153 if target_node_type.find('.CP.') >= 0 or target_node_type.endswith('.CP'):
154 forwarder_point['type'] = 'cp'
155 forwarder_point['node_name'] = find_node_name(relation['target_node_id'], src_node_list)
156 forwarder_point['capability'] = ''
157 if forwarder_point['type'] == 'vnf':
158 for node_tpl in src_json_model["node_templates"]:
159 if fp_node['fp_id'] != node_tpl["name"]:
161 for r_tpl in safe_get(node_tpl, "requirement_templates"):
162 if safe_get(r_tpl, "target_node_template_name") != forwarder_point['node_name']:
164 forwarder_point['capability'] = safe_get(r_tpl, "target_capability_name")
167 fp_node['forwarder_list'].append(forwarder_point)
171 def convert_vnffg_group(src_group, src_group_list, src_node_list):
172 vnffg = {'vnffg_id': src_group['template_name'], 'description': '',
173 'properties': {}, 'members': []}
174 convert_props(src_group, vnffg)
175 for member_node_id in src_group['member_node_ids']:
176 vnffg['members'].append(find_node_name(member_node_id, src_node_list))
180 def convert_imagefile_node(src_node, src_node_list):
181 image_node = {'image_file_id': src_node['template_name'], 'description': '',
183 convert_props(src_node, image_node)
187 def convert_localstorage_node(src_node, src_node_list):
188 localstorage_node = {'local_storage_id': src_node['template_name'], 'description': '',
190 convert_props(src_node, localstorage_node)
191 return localstorage_node
194 def convert_volumestorage_node(src_node, src_node_list):
195 volumestorage_node = {
196 'volume_storage_id': src_node['id'],
199 convert_props(src_node, volumestorage_node)
200 volumestorage_node["properties"]["size"] = convert_factor_unit(
201 volumestorage_node["properties"]["size_of_storage"])
202 return volumestorage_node
205 def convert_vdu_node(src_node, src_node_list, src_json_model):
206 vdu_node = {'vdu_id': src_node['template_name'], 'description': '', 'properties': {},
207 'image_file': '', 'local_storages': [], 'dependencies': [], 'nfv_compute': {},
208 'vls': [], 'artifacts': [], 'volume_storages': []}
209 convert_props(src_node, vdu_node)
211 for relation in src_node.get('relationships', ''):
212 r_id, r_name = safe_get(relation, 'target_node_id'), safe_get(relation, 'name')
213 if r_name == 'guest_os':
214 vdu_node['image_file'] = find_node_name(r_id, src_node_list)
215 elif r_name == 'local_storage':
216 vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
217 elif r_name == 'virtual_storage':
218 vdu_node['volume_storages'].append(r_id)
219 elif r_name.endswith('.AttachesTo'):
220 nt = find_node_type(r_id, src_node_list)
221 if nt.endswith('.BlockStorage.Local') or nt.endswith('.LocalStorage'):
222 vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
224 for capability in src_node['capabilities']:
225 if not capability['type_name'].endswith('.VirtualCompute'):
227 vdu_node['nfv_compute']['flavor_extra_specs'] = {}
228 for prop_name, prop_info in capability['properties'].items():
229 if prop_name == "virtual_cpu":
230 vdu_node['nfv_compute']['num_cpus'] = prop_info["value"]["num_virtual_cpu"]
231 vdu_node['nfv_compute']['cpu_frequency'] = convert_factor_unit(
232 prop_info["value"]["virtual_cpu_clock"])
233 elif prop_name == "virtual_memory":
234 vdu_node['nfv_compute']['mem_size'] = convert_factor_unit(
235 prop_info["value"]["virtual_mem_size"])
236 elif prop_name == "requested_additional_capabilities":
237 for key, val in prop_info["value"].items():
238 vdu_node['nfv_compute']['flavor_extra_specs'].update(
239 val["target_performance_parameters"])
241 vdu_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
243 for cp_node in vdu_node['cps']:
244 for src_cp_node in src_node_list:
245 if src_cp_node['template_name'] != cp_node:
247 for relation in safe_get(src_cp_node, 'relationships'):
248 if relation['name'] != 'virtualLink':
250 vl_node_name = find_node_name(relation['target_node_id'], src_node_list)
251 if vl_node_name not in vdu_node['vls']:
252 vdu_node['vls'].append(vl_node_name)
254 for item in safe_get(src_node, 'artifacts'):
255 artifact = {'artifact_name': item['name'], 'type': item['type_name'],
256 'file': item['source_path'], 'properties': {}}
257 convert_props(item, artifact)
258 for key in artifact['properties']:
259 if 'factor' in artifact['properties'][key] and 'unit' in artifact['properties'][key]:
260 artifact['properties'][key] = convert_factor_unit(artifact['properties'][key])
261 vdu_node['artifacts'].append(artifact)
262 if artifact["type"].endswith(".SwImage"):
263 vdu_node['image_file'] = artifact["artifact_name"]
267 def convert_exposed_node(src_json, src_nodes, exposed):
268 for item in safe_get(safe_get(src_json, 'substitution'), 'requirements'):
269 exposed['external_cps'].append({'key_name': item['mapped_name'],
270 "cp_id": find_node_name(item['node_id'], src_nodes)})
271 for item in safe_get(safe_get(src_json, 'substitution'), 'capabilities'):
272 exposed['forward_cps'].append({'key_name': item['mapped_name'],
273 "cp_id": find_node_name(item['node_id'], src_nodes)})
276 def convert_vnffgs(src_json_inst, src_nodes):
278 src_groups = safe_get(src_json_inst, 'groups')
279 for group in src_groups:
280 type_name = group['type_name'].upper()
281 if type_name.find('.VNFFG.') >= 0 or type_name.endswith('.VNFFG'):
282 vnffgs.append(convert_vnffg_group(group, src_groups, src_nodes))
286 def merge_imagefile_node(img_nodes, vdu_nodes):
287 for vdu_node in vdu_nodes:
288 for artifact in vdu_node.get("artifacts", []):
289 if not artifact["type"].endswith(".SwImage"):
291 imgids = [img["image_file_id"] for img in img_nodes]
292 if artifact["artifact_name"] in imgids:
295 "image_file_id": artifact["artifact_name"],
297 "properties": artifact["properties"]
301 def convert_common(src_json, target_json):
302 if isinstance(src_json, (unicode, str)):
303 src_json_dict = json.loads(src_json)
305 src_json_dict = src_json
306 src_json_inst = src_json_dict["instance"]
307 src_json_model = src_json_dict["model"] if "model" in src_json_dict else {}
309 target_json['metadata'] = convert_metadata(src_json_inst)
310 target_json['inputs'] = convert_inputs(src_json_inst)
311 target_json['vls'] = []
312 target_json['cps'] = []
313 target_json['routers'] = []
315 return src_json_inst, src_json_model
318 def convert_nsd_model(src_json):
319 target_json = {'vnfs': [], 'pnfs': [], 'fps': []}
320 src_json_inst, src_json_model = convert_common(src_json, target_json)
322 src_nodes = src_json_inst['nodes']
323 for node in src_nodes:
324 type_name = node['type_name']
325 if type_name.find('.VNF.') > 0 or type_name.endswith('.VNF'):
326 target_json['vnfs'].append(convert_vnf_node(node, src_json_model))
327 elif type_name.find('.PNF.') > 0 or type_name.endswith('.PNF'):
328 target_json['pnfs'].append(convert_pnf_node(node, src_json_model))
329 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
330 or node['type_name'].find('.RouteExternalVL') > 0:
331 target_json['vls'].append(convert_vl_node(node, src_nodes))
332 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP'):
333 target_json['cps'].append(convert_cp_node(node, src_nodes))
334 elif type_name.find('.FP.') > 0 or type_name.endswith('.FP'):
335 target_json['fps'].append(convert_fp_node(node, src_nodes, src_json_model))
336 elif type_name.endswith('.Router'):
337 target_json['routers'].append(convert_router_node(node, src_nodes))
339 target_json['vnffgs'] = convert_vnffgs(src_json_inst, src_nodes)
341 target_json['ns_exposed'] = {'external_cps': [], 'forward_cps': []}
342 convert_exposed_node(src_json_inst, src_nodes, target_json['ns_exposed'])
343 return json.dumps(target_json)
346 def convert_vnfd_model(src_json):
347 target_json = {'image_files': [], 'local_storages': [], 'vdus': [], 'volume_storages': []}
348 src_json_inst, src_json_model = convert_common(src_json, target_json)
350 src_nodes = src_json_inst['nodes']
351 for node in src_nodes:
352 type_name = node['type_name']
353 if type_name.endswith('.ImageFile'):
354 target_json['image_files'].append(convert_imagefile_node(node, src_nodes))
355 elif type_name.endswith('.BlockStorage.Local') or type_name.endswith('.LocalStorage'):
356 target_json['local_storages'].append(convert_localstorage_node(node, src_nodes))
357 elif type_name.endswith('VDU.VirtualStorage'):
358 target_json['volume_storages'].append(convert_volumestorage_node(node, src_nodes))
359 elif type_name.endswith('VDU.Compute'):
360 target_json['vdus'].append(convert_vdu_node(node, src_nodes, src_json_model))
361 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
362 or type_name.endswith('.VnfVirtualLinkDesc') \
363 or type_name.endswith('.RouteExternalVL'):
364 target_json['vls'].append(convert_vl_node(node, src_nodes))
365 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP') or type_name.endswith(".VduCpd"):
366 target_json['cps'].append(convert_cp_node(node, src_nodes, 'VNFD'))
367 elif type_name.endswith('.Router'):
368 target_json['routers'].append(convert_router_node(node, src_nodes))
370 target_json['vnf_exposed'] = {'external_cps': [], 'forward_cps': []}
371 convert_exposed_node(src_json_inst, src_nodes, target_json['vnf_exposed'])
372 merge_imagefile_node(target_json['image_files'], target_json['vdus'])
373 return json.dumps(target_json)
376 if __name__ == '__main__':
377 src_json = json.dumps({
380 "vnfSoftwareVersion": "1.0.0",
381 "vnfProductName": "zte",
382 "localizationLanguage": [
386 "vnfProvider": "zte",
388 "defaultLocalizationLanguage": "english",
389 "vnfdId": "zte-hss-1.0",
390 "vnfProductInfoDescription": "hss",
391 "vnfdVersion": "1.0.0",
392 "vnfProductInfoName": "hss"
396 "id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
397 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
398 "template_name": "vNAT_Storage",
401 "type_name": "scalar-unit.size",
403 "value": 10000000000,
406 "unit_size": 1000000000
410 "type_name": "string",
414 "type_name": "boolean",
421 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
422 "type_name": "tosca.interfaces.node.lifecycle.Standard",
426 "description": "Standard lifecycle create operation."
430 "description": "Standard lifecycle stop operation."
434 "description": "Standard lifecycle start operation."
438 "description": "Standard lifecycle delete operation."
442 "description": "Standard lifecycle configure operation."
450 "type_name": "tosca.capabilities.Node"
453 "name": "virtual_storage",
454 "type_name": "tosca.capabilities.nfv.VirtualStorage"
459 "id": "sriov_link_2610d7gund4e645wo39dvp238",
460 "type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
461 "template_name": "sriov_link",
469 "connectivity_type": {
470 "type_name": "tosca.datatypes.nfv.ConnectivityType",
472 "layer_protocol": "ipv4",
473 "flow_pattern": "flat"
477 "type_name": "string",
478 "value": "sriov_link"
490 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
491 "type_name": "tosca.interfaces.node.lifecycle.Standard",
495 "description": "Standard lifecycle create operation."
499 "description": "Standard lifecycle stop operation."
503 "description": "Standard lifecycle start operation."
507 "description": "Standard lifecycle delete operation."
511 "description": "Standard lifecycle configure operation."
519 "type_name": "tosca.capabilities.Node"
522 "name": "virtual_linkable",
523 "type_name": "tosca.capabilities.nfv.VirtualLinkable"
528 "id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
529 "type_name": "tosca.nodes.nfv.VDU.Compute",
530 "template_name": "vdu_vNat",
532 "configurable_properties": {
536 "additional_vnfc_configurable_properties": {
551 "type_name": "string",
554 "nfvi_constraints": {
561 "type_name": "string",
562 "value": "the virtual machine of vNat"
568 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
569 "type_name": "tosca.interfaces.node.lifecycle.Standard",
573 "description": "Standard lifecycle create operation."
577 "description": "Standard lifecycle stop operation."
581 "description": "Standard lifecycle start operation."
585 "description": "Standard lifecycle delete operation."
589 "description": "Standard lifecycle configure operation."
596 "name": "vNatVNFImage",
597 "type_name": "tosca.artifacts.nfv.SwImage",
598 "source_path": "/swimages/vRouterVNF_ControlPlane.qcow2",
600 "operating_system": {
601 "type_name": "string",
605 "type_name": "string",
606 "value": "/swimages/vRouterVNF_ControlPlane.qcow2"
609 "type_name": "string",
610 "value": "vNatVNFImage"
613 "type_name": "string",
617 "type_name": "scalar-unit.size",
622 "unit_size": 1000000000
626 "type_name": "string",
630 "type_name": "string",
633 "container_format": {
634 "type_name": "string",
638 "type_name": "scalar-unit.size",
640 "value": 10000000000,
643 "unit_size": 1000000000
646 "supported_virtualisation_environments": {
653 "type_name": "scalar-unit.size",
655 "value": 10000000000,
658 "unit_size": 1000000000
667 "type_name": "tosca.capabilities.Node"
671 "type_name": "tosca.capabilities.OperatingSystem",
674 "type_name": "string",
675 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
678 "type_name": "version",
679 "description": "The Operating System version."
682 "type_name": "string",
683 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
686 "type_name": "string",
687 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
693 "type_name": "tosca.capabilities.Container",
696 "type_name": "scalar-unit.frequency",
697 "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\"."
700 "type_name": "scalar-unit.size",
701 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
704 "type_name": "integer",
705 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
708 "type_name": "scalar-unit.size",
709 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
715 "type_name": "tosca.capabilities.network.Bindable"
719 "type_name": "tosca.capabilities.Scalable",
722 "type_name": "integer",
724 "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."
726 "default_instances": {
727 "type_name": "integer",
728 "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."
731 "type_name": "integer",
733 "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."
738 "name": "virtual_compute",
739 "type_name": "tosca.capabilities.nfv.VirtualCompute",
741 "requested_additional_capabilities": {
745 "requested_additional_capability_name": "ovs_dpdk",
746 "min_requested_additional_capability_version": "1.0",
747 "support_mandatory": True,
748 "target_performance_parameters": {
749 "sw:ovs_dpdk": "true"
751 "preferred_requested_additional_capability_version": "1.0"
754 "requested_additional_capability_name": "hyper_threading",
755 "min_requested_additional_capability_version": "1.0",
756 "support_mandatory": True,
757 "target_performance_parameters": {
759 "hw:cpu_threads": "2",
760 "hw:cpu_threads_policy": "isolate",
761 "hw:cpu_sockets": "2"
763 "preferred_requested_additional_capability_version": "1.0"
766 "requested_additional_capability_name": "numa",
767 "min_requested_additional_capability_version": "1.0",
768 "support_mandatory": True,
769 "target_performance_parameters": {
770 "hw:numa_cpus.0": "0,1",
771 "hw:numa_cpus.1": "2,3,4,5",
772 "hw:numa_nodes": "2",
773 "hw:numa_mem.1": "3072",
774 "hw:numa_mem.0": "1024"
776 "preferred_requested_additional_capability_version": "1.0"
781 "type_name": "tosca.datatypes.nfv.VirtualCpu",
783 "num_virtual_cpu": 2,
784 "virtual_cpu_clock": {
788 "unit_size": 1000000000
790 "cpu_architecture": "X86",
791 "virtual_cpu_oversubscription_policy": "test",
792 "virtual_cpu_pinning": {
796 "cpu_pinning_policy": "static"
801 "type_name": "tosca.datatypes.nfv.VirtualMemory",
803 "virtual_mem_oversubscription_policy": "mem_policy_test",
804 "numa_enabled": True,
805 "virtual_mem_size": {
806 "value": 10000000000,
809 "unit_size": 1000000000
816 "name": "virtual_binding",
817 "type_name": "tosca.capabilities.nfv.VirtualBindable"
822 "name": "virtual_storage",
823 "source_requirement_index": 0,
824 "target_node_id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
827 "type_name": "string",
828 "value": "/mnt/volume_0",
829 "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\"."
832 "source_interfaces": [
835 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
836 "type_name": "tosca.interfaces.relationship.Configure",
839 "name": "add_source",
840 "description": "Operation to notify the target node of a source node which is now available via a relationship."
843 "name": "pre_configure_target",
844 "description": "Operation to pre-configure the target endpoint."
847 "name": "post_configure_source",
848 "description": "Operation to post-configure the source endpoint."
851 "name": "target_changed",
852 "description": "Operation to notify source some property or attribute of the target changed"
855 "name": "pre_configure_source",
856 "description": "Operation to pre-configure the source endpoint."
859 "name": "post_configure_target",
860 "description": "Operation to post-configure the target endpoint."
863 "name": "remove_target",
864 "description": "Operation to remove a target node."
867 "name": "add_target",
868 "description": "Operation to notify the source node of a target node being added via a relationship."
877 "id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
878 "type_name": "tosca.nodes.nfv.VduCpd",
879 "template_name": "SRIOV_Port",
885 "address_type": "ip_address",
887 "ip_address_type": "ipv4",
888 "floating_ip_activated": False,
889 "number_of_ip_address": 1,
890 "ip_address_assignment": True
896 "type_name": "string",
897 "value": "sriov port"
900 "type_name": "string",
903 "virtual_network_interface_requirements": {
910 "support_mandatory": False,
912 "description": "sriov"
918 "support_mandatory": False,
920 "description": "normal"
925 "type_name": "string",
928 "bitrate_requirement": {
929 "type_name": "integer",
936 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
937 "type_name": "tosca.interfaces.node.lifecycle.Standard",
941 "description": "Standard lifecycle create operation."
945 "description": "Standard lifecycle stop operation."
949 "description": "Standard lifecycle start operation."
953 "description": "Standard lifecycle delete operation."
957 "description": "Standard lifecycle configure operation."
965 "type_name": "tosca.capabilities.Node"
970 "name": "virtual_binding",
971 "source_requirement_index": 0,
972 "target_node_id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
973 "source_interfaces": [
976 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
977 "type_name": "tosca.interfaces.relationship.Configure",
980 "name": "add_source",
981 "description": "Operation to notify the target node of a source node which is now available via a relationship."
984 "name": "pre_configure_target",
985 "description": "Operation to pre-configure the target endpoint."
988 "name": "post_configure_source",
989 "description": "Operation to post-configure the source endpoint."
992 "name": "target_changed",
993 "description": "Operation to notify source some property or attribute of the target changed"
996 "name": "pre_configure_source",
997 "description": "Operation to pre-configure the source endpoint."
1000 "name": "post_configure_target",
1001 "description": "Operation to post-configure the target endpoint."
1004 "name": "remove_target",
1005 "description": "Operation to remove a target node."
1008 "name": "add_target",
1009 "description": "Operation to notify the source node of a target node being added via a relationship."
1016 "name": "virtual_link",
1017 "source_requirement_index": 1,
1018 "target_node_id": "sriov_link_2610d7gund4e645wo39dvp238",
1019 "target_capability_name": "feature",
1020 "source_interfaces": [
1022 "name": "Configure",
1023 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
1024 "type_name": "tosca.interfaces.relationship.Configure",
1027 "name": "add_source",
1028 "description": "Operation to notify the target node of a source node which is now available via a relationship."
1031 "name": "pre_configure_target",
1032 "description": "Operation to pre-configure the target endpoint."
1035 "name": "post_configure_source",
1036 "description": "Operation to post-configure the source endpoint."
1039 "name": "target_changed",
1040 "description": "Operation to notify source some property or attribute of the target changed"
1043 "name": "pre_configure_source",
1044 "description": "Operation to pre-configure the source endpoint."
1047 "name": "post_configure_target",
1048 "description": "Operation to post-configure the target endpoint."
1051 "name": "remove_target",
1052 "description": "Operation to remove a target node."
1055 "name": "add_target",
1056 "description": "Operation to notify the source node of a target node being added via a relationship."
1066 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1069 "mapped_name": "sriov_plane",
1070 "node_id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
1071 "name": "virtual_link"
1078 "vnfSoftwareVersion": "1.0.0",
1079 "vnfProductName": "openNAT",
1080 "localizationLanguage": [
1084 "vnfProvider": "intel",
1085 "vnfmInfo": "GVNFM",
1086 "defaultLocalizationLanguage": "english",
1087 "vnfdId": "openNAT-1.0",
1088 "vnfProductInfoDescription": "openNAT",
1089 "vnfdVersion": "1.0.0",
1090 "vnfProductInfoName": "openNAT"
1094 "name": "vNAT_Storage",
1095 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
1096 "default_instances": 1,
1099 "size_of_storage": {
1100 "type_name": "scalar-unit.size",
1102 "value": 10000000000,
1105 "unit_size": 1000000000
1108 "type_of_storage": {
1109 "type_name": "string",
1113 "type_name": "boolean",
1117 "interface_templates": [
1120 "capability_templates": [
1123 "type_name": "tosca.capabilities.Node"
1126 "name": "virtual_storage",
1127 "type_name": "tosca.capabilities.nfv.VirtualStorage"
1133 "type_name": "tosca.nodes.nfv.VDU.Compute",
1134 "default_instances": 1,
1137 "configurable_properties": {
1141 "additional_vnfc_configurable_properties": {
1150 "type_name": "list",
1156 "type_name": "string",
1159 "nfvi_constraints": {
1160 "type_name": "list",
1166 "type_name": "string",
1167 "value": "the virtual machine of vNat"
1170 "interface_templates": [
1173 "artifact_templates": [
1176 "capability_templates": [
1179 "type_name": "tosca.capabilities.Node"
1183 "type_name": "tosca.capabilities.OperatingSystem",
1186 "type_name": "string",
1187 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
1190 "type_name": "version",
1191 "description": "The Operating System version."
1194 "type_name": "string",
1195 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
1198 "type_name": "string",
1199 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
1205 "type_name": "tosca.capabilities.Container",
1206 "valid_source_node_type_names": [
1207 "tosca.nodes.SoftwareComponent"
1211 "type_name": "scalar-unit.frequency",
1212 "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\"."
1215 "type_name": "scalar-unit.size",
1216 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
1219 "type_name": "integer",
1220 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
1223 "type_name": "scalar-unit.size",
1224 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
1230 "type_name": "tosca.capabilities.network.Bindable"
1234 "type_name": "tosca.capabilities.Scalable",
1237 "type_name": "integer",
1239 "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."
1241 "default_instances": {
1242 "type_name": "integer",
1243 "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."
1246 "type_name": "integer",
1248 "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."
1253 "name": "virtual_compute",
1254 "type_name": "tosca.capabilities.nfv.VirtualCompute",
1256 "requested_additional_capabilities": {
1260 "requested_additional_capability_name": "ovs_dpdk",
1261 "min_requested_additional_capability_version": "1.0",
1262 "support_mandatory": True,
1263 "target_performance_parameters": {
1264 "sw:ovs_dpdk": "true"
1266 "preferred_requested_additional_capability_version": "1.0"
1268 "hyper_threading": {
1269 "requested_additional_capability_name": "hyper_threading",
1270 "min_requested_additional_capability_version": "1.0",
1271 "support_mandatory": True,
1272 "target_performance_parameters": {
1273 "hw:cpu_cores": "2",
1274 "hw:cpu_threads": "2",
1275 "hw:cpu_threads_policy": "isolate",
1276 "hw:cpu_sockets": "2"
1278 "preferred_requested_additional_capability_version": "1.0"
1281 "requested_additional_capability_name": "numa",
1282 "min_requested_additional_capability_version": "1.0",
1283 "support_mandatory": True,
1284 "target_performance_parameters": {
1285 "hw:numa_cpus.0": "0,1",
1286 "hw:numa_cpus.1": "2,3,4,5",
1287 "hw:numa_nodes": "2",
1288 "hw:numa_mem.1": "3072",
1289 "hw:numa_mem.0": "1024"
1291 "preferred_requested_additional_capability_version": "1.0"
1296 "type_name": "tosca.datatypes.nfv.VirtualCpu",
1298 "num_virtual_cpu": 2,
1299 "virtual_cpu_clock": {
1300 "value": 2400000000,
1303 "unit_size": 1000000000
1305 "cpu_architecture": "X86",
1306 "virtual_cpu_oversubscription_policy": "test",
1307 "virtual_cpu_pinning": {
1308 "cpu_pinning_map": {
1309 "cpu_pinning_0": "1"
1311 "cpu_pinning_policy": "static"
1316 "type_name": "tosca.datatypes.nfv.VirtualMemory",
1318 "virtual_mem_oversubscription_policy": "mem_policy_test",
1319 "numa_enabled": True,
1320 "virtual_mem_size": {
1321 "value": 10000000000,
1324 "unit_size": 1000000000
1331 "name": "virtual_binding",
1332 "type_name": "tosca.capabilities.nfv.VirtualBindable"
1335 "requirement_templates": [
1337 "name": "virtual_storage",
1338 "target_node_template_name": "vNAT_Storage",
1339 "relationship_template": {
1340 "type_name": "tosca.relationships.nfv.VDU.AttachedTo",
1343 "type_name": "string",
1344 "value": "/mnt/volume_0",
1345 "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\"."
1348 "source_interface_templates": [
1356 "name": "SRIOV_Port",
1357 "type_name": "tosca.nodes.nfv.VduCpd",
1358 "default_instances": 1,
1362 "type_name": "list",
1365 "address_type": "ip_address",
1366 "l3_address_data": {
1367 "ip_address_type": "ipv4",
1368 "floating_ip_activated": False,
1369 "number_of_ip_address": 1,
1370 "ip_address_assignment": True
1376 "type_name": "string",
1377 "value": "sriov port"
1380 "type_name": "string",
1383 "virtual_network_interface_requirements": {
1384 "type_name": "list",
1390 "support_mandatory": False,
1392 "description": "sriov"
1398 "support_mandatory": False,
1400 "description": "normal"
1405 "type_name": "string",
1408 "bitrate_requirement": {
1409 "type_name": "integer",
1413 "interface_templates": [
1416 "capability_templates": [
1419 "type_name": "tosca.capabilities.Node"
1422 "requirement_templates": [
1424 "name": "virtual_binding",
1425 "target_node_template_name": "vdu_vNat",
1426 "relationship_template": {
1427 "type_name": "tosca.relationships.nfv.VirtualBindsTo",
1428 "source_interface_templates": [
1434 "name": "virtual_link",
1435 "target_node_type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
1436 "relationship_template": {
1437 "type_name": "tosca.relationships.nfv.VirtualLinksTo",
1438 "source_interface_templates": [
1446 "substitution_template": {
1447 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1448 "requirement_templates": [
1450 "mapped_name": "sriov_plane",
1451 "node_template_name": "SRIOV_Port",
1452 "name": "virtual_link"
1458 print convert_vnfd_model(src_json)