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 HEAL_ACTION_TYPE = enum(START="vmCreate", RESTART="vmReset")
19 ACTION_TYPE = enum(START=1, STOP=2, REBOOT=3)
20 GRANT_TYPE = enum(INSTANTIATE="INSTANTIATE", TERMINATE="TERMINATE", HEAL_CREATE="Heal Create", HEAL_RESTART="Heal Restart", OPERATE="OPERATE")
21 VNF_STATUS = enum(NULL='null', INSTANTIATING="instantiating", INACTIVE='inactive', ACTIVE="active",
22 FAILED="failed", TERMINATING="terminating", SCALING="scaling", OPERATING="operating",
23 UPDATING="updating", HEALING="healing")
25 RESOURCE_MAP = {'Storage': 'volumn', 'Network': 'network', 'SubNetwork': 'subnet', 'Port': 'port',
26 'Flavour': 'flavor', 'Vm': 'vm'}
28 ROOT_URI = "api/vnflcm/v1/subscriptions/"
30 AUTH_TYPES = ["BASIC", "OAUTH2_CLIENT_CREDENTIALS", "TLS_CERT"]
34 OAUTH2_CLIENT_CREDENTIALS = "OAUTH2_CLIENT_CREDENTIALS"
36 LCCNNOTIFICATION = "VnfLcmOperationOccurrenceNotification"
38 NOTIFICATION_TYPES = [
39 "VnfLcmOperationOccurrenceNotification",
40 "VnfIdentifierCreationNotification",
41 "VnfIdentifierDeletionNotification"
44 LCM_OPERATION_TYPES = [
56 LCM_OPERATION_STATE_TYPES = [
68 "flavourId": "flavour_1",
69 "instantiationLevelId": "instantiationLevel_1",
72 "id": "extVirtualLink_1",
73 "vimConnectionId": "vimConnection_1",
74 "resourceProviderId": "resourceProvider_1",
75 "resourceId": "resource_1",
76 "resourceSubnetId": "resourceSubnet_1",
82 "cpInstanceId": "cpInstance_1",
83 "linkPortId": "linkPort_1",
86 "layerProtocol": "IP_OVER_ETHERNET",
88 "macAddress": "00:f3:43:20:a2:a3",
92 "fixedAddresses": ["192.168.104.2", ],
93 "numDynamicAddresses": 0,
95 "subnetId": "subnet_1",
107 "id": "extLinkPort_1",
109 "vimConnectionId": "vimConnection_1",
110 "resourceProviderId": "resourceProvider_1",
111 "resourceId": "resource_1",
112 "vimLevelResourceType": "vimLevelResourceType_1",
118 "extManagedVirtualLinks": [
120 "id": 'extManagedVirtualLink_1',
121 "virtualLinkDescId": 'virtualLinkDesc_1',
122 "vimConnectionId": 'vimConnection_1',
123 "resourceProviderId": 'resourceProvider_1',
124 "resourceId": 'resource_1',
127 "vimConnectionInfo": [
129 "id": 'vimConnection_1',
133 "apiVersion": "apiVersion_1",
134 "protocolType": "http"
137 "tenant": "tenant_vCPE",
139 "password": "vCPE_321",
144 "localizationLanguage": "en_US",
145 "additionalParams": {
158 'domain_type': u'CN',
159 'version': u'v4.14.10',
160 'vmnumber_overquota_alarm': False,
163 'vnfd_version': u'V00000001',
164 'id': u'sss-vnf-template',
165 'name': u'sss-vnf-template'
170 "description": "vdu description",
172 "name": "vduinstname",
175 "support_scaling": True,
178 "tenant": "tenantname",
179 "availability_zone": "zone1",
182 "local_affinity_antiaffinity_rule": [
184 "affinity_antiaffinity": "anti-affinity",
188 "affinity_antiaffinity": "affinity",
192 "inject_data_list": [
194 "file_name": "abc.xml",
195 "file_data": "<a>xxx</a><b>ssss</b>"
198 "storage_policy": "HIGH",
200 "manual_scale_select_vim": False,
202 "enabledelay": 600000,
205 "is_predefined": False,
206 "allow_scale_updown": False,
207 "inject_network_address": True,
208 "inner_hugepage_num": 100,
209 "inner_hugepage_size": "2048",
212 "image_file": u'sss',
219 "volume_storage_id": "volume_storage1",
220 "location": "/usr/data",
221 "device": "/dev/hda1"
231 "cpu_frequency": "1GHz",
232 "flavor_extra_specs": {
233 "hw: cpu_policy": "shared",
234 "hw: cpu_max_threads": 50,
235 "hw: cpu_sockets": 10,
236 "hw: cpu_max_sockets": 20,
237 "hw: cpu_max_cores": 8,
238 "hw: cpu_threads": 30,
239 "hw: numa_mem.0": 12288,
240 "hw: hugepage_num": 100,
241 "hw: high_performance": "dvs_high",
243 "hw: numa_cpus.0": "2,4,8",
244 "hw: numa_pci": True,
246 "pci_passthrough: alias": "ColetoCreek: 1",
247 "hw: mem_page_size": "large",
248 "hw: mem_paging_mechanism": "EPT"
260 "default_instances": 1
265 "implementation": "<implementationScript>",
267 "param1Name": "value1",
268 "paramNName": "valueN"
272 "implementation": "<implementationScript>",
274 "param1Name": "value1",
275 "paramNName": "valueN"
279 "implementation": "<implementationScript>",
281 "param1Name": "value1",
282 "paramNName": "valueN"
286 "implementation": "<implementationScript>",
288 "param1Name": "value1",
289 "paramNName": "valueN"
293 "implementation": "<implementationScript>",
295 "param1Name": "value1",
296 "paramNName": "valueN"
303 "artifact_name": "software_version_file",
304 "type": "tosca.artifacts.Deployment",
305 "file": "AppSoftwares/zte-cn-xgw-V5.16.11_NFV-version.zip",
314 "volume_storage_id": "volume_storage1",
319 "volume_name": "volumeStorage1",
320 "custom_volume_type": "type1",
322 "delete_on_termination_vm": True,
325 "tenant": "tenantname_1",
326 "availability_zone": "zone1"
328 "is_predefined": False,
341 'policy_id': u'policy_scale_sss-vnf-template',
343 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
352 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
354 'disk_format': u'VMDK',
355 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
356 'container_type': 'vm',
358 'hypervisor_type': 'kvm'
360 'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
367 'disk_format': u'VMDK',
368 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
369 'container_type': 'vm',
371 'hypervisor_type': 'kvm'
373 'image_file_id': u'sss'
381 "name": "umac_241_control",
382 "network_name": "umac_control",
383 "is_predefined": False,
385 "netmask": "255.255.255.0",
387 "network_type": "vlan",
388 "physical_network": "phynet01",
389 "segmentation_id": "30",
390 "vlan_transparent": False,
392 "cidr": "192.168.199.0/24",
394 "gateway_ip": "192.168.199.1",
395 "dhcp_enabled": False,
400 "start_ip": "192.168.199.2",
401 "end_ip": "192.168.199.254",
404 "destination": "10.43.26.0/24",
405 "nexthop": "10.41.23.1"
410 "tenant": "tenantname_1"
414 "route_id": "router01",
415 "route_external": False
424 "mac_address": "00:d9:00:82:11:e1",
425 "ip_address:": "192.168.1.21",
426 "ip_range_start": "192.168.1.20",
427 "ip_range_end": "192.168.1.29",
428 "floating_ip_address": {
429 "external_network": "extnet01",
430 "ip_address": "10.43.53.23"
432 "service_ip_address": "192.168.1.23",
435 "vnic_type": "normal",
436 "allowed_address_pairs": [
438 "ip": "192.168.1.13",
439 "mac": "00:f3:43:20:a2:a3"
444 "macbond": "00:d9:00:82:11:d1",
445 "sfc_encapsulation": "",
447 "gateway_ip": "192.168.199.1",
448 "netmask": "255.255.255.0",
449 "interface_name": "fe-01-02",
451 "function": "control"
463 c1_data_get_tenant_id = {
467 "name": "chinamobile"
473 c2_data_create_volume = {
474 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
477 "vimId": "vim_volume_1",
478 "vimName": "vim_volume_1",
479 "tenantId": "vim_volume_1",
481 "availabilityZone": "availabilityZone",
482 "status": "availuable",
483 "createTime": "2015-12-02T06:39:40.000000",
489 c3_data_get_volume = {
490 "status": "available",
494 "device": "/dev/vdc",
495 "serverId": "3030e666-528e-4954-88f5-cc21dab1262b",
496 "volumeId": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
498 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31"
501 "createTime": "2015-12-02T06:39:40.000000",
503 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
508 c4_data_create_network = {
513 "id": "3c9eebdbbfd345658269340b9ea6fb73",
515 "tenantId": "tenant1",
516 "networkName": "ommnet",
518 "vlanTransparent": True,
519 "networkType": "vlan",
520 "segmentationId": 202,
521 "physicalNetwork": "physnet1",
522 "routerExternal": False
526 c5_data_create_subnet = {
531 "id": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
532 "tenantId": "tenant1",
533 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
534 "networkName": "networkName",
536 "cidr": "10.43.35.0/24",
539 "gatewayIp": "10.43.35.1",
540 "dnsNameservers": [],
543 "start": "192.168.199.2",
544 "end": "192.168.199.254"
551 c6_data_create_port = {
556 "id": " 872019d3-bc6e-4319-9c1d-6722fc136afg",
557 "tenantId": "tenant1",
559 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
560 "networkName": "networkName",
561 "subnetId": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
562 "subnetName": "subnet1",
563 "macAddress": "212.12.61.23",
565 "vnicType": "direct",
570 c7_data_create_flavor = {
574 "id": "142019d3-bc6e-4319-9c1d-6722fc136afg",
575 "tenantId": "tenant1",
583 "extraSpecs": "testtt"
587 c8_data_list_image = {
593 "id": "5e2757c1-f846-4727-915c-9a872553ed75",
601 c9_data_create_vm = {
603 "id": "3c9eebdbbfd345658269340b9ea6fb73",
607 "tenantId": "tenant1",
610 "volumeArray": "dfdf",
611 "availabilityZone": "fdvfdv",
612 "flavorId": "fdvfdv",
613 "metadata": "fdvfdv",
614 "securityGroups": "fdvfdv",
615 "serverGroup": "fdvfdv",
622 "id": "3c9eebdbbfd345658269340b9ea6fb73",
626 "tenantId": "tenant1",
633 "volume_storage_id": "test",
637 "tenant": "chinamobile",
638 "availability_zone": "test",
640 "volume_name": "test",
641 "custom_volume_type": "test",
644 "image_file": "test",
653 "tenant": "chinamobile",
656 "networkName": "test",
657 "networkType": "test",
658 "physicalNetwork": "test",
659 "vlanTransparent": "test",
660 "segmentationId": "1",
662 "dhcpEnabled": "test",
667 "connectivity_type": {
668 "layer_protocol": "ipv4",
670 "dns_nameservers": "test",
671 "host_routes": "test",
673 "route_external": "test",
680 "networkId": "", # TODO
681 "subnetId": "", # TODO
685 "mac_address": "test",
690 "fixed_ip_address": "test"
695 "vnic_type": "direct",
697 "virtual_network_interface_requirements": [
699 "network_interface_requirements": {
700 "interfaceType": '{"schema-version": "0", "schema-location":"", "platform-id": "generic", "mandatory": false, "configuration-value": "SR-IOV"}'
702 "support_mandatory": False,
703 "name": "SRIOV_Port",
704 "description": "sriov"
716 "tenant": "chinamobile",
717 "availability_zone": "test",
724 "vduName": "VDU_vbng_0",
725 "flavorName": "flavor_1",
736 "type": "tosca.nodes.nfv.Vdu.Compute",
739 "num_virtual_cpu": "16",
742 "virtual_mem_size": "8000 MB",
743 "vdu_memory_requirements": {
744 "memoryPageSize": "8 MB",
749 "type_of_storage": "ephemeral",
750 "size_of_storage": "10 GB",
752 "type": "tosca.nodes.nfv.Vdu.Compute",
755 "artifact_name": "sw_image",
761 "volume_storage_id": "test",
768 "local_storages": [],
776 "description": "pe1_idofunderlayvpn"
780 "description": "pe2_idofunderlayvpn"
784 "description": "serviceTypeofunderlayvpn"
788 "description": "descriptionofunderlayvpn"
792 "description": "ac2_routeofunderlayvpn"
796 "description": "ac1_routeofunderlayvpn"
800 "description": "ac1_svlanofunderlayvpn"
804 "description": "ac2_ipofunderlayvpn"
808 "description": "ac1_ipofunderlayvpn"
812 "description": "ac2_portofunderlayvpn"
816 "description": "topologyofunderlayvpn"
820 "description": "technologyofunderlayvpn"
824 "description": "ac1_portofunderlayvpn"
828 "description": "ac2_svlanofunderlayvpn"
832 "description": "Nameofunderlayervpn"
837 "name": "underlayervpn",
838 "csarVersion": "1.0",
840 "csarProvider": "huawei",
843 "id": "ns_underlayervpn_1_0"
849 "csarId": "vOpenNAT",
851 "csarName": "vOpenNAT.csar",
852 "vnfdModel": json.dumps(vnfdModel),
853 "vnfdProvider": "Intel",
854 "vnfdId": "openNAT_1.0",
855 "downloadUrl": "http://10.96.33.39:8806/static/catalog/vOpenNAT/vOpenNAT.csar",
856 "vnfVersion": "v1.0",
857 "vnfdVersion": "v1.0",
858 "vnfPackageId": "vOpenNAT"
867 # "designer": "sdno",
868 # "name": "underlayervpn",
869 # "csarVersion": "1.0",
870 # "csarType": "SSAR",
871 # "csarProvider": "huawei",
874 # "id": "ns_underlayervpn_1_0"
878 # "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
879 # "type_name": "tosca.nodes.sdn.l3ac",
880 # "template_name": "ac2",
883 # "type_name": "string"
886 # "type_name": "string"
889 # "type_name": "string"
892 # "type_name": "string"
897 # "name": "Standard",
898 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
904 # "type_name": "tosca.capabilities.Node"
908 # "type_name": "tosca.capabilities.sdn.ac"
913 # "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
914 # "target_capability_name": "feature"
917 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
918 # "target_capability_name": "feature"
923 # "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
924 # "type_name": "tosca.nodes.sdn.l3ac",
925 # "template_name": "ac1",
928 # "type_name": "string"
931 # "type_name": "string"
934 # "type_name": "string"
937 # "type_name": "string"
942 # "name": "Standard",
943 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
949 # "type_name": "tosca.capabilities.Node"
953 # "type_name": "tosca.capabilities.sdn.ac"
958 # "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
959 # "target_capability_name": "feature"
962 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
963 # "target_capability_name": "feature"
968 # "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
969 # "type_name": "tosca.nodes.sdn.underlayVPN",
970 # "template_name": "vpn",
973 # "type_name": "string"
976 # "type_name": "string"
979 # "type_name": "string"
982 # "type_name": "string"
987 # "name": "Standard",
988 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
994 # "type_name": "tosca.capabilities.Node"
999 # "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
1000 # "target_capability_name": "feature"
1003 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
1004 # "target_capability_name": "feature"
1009 # "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
1010 # "type_name": "tosca.nodes.sdn.l3pe",
1011 # "template_name": "pe1",
1014 # "type_name": "string"
1019 # "name": "Standard",
1020 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1025 # "name": "feature",
1026 # "type_name": "tosca.capabilities.Node"
1030 # "type_name": "tosca.capabilities.sdn.pe"
1035 # "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
1036 # "type_name": "tosca.nodes.sdn.l3pe",
1037 # "template_name": "pe2",
1040 # "type_name": "string"
1045 # "name": "Standard",
1046 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1051 # "name": "feature",
1052 # "type_name": "tosca.capabilities.Node"
1056 # "type_name": "tosca.capabilities.sdn.pe"
1062 # "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
1066 # "type_name": "string",
1067 # "description": "ac2_ipofunderlayvpn"
1070 # "type_name": "string",
1071 # "description": "ac2_routeofunderlayvpn"
1074 # "type_name": "string",
1075 # "description": "serviceTypeofunderlayvpn"
1078 # "type_name": "string",
1079 # "description": "descriptionofunderlayvpn"
1082 # "type_name": "string",
1083 # "description": "pe2_idofunderlayvpn"
1086 # "type_name": "string",
1087 # "description": "ac1_routeofunderlayvpn"
1090 # "type_name": "integer",
1091 # "description": "ac1_svlanofunderlayvpn"
1094 # "type_name": "string",
1095 # "description": "Nameofunderlayervpn"
1098 # "type_name": "string",
1099 # "description": "ac1_ipofunderlayvpn"
1102 # "type_name": "string",
1103 # "description": "ac2_portofunderlayvpn"
1106 # "type_name": "string",
1107 # "description": "pe1_idofunderlayvpn"
1110 # "type_name": "string",
1111 # "description": "technologyofunderlayvpn"
1114 # "type_name": "string",
1115 # "description": "ac1_portofunderlayvpn"
1118 # "type_name": "integer",
1119 # "description": "ac2_svlanofunderlayvpn"
1122 # "type_name": "string",
1123 # "description": "topologyofunderlayvpn"