Update vnf instaniation code of gvnfm vnflcm
[vfc/gvnfm/vnflcm.git] / lcm / lcm / nf / vnfs / const.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 from lcm.pub.utils.jobutil import enum
16
17 VNF_STATUS = enum(NULL='null', INSTANTIATING="instantiating", INACTIVE='inactive', ACTIVE="active",
18                   FAILED="failed", TERMINATING="terminating", SCALING="scaling", OPERATING="operating",
19                   UPDATING="updating", HEALING="healing")
20
21 inst_req_data = {
22     "flavourId": "flavour_1",
23     "instantiationLevelId": "instantiationLevel_1",
24     "extVirtualLinks": [
25         # {
26         #     "vlInstanceId": "1",
27         #     "vim": {
28         #         "vimInfoId": "1",
29         #         "vimId": "1",
30         #         "interfaceInfo": {
31         #             "vimType": "vim",
32         #             "apiVersion": "v2",
33         #             "protocolType": "http"
34         #         },
35         #         "accessInfo": {
36         #             "tenant": "tenant_vCPE",
37         #             "username": "vCPE",
38         #             "password": "vCPE_321"
39         #         },
40         #         "interfaceEndpoint": "http://10.43.21.105:80/"
41         #     },
42         #     "resourceId": "1246",
43         #     "extCps": [
44         #         {
45         #             "cpdId": "11",
46         #             "addresses": [
47         #                 {
48         #                     "addressType": "MAC",
49         #                     "l2AddressData": "00:f3:43:20:a2:a3"
50         #                 },
51         #                 {
52         #                     "addressType": "IP",
53         #                     "l3AddressData": {
54         #                         "iPAddressType": "IPv4",
55         #                         "iPAddress": "192.168.104.2"
56         #                     }
57         #                 }
58         #             ],
59         #             "numDynamicAddresses": 0
60         #         }
61         #     ]
62         # },
63         {
64             "vlInstanceId": '55',
65             "resourceId": '55_network',
66             "resourceSubnetId": '55_subnet',
67             "cpdId": 'cpId1',
68             "vim": {
69                 "vimid": '55_vimid'
70             }
71         }
72     ],
73     "localizationLanguage": "en_US",
74     "additionalParams": {}
75 }
76
77 vnfd_rawdata = {
78     "rawData": {
79         "instance": {
80             "metadata": {
81                 "designer": "sdno",
82                 "name": "underlayervpn",
83                 "csarVersion": "1.0",
84                 "csarType": "SSAR",
85                 "csarProvider": "huawei",
86                 "version": "1.0",
87                 "type": "SSAR",
88                 "id": "ns_underlayervpn_1_0"
89             },
90             "nodes": [
91                 {
92                     "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
93                     "type_name": "tosca.nodes.sdn.l3ac",
94                     "template_name": "ac2",
95                     "properties": {
96                         "ip": {
97                             "type_name": "string"
98                         },
99                         "route": {
100                             "type_name": "string"
101                         },
102                         "port": {
103                             "type_name": "string"
104                         },
105                         "svlan": {
106                             "type_name": "string"
107                         }
108                     },
109                     "interfaces": [
110                         {
111                             "name": "Standard",
112                             "type_name": "tosca.interfaces.node.lifecycle.Standard"
113                         }
114                     ],
115                     "capabilities": [
116                         {
117                             "name": "feature",
118                             "type_name": "tosca.capabilities.Node"
119                         },
120                         {
121                             "name": "ac",
122                             "type_name": "tosca.capabilities.sdn.ac"
123                         }
124                     ],
125                     "relationships": [
126                         {
127                             "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
128                             "target_capability_name": "feature"
129                         },
130                         {
131                             "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
132                             "target_capability_name": "feature"
133                         }
134                     ]
135                 },
136                 {
137                     "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
138                     "type_name": "tosca.nodes.sdn.l3ac",
139                     "template_name": "ac1",
140                     "properties": {
141                         "ip": {
142                             "type_name": "string"
143                         },
144                         "route": {
145                             "type_name": "string"
146                         },
147                         "port": {
148                             "type_name": "string"
149                         },
150                         "svlan": {
151                             "type_name": "string"
152                         }
153                     },
154                     "interfaces": [
155                         {
156                             "name": "Standard",
157                             "type_name": "tosca.interfaces.node.lifecycle.Standard"
158                         }
159                     ],
160                     "capabilities": [
161                         {
162                             "name": "feature",
163                             "type_name": "tosca.capabilities.Node"
164                         },
165                         {
166                             "name": "ac",
167                             "type_name": "tosca.capabilities.sdn.ac"
168                         }
169                     ],
170                     "relationships": [
171                         {
172                             "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
173                             "target_capability_name": "feature"
174                         },
175                         {
176                             "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
177                             "target_capability_name": "feature"
178                         }
179                     ]
180                 },
181                 {
182                     "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
183                     "type_name": "tosca.nodes.sdn.underlayVPN",
184                     "template_name": "vpn",
185                     "properties": {
186                         "serviceType": {
187                             "type_name": "string"
188                         },
189                         "description": {
190                             "type_name": "string"
191                         },
192                         "name": {
193                             "type_name": "string"
194                         },
195                         "topology": {
196                             "type_name": "string"
197                         }
198                     },
199                     "interfaces": [
200                         {
201                             "name": "Standard",
202                             "type_name": "tosca.interfaces.node.lifecycle.Standard"
203                         }
204                     ],
205                     "capabilities": [
206                         {
207                             "name": "feature",
208                             "type_name": "tosca.capabilities.Node"
209                         }
210                     ],
211                     "relationships": [
212                         {
213                             "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
214                             "target_capability_name": "feature"
215                         },
216                         {
217                             "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
218                             "target_capability_name": "feature"
219                         }
220                     ]
221                 },
222                 {
223                     "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
224                     "type_name": "tosca.nodes.sdn.l3pe",
225                     "template_name": "pe1",
226                     "properties": {
227                         "id": {
228                             "type_name": "string"
229                         }
230                     },
231                     "interfaces": [
232                         {
233                             "name": "Standard",
234                             "type_name": "tosca.interfaces.node.lifecycle.Standard"
235                         }
236                     ],
237                     "capabilities": [
238                         {
239                             "name": "feature",
240                             "type_name": "tosca.capabilities.Node"
241                         },
242                         {
243                             "name": "pe",
244                             "type_name": "tosca.capabilities.sdn.pe"
245                         }
246                     ]
247                 },
248                 {
249                     "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
250                     "type_name": "tosca.nodes.sdn.l3pe",
251                     "template_name": "pe2",
252                     "properties": {
253                         "id": {
254                             "type_name": "string"
255                         }
256                     },
257                     "interfaces": [
258                         {
259                             "name": "Standard",
260                             "type_name": "tosca.interfaces.node.lifecycle.Standard"
261                         }
262                     ],
263                     "capabilities": [
264                         {
265                             "name": "feature",
266                             "type_name": "tosca.capabilities.Node"
267                         },
268                         {
269                             "name": "pe",
270                             "type_name": "tosca.capabilities.sdn.pe"
271                         }
272                     ]
273                 }
274             ],
275             "substitution": {
276                 "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
277             },
278             "inputs": {
279                 "ac2_ip": {
280                     "type_name": "string",
281                     "description": "ac2_ipofunderlayvpn"
282                 },
283                 "ac2_route": {
284                     "type_name": "string",
285                     "description": "ac2_routeofunderlayvpn"
286                 },
287                 "serviceType": {
288                     "type_name": "string",
289                     "description": "serviceTypeofunderlayvpn"
290                 },
291                 "description": {
292                     "type_name": "string",
293                     "description": "descriptionofunderlayvpn"
294                 },
295                 "pe2_id": {
296                     "type_name": "string",
297                     "description": "pe2_idofunderlayvpn"
298                 },
299                 "ac1_route": {
300                     "type_name": "string",
301                     "description": "ac1_routeofunderlayvpn"
302                 },
303                 "ac1_svlan": {
304                     "type_name": "integer",
305                     "description": "ac1_svlanofunderlayvpn"
306                 },
307                 "name": {
308                     "type_name": "string",
309                     "description": "Nameofunderlayervpn"
310                 },
311                 "ac1_ip": {
312                     "type_name": "string",
313                     "description": "ac1_ipofunderlayvpn"
314                 },
315                 "ac2_port": {
316                     "type_name": "string",
317                     "description": "ac2_portofunderlayvpn"
318                 },
319                 "pe1_id": {
320                     "type_name": "string",
321                     "description": "pe1_idofunderlayvpn"
322                 },
323                 "technology": {
324                     "type_name": "string",
325                     "description": "technologyofunderlayvpn"
326                 },
327                 "ac1_port": {
328                     "type_name": "string",
329                     "description": "ac1_portofunderlayvpn"
330                 },
331                 "ac2_svlan": {
332                     "type_name": "integer",
333                     "description": "ac2_svlanofunderlayvpn"
334                 },
335                 "topology": {
336                     "type_name": "string",
337                     "description": "topologyofunderlayvpn"
338                 }
339             }
340         }
341     }
342 }
343
344
345 vnfd_model_dict = {
346     'metadata': {
347         'vendor': u'zte',
348         'is_shared': False,
349         'description': '',
350         'domain_type': u'CN',
351         'version': u'v4.14.10',
352         'vmnumber_overquota_alarm': False,
353         'cross_dc': False,
354         'vnf_type': u'SSS',
355         'vnfd_version': u'V00000001',
356         'id': u'sss-vnf-template',
357         'name': u'sss-vnf-template'
358     },
359     'vdus': [
360         {
361             "vdu_id": "vdu1Id",
362             "description": "vdu description",
363             "properties": {
364                 "name": "vduinstname",
365                 "vdu_type": "OMP",
366                 "key_vdu": True,
367                 "support_scaling": True,
368                 "location_info": {
369                     "vimid": "vimid",
370                     "tenant": "tenantname",
371                     "availability_zone": "zone1",
372                     "host": "host1"
373                 },
374                 "local_affinity_antiaffinity_rule": [
375                     {
376                         "affinity_antiaffinity": "anti-affinity",
377                         "scope": "node"
378                     },
379                     {
380                         "affinity_antiaffinity": "affinity",
381                         "scope": "zone"
382                     }
383                 ],
384                 "inject_data_list": [
385                     {
386                         "file_name": "abc.xml",
387                         "file_data": "<a>xxx</a><b>ssss</b>"
388                     }
389                 ],
390                 "storage_policy": "HIGH",
391                 "template_id": "26",
392                 "manual_scale_select_vim": False,
393                 "watchdog": {
394                     "enabledelay": 600000,
395                     "action": "reset"
396                 },
397                 "is_predefined": False,
398                 "allow_scale_updown": False,
399                 "inject_network_address": True,
400                 "inner_hugepage_num": 100,
401                 "inner_hugepage_size": "2048",
402                 "action": "add"
403             },
404             "image_file": u'sss',
405             "local_storages": [
406                 "local_storage_id1",
407                 "local_storage_id2"
408             ],
409             "volume_storages": [
410                 {
411                     "volume_storage_id": "volume_storage1",
412                     "location": "/usr/data",
413                     "device": "/dev/hda1"
414                 }
415             ],
416             "dependencies": [
417                 "vdu1Id",
418                 "vduNId"
419             ],
420             "nfv_compute": {
421                 "num_cpus": 4,
422                 "mem_size": "1024MB",
423                 "cpu_frequency": "1GHz",
424                 "flavor_extra_specs": {
425                     "hw: cpu_policy": "shared",
426                     "hw: cpu_max_threads": 50,
427                     "hw: cpu_sockets": 10,
428                     "hw: cpu_max_sockets": 20,
429                     "hw: cpu_max_cores": 8,
430                     "hw: cpu_threads": 30,
431                     "hw: numa_mem.0": 12288,
432                     "hw: hugepage_num": 100,
433                     "hw: high_performance": "dvs_high",
434                     "hw: numa_nodes": 1,
435                     "hw: numa_cpus.0": "2,4,8",
436                     "hw: numa_pci": True,
437                     "hw: cpu_cores": 4,
438                     "pci_passthrough: alias": "ColetoCreek: 1",
439                     "hw: mem_page_size": "large",
440                     "hw: mem_paging_mechanism": "EPT"
441                 }
442             },
443             "vls": [
444                 "vlId1",
445             ],
446             "cps": [
447                 "cpId1",
448             ],
449             "scalable": {
450                 "min_instances": 1,
451                 "max_instances": 2,
452                 "default_instances": 1
453             },
454             "interfaces": {
455                 "Standard": {
456                     "create": {
457                         "implementation": "<implementationScript>",
458                         "inputs": {
459                             "param1Name": "value1",
460                             "paramNName": "valueN"
461                         }
462                     },
463                     "configure": {
464                         "implementation": "<implementationScript>",
465                         "inputs": {
466                             "param1Name": "value1",
467                             "paramNName": "valueN"
468                         }
469                     },
470                     "start": {
471                         "implementation": "<implementationScript>",
472                         "inputs": {
473                             "param1Name": "value1",
474                             "paramNName": "valueN"
475                         }
476                     },
477                     "stop": {
478                         "implementation": "<implementationScript>",
479                         "inputs": {
480                             "param1Name": "value1",
481                             "paramNName": "valueN"
482                         }
483                     },
484                     "delete": {
485                         "implementation": "<implementationScript>",
486                         "inputs": {
487                             "param1Name": "value1",
488                             "paramNName": "valueN"
489                         }
490                     }
491                 }
492             },
493             "artifacts": [
494                 {
495                     "artifact_name": "software_version_file",
496                     "type": "tosca.artifacts.Deployment",
497                     "file": "AppSoftwares/zte-cn-xgw-V5.16.11_NFV-version.zip",
498                     "repository": "",
499                     "deploy_path": ""
500                 }
501             ]
502         }
503     ],
504     'volume_storages': [
505         {
506             "volume_storage_id": "volume_storage1",
507             "description": "",
508             "properties": {
509                 "size": "100 GB",
510                 "volume_id": "",
511                 "volume_name": "volumeStorage1",
512                 "custom_volume_type": "type1",
513                 "disk_type": "data",
514                 "delete_on_termination_vm": True,
515                 "location_info": {
516                     "vimid": "vimid_1",
517                     "tenant": "tenantname_1",
518                     "availability_zone": "zone1"
519                 },
520                 "is_predefined": False,
521                 "is_shared": False
522             },
523             "image_file": [
524                 "volume_image"
525             ]
526         }
527     ],
528     'policies': {
529         'scaling': {
530             'targets': {
531
532             },
533             'policy_id': u'policy_scale_sss-vnf-template',
534             'properties': {
535                 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
536             },
537             'description': ''
538         }
539     },
540     'image_files': [
541         {
542             'description': '',
543             'properties': {
544                 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
545                 'checksum': '',
546                 'disk_format': u'VMDK',
547                 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
548                 'container_type': 'vm',
549                 'version': '',
550                 'hypervisor_type': 'kvm'
551             },
552             'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
553         },
554         {
555             'description': '',
556             'properties': {
557                 'name': u'sss.vmdk',
558                 'checksum': '',
559                 'disk_format': u'VMDK',
560                 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
561                 'container_type': 'vm',
562                 'version': '',
563                 'hypervisor_type': 'kvm'
564             },
565             'image_file_id': u'sss'
566         }
567     ],
568     'vls': [
569         {
570             "vl_id": "vldId1",
571             "description": "",
572             "properties": {
573                 "name": "umac_241_control",
574                 "network_name": "umac_control",
575                 "is_predefined": False,
576                 "vendor": "zte",
577                 "netmask": "255.255.255.0",
578                 "mtu": 1500,
579                 "network_type": "vlan",
580                 "physical_network": "phynet01",
581                 "segmentation_id": "30",
582                 "vlan_transparent": False,
583                 "vds_name": "vds1",
584                 "cidr": "192.168.199.0/24",
585                 "ip_version": 4,
586                 "gateway_ip": "192.168.199.1",
587                 "dhcp_enabled": False,
588                 "dns_nameservers": [
589                     "192.168.0.4",
590                     "192.168.0.10"
591                 ],
592                 "start_ip": "192.168.199.2",
593                 "end_ip": "192.168.199.254",
594                 "host_routes": [
595                     {
596                         "destination": "10.43.26.0/24",
597                         "nexthop": "10.41.23.1"
598                     }
599                 ],
600                 "location_info": {
601                     "vimid": "vimid_1",
602                     "tenant": "tenantname_1"
603                 },
604                 "cloud_type": "IaaS"
605             },
606             "route_id": "router01",
607             "route_external": False
608         }
609     ],
610     'cps': [
611         {
612             "cp_id": "cpId1",
613             "description": "",
614             "properties": {
615                 "name": "",
616                 "mac_address": "00:d9:00:82:11:e1",
617                 "ip_address:": "192.168.1.21",
618                 "ip_range_start": "192.168.1.20",
619                 "ip_range_end": "192.168.1.29",
620                 "floating_ip_address": {
621                     "external_network": "extnet01",
622                     "ip_address": "10.43.53.23"
623                 },
624                 "service_ip_address": "192.168.1.23",
625                 "order": 1,
626                 "bandwidth": 1000,
627                 "vnic_type": "normal",
628                 "allowed_address_pairs": [
629                     {
630                         "ip": "192.168.1.13",
631                         "mac": "00:f3:43:20:a2:a3"
632                     }
633                 ],
634                 "bond": "none",
635                 "bond_index": 1,
636                 "macbond": "00:d9:00:82:11:d1",
637                 "sfc_encapsulation": "",
638                 "direction": "",
639                 "gateway_ip": "192.168.199.1",
640                 "netmask": "255.255.255.0",
641                 "interface_name": "fe-01-02",
642                 "is_virtual": False,
643                 "function": "control"
644             },
645             "vl_id": "vldId1",
646             "vdu_id": "vdu1Id"
647         }
648     ],
649     'local_storages': [
650
651     ],
652 }
653
654 c1_data_get_tenant_id = {  # get_tenant_id
655     "tenants": [
656         {
657             "id": "1",
658             "name": "tenantname_1"
659         }
660     ]
661 }
662 c2_data_create_volume = {
663     "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
664     "name": "volume1",
665     "returnCode": 1,
666     "vimId": "vim_volume_1",
667     "vimName": "vim_volume_1",
668     "tenantId": "vim_volume_1",
669     "volumeType": "123",
670     "availabilityZone": "availabilityZone",
671     "status": "availuable",
672     "createTime": "2015-12-02T06:39:40.000000",
673     "type": None,
674     "size": 40
675 }
676 c3_data_get_volume = {  # get_volume
677     "status": "available",
678     "name": "wangsong",
679     "attachments": [
680         {
681             "device": "/dev/vdc",
682             "serverId": "3030e666-528e-4954-88f5-cc21dab1262b",
683             "volumeId": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
684             "hostName": None,
685             "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31"
686         }
687     ],
688     "createTime": "2015-12-02T06:39:40.000000",
689     "type": None,
690     "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
691     "size": 40
692 }
693 c4_data_create_network = {  # create_network
694     "returnCode": 0,
695     "vimId": "11111",
696     "vimName": "11111",
697     "status": "ACTIVE",
698     "id": "3c9eebdbbfd345658269340b9ea6fb73",
699     "name": "net1",
700     "tenantId": "tenant1",
701     "networkName": "ommnet",
702     "shared": True,
703     "vlanTransparent": True,
704     "networkType": "vlan",
705     "segmentationId": 202,
706     "physicalNetwork": "ctrl",
707     "routerExternal": False
708 }
709 c5_data_create_subnet = {
710     "returnCode": 0,
711     "vimId": "11111",
712     "vimName": "11111",
713     "status": " ACTIVE",
714     "id": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
715     "tenantId": "tenant1",
716     "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
717     "networkName": "networkName",
718     "name": "subnet1",
719     "cidr": "10.43.35.0/24",
720     "ipVersion": 4,
721     "enableDhcp": 1,
722     "gatewayIp": "10.43.35.1",
723     "dnsNameservers": [],
724     "allocationPools": [
725         {
726             "start": "192.168.199.2",
727             "end": "192.168.199.254"
728         }
729     ],
730     "hostRoutes": []
731 }
732 c6_data_create_port = {
733     "returnCode": 0,
734     "vimId": "11111",
735     "vimName": "11111",
736     "status": " ACTIVE",
737     "id": " 872019d3-bc6e-4319-9c1d-6722fc136afg",
738     "tenantId": "tenant1",
739     "name": "subnet1",
740     "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
741     "networkName": "networkName",
742     "subnetId": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
743     "subnetName": "subnet1",
744     "macAddress": "212.12.61.23",
745     "ip": "10.43.38.11",
746     "vnicType": "normal",
747     "securityGroups": ""
748 }
749 c7_data_create_flavor ={
750     "returnCode": 0,
751     "vimId": "11111",
752     "vimName": "11111",
753     "id": "142019d3-bc6e-4319-9c1d-6722fc136afg",
754     "tenantId": "tenant1",
755     "name": "subnet1",
756     "vcpu": 5,
757     "memory": 2,
758     "disk": 40,
759     "ephemeral": 40,
760     "swap": 20,
761     "isPublic": True,
762     "extraSpecs": "testtt"
763 }
764
765 c8_data_list_image = {
766     "vimid": "",
767     "vimname": "",
768     "imageList": [
769         {
770             "status": "active",
771             "id": "5e2757c1-f846-4727-915c-9a872553ed75",
772             "size": 862016,
773             "name": u'sss.vmdk'
774         }
775     ]
776 }
777 c9_data_create_vm = {
778     "returnCode": 1,
779     "id": "3c9eebdbbfd345658269340b9ea6fb73",
780     "name": "vm1",
781     "vimId": "11111",
782     "vimName": "11111",
783     "tenantId": "tenant1",
784     "boot": "boot_1",
785     "nicArray": "dfdf",
786     "volumeArray": "dfdf",
787     "availabilityZone": "fdvfdv",
788     "flavorId": "fdvfdv",
789     "metadata": "fdvfdv",
790     "securityGroups": "fdvfdv",
791     "serverGroup": "fdvfdv",
792     "status": "ACTIVE"
793 }
794 c10_data_get_vm = {
795     "returnCode": 1,
796     "id": "3c9eebdbbfd345658269340b9ea6fb73",
797     "name": "vm1",
798     "vimId": "11111",
799     "vimName": "11111",
800     "tenantId": "tenant1",
801     "status": "ACTIVE"
802 }