1 # Copyright 2017 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 from lcm.pub.utils.jobutil import enum
18 VNF_STATUS = enum(NULL='null', INSTANTIATING="instantiating", INACTIVE='inactive', ACTIVE="active",
19 FAILED="failed", TERMINATING="terminating", SCALING="scaling", OPERATING="operating",
20 UPDATING="updating", HEALING="healing")
22 RESOURCE_MAP = {'Storage': 'volumn', 'Network': 'network', 'SubNetwork': 'subnet', 'Port': 'port',
23 'Flavour': 'flavor', 'Vm': 'vm'}
25 ROOT_URI = "api/vnflcm/v1/subscriptions/"
27 AUTH_TYPES = ["BASIC", "OAUTH2_CLIENT_CREDENTIALS", "TLS_CERT"]
31 OAUTH2_CLIENT_CREDENTIALS = "OAUTH2_CLIENT_CREDENTIALS"
33 LCCNNOTIFICATION = "VnfLcmOperationOccurrenceNotification"
36 "flavourId": "flavour_1",
37 "instantiationLevelId": "instantiationLevel_1",
40 "id": "extVirtualLink_1",
41 "vimConnectionId": "vimConnection_1",
42 "resourceProviderId": "resourceProvider_1",
43 "resourceId": "resource_1",
44 "resourceSubnetId": "resourceSubnet_1",
50 "cpInstanceId": "cpInstance_1",
51 "linkPortId": "linkPort_1",
54 "layerProtocol": "IP_OVER_ETHERNET",
56 "macAddress": "00:f3:43:20:a2:a3",
60 "fixedAddresses": ["192.168.104.2", ],
61 "numDynamicAddresses": 0,
63 "subnetId": "subnet_1",
75 "id": "extLinkPort_1",
77 "vimConnectionId": "vimConnection_1",
78 "resourceProviderId": "resourceProvider_1",
79 "resourceId": "resource_1",
80 "vimLevelResourceType": "vimLevelResourceType_1",
86 "extManagedVirtualLinks": [
88 "id": 'extManagedVirtualLink_1',
89 "virtualLinkDescId": 'virtualLinkDesc_1',
90 "vimConnectionId": 'vimConnection_1',
91 "resourceProviderId": 'resourceProvider_1',
92 "resourceId": 'resource_1',
95 "vimConnectionInfo": [
97 "id": 'vimConnection_1',
101 "apiVersion": "apiVersion_1",
102 "protocolType": "http"
105 "tenant": "tenant_vCPE",
107 "password": "vCPE_321",
112 "localizationLanguage": "en_US",
113 "additionalParams": {
126 'domain_type': u'CN',
127 'version': u'v4.14.10',
128 'vmnumber_overquota_alarm': False,
131 'vnfd_version': u'V00000001',
132 'id': u'sss-vnf-template',
133 'name': u'sss-vnf-template'
138 "description": "vdu description",
140 "name": "vduinstname",
143 "support_scaling": True,
146 "tenant": "tenantname",
147 "availability_zone": "zone1",
150 "local_affinity_antiaffinity_rule": [
152 "affinity_antiaffinity": "anti-affinity",
156 "affinity_antiaffinity": "affinity",
160 "inject_data_list": [
162 "file_name": "abc.xml",
163 "file_data": "<a>xxx</a><b>ssss</b>"
166 "storage_policy": "HIGH",
168 "manual_scale_select_vim": False,
170 "enabledelay": 600000,
173 "is_predefined": False,
174 "allow_scale_updown": False,
175 "inject_network_address": True,
176 "inner_hugepage_num": 100,
177 "inner_hugepage_size": "2048",
180 "image_file": u'sss',
187 "volume_storage_id": "volume_storage1",
188 "location": "/usr/data",
189 "device": "/dev/hda1"
199 "cpu_frequency": "1GHz",
200 "flavor_extra_specs": {
201 "hw: cpu_policy": "shared",
202 "hw: cpu_max_threads": 50,
203 "hw: cpu_sockets": 10,
204 "hw: cpu_max_sockets": 20,
205 "hw: cpu_max_cores": 8,
206 "hw: cpu_threads": 30,
207 "hw: numa_mem.0": 12288,
208 "hw: hugepage_num": 100,
209 "hw: high_performance": "dvs_high",
211 "hw: numa_cpus.0": "2,4,8",
212 "hw: numa_pci": True,
214 "pci_passthrough: alias": "ColetoCreek: 1",
215 "hw: mem_page_size": "large",
216 "hw: mem_paging_mechanism": "EPT"
228 "default_instances": 1
233 "implementation": "<implementationScript>",
235 "param1Name": "value1",
236 "paramNName": "valueN"
240 "implementation": "<implementationScript>",
242 "param1Name": "value1",
243 "paramNName": "valueN"
247 "implementation": "<implementationScript>",
249 "param1Name": "value1",
250 "paramNName": "valueN"
254 "implementation": "<implementationScript>",
256 "param1Name": "value1",
257 "paramNName": "valueN"
261 "implementation": "<implementationScript>",
263 "param1Name": "value1",
264 "paramNName": "valueN"
271 "artifact_name": "software_version_file",
272 "type": "tosca.artifacts.Deployment",
273 "file": "AppSoftwares/zte-cn-xgw-V5.16.11_NFV-version.zip",
282 "volume_storage_id": "volume_storage1",
287 "volume_name": "volumeStorage1",
288 "custom_volume_type": "type1",
290 "delete_on_termination_vm": True,
293 "tenant": "tenantname_1",
294 "availability_zone": "zone1"
296 "is_predefined": False,
309 'policy_id': u'policy_scale_sss-vnf-template',
311 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
320 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
322 'disk_format': u'VMDK',
323 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
324 'container_type': 'vm',
326 'hypervisor_type': 'kvm'
328 'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
335 'disk_format': u'VMDK',
336 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
337 'container_type': 'vm',
339 'hypervisor_type': 'kvm'
341 'image_file_id': u'sss'
349 "name": "umac_241_control",
350 "network_name": "umac_control",
351 "is_predefined": False,
353 "netmask": "255.255.255.0",
355 "network_type": "vlan",
356 "physical_network": "phynet01",
357 "segmentation_id": "30",
358 "vlan_transparent": False,
360 "cidr": "192.168.199.0/24",
362 "gateway_ip": "192.168.199.1",
363 "dhcp_enabled": False,
368 "start_ip": "192.168.199.2",
369 "end_ip": "192.168.199.254",
372 "destination": "10.43.26.0/24",
373 "nexthop": "10.41.23.1"
378 "tenant": "tenantname_1"
382 "route_id": "router01",
383 "route_external": False
392 "mac_address": "00:d9:00:82:11:e1",
393 "ip_address:": "192.168.1.21",
394 "ip_range_start": "192.168.1.20",
395 "ip_range_end": "192.168.1.29",
396 "floating_ip_address": {
397 "external_network": "extnet01",
398 "ip_address": "10.43.53.23"
400 "service_ip_address": "192.168.1.23",
403 "vnic_type": "normal",
404 "allowed_address_pairs": [
406 "ip": "192.168.1.13",
407 "mac": "00:f3:43:20:a2:a3"
412 "macbond": "00:d9:00:82:11:d1",
413 "sfc_encapsulation": "",
415 "gateway_ip": "192.168.199.1",
416 "netmask": "255.255.255.0",
417 "interface_name": "fe-01-02",
419 "function": "control"
431 c1_data_get_tenant_id = {
435 "name": "chinamobile"
441 c2_data_create_volume = {
442 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
445 "vimId": "vim_volume_1",
446 "vimName": "vim_volume_1",
447 "tenantId": "vim_volume_1",
449 "availabilityZone": "availabilityZone",
450 "status": "availuable",
451 "createTime": "2015-12-02T06:39:40.000000",
457 c3_data_get_volume = {
458 "status": "available",
462 "device": "/dev/vdc",
463 "serverId": "3030e666-528e-4954-88f5-cc21dab1262b",
464 "volumeId": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
466 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31"
469 "createTime": "2015-12-02T06:39:40.000000",
471 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
476 c4_data_create_network = {
481 "id": "3c9eebdbbfd345658269340b9ea6fb73",
483 "tenantId": "tenant1",
484 "networkName": "ommnet",
486 "vlanTransparent": True,
487 "networkType": "vlan",
488 "segmentationId": 202,
489 "physicalNetwork": "ctrl",
490 "routerExternal": False
494 c5_data_create_subnet = {
499 "id": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
500 "tenantId": "tenant1",
501 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
502 "networkName": "networkName",
504 "cidr": "10.43.35.0/24",
507 "gatewayIp": "10.43.35.1",
508 "dnsNameservers": [],
511 "start": "192.168.199.2",
512 "end": "192.168.199.254"
519 c6_data_create_port = {
524 "id": " 872019d3-bc6e-4319-9c1d-6722fc136afg",
525 "tenantId": "tenant1",
527 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
528 "networkName": "networkName",
529 "subnetId": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
530 "subnetName": "subnet1",
531 "macAddress": "212.12.61.23",
533 "vnicType": "normal",
538 c7_data_create_flavor = {
542 "id": "142019d3-bc6e-4319-9c1d-6722fc136afg",
543 "tenantId": "tenant1",
551 "extraSpecs": "testtt"
555 c8_data_list_image = {
561 "id": "5e2757c1-f846-4727-915c-9a872553ed75",
569 c9_data_create_vm = {
571 "id": "3c9eebdbbfd345658269340b9ea6fb73",
575 "tenantId": "tenant1",
578 "volumeArray": "dfdf",
579 "availabilityZone": "fdvfdv",
580 "flavorId": "fdvfdv",
581 "metadata": "fdvfdv",
582 "securityGroups": "fdvfdv",
583 "serverGroup": "fdvfdv",
590 "id": "3c9eebdbbfd345658269340b9ea6fb73",
594 "tenantId": "tenant1",
601 "volume_storage_id": "test",
605 "tenant": "chinamobile",
606 "availability_zone": "test",
608 "volume_name": "test",
609 "custom_volume_type": "test",
612 "image_file": "test",
621 "tenant": "chinamobile",
624 "networkName": "test",
625 "networkType": "test",
626 "physicalNetwork": "test",
627 "vlanTransparent": "test",
628 "segmentationId": "1",
630 "dhcpEnabled": "test",
635 "connectivity_type": {
636 "layer_protocol": "ipv4",
638 "dns_nameservers": "test",
639 "host_routes": "test",
641 "route_external": "test",
648 "networkId": "", # TODO
649 "subnetId": "", # TODO
653 "mac_address": "test",
658 "fixed_ip_address": "test"
673 "tenant": "chinamobile",
674 "availability_zone": "test",
682 "type": "tosca.nodes.nfv.Vdu.Compute",
685 "num_virtual_cpu": "16",
688 "virtual_mem_size": "8000 MB",
689 "vdu_memory_requirements": {
690 "memoryPageSize": "8 MB",
695 "type_of_storage": "ephemeral",
696 "size_of_storage": "10 GB",
698 "type": "tosca.nodes.nfv.Vdu.Compute",
701 "artifact_name": "sw_image",
707 "volume_storage_id": "test",
714 "local_storages": [],
722 "description": "pe1_idofunderlayvpn"
726 "description": "pe2_idofunderlayvpn"
730 "description": "serviceTypeofunderlayvpn"
734 "description": "descriptionofunderlayvpn"
738 "description": "ac2_routeofunderlayvpn"
742 "description": "ac1_routeofunderlayvpn"
746 "description": "ac1_svlanofunderlayvpn"
750 "description": "ac2_ipofunderlayvpn"
754 "description": "ac1_ipofunderlayvpn"
758 "description": "ac2_portofunderlayvpn"
762 "description": "topologyofunderlayvpn"
766 "description": "technologyofunderlayvpn"
770 "description": "ac1_portofunderlayvpn"
774 "description": "ac2_svlanofunderlayvpn"
778 "description": "Nameofunderlayervpn"
783 "name": "underlayervpn",
784 "csarVersion": "1.0",
786 "csarProvider": "huawei",
789 "id": "ns_underlayervpn_1_0"
795 "csarId": "vOpenNAT",
797 "csarName": "vOpenNAT.csar",
798 "vnfdModel": json.dumps(vnfdModel),
799 "vnfdProvider": "Intel",
800 "vnfdId": "openNAT_1.0",
801 "downloadUrl": "http://10.96.33.39:8806/static/catalog/vOpenNAT/vOpenNAT.csar",
802 "vnfVersion": "v1.0",
803 "vnfdVersion": "v1.0",
804 "vnfPackageId": "vOpenNAT"
813 # "designer": "sdno",
814 # "name": "underlayervpn",
815 # "csarVersion": "1.0",
816 # "csarType": "SSAR",
817 # "csarProvider": "huawei",
820 # "id": "ns_underlayervpn_1_0"
824 # "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
825 # "type_name": "tosca.nodes.sdn.l3ac",
826 # "template_name": "ac2",
829 # "type_name": "string"
832 # "type_name": "string"
835 # "type_name": "string"
838 # "type_name": "string"
843 # "name": "Standard",
844 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
850 # "type_name": "tosca.capabilities.Node"
854 # "type_name": "tosca.capabilities.sdn.ac"
859 # "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
860 # "target_capability_name": "feature"
863 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
864 # "target_capability_name": "feature"
869 # "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
870 # "type_name": "tosca.nodes.sdn.l3ac",
871 # "template_name": "ac1",
874 # "type_name": "string"
877 # "type_name": "string"
880 # "type_name": "string"
883 # "type_name": "string"
888 # "name": "Standard",
889 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
895 # "type_name": "tosca.capabilities.Node"
899 # "type_name": "tosca.capabilities.sdn.ac"
904 # "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
905 # "target_capability_name": "feature"
908 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
909 # "target_capability_name": "feature"
914 # "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
915 # "type_name": "tosca.nodes.sdn.underlayVPN",
916 # "template_name": "vpn",
919 # "type_name": "string"
922 # "type_name": "string"
925 # "type_name": "string"
928 # "type_name": "string"
933 # "name": "Standard",
934 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
940 # "type_name": "tosca.capabilities.Node"
945 # "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
946 # "target_capability_name": "feature"
949 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
950 # "target_capability_name": "feature"
955 # "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
956 # "type_name": "tosca.nodes.sdn.l3pe",
957 # "template_name": "pe1",
960 # "type_name": "string"
965 # "name": "Standard",
966 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
972 # "type_name": "tosca.capabilities.Node"
976 # "type_name": "tosca.capabilities.sdn.pe"
981 # "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
982 # "type_name": "tosca.nodes.sdn.l3pe",
983 # "template_name": "pe2",
986 # "type_name": "string"
991 # "name": "Standard",
992 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
998 # "type_name": "tosca.capabilities.Node"
1002 # "type_name": "tosca.capabilities.sdn.pe"
1008 # "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
1012 # "type_name": "string",
1013 # "description": "ac2_ipofunderlayvpn"
1016 # "type_name": "string",
1017 # "description": "ac2_routeofunderlayvpn"
1020 # "type_name": "string",
1021 # "description": "serviceTypeofunderlayvpn"
1024 # "type_name": "string",
1025 # "description": "descriptionofunderlayvpn"
1028 # "type_name": "string",
1029 # "description": "pe2_idofunderlayvpn"
1032 # "type_name": "string",
1033 # "description": "ac1_routeofunderlayvpn"
1036 # "type_name": "integer",
1037 # "description": "ac1_svlanofunderlayvpn"
1040 # "type_name": "string",
1041 # "description": "Nameofunderlayervpn"
1044 # "type_name": "string",
1045 # "description": "ac1_ipofunderlayvpn"
1048 # "type_name": "string",
1049 # "description": "ac2_portofunderlayvpn"
1052 # "type_name": "string",
1053 # "description": "pe1_idofunderlayvpn"
1056 # "type_name": "string",
1057 # "description": "technologyofunderlayvpn"
1060 # "type_name": "string",
1061 # "description": "ac1_portofunderlayvpn"
1064 # "type_name": "integer",
1065 # "description": "ac2_svlanofunderlayvpn"
1068 # "type_name": "string",
1069 # "description": "topologyofunderlayvpn"