1b01989db148318eed728987a320d56b8be2ae9a
[vfc/nfvo/lcm.git] / lcm / pub / utils / toscautil_new.py
1 # Copyright 2017 ZTE Corporation.
2 #
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
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 import json
16
17 def safe_get(key_val, key):
18     return key_val[key] if key in key_val else ""
19
20
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)
26
27
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)
33
34
35 def find_related_node(node_id, src_json_model, requirement_name):
36     related_nodes = []
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'])
42     return related_nodes
43
44
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']   
50
51
52 def convert_metadata(src_json):
53     return src_json['metadata'] if 'metadata' in src_json else {}
54
55 def convert_factor_unit(value):
56     if isinstance(value, (str, unicode)):
57         return value
58     return "%s %s" % (value["factor"], value["unit"])
59
60 def convert_inputs(src_json):
61     inputs = {}
62     if 'inputs' in src_json:
63         src_inputs = src_json['inputs']
64         for param_name, param_info in src_inputs.items():
65             input_param = {}
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
73     return inputs
74
75
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']:
82             continue
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']
91     return vnf_node
92
93
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')
98     return pnf_node
99
100
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)
108             break
109     vl_node['route_external'] = (src_node['type_name'].find('.RouteExternalVL') > 0)
110     return vl_node
111
112
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)
123     return cp_node
124
125
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':
131             continue
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:
135             continue
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'])
139         break
140     return router_node
141
142
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':
149             continue
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"]:
159                     continue
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']:
162                         continue
163                     forwarder_point['capability'] = safe_get(r_tpl, "target_capability_name")
164                     break
165                 break
166         fp_node['forwarder_list'].append(forwarder_point)
167     return fp_node
168
169
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))
176     return vnffg
177
178
179 def convert_imagefile_node(src_node, src_node_list):
180     image_node = {'image_file_id': src_node['template_name'], 'description': '', 
181         'properties': {}}
182     convert_props(src_node, image_node)
183     return image_node
184
185
186 def convert_localstorage_node(src_node, src_node_list):
187     localstorage_node = {'local_storage_id': src_node['template_name'], 'description': '', 
188         'properties': {}}
189     convert_props(src_node, localstorage_node)
190     return localstorage_node
191
192 def convert_volumestorage_node(src_node, src_node_list):
193     volumestorage_node = {
194         'volume_storage_id': src_node['id'], 
195         'description': "", 
196         'properties': {}}
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
201
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)
207
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))
220
221     for capability in src_node['capabilities']:
222         if not capability['type_name'].endswith('.VirtualCompute'):
223             continue
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"])
239
240     vdu_node['cps'] = find_related_node(src_node['id'], src_json_model, 'virtualbinding')
241
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:
245                 continue
246             for relation in safe_get(src_cp_node, 'relationships'):
247                 if relation['name'] != 'virtualLink':
248                     continue
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)
252
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"]
263     return vdu_node
264
265
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)})
273
274
275 def convert_vnffgs(src_json_inst, src_nodes):
276     vnffgs = []
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))
282     return vnffgs
283
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"):
288                 continue
289             imgids = [img["image_file_id"] for img in img_nodes]
290             if artifact["artifact_name"] in imgids:
291                 continue
292             img_nodes.append({
293                 "image_file_id": artifact["artifact_name"],
294                 "description": "",
295                 "properties": artifact["properties"]
296             })
297
298 def convert_common(src_json, target_json):
299     if isinstance(src_json, (unicode, str)):
300         src_json_dict = json.loads(src_json)
301     else:
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 {}
305
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'] = []
311
312     return src_json_inst, src_json_model
313
314
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)
318    
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))
335
336     target_json['vnffgs'] = convert_vnffgs(src_json_inst, src_nodes)
337
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)
341
342
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)
346
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))
366     
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)
371
372 if __name__ == '__main__':
373     src_json = json.dumps({
374         "instance": {
375             "metadata": {
376                 "vnfSoftwareVersion": "1.0.0",
377                 "vnfProductName": "zte",
378                 "localizationLanguage": [
379                     "english",
380                     "chinese"
381                 ],
382                 "vnfProvider": "zte",
383                 "vnfmInfo": "zte",
384                 "defaultLocalizationLanguage": "english",
385                 "vnfdId": "zte-hss-1.0",
386                 "vnfProductInfoDescription": "hss",
387                 "vnfdVersion": "1.0.0",
388                 "vnfProductInfoName": "hss"
389             },
390             "nodes": [
391                 {
392                     "id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
393                     "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
394                     "template_name": "vNAT_Storage",
395                     "properties": {
396                         "size_of_storage": {
397                             "type_name": "scalar-unit.size",
398                             "value": {
399                                 "value": 10000000000,
400                                 "factor": 10,
401                                 "unit": "GB",
402                                 "unit_size": 1000000000
403                             }
404                         },
405                         "type_of_storage": {
406                             "type_name": "string",
407                             "value": "volume"
408                         },
409                         "rdma_enabled": {
410                             "type_name": "boolean",
411                             "value": False
412                         }
413                     },
414                     "interfaces": [
415                         {
416                             "name": "Standard",
417                             "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
418                             "type_name": "tosca.interfaces.node.lifecycle.Standard",
419                             "operations": [
420                                 {
421                                     "name": "create",
422                                     "description": "Standard lifecycle create operation."
423                                 },
424                                 {
425                                     "name": "stop",
426                                     "description": "Standard lifecycle stop operation."
427                                 },
428                                 {
429                                     "name": "start",
430                                     "description": "Standard lifecycle start operation."
431                                 },
432                                 {
433                                     "name": "delete",
434                                     "description": "Standard lifecycle delete operation."
435                                 },
436                                 {
437                                     "name": "configure",
438                                     "description": "Standard lifecycle configure operation."
439                                 }
440                             ]
441                         }
442                     ],
443                     "capabilities": [
444                         {
445                             "name": "feature",
446                             "type_name": "tosca.capabilities.Node"
447                         },
448                         {
449                             "name": "virtual_storage",
450                             "type_name": "tosca.capabilities.nfv.VirtualStorage"
451                         }
452                     ]
453                 },
454                 {
455                     "id": "sriov_link_2610d7gund4e645wo39dvp238",
456                     "type_name": "tosca.nodes.nfv.VnfVirtualLinkDesc",
457                     "template_name": "sriov_link",
458                     "properties": {
459                         "vl_flavours": {
460                             "type_name": "map",
461                             "value": {
462                                 "vl_id": "aaaa"
463                             }
464                         },
465                         "connectivity_type": {
466                             "type_name": "tosca.datatypes.nfv.ConnectivityType",
467                             "value": {
468                                 "layer_protocol": "ipv4",
469                                 "flow_pattern": "flat"
470                             }
471                         },
472                         "description": {
473                             "type_name": "string",
474                             "value": "sriov_link"
475                         },
476                         "test_access": {
477                             "type_name": "list",
478                             "value": [
479                                 "test"
480                             ]
481                         }
482                     },
483                     "interfaces": [
484                         {
485                             "name": "Standard",
486                             "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
487                             "type_name": "tosca.interfaces.node.lifecycle.Standard",
488                             "operations": [
489                                 {
490                                     "name": "create",
491                                     "description": "Standard lifecycle create operation."
492                                 },
493                                 {
494                                     "name": "stop",
495                                     "description": "Standard lifecycle stop operation."
496                                 },
497                                 {
498                                     "name": "start",
499                                     "description": "Standard lifecycle start operation."
500                                 },
501                                 {
502                                     "name": "delete",
503                                     "description": "Standard lifecycle delete operation."
504                                 },
505                                 {
506                                     "name": "configure",
507                                     "description": "Standard lifecycle configure operation."
508                                 }
509                             ]
510                         }
511                     ],
512                     "capabilities": [
513                         {
514                             "name": "feature",
515                             "type_name": "tosca.capabilities.Node"
516                         },
517                         {
518                             "name": "virtual_linkable",
519                             "type_name": "tosca.capabilities.nfv.VirtualLinkable"
520                         }
521                     ]
522                 },
523                 {
524                     "id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
525                     "type_name": "tosca.nodes.nfv.VDU.Compute",
526                     "template_name": "vdu_vNat",
527                     "properties": {
528                         "configurable_properties": {
529                             "type_name": "map",
530                             "value": {
531                                 "test": {
532                                     "additional_vnfc_configurable_properties": {
533                                         "aaa": "1",
534                                         "bbb": "2",
535                                         "ccc": "3"
536                                     }
537                                 }
538                             }
539                         },
540                         "boot_order": {
541                             "type_name": "list",
542                             "value": [
543                                 "vNAT_Storage"
544                             ]
545                         },
546                         "name": {
547                             "type_name": "string",
548                             "value": "vNat"
549                         },
550                         "nfvi_constraints": {
551                             "type_name": "list",
552                             "value": [
553                                 "test"
554                             ]
555                         },
556                         "description": {
557                             "type_name": "string",
558                             "value": "the virtual machine of vNat"
559                         }
560                     },
561                     "interfaces": [
562                         {
563                             "name": "Standard",
564                             "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
565                             "type_name": "tosca.interfaces.node.lifecycle.Standard",
566                             "operations": [
567                                 {
568                                     "name": "create",
569                                     "description": "Standard lifecycle create operation."
570                                 },
571                                 {
572                                     "name": "stop",
573                                     "description": "Standard lifecycle stop operation."
574                                 },
575                                 {
576                                     "name": "start",
577                                     "description": "Standard lifecycle start operation."
578                                 },
579                                 {
580                                     "name": "delete",
581                                     "description": "Standard lifecycle delete operation."
582                                 },
583                                 {
584                                     "name": "configure",
585                                     "description": "Standard lifecycle configure operation."
586                                 }
587                             ]
588                         }
589                     ],
590                     "artifacts": [
591                         {
592                             "name": "vNatVNFImage",
593                             "type_name": "tosca.artifacts.nfv.SwImage",
594                             "source_path": "/swimages/vRouterVNF_ControlPlane.qcow2",
595                             "properties": {
596                                 "operating_system": {
597                                     "type_name": "string",
598                                     "value": "linux"
599                                 },
600                                 "sw_image": {
601                                     "type_name": "string",
602                                     "value": "/swimages/vRouterVNF_ControlPlane.qcow2"
603                                 },
604                                 "name": {
605                                     "type_name": "string",
606                                     "value": "vNatVNFImage"
607                                 },
608                                 "checksum": {
609                                     "type_name": "string",
610                                     "value": "5000"
611                                 },
612                                 "min_ram": {
613                                     "type_name": "scalar-unit.size",
614                                     "value": {
615                                         "value": 1000000000,
616                                         "factor": 1,
617                                         "unit": "GB",
618                                         "unit_size": 1000000000
619                                     }
620                                 },
621                                 "disk_format": {
622                                     "type_name": "string",
623                                     "value": "qcow2"
624                                 },
625                                 "version": {
626                                     "type_name": "string",
627                                     "value": "1.0"
628                                 },
629                                 "container_format": {
630                                     "type_name": "string",
631                                     "value": "bare"
632                                 },
633                                 "min_disk": {
634                                     "type_name": "scalar-unit.size",
635                                     "value": {
636                                         "value": 10000000000,
637                                         "factor": 10,
638                                         "unit": "GB",
639                                         "unit_size": 1000000000
640                                     }
641                                 },
642                                 "supported_virtualisation_environments": {
643                                     "type_name": "list",
644                                     "value": [
645                                         "test_0"
646                                     ]
647                                 },
648                                 "size": {
649                                     "type_name": "scalar-unit.size",
650                                     "value": {
651                                         "value": 10000000000,
652                                         "factor": 10,
653                                         "unit": "GB",
654                                         "unit_size": 1000000000
655                                     }
656                                 }
657                             }
658                         }
659                     ],
660                     "capabilities": [
661                         {
662                             "name": "feature",
663                             "type_name": "tosca.capabilities.Node"
664                         },
665                         {
666                             "name": "os",
667                             "type_name": "tosca.capabilities.OperatingSystem",
668                             "properties": {
669                                 "distribution": {
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."
672                                 },
673                                 "version": {
674                                     "type_name": "version",
675                                     "description": "The Operating System version."
676                                 },
677                                 "type": {
678                                     "type_name": "string",
679                                     "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
680                                 },
681                                 "architecture": {
682                                     "type_name": "string",
683                                     "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
684                                 }
685                             }
686                         },
687                         {
688                             "name": "host",
689                             "type_name": "tosca.capabilities.Container",
690                             "properties": {
691                                 "cpu_frequency": {
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\"."
694                                 },
695                                 "mem_size": {
696                                     "type_name": "scalar-unit.size",
697                                     "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
698                                 },
699                                 "num_cpus": {
700                                     "type_name": "integer",
701                                     "description": "Number of (actual or virtual) CPUs associated with the Compute node."
702                                 },
703                                 "disk_size": {
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)."
706                                 }
707                             }
708                         },
709                         {
710                             "name": "binding",
711                             "type_name": "tosca.capabilities.network.Bindable"
712                         },
713                         {
714                             "name": "scalable",
715                             "type_name": "tosca.capabilities.Scalable",
716                             "properties": {
717                                 "min_instances": {
718                                     "type_name": "integer",
719                                     "value": 1,
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."
721                                 },
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."
725                                 },
726                                 "max_instances": {
727                                     "type_name": "integer",
728                                     "value": 1,
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."
730                                 }
731                             }
732                         },
733                         {
734                             "name": "virtual_compute",
735                             "type_name": "tosca.capabilities.nfv.VirtualCompute",
736                             "properties": {
737                                 "requested_additional_capabilities": {
738                                     "type_name": "map",
739                                     "value": {
740                                         "ovs_dpdk": {
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"
746                                             },
747                                             "preferred_requested_additional_capability_version": "1.0"
748                                         },
749                                         "hyper_threading": {
750                                             "requested_additional_capability_name": "hyper_threading",
751                                             "min_requested_additional_capability_version": "1.0",
752                                             "support_mandatory": True,
753                                             "target_performance_parameters": {
754                                                 "hw:cpu_cores": "2",
755                                                 "hw:cpu_threads": "2",
756                                                 "hw:cpu_threads_policy": "isolate",
757                                                 "hw:cpu_sockets": "2"
758                                             },
759                                             "preferred_requested_additional_capability_version": "1.0"
760                                         },
761                                         "numa": {
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"
771                                             },
772                                             "preferred_requested_additional_capability_version": "1.0"
773                                         }
774                                     }
775                                 },
776                                 "virtual_cpu": {
777                                     "type_name": "tosca.datatypes.nfv.VirtualCpu",
778                                     "value": {
779                                         "num_virtual_cpu": 2,
780                                         "virtual_cpu_clock": {
781                                             "value": 2400000000,
782                                             "factor": 2.4,
783                                             "unit": "GHz",
784                                             "unit_size": 1000000000
785                                         },
786                                         "cpu_architecture": "X86",
787                                         "virtual_cpu_oversubscription_policy": "test",
788                                         "virtual_cpu_pinning": {
789                                             "cpu_pinning_map": {
790                                                 "cpu_pinning_0": "1"
791                                             },
792                                             "cpu_pinning_policy": "static"
793                                         }
794                                     }
795                                 },
796                                 "virtual_memory": {
797                                     "type_name": "tosca.datatypes.nfv.VirtualMemory",
798                                     "value": {
799                                         "virtual_mem_oversubscription_policy": "mem_policy_test",
800                                         "numa_enabled": True,
801                                         "virtual_mem_size": {
802                                             "value": 10000000000,
803                                             "factor": 10,
804                                             "unit": "GB",
805                                             "unit_size": 1000000000
806                                         }
807                                     }
808                                 }
809                             }
810                         },
811                         {
812                             "name": "virtual_binding",
813                             "type_name": "tosca.capabilities.nfv.VirtualBindable"
814                         }
815                     ],
816                     "relationships": [
817                         {
818                             "name": "virtual_storage",
819                             "source_requirement_index": 0,
820                             "target_node_id": "vNAT_Storage_6wdgwzedlb6sq18uzrr41sof7",
821                             "properties": {
822                                 "location": {
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\"."
826                                 }
827                             },
828                             "source_interfaces": [
829                                 {
830                                     "name": "Configure",
831                                     "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
832                                     "type_name": "tosca.interfaces.relationship.Configure",
833                                     "operations": [
834                                         {
835                                             "name": "add_source",
836                                             "description": "Operation to notify the target node of a source node which is now available via a relationship."
837                                         },
838                                         {
839                                             "name": "pre_configure_target",
840                                             "description": "Operation to pre-configure the target endpoint."
841                                         },
842                                         {
843                                             "name": "post_configure_source",
844                                             "description": "Operation to post-configure the source endpoint."
845                                         },
846                                         {
847                                             "name": "target_changed",
848                                             "description": "Operation to notify source some property or attribute of the target changed"
849                                         },
850                                         {
851                                             "name": "pre_configure_source",
852                                             "description": "Operation to pre-configure the source endpoint."
853                                         },
854                                         {
855                                             "name": "post_configure_target",
856                                             "description": "Operation to post-configure the target endpoint."
857                                         },
858                                         {
859                                             "name": "remove_target",
860                                             "description": "Operation to remove a target node."
861                                         },
862                                         {
863                                             "name": "add_target",
864                                             "description": "Operation to notify the source node of a target node being added via a relationship."
865                                         }
866                                     ]
867                                 }
868                             ]
869                         }
870                     ]
871                 },
872                 {
873                     "id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
874                     "type_name": "tosca.nodes.nfv.VduCpd",
875                     "template_name": "SRIOV_Port",
876                     "properties": {
877                         "address_data": {
878                             "type_name": "list",
879                             "value": [
880                                 {
881                                     "address_type": "ip_address",
882                                     "l3_address_data": {
883                                         "ip_address_type": "ipv4",
884                                         "floating_ip_activated": False,
885                                         "number_of_ip_address": 1,
886                                         "ip_address_assignment": True
887                                     }
888                                 }
889                             ]
890                         },
891                         "description": {
892                             "type_name": "string",
893                             "value": "sriov port"
894                         },
895                         "layer_protocol": {
896                             "type_name": "string",
897                             "value": "ipv4"
898                         },
899                         "virtual_network_interface_requirements": {
900                             "type_name": "list",
901                             "value": [
902                                 {
903                                     "requirement": {
904                                         "SRIOV": "true"
905                                     },
906                                     "support_mandatory": False,
907                                     "name": "sriov",
908                                     "description": "sriov"
909                                 },
910                                 {
911                                     "requirement": {
912                                         "SRIOV": "false"
913                                     },
914                                     "support_mandatory": False,
915                                     "name": "normal",
916                                     "description": "normal"
917                                 }
918                             ]
919                         },
920                         "role": {
921                             "type_name": "string",
922                             "value": "root"
923                         },
924                         "bitrate_requirement": {
925                             "type_name": "integer",
926                             "value": 10
927                         }
928                     },
929                     "interfaces": [
930                         {
931                             "name": "Standard",
932                             "description": "This lifecycle interface defines the essential, normative operations that TOSCA nodes may support.",
933                             "type_name": "tosca.interfaces.node.lifecycle.Standard",
934                             "operations": [
935                                 {
936                                     "name": "create",
937                                     "description": "Standard lifecycle create operation."
938                                 },
939                                 {
940                                     "name": "stop",
941                                     "description": "Standard lifecycle stop operation."
942                                 },
943                                 {
944                                     "name": "start",
945                                     "description": "Standard lifecycle start operation."
946                                 },
947                                 {
948                                     "name": "delete",
949                                     "description": "Standard lifecycle delete operation."
950                                 },
951                                 {
952                                     "name": "configure",
953                                     "description": "Standard lifecycle configure operation."
954                                 }
955                             ]
956                         }
957                     ],
958                     "capabilities": [
959                         {
960                             "name": "feature",
961                             "type_name": "tosca.capabilities.Node"
962                         }
963                     ],
964                     "relationships": [
965                         {
966                             "name": "virtual_binding",
967                             "source_requirement_index": 0,
968                             "target_node_id": "vdu_vNat_7ozwkcr86sa87fmd2nue2ww07",
969                             "source_interfaces": [
970                                 {
971                                     "name": "Configure",
972                                     "description": "The lifecycle interfaces define the essential, normative operations that each TOSCA Relationship Types may support.",
973                                     "type_name": "tosca.interfaces.relationship.Configure",
974                                     "operations": [
975                                         {
976                                             "name": "add_source",
977                                             "description": "Operation to notify the target node of a source node which is now available via a relationship."
978                                         },
979                                         {
980                                             "name": "pre_configure_target",
981                                             "description": "Operation to pre-configure the target endpoint."
982                                         },
983                                         {
984                                             "name": "post_configure_source",
985                                             "description": "Operation to post-configure the source endpoint."
986                                         },
987                                         {
988                                             "name": "target_changed",
989                                             "description": "Operation to notify source some property or attribute of the target changed"
990                                         },
991                                         {
992                                             "name": "pre_configure_source",
993                                             "description": "Operation to pre-configure the source endpoint."
994                                         },
995                                         {
996                                             "name": "post_configure_target",
997                                             "description": "Operation to post-configure the target endpoint."
998                                         },
999                                         {
1000                                             "name": "remove_target",
1001                                             "description": "Operation to remove a target node."
1002                                         },
1003                                         {
1004                                             "name": "add_target",
1005                                             "description": "Operation to notify the source node of a target node being added via a relationship."
1006                                         }
1007                                     ]
1008                                 }
1009                             ]
1010                         },
1011                         {
1012                             "name": "virtual_link",
1013                             "source_requirement_index": 1,
1014                             "target_node_id": "sriov_link_2610d7gund4e645wo39dvp238",
1015                             "target_capability_name": "feature",
1016                             "source_interfaces": [
1017                                 {
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",
1021                                     "operations": [
1022                                         {
1023                                             "name": "add_source",
1024                                             "description": "Operation to notify the target node of a source node which is now available via a relationship."
1025                                         },
1026                                         {
1027                                             "name": "pre_configure_target",
1028                                             "description": "Operation to pre-configure the target endpoint."
1029                                         },
1030                                         {
1031                                             "name": "post_configure_source",
1032                                             "description": "Operation to post-configure the source endpoint."
1033                                         },
1034                                         {
1035                                             "name": "target_changed",
1036                                             "description": "Operation to notify source some property or attribute of the target changed"
1037                                         },
1038                                         {
1039                                             "name": "pre_configure_source",
1040                                             "description": "Operation to pre-configure the source endpoint."
1041                                         },
1042                                         {
1043                                             "name": "post_configure_target",
1044                                             "description": "Operation to post-configure the target endpoint."
1045                                         },
1046                                         {
1047                                             "name": "remove_target",
1048                                             "description": "Operation to remove a target node."
1049                                         },
1050                                         {
1051                                             "name": "add_target",
1052                                             "description": "Operation to notify the source node of a target node being added via a relationship."
1053                                         }
1054                                     ]
1055                                 }
1056                             ]
1057                         }
1058                     ]
1059                 }
1060             ],
1061             "substitution": {
1062                 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1063                 "requirements": [
1064                     {
1065                         "mapped_name": "sriov_plane",
1066                         "node_id": "SRIOV_Port_leu1j6rfdt4c8vta6aec1xe39",
1067                         "name": "virtual_link"
1068                     }
1069                 ]
1070             }
1071         },
1072         "model": {
1073             "metadata": {
1074                 "vnfSoftwareVersion": "1.0.0",
1075                 "vnfProductName": "openNAT",
1076                 "localizationLanguage": [
1077                     "english",
1078                     "chinese"
1079                 ],
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"
1087             },
1088             "node_templates": [
1089                 {
1090                     "name": "vNAT_Storage",
1091                     "type_name": "tosca.nodes.nfv.VDU.VirtualStorage",
1092                     "default_instances": 1,
1093                     "min_instances": 0,
1094                     "properties": {
1095                         "size_of_storage": {
1096                             "type_name": "scalar-unit.size",
1097                             "value": {
1098                                 "value": 10000000000,
1099                                 "factor": 10,
1100                                 "unit": "GB",
1101                                 "unit_size": 1000000000
1102                             }
1103                         },
1104                         "type_of_storage": {
1105                             "type_name": "string",
1106                             "value": "volume"
1107                         },
1108                         "rdma_enabled": {
1109                             "type_name": "boolean",
1110                             "value": False
1111                         }
1112                     },
1113                     "interface_templates": [
1114                         ""
1115                     ],
1116                     "capability_templates": [
1117                         {
1118                             "name": "feature",
1119                             "type_name": "tosca.capabilities.Node"
1120                         },
1121                         {
1122                             "name": "virtual_storage",
1123                             "type_name": "tosca.capabilities.nfv.VirtualStorage"
1124                         }
1125                     ]
1126                 },
1127                 {
1128                     "name": "vdu_vNat",
1129                     "type_name": "tosca.nodes.nfv.VDU.Compute",
1130                     "default_instances": 1,
1131                     "min_instances": 0,
1132                     "properties": {
1133                         "configurable_properties": {
1134                             "type_name": "map",
1135                             "value": {
1136                                 "test": {
1137                                     "additional_vnfc_configurable_properties": {
1138                                         "aaa": "1",
1139                                         "bbb": "2",
1140                                         "ccc": "3"
1141                                     }
1142                                 }
1143                             }
1144                         },
1145                         "boot_order": {
1146                             "type_name": "list",
1147                             "value": [
1148                                 "vNAT_Storage"
1149                             ]
1150                         },
1151                         "name": {
1152                             "type_name": "string",
1153                             "value": "vNat"
1154                         },
1155                         "nfvi_constraints": {
1156                             "type_name": "list",
1157                             "value": [
1158                                 "test"
1159                             ]
1160                         },
1161                         "description": {
1162                             "type_name": "string",
1163                             "value": "the virtual machine of vNat"
1164                         }
1165                     },
1166                     "interface_templates": [
1167                         ""
1168                     ],
1169                     "artifact_templates": [
1170                         ""
1171                     ],
1172                     "capability_templates": [
1173                         {
1174                             "name": "feature",
1175                             "type_name": "tosca.capabilities.Node"
1176                         },
1177                         {
1178                             "name": "os",
1179                             "type_name": "tosca.capabilities.OperatingSystem",
1180                             "properties": {
1181                                 "distribution": {
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."
1184                                 },
1185                                 "version": {
1186                                     "type_name": "version",
1187                                     "description": "The Operating System version."
1188                                 },
1189                                 "type": {
1190                                     "type_name": "string",
1191                                     "description": "The Operating System (OS) type. Examples of valid values include: linux, aix, mac, windows, etc."
1192                                 },
1193                                 "architecture": {
1194                                     "type_name": "string",
1195                                     "description": "The Operating System (OS) architecture. Examples of valid values include: x86_32, x86_64, etc."
1196                                 }
1197                             }
1198                         },
1199                         {
1200                             "name": "host",
1201                             "type_name": "tosca.capabilities.Container",
1202                             "valid_source_node_type_names": [
1203                                 "tosca.nodes.SoftwareComponent"
1204                             ],
1205                             "properties": {
1206                                 "cpu_frequency": {
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\"."
1209                                 },
1210                                 "mem_size": {
1211                                     "type_name": "scalar-unit.size",
1212                                     "description": "Size of memory available to applications running on the Compute node (default unit is MB)."
1213                                 },
1214                                 "num_cpus": {
1215                                     "type_name": "integer",
1216                                     "description": "Number of (actual or virtual) CPUs associated with the Compute node."
1217                                 },
1218                                 "disk_size": {
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)."
1221                                 }
1222                             }
1223                         },
1224                         {
1225                             "name": "binding",
1226                             "type_name": "tosca.capabilities.network.Bindable"
1227                         },
1228                         {
1229                             "name": "scalable",
1230                             "type_name": "tosca.capabilities.Scalable",
1231                             "properties": {
1232                                 "min_instances": {
1233                                     "type_name": "integer",
1234                                     "value": 1,
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."
1236                                 },
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."
1240                                 },
1241                                 "max_instances": {
1242                                     "type_name": "integer",
1243                                     "value": 1,
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."
1245                                 }
1246                             }
1247                         },
1248                         {
1249                             "name": "virtual_compute",
1250                             "type_name": "tosca.capabilities.nfv.VirtualCompute",
1251                             "properties": {
1252                                 "requested_additional_capabilities": {
1253                                     "type_name": "map",
1254                                     "value": {
1255                                         "ovs_dpdk": {
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"
1261                                             },
1262                                             "preferred_requested_additional_capability_version": "1.0"
1263                                         },
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"
1273                                             },
1274                                             "preferred_requested_additional_capability_version": "1.0"
1275                                         },
1276                                         "numa": {
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"
1286                                             },
1287                                             "preferred_requested_additional_capability_version": "1.0"
1288                                         }
1289                                     }
1290                                 },
1291                                 "virtual_cpu": {
1292                                     "type_name": "tosca.datatypes.nfv.VirtualCpu",
1293                                     "value": {
1294                                         "num_virtual_cpu": 2,
1295                                         "virtual_cpu_clock": {
1296                                             "value": 2400000000,
1297                                             "factor": 2.4,
1298                                             "unit": "GHz",
1299                                             "unit_size": 1000000000
1300                                         },
1301                                         "cpu_architecture": "X86",
1302                                         "virtual_cpu_oversubscription_policy": "test",
1303                                         "virtual_cpu_pinning": {
1304                                             "cpu_pinning_map": {
1305                                                 "cpu_pinning_0": "1"
1306                                             },
1307                                             "cpu_pinning_policy": "static"
1308                                         }
1309                                     }
1310                                 },
1311                                 "virtual_memory": {
1312                                     "type_name": "tosca.datatypes.nfv.VirtualMemory",
1313                                     "value": {
1314                                         "virtual_mem_oversubscription_policy": "mem_policy_test",
1315                                         "numa_enabled": True,
1316                                         "virtual_mem_size": {
1317                                             "value": 10000000000,
1318                                             "factor": 10,
1319                                             "unit": "GB",
1320                                             "unit_size": 1000000000
1321                                         }
1322                                     }
1323                                 }
1324                             }
1325                         },
1326                         {
1327                             "name": "virtual_binding",
1328                             "type_name": "tosca.capabilities.nfv.VirtualBindable"
1329                         }
1330                     ],
1331                     "requirement_templates": [
1332                         {
1333                             "name": "virtual_storage",
1334                             "target_node_template_name": "vNAT_Storage",
1335                             "relationship_template": {
1336                                 "type_name": "tosca.relationships.nfv.VDU.AttachedTo",
1337                                 "properties": {
1338                                     "location": {
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\"."
1342                                     }
1343                                 },
1344                                 "source_interface_templates": [
1345                                     ""
1346                                 ]
1347                             }
1348                         }
1349                     ]
1350                 },
1351                 {
1352                     "name": "SRIOV_Port",
1353                     "type_name": "tosca.nodes.nfv.VduCpd",
1354                     "default_instances": 1,
1355                     "min_instances": 0,
1356                     "properties": {
1357                         "address_data": {
1358                             "type_name": "list",
1359                             "value": [
1360                                 {
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
1367                                     }
1368                                 }
1369                             ]
1370                         },
1371                         "description": {
1372                             "type_name": "string",
1373                             "value": "sriov port"
1374                         },
1375                         "layer_protocol": {
1376                             "type_name": "string",
1377                             "value": "ipv4"
1378                         },
1379                         "virtual_network_interface_requirements": {
1380                             "type_name": "list",
1381                             "value": [
1382                                 {
1383                                     "requirement": {
1384                                         "SRIOV": "true"
1385                                     },
1386                                     "support_mandatory": False,
1387                                     "name": "sriov",
1388                                     "description": "sriov"
1389                                 },
1390                                 {
1391                                     "requirement": {
1392                                         "SRIOV": "false"
1393                                     },
1394                                     "support_mandatory": False,
1395                                     "name": "normal",
1396                                     "description": "normal"
1397                                 }
1398                             ]
1399                         },
1400                         "role": {
1401                             "type_name": "string",
1402                             "value": "root"
1403                         },
1404                         "bitrate_requirement": {
1405                             "type_name": "integer",
1406                             "value": 10
1407                         }
1408                     },
1409                     "interface_templates": [
1410                         ""
1411                     ],
1412                     "capability_templates": [
1413                         {
1414                             "name": "feature",
1415                             "type_name": "tosca.capabilities.Node"
1416                         }
1417                     ],
1418                     "requirement_templates": [
1419                         {
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": [
1425                                     ""
1426                                 ]
1427                             }
1428                         },
1429                         {
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": [
1435                                     ""
1436                                 ]
1437                             }
1438                         }
1439                     ]
1440                 }
1441             ],
1442             "substitution_template": {
1443                 "node_type_name": "tosca.nodes.nfv.VNF.vOpenNAT",
1444                 "requirement_templates": [
1445                     {
1446                         "mapped_name": "sriov_plane",
1447                         "node_template_name": "SRIOV_Port",
1448                         "name": "virtual_link"
1449                     }
1450                 ]
1451             }
1452         }
1453     })
1454     print convert_vnfd_model(src_json)
1455
1456
1457
1458