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 OPERATION_TYPE = enum(
26 INSTANTIATE="INSTANTIATE",
28 SCALE_TO_LEVEL="SCALE_TO_LEVEL",
29 CHANGE_FLAVOUR="CHANGE_FLAVOUR",
30 TERMINATE="TERMINATE",
33 CHANGE_EXT_CONN="CHANGE_EXT_CONN",
34 MODIFY_INFO="MODIFY_INFO"
37 OPERATION_STATE_TYPE = enum(
39 PROCESSING="PROCESSING",
40 COMPLETED="COMPLETED",
41 FAILED_TEMP="FAILED_TEMP",
43 ROLLING_BACK="ROLLING_BACK",
44 ROLLED_BACK="ROLLED_BACK"
51 TEMPORARY='TEMPORARY',
52 LINK_PORT_ADDED='LINK_PORT_ADDED',
53 LINK_PORT_REMOVED='LINK_PORT_REMOVED'
56 RESOURCE_MAP = {'Storage': 'volumn', 'Network': 'network', 'SubNetwork': 'subnet', 'Port': 'port',
57 'Flavour': 'flavor', 'Vm': 'vm'}
59 ROOT_URI = "api/vnflcm/v1/subscriptions/"
61 AUTH_TYPES = ["BASIC", "OAUTH2_CLIENT_CREDENTIALS", "TLS_CERT"]
65 OAUTH2_CLIENT_CREDENTIALS = "OAUTH2_CLIENT_CREDENTIALS"
67 LCCNNOTIFICATION = "VnfLcmOperationOccurrenceNotification"
69 NOTIFICATION_TYPES = [
70 "VnfLcmOperationOccurrenceNotification",
71 "VnfIdentifierCreationNotification",
72 "VnfIdentifierDeletionNotification"
75 LCM_OPERATION_TYPES = [
76 OPERATION_TYPE.INSTANTIATE,
78 OPERATION_TYPE.SCALE_TO_LEVEL,
79 OPERATION_TYPE.CHANGE_FLAVOUR,
80 OPERATION_TYPE.TERMINATE,
82 OPERATION_TYPE.OPERATE,
83 OPERATION_TYPE.CHANGE_EXT_CONN,
84 OPERATION_TYPE.MODIFY_INFO
87 LCM_OPERATION_STATE_TYPES = [
88 OPERATION_STATE_TYPE.STARTING,
89 OPERATION_STATE_TYPE.PROCESSING,
90 OPERATION_STATE_TYPE.COMPLETED,
91 OPERATION_STATE_TYPE.FAILED_TEMP,
92 OPERATION_STATE_TYPE.FAILED,
93 OPERATION_STATE_TYPE.ROLLING_BACK,
94 OPERATION_STATE_TYPE.ROLLED_BACK
99 "flavourId": "flavour_1",
100 "instantiationLevelId": "instantiationLevel_1",
103 "id": "extVirtualLink_1",
104 "vimConnectionId": "vimConnection_1",
105 "resourceProviderId": "resourceProvider_1",
106 "resourceId": "resource_1",
107 "resourceSubnetId": "resourceSubnet_1",
113 "cpInstanceId": "cpInstance_1",
114 "linkPortId": "linkPort_1",
117 "layerProtocol": "IP_OVER_ETHERNET",
119 "macAddress": "00:f3:43:20:a2:a3",
123 "fixedAddresses": ["192.168.104.2", ],
124 "numDynamicAddresses": 0,
125 "addressRange": None,
126 "subnetId": "subnet_1",
138 "id": "extLinkPort_1",
140 "vimConnectionId": "vimConnection_1",
141 "resourceProviderId": "resourceProvider_1",
142 "resourceId": "resource_1",
143 "vimLevelResourceType": "vimLevelResourceType_1",
149 "extManagedVirtualLinks": [
151 "id": 'extManagedVirtualLink_1',
152 "virtualLinkDescId": 'virtualLinkDesc_1',
153 "vimConnectionId": 'vimConnection_1',
154 "resourceProviderId": 'resourceProvider_1',
155 "resourceId": 'resource_1',
158 "vimConnectionInfo": [
160 "id": 'vimConnection_1',
164 "apiVersion": "apiVersion_1",
165 "protocolType": "http"
168 "tenant": "tenant_vCPE",
170 "password": "vCPE_321",
175 "localizationLanguage": "en_US",
176 "additionalParams": {
189 'domain_type': u'CN',
190 'version': u'v4.14.10',
191 'vmnumber_overquota_alarm': False,
194 'vnfd_version': u'V00000001',
195 'id': u'sss-vnf-template',
196 'name': u'sss-vnf-template'
201 "description": "vdu description",
203 "name": "vduinstname",
206 "support_scaling": True,
209 "tenant": "tenantname",
210 "availability_zone": "zone1",
213 "local_affinity_antiaffinity_rule": [
215 "affinity_antiaffinity": "anti-affinity",
219 "affinity_antiaffinity": "affinity",
223 "inject_data_list": [
225 "file_name": "abc.xml",
226 "file_data": "<a>xxx</a><b>ssss</b>"
229 "storage_policy": "HIGH",
231 "manual_scale_select_vim": False,
233 "enabledelay": 600000,
236 "is_predefined": False,
237 "allow_scale_updown": False,
238 "inject_network_address": True,
239 "inner_hugepage_num": 100,
240 "inner_hugepage_size": "2048",
243 "image_file": u'sss',
250 "volume_storage_id": "volume_storage1",
251 "location": "/usr/data",
252 "device": "/dev/hda1"
262 "cpu_frequency": "1GHz",
263 "flavor_extra_specs": {
264 "hw: cpu_policy": "shared",
265 "hw: cpu_max_threads": 50,
266 "hw: cpu_sockets": 10,
267 "hw: cpu_max_sockets": 20,
268 "hw: cpu_max_cores": 8,
269 "hw: cpu_threads": 30,
270 "hw: numa_mem.0": 12288,
271 "hw: hugepage_num": 100,
272 "hw: high_performance": "dvs_high",
274 "hw: numa_cpus.0": "2,4,8",
275 "hw: numa_pci": True,
277 "pci_passthrough: alias": "ColetoCreek: 1",
278 "hw: mem_page_size": "large",
279 "hw: mem_paging_mechanism": "EPT"
291 "default_instances": 1
296 "implementation": "<implementationScript>",
298 "param1Name": "value1",
299 "paramNName": "valueN"
303 "implementation": "<implementationScript>",
305 "param1Name": "value1",
306 "paramNName": "valueN"
310 "implementation": "<implementationScript>",
312 "param1Name": "value1",
313 "paramNName": "valueN"
317 "implementation": "<implementationScript>",
319 "param1Name": "value1",
320 "paramNName": "valueN"
324 "implementation": "<implementationScript>",
326 "param1Name": "value1",
327 "paramNName": "valueN"
338 "volume_storage_id": "volume_storage1",
343 "volume_name": "volumeStorage1",
344 "custom_volume_type": "type1",
346 "delete_on_termination_vm": True,
349 "tenant": "tenantname_1",
350 "availability_zone": "zone1"
352 "is_predefined": False,
365 'policy_id': u'policy_scale_sss-vnf-template',
367 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
376 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
378 'disk_format': u'VMDK',
379 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
380 'container_type': 'vm',
382 'hypervisor_type': 'kvm'
384 'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
391 'disk_format': u'VMDK',
392 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
393 'container_type': 'vm',
395 'hypervisor_type': 'kvm'
397 'image_file_id': u'sss'
405 "name": "umac_241_control",
406 "network_name": "umac_control",
407 "is_predefined": False,
409 "netmask": "255.255.255.0",
411 "network_type": "vlan",
412 "physical_network": "phynet01",
413 "segmentation_id": "30",
414 "vlan_transparent": False,
416 "cidr": "192.168.199.0/24",
418 "gateway_ip": "192.168.199.1",
419 "dhcp_enabled": False,
424 "start_ip": "192.168.199.2",
425 "end_ip": "192.168.199.254",
428 "destination": "10.43.26.0/24",
429 "nexthop": "10.41.23.1"
434 "tenant": "tenantname_1"
438 "route_id": "router01",
439 "route_external": False
448 "mac_address": "00:d9:00:82:11:e1",
449 "ip_address:": "192.168.1.21",
450 "ip_range_start": "192.168.1.20",
451 "ip_range_end": "192.168.1.29",
452 "floating_ip_address": {
453 "external_network": "extnet01",
454 "ip_address": "10.43.53.23"
456 "service_ip_address": "192.168.1.23",
459 "vnic_type": "normal",
460 "allowed_address_pairs": [
462 "ip": "192.168.1.13",
463 "mac": "00:f3:43:20:a2:a3"
468 "macbond": "00:d9:00:82:11:d1",
469 "sfc_encapsulation": "",
471 "gateway_ip": "192.168.199.1",
472 "netmask": "255.255.255.0",
473 "interface_name": "fe-01-02",
475 "function": "control"
487 c1_data_get_tenant_id = {
491 "name": "chinamobile"
495 c1_data_get_tenant_id_1 = {
506 c2_data_create_volume = {
507 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
510 "vimId": "vim_volume_1",
511 "vimName": "vim_volume_1",
512 "tenantId": "vim_volume_1",
514 "availabilityZone": "availabilityZone",
515 "status": "availuable",
516 "createTime": "2015-12-02T06:39:40.000000",
522 c3_data_get_volume = {
523 "status": "available",
527 "device": "/dev/vdc",
528 "serverId": "3030e666-528e-4954-88f5-cc21dab1262b",
529 "volumeId": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
531 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31"
534 "createTime": "2015-12-02T06:39:40.000000",
536 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
541 c4_data_create_network = {
546 "id": "3c9eebdbbfd345658269340b9ea6fb73",
548 "tenantId": "tenant1",
549 "networkName": "ommnet",
551 "vlanTransparent": True,
552 "networkType": "vlan",
553 "segmentationId": 202,
554 "physicalNetwork": "physnet1",
555 "routerExternal": False
559 c5_data_create_subnet = {
564 "id": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
565 "tenantId": "tenant1",
566 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
567 "networkName": "networkName",
569 "cidr": "10.43.35.0/24",
572 "gatewayIp": "10.43.35.1",
573 "dnsNameservers": [],
576 "start": "192.168.199.2",
577 "end": "192.168.199.254"
584 c6_data_create_port = {
589 "id": " 872019d3-bc6e-4319-9c1d-6722fc136afg",
590 "tenantId": "tenant1",
592 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
593 "networkName": "networkName",
594 "subnetId": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
595 "subnetName": "subnet1",
596 "macAddress": "212.12.61.23",
598 "vnicType": "direct",
603 c7_data_create_flavor = {
607 "id": "142019d3-bc6e-4319-9c1d-6722fc136afg",
608 "tenantId": "tenant1",
616 "extraSpecs": "testtt"
620 c8_data_list_image = {
626 "id": "5e2757c1-f846-4727-915c-9a872553ed75",
634 c9_data_create_vm = {
636 "id": "3c9eebdbbfd345658269340b9ea6fb73",
640 "tenantId": "tenant1",
643 "volumeArray": "dfdf",
644 "availabilityZone": "fdvfdv",
645 "flavorId": "fdvfdv",
646 "metadata": "fdvfdv",
647 "securityGroups": "fdvfdv",
648 "serverGroup": "fdvfdv",
655 "id": "3c9eebdbbfd345658269340b9ea6fb73",
659 "tenantId": "tenant1",
666 "volume_storage_id": "test",
670 "tenant": "chinamobile",
671 "availability_zone": "test",
673 "volume_name": "test",
674 "custom_volume_type": "test",
677 "image_file": "test",
686 "tenant": "chinamobile",
689 "networkName": "test",
690 "networkType": "test",
691 "physicalNetwork": "test",
692 "vlanTransparent": "test",
693 "segmentationId": "1",
695 "dhcpEnabled": "test",
700 "connectivity_type": {
701 "layer_protocol": "ipv4",
703 "dns_nameservers": "test",
704 "host_routes": "test",
706 "route_external": "test",
713 "networkId": "", # TODO
714 "subnetId": "", # TODO
718 "mac_address": "test",
723 "fixed_ip_address": "test"
728 "vnic_type": "direct",
730 "virtual_network_interface_requirements": [
732 "network_interface_requirements": {
733 "interfaceType": '{"schema-version": "0", "schema-location":"", "platform-id": "generic", "mandatory": false, "configuration-value": "SR-IOV"}'
735 "support_mandatory": False,
736 "name": "SRIOV_Port",
737 "description": "sriov"
749 "tenant": "chinamobile",
750 "availability_zone": "test",
757 "vduName": "VDU_vbng_0",
758 "flavorName": "flavor_1",
769 "type": "tosca.nodes.nfv.Vdu.Compute",
772 "num_virtual_cpu": "16",
775 "virtual_mem_size": "8000 MB",
776 "vdu_memory_requirements": {
777 "memoryPageSize": "8 MB",
782 "type_of_storage": "ephemeral",
783 "size_of_storage": "10 GB",
785 "type": "tosca.nodes.nfv.Vdu.Compute",
788 "artifact_name": "sw_image",
794 "volume_storage_id": "test",
801 "local_storages": [],
809 "description": "pe1_idofunderlayvpn"
813 "description": "pe2_idofunderlayvpn"
817 "description": "serviceTypeofunderlayvpn"
821 "description": "descriptionofunderlayvpn"
825 "description": "ac2_routeofunderlayvpn"
829 "description": "ac1_routeofunderlayvpn"
833 "description": "ac1_svlanofunderlayvpn"
837 "description": "ac2_ipofunderlayvpn"
841 "description": "ac1_ipofunderlayvpn"
845 "description": "ac2_portofunderlayvpn"
849 "description": "topologyofunderlayvpn"
853 "description": "technologyofunderlayvpn"
857 "description": "ac1_portofunderlayvpn"
861 "description": "ac2_svlanofunderlayvpn"
865 "description": "Nameofunderlayervpn"
870 "name": "underlayervpn",
871 "csarVersion": "1.0",
873 "csarProvider": "huawei",
876 "id": "ns_underlayervpn_1_0"
882 "csarId": "vOpenNAT",
884 "csarName": "vOpenNAT.csar",
885 "vnfdModel": json.dumps(vnfdModel),
886 "vnfdProvider": "Intel",
887 "vnfdId": "openNAT_1.0",
888 "downloadUrl": "http://10.96.33.39:8806/static/catalog/vOpenNAT/vOpenNAT.csar",
889 "vnfVersion": "v1.0",
890 "vnfdVersion": "v1.0",
891 "vnfPackageId": "vOpenNAT"
900 # "designer": "sdno",
901 # "name": "underlayervpn",
902 # "csarVersion": "1.0",
903 # "csarType": "SSAR",
904 # "csarProvider": "huawei",
907 # "id": "ns_underlayervpn_1_0"
911 # "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
912 # "type_name": "tosca.nodes.sdn.l3ac",
913 # "template_name": "ac2",
916 # "type_name": "string"
919 # "type_name": "string"
922 # "type_name": "string"
925 # "type_name": "string"
930 # "name": "Standard",
931 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
937 # "type_name": "tosca.capabilities.Node"
941 # "type_name": "tosca.capabilities.sdn.ac"
946 # "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
947 # "target_capability_name": "feature"
950 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
951 # "target_capability_name": "feature"
956 # "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
957 # "type_name": "tosca.nodes.sdn.l3ac",
958 # "template_name": "ac1",
961 # "type_name": "string"
964 # "type_name": "string"
967 # "type_name": "string"
970 # "type_name": "string"
975 # "name": "Standard",
976 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
982 # "type_name": "tosca.capabilities.Node"
986 # "type_name": "tosca.capabilities.sdn.ac"
991 # "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
992 # "target_capability_name": "feature"
995 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
996 # "target_capability_name": "feature"
1001 # "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
1002 # "type_name": "tosca.nodes.sdn.underlayVPN",
1003 # "template_name": "vpn",
1006 # "type_name": "string"
1009 # "type_name": "string"
1012 # "type_name": "string"
1015 # "type_name": "string"
1020 # "name": "Standard",
1021 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1026 # "name": "feature",
1027 # "type_name": "tosca.capabilities.Node"
1030 # "relationships": [
1032 # "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
1033 # "target_capability_name": "feature"
1036 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
1037 # "target_capability_name": "feature"
1042 # "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
1043 # "type_name": "tosca.nodes.sdn.l3pe",
1044 # "template_name": "pe1",
1047 # "type_name": "string"
1052 # "name": "Standard",
1053 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1058 # "name": "feature",
1059 # "type_name": "tosca.capabilities.Node"
1063 # "type_name": "tosca.capabilities.sdn.pe"
1068 # "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
1069 # "type_name": "tosca.nodes.sdn.l3pe",
1070 # "template_name": "pe2",
1073 # "type_name": "string"
1078 # "name": "Standard",
1079 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1084 # "name": "feature",
1085 # "type_name": "tosca.capabilities.Node"
1089 # "type_name": "tosca.capabilities.sdn.pe"
1095 # "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
1099 # "type_name": "string",
1100 # "description": "ac2_ipofunderlayvpn"
1103 # "type_name": "string",
1104 # "description": "ac2_routeofunderlayvpn"
1107 # "type_name": "string",
1108 # "description": "serviceTypeofunderlayvpn"
1111 # "type_name": "string",
1112 # "description": "descriptionofunderlayvpn"
1115 # "type_name": "string",
1116 # "description": "pe2_idofunderlayvpn"
1119 # "type_name": "string",
1120 # "description": "ac1_routeofunderlayvpn"
1123 # "type_name": "integer",
1124 # "description": "ac1_svlanofunderlayvpn"
1127 # "type_name": "string",
1128 # "description": "Nameofunderlayervpn"
1131 # "type_name": "string",
1132 # "description": "ac1_ipofunderlayvpn"
1135 # "type_name": "string",
1136 # "description": "ac2_portofunderlayvpn"
1139 # "type_name": "string",
1140 # "description": "pe1_idofunderlayvpn"
1143 # "type_name": "string",
1144 # "description": "technologyofunderlayvpn"
1147 # "type_name": "string",
1148 # "description": "ac1_portofunderlayvpn"
1151 # "type_name": "integer",
1152 # "description": "ac2_svlanofunderlayvpn"
1155 # "type_name": "string",
1156 # "description": "topologyofunderlayvpn"