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 if isinstance(value, (str, unicode)):
60 return "%s %s" % (value["factor"], value["unit"])
63 def convert_inputs(src_json):
65 if 'inputs' in src_json:
66 src_inputs = src_json['inputs']
67 for param_name, param_info in src_inputs.items():
69 if 'type_name' in param_info:
70 input_param['type'] = param_info['type_name']
71 if 'description' in param_info:
72 input_param['description'] = param_info['description']
73 if 'value' in param_info:
74 input_param['value'] = param_info['value']
75 inputs[param_name] = input_param
79 def convert_vnf_node(src_node, src_json_model):
80 vnf_node = {'type': src_node['type_name'], 'vnf_id': src_node['template_name'],
81 'description': '', 'properties': {}, 'dependencies': [], 'networks': []}
82 convert_props(src_node, vnf_node)
83 for model_tpl in safe_get(src_json_model, "node_templates"):
84 if model_tpl['name'] != vnf_node['vnf_id']:
86 vnf_node['dependencies'] = [{
87 'key_name': requirement['name'],
88 'vl_id': requirement['target_node_template_name']} for
89 requirement in safe_get(model_tpl, 'requirement_templates') if
90 safe_get(requirement, 'target_capability_name') == 'virtual_linkable']
91 vnf_node['networks'] = [requirement['target_node_template_name'] for
92 requirement in safe_get(model_tpl, 'requirement_templates') if
93 safe_get(requirement, 'name') == 'dependency']
97 def convert_pnf_node(src_node, src_json_model):
98 pnf_node = {'pnf_id': src_node['template_name'], 'description': '', 'properties': {}}
99 convert_props(src_node, pnf_node)
100 pnf_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
104 def convert_vl_node(src_node, src_node_list):
105 vl_node = {'vl_id': src_node['template_name'], 'description': '', 'properties': {}}
106 convert_props(src_node, vl_node)
107 vl_node['route_id'] = ''
108 for relation in safe_get(src_node, 'relationships'):
109 if safe_get(relation, 'type_name').endswith('.VirtualLinksTo'):
110 vl_node['route_id'] = find_node_name(relation['target_node_id'], src_node_list)
112 vl_node['route_external'] = (src_node['type_name'].find('.RouteExternalVL') > 0)
116 def convert_cp_node(src_node, src_node_list, model_type='NSD'):
117 cp_node = {'cp_id': src_node['template_name'], 'description': '', 'properties': {}}
118 convert_props(src_node, cp_node)
119 src_relationships = src_node['relationships']
120 for relation in src_relationships:
121 if safe_get(relation, 'name') in ('virtualLink', 'virtual_link'):
122 cp_node['vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
123 elif safe_get(relation, 'name') in ('virtualbinding', 'virtual_binding'):
124 node_key = 'pnf_id' if model_type == 'NSD' else 'vdu_id'
125 cp_node[node_key] = find_node_name(relation['target_node_id'], src_node_list)
129 def convert_router_node(src_node, src_node_list):
130 router_node = {'router_id': src_node['template_name'], 'description': '', 'properties': {}}
131 convert_props(src_node, router_node)
132 for relation in src_node['relationships']:
133 if safe_get(relation, 'name') != 'external_virtual_link':
135 router_node['external_vl_id'] = find_node_name(relation['target_node_id'], src_node_list)
136 router_node['external_ip_addresses'] = []
137 if 'properties' not in relation:
139 for prop_name, prop_info in relation['properties'].items():
140 if prop_name == 'router_ip_address':
141 router_node['external_ip_addresses'].append(prop_info['value'])
146 def convert_fp_node(src_node, src_node_list, src_json_model):
147 fp_node = {'fp_id': src_node['template_name'], 'description': '',
148 'properties': {}, 'forwarder_list': []}
149 convert_props(src_node, fp_node)
150 for relation in safe_get(src_node, 'relationships'):
151 if safe_get(relation, 'name') != 'forwarder':
153 forwarder_point = {'type': 'vnf'}
154 target_node_type = find_node_type(relation['target_node_id'], src_node_list).upper()
155 if target_node_type.find('.CP.') >= 0 or target_node_type.endswith('.CP'):
156 forwarder_point['type'] = 'cp'
157 forwarder_point['node_name'] = find_node_name(relation['target_node_id'], src_node_list)
158 forwarder_point['capability'] = ''
159 if forwarder_point['type'] == 'vnf':
160 for node_tpl in src_json_model["node_templates"]:
161 if fp_node['fp_id'] != node_tpl["name"]:
163 for r_tpl in safe_get(node_tpl, "requirement_templates"):
164 if safe_get(r_tpl, "target_node_template_name") != forwarder_point['node_name']:
166 forwarder_point['capability'] = safe_get(r_tpl, "target_capability_name")
169 fp_node['forwarder_list'].append(forwarder_point)
173 def convert_vnffg_group(src_group, src_group_list, src_node_list):
174 vnffg = {'vnffg_id': src_group['template_name'], 'description': '',
175 'properties': {}, 'members': []}
176 convert_props(src_group, vnffg)
177 for member_node_id in src_group['member_node_ids']:
178 vnffg['members'].append(find_node_name(member_node_id, src_node_list))
182 def convert_imagefile_node(src_node, src_node_list):
183 image_node = {'image_file_id': src_node['template_name'], 'description': '',
185 convert_props(src_node, image_node)
189 def convert_localstorage_node(src_node, src_node_list):
190 localstorage_node = {'local_storage_id': src_node['template_name'], 'description': '',
192 convert_props(src_node, localstorage_node)
193 return localstorage_node
196 def convert_volumestorage_node(src_node, src_node_list):
197 volumestorage_node = {
198 'volume_storage_id': src_node['id'],
201 convert_props(src_node, volumestorage_node)
202 volumestorage_node["properties"]["size"] = convert_factor_unit(
203 volumestorage_node["properties"]["size_of_storage"])
204 return volumestorage_node
207 def convert_vdu_node(src_node, src_node_list, src_json_model):
208 vdu_node = {'vdu_id': src_node['template_name'], 'description': '', 'properties': {},
209 'image_file': '', 'local_storages': [], 'dependencies': [], 'nfv_compute': {},
210 'vls': [], 'artifacts': [], 'volume_storages': []}
211 convert_props(src_node, vdu_node)
213 for relation in src_node.get('relationships', ''):
214 r_id, r_name = safe_get(relation, 'target_node_id'), safe_get(relation, 'name')
215 if r_name == 'guest_os':
216 vdu_node['image_file'] = find_node_name(r_id, src_node_list)
217 elif r_name == 'local_storage':
218 vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
219 elif r_name == 'virtual_storage':
220 vdu_node['volume_storages'].append(r_id)
221 elif r_name.endswith('.AttachesTo'):
222 nt = find_node_type(r_id, src_node_list)
223 if nt.endswith('.BlockStorage.Local') or nt.endswith('.LocalStorage'):
224 vdu_node['local_storages'].append(find_node_name(r_id, src_node_list))
226 for capability in src_node['capabilities']:
227 if not capability['type_name'].endswith('.VirtualCompute'):
229 vdu_node['nfv_compute']['flavor_extra_specs'] = {}
230 for prop_name, prop_info in capability['properties'].items():
231 if prop_name == "virtual_cpu":
232 vdu_node['nfv_compute']['num_cpus'] = prop_info["value"]["num_virtual_cpu"]
233 vdu_node['nfv_compute']['cpu_frequency'] = convert_factor_unit(
234 prop_info["value"]["virtual_cpu_clock"])
235 elif prop_name == "virtual_memory":
236 vdu_node['nfv_compute']['mem_size'] = convert_factor_unit(
237 prop_info["value"]["virtual_mem_size"])
238 elif prop_name == "requested_additional_capabilities":
239 for key, val in prop_info["value"].items():
240 vdu_node['nfv_compute']['flavor_extra_specs'].update(
241 val["target_performance_parameters"])
243 vdu_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
245 for cp_node in vdu_node['cps']:
246 for src_cp_node in src_node_list:
247 if src_cp_node['template_name'] != cp_node:
249 for relation in safe_get(src_cp_node, 'relationships'):
250 if relation['name'] != 'virtualLink':
252 vl_node_name = find_node_name(relation['target_node_id'], src_node_list)
253 if vl_node_name not in vdu_node['vls']:
254 vdu_node['vls'].append(vl_node_name)
256 for item in safe_get(src_node, 'artifacts'):
257 artifact = {'artifact_name': item['name'], 'type': item['type_name'],
258 'file': item['source_path'], 'properties': {}}
259 convert_props(item, artifact)
260 for key in artifact['properties']:
261 if 'factor' in artifact['properties'][key] and 'unit' in artifact['properties'][key]:
262 artifact['properties'][key] = convert_factor_unit(artifact['properties'][key])
263 vdu_node['artifacts'].append(artifact)
264 if artifact["type"].endswith(".SwImage"):
265 vdu_node['image_file'] = artifact["artifact_name"]
269 def convert_exposed_node(src_json, src_nodes, exposed):
270 for item in safe_get(safe_get(src_json, 'substitution'), 'requirements'):
271 exposed['external_cps'].append({'key_name': item['mapped_name'],
272 "cp_id": find_node_name(item['node_id'], src_nodes)})
273 for item in safe_get(safe_get(src_json, 'substitution'), 'capabilities'):
274 exposed['forward_cps'].append({'key_name': item['mapped_name'],
275 "cp_id": find_node_name(item['node_id'], src_nodes)})
278 def convert_vnffgs(src_json_inst, src_nodes):
280 src_groups = safe_get(src_json_inst, 'groups')
281 for group in src_groups:
282 type_name = group['type_name'].upper()
283 if type_name.find('.VNFFG.') >= 0 or type_name.endswith('.VNFFG'):
284 vnffgs.append(convert_vnffg_group(group, src_groups, src_nodes))
288 def merge_imagefile_node(img_nodes, vdu_nodes):
289 for vdu_node in vdu_nodes:
290 for artifact in vdu_node.get("artifacts", []):
291 if not artifact["type"].endswith(".SwImage"):
293 imgids = [img["image_file_id"] for img in img_nodes]
294 if artifact["artifact_name"] in imgids:
297 "image_file_id": artifact["artifact_name"],
299 "properties": artifact["properties"]
303 def convert_common(src_json, target_json):
304 if isinstance(src_json, (unicode, str)):
305 src_json_dict = json.loads(src_json)
307 src_json_dict = src_json
308 src_json_inst = src_json_dict["instance"]
309 src_json_model = src_json_dict["model"] if "model" in src_json_dict else {}
311 target_json['metadata'] = convert_metadata(src_json_inst)
312 target_json['inputs'] = convert_inputs(src_json_inst)
313 target_json['vls'] = []
314 target_json['cps'] = []
315 target_json['routers'] = []
317 return src_json_inst, src_json_model
320 def convert_nsd_model(src_json):
321 target_json = {'vnfs': [], 'pnfs': [], 'fps': []}
322 src_json_inst, src_json_model = convert_common(src_json, target_json)
324 src_nodes = src_json_inst['nodes']
325 for node in src_nodes:
326 type_name = node['type_name']
327 if type_name.find('.VNF.') > 0 or type_name.endswith('.VNF'):
328 target_json['vnfs'].append(convert_vnf_node(node, src_json_model))
329 elif type_name.find('.PNF.') > 0 or type_name.endswith('.PNF'):
330 target_json['pnfs'].append(convert_pnf_node(node, src_json_model))
331 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
332 or node['type_name'].find('.RouteExternalVL') > 0:
333 target_json['vls'].append(convert_vl_node(node, src_nodes))
334 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP'):
335 target_json['cps'].append(convert_cp_node(node, src_nodes))
336 elif type_name.find('.FP.') > 0 or type_name.endswith('.FP'):
337 target_json['fps'].append(convert_fp_node(node, src_nodes, src_json_model))
338 elif type_name.endswith('.Router'):
339 target_json['routers'].append(convert_router_node(node, src_nodes))
341 target_json['vnffgs'] = convert_vnffgs(src_json_inst, src_nodes)
343 target_json['ns_exposed'] = {'external_cps': [], 'forward_cps': []}
344 convert_exposed_node(src_json_inst, src_nodes, target_json['ns_exposed'])
345 return json.dumps(target_json)
348 def convert_vnfd_model(src_json):
349 target_json = {'image_files': [], 'local_storages': [], 'vdus': [], 'volume_storages': []}
350 src_json_inst, src_json_model = convert_common(src_json, target_json)
352 src_nodes = src_json_inst['nodes']
353 for node in src_nodes:
354 type_name = node['type_name']
355 if type_name.endswith('.ImageFile'):
356 target_json['image_files'].append(convert_imagefile_node(node, src_nodes))
357 elif type_name.endswith('.BlockStorage.Local') or type_name.endswith('.LocalStorage'):
358 target_json['local_storages'].append(convert_localstorage_node(node, src_nodes))
359 elif type_name.endswith('VDU.VirtualStorage'):
360 target_json['volume_storages'].append(convert_volumestorage_node(node, src_nodes))
361 elif type_name.endswith('VDU.Compute'):
362 target_json['vdus'].append(convert_vdu_node(node, src_nodes, src_json_model))
363 elif type_name.find('.VL.') > 0 or type_name.endswith('.VL') \
364 or type_name.endswith('.VnfVirtualLinkDesc') \
365 or type_name.endswith('.RouteExternalVL'):
366 target_json['vls'].append(convert_vl_node(node, src_nodes))
367 elif type_name.find('.CP.') > 0 or type_name.endswith('.CP') or type_name.endswith(".VduCpd"):
368 target_json['cps'].append(convert_cp_node(node, src_nodes, 'VNFD'))
369 elif type_name.endswith('.Router'):
370 target_json['routers'].append(convert_router_node(node, src_nodes))
372 target_json['vnf_exposed'] = {'external_cps': [], 'forward_cps': []}
373 convert_exposed_node(src_json_inst, src_nodes, target_json['vnf_exposed'])
374 merge_imagefile_node(target_json['image_files'], target_json['vdus'])
375 return json.dumps(target_json)
378 if __name__ == '__main__':
379 src_json = json.dumps({
382 "vnfSoftwareVersion": "1.0.0",
383 "vnfProductName": "zte",
384 "localizationLanguage": [
388 "vnfProvider": "zte",
390 "defaultLocalizationLanguage": "english",
391 "vnfdId": "zte-hss-1.0",
392 "vnfProductInfoDescription": "hss",
393 "vnfdVersion": "1.0.0",
394 "vnfProductInfoName": "hss"
398 "id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
399 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
400 "template_name": "vNAT_Storage",
403 "type_name": "scalar-unit.size",
405 "value": 10000000000,
408 "unit_size": 1000000000
412 "type_name": "string",
416 "type_name": "boolean",
423 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
424 "type_name": "tosca.interfaces.node.lifecycle.Standard",
428 "description": "Standard lifecycle create operation."
432 "description": "Standard lifecycle stop operation."
436 "description": "Standard lifecycle start operation."
440 "description": "Standard lifecycle delete operation."
444 "description": "Standard lifecycle configure operation."
452 "type_name": "tosca.capabilities.Node"
455 "name": "virtual_storage",
456 "type_name": "tosca.capabilities.nfv.VirtualStorage"
461 "id": "sriov_link_2610d7gund4e645wo39dvp238",
462 "type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
463 "template_name": "sriov_link",
471 "connectivity_type": {
472 "type_name": "tosca.datatypes.nfv.ConnectivityType",
474 "layer_protocol": "ipv4",
475 "flow_pattern": "flat"
479 "type_name": "string",
480 "value": "sriov_link"
492 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
493 "type_name": "tosca.interfaces.node.lifecycle.Standard",
497 "description": "Standard lifecycle create operation."
501 "description": "Standard lifecycle stop operation."
505 "description": "Standard lifecycle start operation."
509 "description": "Standard lifecycle delete operation."
513 "description": "Standard lifecycle configure operation."
521 "type_name": "tosca.capabilities.Node"
524 "name": "virtual_linkable",
525 "type_name": "tosca.capabilities.nfv.VirtualLinkable"
530 "id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
531 "type_name": "tosca.nodes.nfv.VDU.Compute",
532 "template_name": "vdu_vNat",
534 "configurable_properties": {
538 "additional_vnfc_configurable_properties": {
553 "type_name": "string",
556 "nfvi_constraints": {
563 "type_name": "string",
564 "value": "the virtual machine of vNat"
570 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
571 "type_name": "tosca.interfaces.node.lifecycle.Standard",
575 "description": "Standard lifecycle create operation."
579 "description": "Standard lifecycle stop operation."
583 "description": "Standard lifecycle start operation."
587 "description": "Standard lifecycle delete operation."
591 "description": "Standard lifecycle configure operation."
598 "name": "vNatVNFImage",
599 "type_name": "tosca.artifacts.nfv.SwImage",
600 "source_path": "/swimages/vRouterVNF_ControlPlane.qcow2",
602 "operating_system": {
603 "type_name": "string",
607 "type_name": "string",
608 "value": "/swimages/vRouterVNF_ControlPlane.qcow2"
611 "type_name": "string",
612 "value": "vNatVNFImage"
615 "type_name": "string",
619 "type_name": "scalar-unit.size",
624 "unit_size": 1000000000
628 "type_name": "string",
632 "type_name": "string",
635 "container_format": {
636 "type_name": "string",
640 "type_name": "scalar-unit.size",
642 "value": 10000000000,
645 "unit_size": 1000000000
648 "supported_virtualisation_environments": {
655 "type_name": "scalar-unit.size",
657 "value": 10000000000,
660 "unit_size": 1000000000
669 "type_name": "tosca.capabilities.Node"
673 "type_name": "tosca.capabilities.OperatingSystem",
676 "type_name": "string",
677 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
680 "type_name": "version",
681 "description": "The Operating System version."
684 "type_name": "string",
685 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
688 "type_name": "string",
689 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
695 "type_name": "tosca.capabilities.Container",
698 "type_name": "scalar-unit.frequency",
699 "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\"."
702 "type_name": "scalar-unit.size",
703 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
706 "type_name": "integer",
707 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
710 "type_name": "scalar-unit.size",
711 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
717 "type_name": "tosca.capabilities.network.Bindable"
721 "type_name": "tosca.capabilities.Scalable",
724 "type_name": "integer",
726 "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."
728 "default_instances": {
729 "type_name": "integer",
730 "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."
733 "type_name": "integer",
735 "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."
740 "name": "virtual_compute",
741 "type_name": "tosca.capabilities.nfv.VirtualCompute",
743 "requested_additional_capabilities": {
747 "requested_additional_capability_name": "ovs_dpdk",
748 "min_requested_additional_capability_version": "1.0",
749 "support_mandatory": True,
750 "target_performance_parameters": {
751 "sw:ovs_dpdk": "true"
753 "preferred_requested_additional_capability_version": "1.0"
756 "requested_additional_capability_name": "hyper_threading",
757 "min_requested_additional_capability_version": "1.0",
758 "support_mandatory": True,
759 "target_performance_parameters": {
761 "hw:cpu_threads": "2",
762 "hw:cpu_threads_policy": "isolate",
763 "hw:cpu_sockets": "2"
765 "preferred_requested_additional_capability_version": "1.0"
768 "requested_additional_capability_name": "numa",
769 "min_requested_additional_capability_version": "1.0",
770 "support_mandatory": True,
771 "target_performance_parameters": {
772 "hw:numa_cpus.0": "0,1",
773 "hw:numa_cpus.1": "2,3,4,5",
774 "hw:numa_nodes": "2",
775 "hw:numa_mem.1": "3072",
776 "hw:numa_mem.0": "1024"
778 "preferred_requested_additional_capability_version": "1.0"
783 "type_name": "tosca.datatypes.nfv.VirtualCpu",
785 "num_virtual_cpu": 2,
786 "virtual_cpu_clock": {
790 "unit_size": 1000000000
792 "cpu_architecture": "X86",
793 "virtual_cpu_oversubscription_policy": "test",
794 "virtual_cpu_pinning": {
798 "cpu_pinning_policy": "static"
803 "type_name": "tosca.datatypes.nfv.VirtualMemory",
805 "virtual_mem_oversubscription_policy": "mem_policy_test",
806 "numa_enabled": True,
807 "virtual_mem_size": {
808 "value": 10000000000,
811 "unit_size": 1000000000
818 "name": "virtual_binding",
819 "type_name": "tosca.capabilities.nfv.VirtualBindable"
824 "name": "virtual_storage",
825 "source_requirement_index": 0,
826 "target_node_id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
829 "type_name": "string",
830 "value": "/mnt/volume_0",
831 "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\"."
834 "source_interfaces": [
837 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
838 "type_name": "tosca.interfaces.relationship.Configure",
841 "name": "add_source",
842 "description": "Operation to notify the target node of a source node which is now available via a relationship."
845 "name": "pre_configure_target",
846 "description": "Operation to pre-configure the target endpoint."
849 "name": "post_configure_source",
850 "description": "Operation to post-configure the source endpoint."
853 "name": "target_changed",
854 "description": "Operation to notify source some property or attribute of the target changed"
857 "name": "pre_configure_source",
858 "description": "Operation to pre-configure the source endpoint."
861 "name": "post_configure_target",
862 "description": "Operation to post-configure the target endpoint."
865 "name": "remove_target",
866 "description": "Operation to remove a target node."
869 "name": "add_target",
870 "description": "Operation to notify the source node of a target node being added via a relationship."
879 "id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
880 "type_name": "tosca.nodes.nfv.VduCpd",
881 "template_name": "SRIOV_Port",
887 "address_type": "ip_address",
889 "ip_address_type": "ipv4",
890 "floating_ip_activated": False,
891 "number_of_ip_address": 1,
892 "ip_address_assignment": True
898 "type_name": "string",
899 "value": "sriov port"
902 "type_name": "string",
905 "virtual_network_interface_requirements": {
912 "support_mandatory": False,
914 "description": "sriov"
920 "support_mandatory": False,
922 "description": "normal"
927 "type_name": "string",
930 "bitrate_requirement": {
931 "type_name": "integer",
938 "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
939 "type_name": "tosca.interfaces.node.lifecycle.Standard",
943 "description": "Standard lifecycle create operation."
947 "description": "Standard lifecycle stop operation."
951 "description": "Standard lifecycle start operation."
955 "description": "Standard lifecycle delete operation."
959 "description": "Standard lifecycle configure operation."
967 "type_name": "tosca.capabilities.Node"
972 "name": "virtual_binding",
973 "source_requirement_index": 0,
974 "target_node_id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
975 "source_interfaces": [
978 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
979 "type_name": "tosca.interfaces.relationship.Configure",
982 "name": "add_source",
983 "description": "Operation to notify the target node of a source node which is now available via a relationship."
986 "name": "pre_configure_target",
987 "description": "Operation to pre-configure the target endpoint."
990 "name": "post_configure_source",
991 "description": "Operation to post-configure the source endpoint."
994 "name": "target_changed",
995 "description": "Operation to notify source some property or attribute of the target changed"
998 "name": "pre_configure_source",
999 "description": "Operation to pre-configure the source endpoint."
1002 "name": "post_configure_target",
1003 "description": "Operation to post-configure the target endpoint."
1006 "name": "remove_target",
1007 "description": "Operation to remove a target node."
1010 "name": "add_target",
1011 "description": "Operation to notify the source node of a target node being added via a relationship."
1018 "name": "virtual_link",
1019 "source_requirement_index": 1,
1020 "target_node_id": "sriov_link_2610d7gund4e645wo39dvp238",
1021 "target_capability_name": "feature",
1022 "source_interfaces": [
1024 "name": "Configure",
1025 "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
1026 "type_name": "tosca.interfaces.relationship.Configure",
1029 "name": "add_source",
1030 "description": "Operation to notify the target node of a source node which is now available via a relationship."
1033 "name": "pre_configure_target",
1034 "description": "Operation to pre-configure the target endpoint."
1037 "name": "post_configure_source",
1038 "description": "Operation to post-configure the source endpoint."
1041 "name": "target_changed",
1042 "description": "Operation to notify source some property or attribute of the target changed"
1045 "name": "pre_configure_source",
1046 "description": "Operation to pre-configure the source endpoint."
1049 "name": "post_configure_target",
1050 "description": "Operation to post-configure the target endpoint."
1053 "name": "remove_target",
1054 "description": "Operation to remove a target node."
1057 "name": "add_target",
1058 "description": "Operation to notify the source node of a target node being added via a relationship."
1068 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1071 "mapped_name": "sriov_plane",
1072 "node_id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
1073 "name": "virtual_link"
1080 "vnfSoftwareVersion": "1.0.0",
1081 "vnfProductName": "openNAT",
1082 "localizationLanguage": [
1086 "vnfProvider": "intel",
1087 "vnfmInfo": "GVNFM",
1088 "defaultLocalizationLanguage": "english",
1089 "vnfdId": "openNAT-1.0",
1090 "vnfProductInfoDescription": "openNAT",
1091 "vnfdVersion": "1.0.0",
1092 "vnfProductInfoName": "openNAT"
1096 "name": "vNAT_Storage",
1097 "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
1098 "default_instances": 1,
1101 "size_of_storage": {
1102 "type_name": "scalar-unit.size",
1104 "value": 10000000000,
1107 "unit_size": 1000000000
1110 "type_of_storage": {
1111 "type_name": "string",
1115 "type_name": "boolean",
1119 "interface_templates": [
1122 "capability_templates": [
1125 "type_name": "tosca.capabilities.Node"
1128 "name": "virtual_storage",
1129 "type_name": "tosca.capabilities.nfv.VirtualStorage"
1135 "type_name": "tosca.nodes.nfv.VDU.Compute",
1136 "default_instances": 1,
1139 "configurable_properties": {
1143 "additional_vnfc_configurable_properties": {
1152 "type_name": "list",
1158 "type_name": "string",
1161 "nfvi_constraints": {
1162 "type_name": "list",
1168 "type_name": "string",
1169 "value": "the virtual machine of vNat"
1172 "interface_templates": [
1175 "artifact_templates": [
1178 "capability_templates": [
1181 "type_name": "tosca.capabilities.Node"
1185 "type_name": "tosca.capabilities.OperatingSystem",
1188 "type_name": "string",
1189 "description": "The Operating System (OS) distribution. Examples of valid values for a \"type\" of \"Linux\" would include: debian, fedora, rhel and ubuntu."
1192 "type_name": "version",
1193 "description": "The Operating System version."
1196 "type_name": "string",
1197 "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
1200 "type_name": "string",
1201 "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
1207 "type_name": "tosca.capabilities.Container",
1208 "valid_source_node_type_names": [
1209 "tosca.nodes.SoftwareComponent"
1213 "type_name": "scalar-unit.frequency",
1214 "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\"."
1217 "type_name": "scalar-unit.size",
1218 "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
1221 "type_name": "integer",
1222 "description": "Number of (actual or virtual) CPUs associated with the Compute node."
1225 "type_name": "scalar-unit.size",
1226 "description": "Size of the local disk available to applications running on the Compute node (default unit is MB)."
1232 "type_name": "tosca.capabilities.network.Bindable"
1236 "type_name": "tosca.capabilities.Scalable",
1239 "type_name": "integer",
1241 "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."
1243 "default_instances": {
1244 "type_name": "integer",
1245 "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."
1248 "type_name": "integer",
1250 "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."
1255 "name": "virtual_compute",
1256 "type_name": "tosca.capabilities.nfv.VirtualCompute",
1258 "requested_additional_capabilities": {
1262 "requested_additional_capability_name": "ovs_dpdk",
1263 "min_requested_additional_capability_version": "1.0",
1264 "support_mandatory": True,
1265 "target_performance_parameters": {
1266 "sw:ovs_dpdk": "true"
1268 "preferred_requested_additional_capability_version": "1.0"
1270 "hyper_threading": {
1271 "requested_additional_capability_name": "hyper_threading",
1272 "min_requested_additional_capability_version": "1.0",
1273 "support_mandatory": True,
1274 "target_performance_parameters": {
1275 "hw:cpu_cores": "2",
1276 "hw:cpu_threads": "2",
1277 "hw:cpu_threads_policy": "isolate",
1278 "hw:cpu_sockets": "2"
1280 "preferred_requested_additional_capability_version": "1.0"
1283 "requested_additional_capability_name": "numa",
1284 "min_requested_additional_capability_version": "1.0",
1285 "support_mandatory": True,
1286 "target_performance_parameters": {
1287 "hw:numa_cpus.0": "0,1",
1288 "hw:numa_cpus.1": "2,3,4,5",
1289 "hw:numa_nodes": "2",
1290 "hw:numa_mem.1": "3072",
1291 "hw:numa_mem.0": "1024"
1293 "preferred_requested_additional_capability_version": "1.0"
1298 "type_name": "tosca.datatypes.nfv.VirtualCpu",
1300 "num_virtual_cpu": 2,
1301 "virtual_cpu_clock": {
1302 "value": 2400000000,
1305 "unit_size": 1000000000
1307 "cpu_architecture": "X86",
1308 "virtual_cpu_oversubscription_policy": "test",
1309 "virtual_cpu_pinning": {
1310 "cpu_pinning_map": {
1311 "cpu_pinning_0": "1"
1313 "cpu_pinning_policy": "static"
1318 "type_name": "tosca.datatypes.nfv.VirtualMemory",
1320 "virtual_mem_oversubscription_policy": "mem_policy_test",
1321 "numa_enabled": True,
1322 "virtual_mem_size": {
1323 "value": 10000000000,
1326 "unit_size": 1000000000
1333 "name": "virtual_binding",
1334 "type_name": "tosca.capabilities.nfv.VirtualBindable"
1337 "requirement_templates": [
1339 "name": "virtual_storage",
1340 "target_node_template_name": "vNAT_Storage",
1341 "relationship_template": {
1342 "type_name": "tosca.relationships.nfv.VDU.AttachedTo",
1345 "type_name": "string",
1346 "value": "/mnt/volume_0",
1347 "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\"."
1350 "source_interface_templates": [
1358 "name": "SRIOV_Port",
1359 "type_name": "tosca.nodes.nfv.VduCpd",
1360 "default_instances": 1,
1364 "type_name": "list",
1367 "address_type": "ip_address",
1368 "l3_address_data": {
1369 "ip_address_type": "ipv4",
1370 "floating_ip_activated": False,
1371 "number_of_ip_address": 1,
1372 "ip_address_assignment": True
1378 "type_name": "string",
1379 "value": "sriov port"
1382 "type_name": "string",
1385 "virtual_network_interface_requirements": {
1386 "type_name": "list",
1392 "support_mandatory": False,
1394 "description": "sriov"
1400 "support_mandatory": False,
1402 "description": "normal"
1407 "type_name": "string",
1410 "bitrate_requirement": {
1411 "type_name": "integer",
1415 "interface_templates": [
1418 "capability_templates": [
1421 "type_name": "tosca.capabilities.Node"
1424 "requirement_templates": [
1426 "name": "virtual_binding",
1427 "target_node_template_name": "vdu_vNat",
1428 "relationship_template": {
1429 "type_name": "tosca.relationships.nfv.VirtualBindsTo",
1430 "source_interface_templates": [
1436 "name": "virtual_link",
1437 "target_node_type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
1438 "relationship_template": {
1439 "type_name": "tosca.relationships.nfv.VirtualLinksTo",
1440 "source_interface_templates": [
1448 "substitution_template": {
1449 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1450 "requirement_templates": [
1452 "mapped_name": "sriov_plane",
1453 "node_template_name": "SRIOV_Port",
1454 "name": "virtual_link"
1460 print convert_vnfd_model(src_json)