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 LCM_NOTIFICATION_STATUS = enum(START="START", RESULT="RESULT")
39 OPERATION_STATE_TYPE = enum(
41 PROCESSING="PROCESSING",
42 COMPLETED="COMPLETED",
43 FAILED_TEMP="FAILED_TEMP",
45 ROLLING_BACK="ROLLING_BACK",
46 ROLLED_BACK="ROLLED_BACK"
53 TEMPORARY='TEMPORARY',
54 LINK_PORT_ADDED='LINK_PORT_ADDED',
55 LINK_PORT_REMOVED='LINK_PORT_REMOVED'
58 RESOURCE_MAP = {'Storage': 'volumn', 'Network': 'network', 'SubNetwork': 'subnet', 'Port': 'port',
59 'Flavour': 'flavor', 'Vm': 'vm'}
61 ROOT_URI = "api/vnflcm/v1/subscriptions/"
63 AUTH_TYPES = ["BASIC", "OAUTH2_CLIENT_CREDENTIALS", "TLS_CERT"]
67 OAUTH2_CLIENT_CREDENTIALS = "OAUTH2_CLIENT_CREDENTIALS"
69 LCCNNOTIFICATION = "VnfLcmOperationOccurrenceNotification"
71 NOTIFICATION_TYPES = [
72 "VnfLcmOperationOccurrenceNotification",
73 "VnfIdentifierCreationNotification",
74 "VnfIdentifierDeletionNotification"
77 LCM_OPERATION_TYPES = [
78 OPERATION_TYPE.INSTANTIATE,
80 OPERATION_TYPE.SCALE_TO_LEVEL,
81 OPERATION_TYPE.CHANGE_FLAVOUR,
82 OPERATION_TYPE.TERMINATE,
84 OPERATION_TYPE.OPERATE,
85 OPERATION_TYPE.CHANGE_EXT_CONN,
86 OPERATION_TYPE.MODIFY_INFO
89 LCM_OPERATION_STATE_TYPES = [
90 OPERATION_STATE_TYPE.STARTING,
91 OPERATION_STATE_TYPE.PROCESSING,
92 OPERATION_STATE_TYPE.COMPLETED,
93 OPERATION_STATE_TYPE.FAILED_TEMP,
94 OPERATION_STATE_TYPE.FAILED,
95 OPERATION_STATE_TYPE.ROLLING_BACK,
96 OPERATION_STATE_TYPE.ROLLED_BACK
101 "flavourId": "flavour_1",
102 "instantiationLevelId": "instantiationLevel_1",
105 "id": "extVirtualLink_1",
106 "vimConnectionId": "vimConnection_1",
107 "resourceProviderId": "resourceProvider_1",
108 "resourceId": "resource_1",
109 "resourceSubnetId": "resourceSubnet_1",
115 "cpInstanceId": "cpInstance_1",
116 "linkPortId": "linkPort_1",
119 "layerProtocol": "IP_OVER_ETHERNET",
121 "macAddress": "00:f3:43:20:a2:a3",
125 "fixedAddresses": ["192.168.104.2", ],
126 "numDynamicAddresses": 0,
127 "addressRange": None,
128 "subnetId": "subnet_1",
140 "id": "extLinkPort_1",
142 "vimConnectionId": "vimConnection_1",
143 "resourceProviderId": "resourceProvider_1",
144 "resourceId": "resource_1",
145 "vimLevelResourceType": "vimLevelResourceType_1",
151 "extManagedVirtualLinks": [
153 "id": 'extManagedVirtualLink_1',
154 "virtualLinkDescId": 'virtualLinkDesc_1',
155 "vimConnectionId": 'vimConnection_1',
156 "resourceProviderId": 'resourceProvider_1',
157 "resourceId": 'resource_1',
160 "vimConnectionInfo": [
162 "id": 'vimConnection_1',
166 "apiVersion": "apiVersion_1",
167 "protocolType": "http"
170 "tenant": "tenant_vCPE",
172 "password": "vCPE_321",
177 "localizationLanguage": "en_US",
178 "additionalParams": {
191 'domain_type': u'CN',
192 'version': u'v4.14.10',
193 'vmnumber_overquota_alarm': False,
196 'vnfd_version': u'V00000001',
197 'id': u'sss-vnf-template',
198 'name': u'sss-vnf-template'
203 "description": "vdu description",
205 "name": "vduinstname",
208 "support_scaling": True,
211 "tenant": "tenantname",
212 "availability_zone": "zone1",
215 "local_affinity_antiaffinity_rule": [
217 "affinity_antiaffinity": "anti-affinity",
221 "affinity_antiaffinity": "affinity",
225 "inject_data_list": [
227 "file_name": "abc.xml",
228 "file_data": "<a>xxx</a><b>ssss</b>"
231 "storage_policy": "HIGH",
233 "manual_scale_select_vim": False,
235 "enabledelay": 600000,
238 "is_predefined": False,
239 "allow_scale_updown": False,
240 "inject_network_address": True,
241 "inner_hugepage_num": 100,
242 "inner_hugepage_size": "2048",
245 "image_file": u'sss',
250 "virtual_storages": [
252 "virtual_storage_id": "volume_storage1",
253 "location": "/usr/data",
254 "device": "/dev/hda1"
264 "cpu_frequency": "1GHz",
265 "flavor_extra_specs": {
266 "hw: cpu_policy": "shared",
267 "hw: cpu_max_threads": 50,
268 "hw: cpu_sockets": 10,
269 "hw: cpu_max_sockets": 20,
270 "hw: cpu_max_cores": 8,
271 "hw: cpu_threads": 30,
272 "hw: numa_mem.0": 12288,
273 "hw: hugepage_num": 100,
274 "hw: high_performance": "dvs_high",
276 "hw: numa_cpus.0": "2,4,8",
277 "hw: numa_pci": True,
279 "pci_passthrough: alias": "ColetoCreek: 1",
280 "hw: mem_page_size": "large",
281 "hw: mem_paging_mechanism": "EPT"
293 "default_instances": 1
298 "implementation": "<implementationScript>",
300 "param1Name": "value1",
301 "paramNName": "valueN"
305 "implementation": "<implementationScript>",
307 "param1Name": "value1",
308 "paramNName": "valueN"
312 "implementation": "<implementationScript>",
314 "param1Name": "value1",
315 "paramNName": "valueN"
319 "implementation": "<implementationScript>",
321 "param1Name": "value1",
322 "paramNName": "valueN"
326 "implementation": "<implementationScript>",
328 "param1Name": "value1",
329 "paramNName": "valueN"
340 "volume_storage_id": "volume_storage1",
343 "size": "\"100 GB\"",
345 "volume_name": "volumeStorage1",
346 "custom_volume_type": "type1",
348 "delete_on_termination_vm": True,
351 "tenant": "tenantname_1",
352 "availability_zone": "zone1"
354 "is_predefined": False,
367 'policy_id': u'policy_scale_sss-vnf-template',
369 'policy_file': '*-vnfd.zip/*-vnf-policy.xml'
378 'name': u'opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
380 'disk_format': u'VMDK',
381 'file_url': u'./zte-cn-sss-main-image/OMM/opencos_sss_omm_img_release_20150723-1-disk1.vmdk',
382 'container_type': 'vm',
384 'hypervisor_type': 'kvm'
386 'image_file_id': u'opencos_sss_omm_img_release_20150723-1-disk1'
393 'disk_format': u'VMDK',
394 'file_url': u'./zte-cn-sss-main-image/NE/sss.vmdk',
395 'container_type': 'vm',
397 'hypervisor_type': 'kvm'
399 'image_file_id': u'sss'
407 "name": "umac_241_control",
408 "network_name": "umac_control",
409 "is_predefined": False,
411 "netmask": "255.255.255.0",
413 "network_type": "vlan",
414 "physical_network": "phynet01",
415 "segmentation_id": "30",
416 "vlan_transparent": False,
418 "cidr": "192.168.199.0/24",
420 "gateway_ip": "192.168.199.1",
421 "dhcp_enabled": False,
426 "start_ip": "192.168.199.2",
427 "end_ip": "192.168.199.254",
430 "destination": "10.43.26.0/24",
431 "nexthop": "10.41.23.1"
436 "tenant": "tenantname_1"
440 "route_id": "router01",
441 "route_external": False
450 "mac_address": "00:d9:00:82:11:e1",
451 "ip_address:": "192.168.1.21",
452 "ip_range_start": "192.168.1.20",
453 "ip_range_end": "192.168.1.29",
454 "floating_ip_address": {
455 "external_network": "extnet01",
456 "ip_address": "10.43.53.23"
458 "service_ip_address": "192.168.1.23",
461 "vnic_type": "normal",
462 "allowed_address_pairs": [
464 "ip": "192.168.1.13",
465 "mac": "00:f3:43:20:a2:a3"
470 "macbond": "00:d9:00:82:11:d1",
471 "sfc_encapsulation": "",
473 "gateway_ip": "192.168.199.1",
474 "netmask": "255.255.255.0",
475 "interface_name": "fe-01-02",
477 "function": "control"
489 c1_data_get_tenant_id = {
493 "name": "chinamobile"
497 c1_data_get_tenant_id_1 = {
508 c2_data_create_volume = {
509 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
512 "vimId": "vim_volume_1",
513 "vimName": "vim_volume_1",
514 "tenantId": "vim_volume_1",
516 "availabilityZone": "availabilityZone",
517 "status": "availuable",
518 "createTime": "2015-12-02T06:39:40.000000",
524 c3_data_get_volume = {
525 "status": "available",
529 "device": "/dev/vdc",
530 "serverId": "3030e666-528e-4954-88f5-cc21dab1262b",
531 "volumeId": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
533 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31"
536 "createTime": "2015-12-02T06:39:40.000000",
538 "id": "4bd3e9eb-cd8b-456a-8589-910836a0ab31",
543 c4_data_create_network = {
548 "id": "3c9eebdbbfd345658269340b9ea6fb73",
550 "tenantId": "tenant1",
551 "networkName": "ommnet",
553 "vlanTransparent": True,
554 "networkType": "vlan",
555 "segmentationId": 202,
556 "physicalNetwork": "physnet1",
557 "routerExternal": False
561 c5_data_create_subnet = {
566 "id": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
567 "tenantId": "tenant1",
568 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
569 "networkName": "networkName",
571 "cidr": "10.43.35.0/24",
574 "gatewayIp": "10.43.35.1",
575 "dnsNameservers": [],
578 "start": "192.168.199.2",
579 "end": "192.168.199.254"
586 c6_data_create_port = {
591 "id": " 872019d3-bc6e-4319-9c1d-6722fc136afg",
592 "tenantId": "tenant1",
594 "networkId": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
595 "networkName": "networkName",
596 "subnetId": "d62019d3-bc6e-4319-9c1d-6722fc136a23",
597 "subnetName": "subnet1",
598 "macAddress": "212.12.61.23",
600 "vnicType": "direct",
605 c7_data_create_flavor = {
609 "id": "142019d3-bc6e-4319-9c1d-6722fc136afg",
610 "tenantId": "tenant1",
618 "extraSpecs": "testtt"
622 c8_data_list_image = {
628 "id": "5e2757c1-f846-4727-915c-9a872553ed75",
636 c9_data_create_vm = {
638 "id": "3c9eebdbbfd345658269340b9ea6fb73",
642 "tenantId": "tenant1",
645 "volumeArray": "dfdf",
646 "availabilityZone": "fdvfdv",
647 "flavorId": "fdvfdv",
648 "metadata": "fdvfdv",
649 "securityGroups": "fdvfdv",
650 "serverGroup": "fdvfdv",
657 "id": "3c9eebdbbfd345658269340b9ea6fb73",
661 "tenantId": "tenant1",
668 "volume_storage_id": "test",
672 "tenant": "chinamobile",
673 "availability_zone": "test",
675 "volume_name": "test",
676 "custom_volume_type": "test",
677 "size_of_storage": "\"10 GB\"",
679 "image_file": "test",
688 "tenant": "chinamobile",
691 "networkName": "test",
692 "networkType": "test",
693 "physicalNetwork": "test",
694 "vlanTransparent": "test",
695 "segmentationId": "1",
697 "dhcpEnabled": "test",
702 "connectivity_type": {
703 "layer_protocol": "ipv4",
705 "dns_nameservers": "test",
706 "host_routes": "test",
708 "route_external": "test",
715 "networkId": "", # TODO
716 "subnetId": "", # TODO
720 "mac_address": "test",
725 "fixed_ip_address": "test"
730 "vnic_type": "direct",
732 "virtual_network_interface_requirements": [
734 "network_interface_requirements": {
735 "interfaceType": '{"schemaVersion": "0", "schemaLocation":"", "platformId": "generic", "mandatory": false, "configurationValue": "SR-IOV"}'
737 "support_mandatory": False,
738 "name": "SRIOV_Port",
739 "description": "sriov"
751 "tenant": "chinamobile",
752 "availability_zone": "test",
759 "vduName": "VDU_vbng_0",
771 "type": "tosca.nodes.nfv.Vdu.Compute",
774 "num_virtual_cpu": "16",
777 "virtual_mem_size": "8000 MB",
778 "vdu_memory_requirements": {
779 "memoryPageSize": "8 MB",
783 "virtual_storages": [{
784 "virtual_storage_id": "test",
785 "type_of_storage": "ephemeral",
786 "size_of_storage": "10 GB",
788 "type": "tosca.nodes.nfv.Vdu.Compute",
791 "artifact_name": "sw_image",
797 "volume_storage_id": "test",
804 "local_storages": [],
812 "description": "pe1_idofunderlayvpn"
816 "description": "pe2_idofunderlayvpn"
820 "description": "serviceTypeofunderlayvpn"
824 "description": "descriptionofunderlayvpn"
828 "description": "ac2_routeofunderlayvpn"
832 "description": "ac1_routeofunderlayvpn"
836 "description": "ac1_svlanofunderlayvpn"
840 "description": "ac2_ipofunderlayvpn"
844 "description": "ac1_ipofunderlayvpn"
848 "description": "ac2_portofunderlayvpn"
852 "description": "topologyofunderlayvpn"
856 "description": "technologyofunderlayvpn"
860 "description": "ac1_portofunderlayvpn"
864 "description": "ac2_svlanofunderlayvpn"
868 "description": "Nameofunderlayervpn"
873 "name": "underlayervpn",
874 "csarVersion": "1.0",
876 "csarProvider": "huawei",
879 "id": "ns_underlayervpn_1_0"
885 "csarId": "vOpenNAT",
887 "csarName": "vOpenNAT.csar",
888 "vnfdModel": json.dumps(vnfdModel),
889 "vnfdProvider": "Intel",
890 "vnfdId": "openNAT_1.0",
891 "downloadUrl": "http://10.96.33.39:8806/static/catalog/vOpenNAT/vOpenNAT.csar",
892 "vnfVersion": "v1.0",
893 "vnfdVersion": "v1.0",
894 "vnfPackageId": "vOpenNAT"
903 # "designer": "sdno",
904 # "name": "underlayervpn",
905 # "csarVersion": "1.0",
906 # "csarType": "SSAR",
907 # "csarProvider": "huawei",
910 # "id": "ns_underlayervpn_1_0"
914 # "id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
915 # "type_name": "tosca.nodes.sdn.l3ac",
916 # "template_name": "ac2",
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"
944 # "type_name": "tosca.capabilities.sdn.ac"
949 # "target_node_id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
950 # "target_capability_name": "feature"
953 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
954 # "target_capability_name": "feature"
959 # "id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
960 # "type_name": "tosca.nodes.sdn.l3ac",
961 # "template_name": "ac1",
964 # "type_name": "string"
967 # "type_name": "string"
970 # "type_name": "string"
973 # "type_name": "string"
978 # "name": "Standard",
979 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
985 # "type_name": "tosca.capabilities.Node"
989 # "type_name": "tosca.capabilities.sdn.ac"
994 # "target_node_id": "pe1_e58ekps6m45g6w9egs9lue2j7",
995 # "target_capability_name": "feature"
998 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
999 # "target_capability_name": "feature"
1004 # "id": "vpn_ie0xim076f7cje67fvrrq9tg1",
1005 # "type_name": "tosca.nodes.sdn.underlayVPN",
1006 # "template_name": "vpn",
1009 # "type_name": "string"
1012 # "type_name": "string"
1015 # "type_name": "string"
1018 # "type_name": "string"
1023 # "name": "Standard",
1024 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1029 # "name": "feature",
1030 # "type_name": "tosca.capabilities.Node"
1033 # "relationships": [
1035 # "target_node_id": "ac1_jqows1ai0j0cmwk9jdvuknt97",
1036 # "target_capability_name": "feature"
1039 # "target_node_id": "ac2_fdhrbk3dvan8hl5wifm9lp1e9",
1040 # "target_capability_name": "feature"
1045 # "id": "pe1_e58ekps6m45g6w9egs9lue2j7",
1046 # "type_name": "tosca.nodes.sdn.l3pe",
1047 # "template_name": "pe1",
1050 # "type_name": "string"
1055 # "name": "Standard",
1056 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1061 # "name": "feature",
1062 # "type_name": "tosca.capabilities.Node"
1066 # "type_name": "tosca.capabilities.sdn.pe"
1071 # "id": "pe2_go3vo1ctxr1vlbl0ij8stbtj6",
1072 # "type_name": "tosca.nodes.sdn.l3pe",
1073 # "template_name": "pe2",
1076 # "type_name": "string"
1081 # "name": "Standard",
1082 # "type_name": "tosca.interfaces.node.lifecycle.Standard"
1087 # "name": "feature",
1088 # "type_name": "tosca.capabilities.Node"
1092 # "type_name": "tosca.capabilities.sdn.pe"
1098 # "node_type_name": "tosca.nodes.sdn.ext.NS.ns_underlayervpn"
1102 # "type_name": "string",
1103 # "description": "ac2_ipofunderlayvpn"
1106 # "type_name": "string",
1107 # "description": "ac2_routeofunderlayvpn"
1110 # "type_name": "string",
1111 # "description": "serviceTypeofunderlayvpn"
1114 # "type_name": "string",
1115 # "description": "descriptionofunderlayvpn"
1118 # "type_name": "string",
1119 # "description": "pe2_idofunderlayvpn"
1122 # "type_name": "string",
1123 # "description": "ac1_routeofunderlayvpn"
1126 # "type_name": "integer",
1127 # "description": "ac1_svlanofunderlayvpn"
1130 # "type_name": "string",
1131 # "description": "Nameofunderlayervpn"
1134 # "type_name": "string",
1135 # "description": "ac1_ipofunderlayvpn"
1138 # "type_name": "string",
1139 # "description": "ac2_portofunderlayvpn"
1142 # "type_name": "string",
1143 # "description": "pe1_idofunderlayvpn"
1146 # "type_name": "string",
1147 # "description": "technologyofunderlayvpn"
1150 # "type_name": "string",
1151 # "description": "ac1_portofunderlayvpn"
1154 # "type_name": "integer",
1155 # "description": "ac2_svlanofunderlayvpn"
1158 # "type_name": "string",
1159 # "description": "topologyofunderlayvpn"