Refactor code of apply_grant
[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 vnfd_rawdata = {
22     "rawData": {
23         "instance": {
24             "metadata": {
25                 "designer": "sdno",
26                 "name": "underlayervpn",
27                 "csarVersion": "1.0",
28                 "csarType": "SSAR",
29                 "csarProvider": "huawei",
30                 "version": "1.0",
31                 "type": "SSAR",
32                 "id": "ns_underlayervpn_1_0"
33             },
34             "nodes": [
35                 {
36                     "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
37                     "type_name": "tosca.nodes.sdn.l3ac",
38                     "template_name": "ac2",
39                     "properties": {
40                         "ip": {
41                             "type_name": "string"
42                         },
43                         "route": {
44                             "type_name": "string"
45                         },
46                         "port": {
47                             "type_name": "string"
48                         },
49                         "svlan": {
50                             "type_name": "string"
51                         }
52                     },
53                     "interfaces": [
54                         {
55                             "name": "Standard",
56                             "type_name": "tosca.interfaces.node.lifecycle.Standard"
57                         }
58                     ],
59                     "capabilities": [
60                         {
61                             "name": "feature",
62                             "type_name": "tosca.capabilities.Node"
63                         },
64                         {
65                             "name": "ac",
66                             "type_name": "tosca.capabilities.sdn.ac"
67                         }
68                     ],
69                     "relationships": [
70                         {
71                             "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
72                             "target_capability_name": "feature"
73                         },
74                         {
75                             "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
76                             "target_capability_name": "feature"
77                         }
78                     ]
79                 },
80                 {
81                     "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
82                     "type_name": "tosca.nodes.sdn.l3ac",
83                     "template_name": "ac1",
84                     "properties": {
85                         "ip": {
86                             "type_name": "string"
87                         },
88                         "route": {
89                             "type_name": "string"
90                         },
91                         "port": {
92                             "type_name": "string"
93                         },
94                         "svlan": {
95                             "type_name": "string"
96                         }
97                     },
98                     "interfaces": [
99                         {
100                             "name": "Standard",
101                             "type_name": "tosca.interfaces.node.lifecycle.Standard"
102                         }
103                     ],
104                     "capabilities": [
105                         {
106                             "name": "feature",
107                             "type_name": "tosca.capabilities.Node"
108                         },
109                         {
110                             "name": "ac",
111                             "type_name": "tosca.capabilities.sdn.ac"
112                         }
113                     ],
114                     "relationships": [
115                         {
116                             "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
117                             "target_capability_name": "feature"
118                         },
119                         {
120                             "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
121                             "target_capability_name": "feature"
122                         }
123                     ]
124                 },
125                 {
126                     "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
127                     "type_name": "tosca.nodes.sdn.underlayVPN",
128                     "template_name": "vpn",
129                     "properties": {
130                         "serviceType": {
131                             "type_name": "string"
132                         },
133                         "description": {
134                             "type_name": "string"
135                         },
136                         "name": {
137                             "type_name": "string"
138                         },
139                         "topology": {
140                             "type_name": "string"
141                         }
142                     },
143                     "interfaces": [
144                         {
145                             "name": "Standard",
146                             "type_name": "tosca.interfaces.node.lifecycle.Standard"
147                         }
148                     ],
149                     "capabilities": [
150                         {
151                             "name": "feature",
152                             "type_name": "tosca.capabilities.Node"
153                         }
154                     ],
155                     "relationships": [
156                         {
157                             "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
158                             "target_capability_name": "feature"
159                         },
160                         {
161                             "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
162                             "target_capability_name": "feature"
163                         }
164                     ]
165                 },
166                 {
167                     "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
168                     "type_name": "tosca.nodes.sdn.l3pe",
169                     "template_name": "pe1",
170                     "properties": {
171                         "id": {
172                             "type_name": "string"
173                         }
174                     },
175                     "interfaces": [
176                         {
177                             "name": "Standard",
178                             "type_name": "tosca.interfaces.node.lifecycle.Standard"
179                         }
180                     ],
181                     "capabilities": [
182                         {
183                             "name": "feature",
184                             "type_name": "tosca.capabilities.Node"
185                         },
186                         {
187                             "name": "pe",
188                             "type_name": "tosca.capabilities.sdn.pe"
189                         }
190                     ]
191                 },
192                 {
193                     "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
194                     "type_name": "tosca.nodes.sdn.l3pe",
195                     "template_name": "pe2",
196                     "properties": {
197                         "id": {
198                             "type_name": "string"
199                         }
200                     },
201                     "interfaces": [
202                         {
203                             "name": "Standard",
204                             "type_name": "tosca.interfaces.node.lifecycle.Standard"
205                         }
206                     ],
207                     "capabilities": [
208                         {
209                             "name": "feature",
210                             "type_name": "tosca.capabilities.Node"
211                         },
212                         {
213                             "name": "pe",
214                             "type_name": "tosca.capabilities.sdn.pe"
215                         }
216                     ]
217                 }
218             ],
219             "substitution": {
220                 "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
221             },
222             "inputs": {
223                 "ac2_ip": {
224                     "type_name": "string",
225                     "description": "ac2_ipofunderlayvpn"
226                 },
227                 "ac2_route": {
228                     "type_name": "string",
229                     "description": "ac2_routeofunderlayvpn"
230                 },
231                 "serviceType": {
232                     "type_name": "string",
233                     "description": "serviceTypeofunderlayvpn"
234                 },
235                 "description": {
236                     "type_name": "string",
237                     "description": "descriptionofunderlayvpn"
238                 },
239                 "pe2_id": {
240                     "type_name": "string",
241                     "description": "pe2_idofunderlayvpn"
242                 },
243                 "ac1_route": {
244                     "type_name": "string",
245                     "description": "ac1_routeofunderlayvpn"
246                 },
247                 "ac1_svlan": {
248                     "type_name": "integer",
249                     "description": "ac1_svlanofunderlayvpn"
250                 },
251                 "name": {
252                     "type_name": "string",
253                     "description": "Nameofunderlayervpn"
254                 },
255                 "ac1_ip": {
256                     "type_name": "string",
257                     "description": "ac1_ipofunderlayvpn"
258                 },
259                 "ac2_port": {
260                     "type_name": "string",
261                     "description": "ac2_portofunderlayvpn"
262                 },
263                 "pe1_id": {
264                     "type_name": "string",
265                     "description": "pe1_idofunderlayvpn"
266                 },
267                 "technology": {
268                     "type_name": "string",
269                     "description": "technologyofunderlayvpn"
270                 },
271                 "ac1_port": {
272                     "type_name": "string",
273                     "description": "ac1_portofunderlayvpn"
274                 },
275                 "ac2_svlan": {
276                     "type_name": "integer",
277                     "description": "ac2_svlanofunderlayvpn"
278                 },
279                 "topology": {
280                     "type_name": "string",
281                     "description": "topologyofunderlayvpn"
282                 }
283             }
284         }
285     }
286 }
287
288
289 vnfd_model_dict = {
290     'local_storages': [],
291     'vdus': [
292         {
293             'volumn_storages': [],
294             'nfv_compute': {
295                 'mem_size': '',
296                 'num_cpus': u'2'},
297             'local_storages': [],
298             'vdu_id': u'vdu_omm.001',
299             'image_file': u'opencos_sss_omm_img_release_20150723-1-disk1',
300             'dependencies': [],
301             'vls': [],
302             'cps': [],
303             'properties': {
304                 'key_vdu': '',
305                 'support_scaling': False,
306                 'vdu_type': '',
307                 'name': '',
308                 'storage_policy': '',
309                 'location_info': {
310                     'vimId': '',
311                     'availability_zone': '',
312                     'region': '',
313                     'dc': '',
314                     'host': '',
315                     'tenant': ''},
316                 'inject_data_list': [],
317                 'watchdog': {
318                     'action': '',
319                     'enabledelay': ''},
320                 'local_affinity_antiaffinity_rule': {},
321                 'template_id': u'omm.001',
322                 'manual_scale_select_vim': False},
323             'description': u'singleommvm'},
324         {
325             'volumn_storages': [],
326             'nfv_compute': {
327                 'mem_size': '',
328                 'num_cpus': u'4'},
329             'local_storages': [],
330             'vdu_id': u'vdu_1',
331             'image_file': u'sss',
332             'dependencies': [],
333             'vls': [],
334             'cps': [],
335             'properties': {
336                 'key_vdu': '',
337                 'support_scaling': False,
338                 'vdu_type': '',
339                 'name': '',
340                 'storage_policy': '',
341                 'location_info': {
342                     'vimId': '',
343                     'availability_zone': '',
344                     'region': '',
345                     'dc': '',
346                     'host': '',
347                     'tenant': ''},
348                 'inject_data_list': [],
349                 'watchdog': {
350                     'action': '',
351                     'enabledelay': ''},
352                 'local_affinity_antiaffinity_rule': {},
353                 'template_id': u'1',
354                 'manual_scale_select_vim': False},
355             'description': u'ompvm'},
356         {
357             'volumn_storages': [],
358             'nfv_compute': {
359                 'mem_size': '',
360                 'num_cpus': u'14'},
361             'local_storages': [],
362             'vdu_id': u'vdu_2',
363             'image_file': u'sss',
364             'dependencies': [],
365             'vls': [],
366             'cps': [],
367             'properties': {
368                 'key_vdu': '',
369                 'support_scaling': False,
370                 'vdu_type': '',
371                 'name': '',
372                 'storage_policy': '',
373                 'location_info': {
374                     'vimId': '',
375                     'availability_zone': '',
376                     'region': '',
377                     'dc': '',
378                     'host': '',
379                     'tenant': ''},
380                 'inject_data_list': [],
381                 'watchdog': {
382                     'action': '',
383                     'enabledelay': ''},
384                 'local_affinity_antiaffinity_rule': {},
385                 'template_id': u'2',
386                 'manual_scale_select_vim': False},
387             'description': u'ompvm'},
388         {
389             'volumn_storages': [],
390             'nfv_compute': {
391                 'mem_size': '',
392                 'num_cpus': u'14'},
393             'local_storages': [],
394             'vdu_id': u'vdu_3',
395             'image_file': u'sss',
396             'dependencies': [],
397             'vls': [],
398             'cps': [],
399             'properties': {
400                 'key_vdu': '',
401                 'support_scaling': False,
402                 'vdu_type': '',
403                 'name': '',
404                 'storage_policy': '',
405                 'location_info': {
406                     'vimId': '',
407                     'availability_zone': '',
408                     'region': '',
409                     'dc': '',
410                     'host': '',
411                     'tenant': ''},
412                 'inject_data_list': [],
413                 'watchdog': {
414                     'action': '',
415                     'enabledelay': ''},
416                 'local_affinity_antiaffinity_rule': {},
417                 'template_id': u'3',
418                 'manual_scale_select_vim': False},
419             'description': u'ompvm'},
420         {
421             'volumn_storages': [],
422             'nfv_compute': {
423                 'mem_size': '',
424                 'num_cpus': u'4'},
425             'local_storages': [],
426             'vdu_id': u'vdu_10',
427             'image_file': u'sss',
428             'dependencies': [],
429             'vls': [],
430             'cps': [],
431             'properties': {
432                 'key_vdu': '',
433                 'support_scaling': False,
434                 'vdu_type': '',
435                 'name': '',
436                 'storage_policy': '',
437                 'location_info': {
438                     'vimId': '',
439                     'availability_zone': '',
440                     'region': '',
441                     'dc': '',
442                     'host': '',
443                     'tenant': ''},
444                 'inject_data_list': [],
445                 'watchdog': {
446                     'action': '',
447                     'enabledelay': ''},
448                 'local_affinity_antiaffinity_rule': {},
449                 'template_id': u'10',
450                 'manual_scale_select_vim': False},
451             'description': u'ppvm'},
452         {
453             'volumn_storages': [],
454             'nfv_compute': {
455                 'mem_size': '',
456                 'num_cpus': u'14'},
457             'local_storages': [],
458             'vdu_id': u'vdu_11',
459             'image_file': u'sss',
460             'dependencies': [],
461             'vls': [],
462             'cps': [],
463             'properties': {
464                 'key_vdu': '',
465                 'support_scaling': False,
466                 'vdu_type': '',
467                 'name': '',
468                 'storage_policy': '',
469                 'location_info': {
470                     'vimId': '',
471                     'availability_zone': '',
472                     'region': '',
473                     'dc': '',
474                     'host': '',
475                     'tenant': ''},
476                 'inject_data_list': [],
477                 'watchdog': {
478                     'action': '',
479                     'enabledelay': ''},
480                 'local_affinity_antiaffinity_rule': {},
481                 'template_id': u'11',
482                 'manual_scale_select_vim': False},
483             'description': u'ppvm'},
484         {
485             'volumn_storages': [],
486             'nfv_compute': {
487                 'mem_size': '',
488                 'num_cpus': u'14'},
489             'local_storages': [],
490             'vdu_id': u'vdu_12',
491             'image_file': u'sss',
492             'dependencies': [],
493             'vls': [],
494             'cps': [],
495             'properties': {
496                 'key_vdu': '',
497                 'support_scaling': False,
498                 'vdu_type': '',
499                 'name': '',
500                 'storage_policy': '',
501                 'location_info': {
502                     'vimId': '',
503                     'availability_zone': '',
504                     'region': '',
505                     'dc': '',
506                     'host': '',
507                     'tenant': ''},
508                 'inject_data_list': [],
509                 'watchdog': {
510                     'action': '',
511                     'enabledelay': ''},
512                 'local_affinity_antiaffinity_rule': {},
513                 'template_id': u'12',
514                 'manual_scale_select_vim': False},
515             'description': u'ppvm'}],
516     'volumn_storages': [],
517     'policies': {
518         'scaling': {
519             'targets': {},
520             'policy_id': u'policy_scale_sss-vnf-template',
521             'properties': {
522                 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'},
523             'description': ''}},
524     'image_files': [
525         {
526             'description': '',
527             'properties': {
528                 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
529                 'checksum': '',
530                 'disk_format': u'VMDK',
531                 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
532                 'container_type': 'vm',
533                 'version': '',
534                 'hypervisor_type': 'kvm'},
535             'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'},
536         {
537             'description': '',
538             'properties': {
539                 'name': u'sss.vmdk',
540                 'checksum': '',
541                 'disk_format': u'VMDK',
542                 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
543                 'container_type': 'vm',
544                 'version': '',
545                 'hypervisor_type': 'kvm'},
546             'image_file_id': u'sss'}],
547     'vls': [],
548     'cps': [],
549     'metadata': {
550         'vendor': u'zte',
551         'is_shared': False,
552         'description': '',
553         'domain_type': u'CN',
554         'version': u'v4.14.10',
555         'vmnumber_overquota_alarm': False,
556         'cross_dc': False,
557         'vnf_type': u'SSS',
558         'vnfd_version': u'V00000001',
559         'id': u'sss-vnf-template',
560         'name': u'sss-vnf-template'},
561     "flavourId": "flavour_1",
562     "instantiationLevelId": "instantiationLevel_1",
563     "extVirtualLinks": [
564         {
565             "vlInstanceId": "1",
566             "vim": {
567                 "vimInfoId": "1",
568                 "vimId": "1",
569                 "interfaceInfo": {
570                     "vimType": "vim",
571                     "apiVersion": "v2",
572                     "protocolType": "http"
573                 },
574                 "accessInfo": {
575                     "tenant": "tenant_vCPE",
576                     "username": "vCPE",
577                     "password": "vCPE_321"
578                 },
579                 "interfaceEndpoint": "http://10.43.21.105:80/"
580             },
581             "resourceId": "1246",
582             "extCps": [
583                 {
584                     "cpdId": "11",
585                     "addresses": [
586                         {
587                             "addressType": "MAC",
588                             "l2AddressData": "00:f3:43:20:a2:a3"
589                         },
590                         {
591                             "addressType": "IP",
592                             "l3AddressData": {
593                                 "iPAddressType": "IPv4",
594                                 "iPAddress": "192.168.104.2"
595                             }
596                         }
597                     ],
598                     "numDynamicAddresses": 0
599                 }
600             ]
601         }
602     ],
603     "localizationLanguage": "en_US",
604     "additionalParams": {}
605 }